/usr/bin/ecryptfs-verify is in ecryptfs-utils 111-0ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | #!/bin/sh -e
# ecryptfs-verify
# Copyright (C) 2011 Dustin Kirkland <kirkland@ubuntu.com>
#
# Authors: Dustin Kirkland <kirkland@ubuntu.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
error() {
echo `gettext "ERROR:"` "$@" 1>&2
echo `gettext "ERROR:"` "Configuration invalid" 1>&2
exit 1
}
info() {
echo `gettext "INFO:"` "$@"
}
usage() {
echo "
Usage:
ecryptfs-verify [-h|--home] [-p|--private] [-e|--filenames-encrypted] [-n|--filenames-not-encrypted] [-u|--user USER] [--help]
-h|--home True if HOME is correctly configured for
encryption, False otherwise
-p|--private True if a non-HOME directory is correctly
configured for encryption, False otherwise
-e|--filenames-encrypted True if filenames are set for encryption,
False otherwise
-n|--filenames-not-encrypted True if filenames are not encrypted,
False otherwise
-u|--user USER By default, the current user's configuration
is checked, override with this option
--help This usage information
Note that options are additive. ALL checks must pass in order for this
program to exit 0. Any failing check will cause this program to exit
non-zero.
"
return 1
}
ecryptfs_exists() {
local dotecryptfs="$1/.ecryptfs"
if [ -d "$dotecryptfs" ]; then
info "[$dotecryptfs] exists"
else
error "[$dotecryptfs] does not exist"
fi
return 0
}
sigfile_valid() {
local sigfile="$1/.ecryptfs/Private.sig"
if [ -f "$sigfile" ]; then
info "[$sigfile] exists"
else
error "[$sigfile] does not exist"
fi
local c=$(wc -l "$sigfile" | awk '{print $1}')
if [ "$c" = "1" ] || [ "$c" = "2" ]; then
info "[$sigfile] contains [$c] signatures"
else
error "[$sigfile] does not contain exactly 1 or 2 lines"
fi
return 0
}
mountfile_valid() {
local mountfile="$1/.ecryptfs/Private.mnt"
if [ -f "$mountfile" ]; then
info "[$mountfile] exists"
else
error "[$mountfile] does not exist"
fi
local m=$(cat "$mountfile")
if [ -d "$m" ]; then
info "[$m] is a directory"
else
error "[$m] is not a directory"
fi
return 0
}
automount_true() {
local home="$1"
local automount="$1/.ecryptfs/auto-mount"
if [ -f "$automount" ]; then
info "[$automount] Automount is set"
else
error "[$home/.ecryptfs/auto-mount] does not exist"
fi
return 0
}
owns_mountpoint() {
local owner=$(stat -c "%U" "$2")
if [ "$owner" = "$1" ]; then
info "Ownership [$owner] of mount point [$2] is correct"
else
error "Invalid owner [$owner] of mount point [$2]"
fi
}
mount_is_home() {
local home="$1"
local mountfile="$home/.ecryptfs/Private.mnt"
local m=$(cat "$mountfile")
if [ "$m" = "$home" ]; then
info "Mount point [$m] is the user's home"
else
error "Mount point [$m] is not the user's home [$home]"
fi
owns_mountpoint "$user" "$m"
return 0
}
mount_is_private() {
local home="$1"
local mountfile="$home/.ecryptfs/Private.mnt"
local m=$(cat "$mountfile")
if [ "$m" != "$home" ]; then
info "Mount point [$m] is not the user's home [$home]"
else
error "Mount point [$m] is the user's home"
fi
if [ -d "$m" ]; then
info "Mount point [$m] is a valid directory"
else
error "[$m] is not a valid mount point"
fi
owns_mountpoint "$user" "$m"
return 0
}
filenames_encrypted() {
local sigfile="$1/.ecryptfs/Private.sig"
local c=$(wc -l "$sigfile" | awk '{print $1}')
if [ "$c" = "2" ]; then
info "Filenames are encrypted"
else
error "Filenames are not encrypted"
fi
return 0
}
filenames_not_encrypted() {
local sigfile="$1/.ecryptfs/Private.sig"
local c=$(wc -l "$sigfile" | awk '{print $1}')
if [ "$c" = "1" ]; then
info "Filenames are not encrypted"
else
error "Filenames are encrypted"
fi
return 0
}
home="$HOME"
user="$USER"
checks=
while [ ! -z "$1" ]; do
case "$1" in
-h|--home)
checks="$checks check_home"
shift
;;
-p|--private)
checks="$checks check_private"
shift
;;
-e|--filenames-encrypted)
checks="$checks check_filenames_encrypted"
shift
;;
-n|--filenames-not-encrypted)
checks="$checks check_filenames_not_encrypted"
shift
;;
--help)
usage
;;
-u|--user)
user="$2"
home=$(getent passwd "$user" | awk -F: '{print $6}')
if [ ! -d "$home" ]; then
error "Invalid home directory [$home] of [$user]"
fi
shift 2
;;
esac
done
if [ -z "$checks" ]; then
error "No checks given"
fi
for i in $checks; do
case "$i" in
check_home)
ecryptfs_exists "$home"
sigfile_valid "$home"
mountfile_valid "$home"
automount_true "$home"
mount_is_home "$home"
;;
check_private)
ecryptfs_exists "$home"
sigfile_valid "$home"
mountfile_valid "$home"
mount_is_private "$home"
;;
check_filenames_encrypted)
ecryptfs_exists "$home"
sigfile_valid "$home"
filenames_encrypted "$home"
;;
check_filenames_not_encrypted)
ecryptfs_exists "$home"
sigfile_valid "$home"
filenames_not_encrypted "$home"
;;
*)
error "Invalid check [$i]"
;;
esac
done
info "Configuration valid"
exit 0
|