4 changed files with 89 additions and 17 deletions
@ -0,0 +1,42 @@ |
|||||
|
function key_exists() { |
||||
|
/bin/keyctl list @u | /bin/grep -q "${1}" |
||||
|
return $? |
||||
|
} |
||||
|
|
||||
|
function insert_key() { |
||||
|
local INSERT=/usr/bin/ecryptfs-insert-wrapped-passphrase-into-keyring |
||||
|
|
||||
|
key_exists "${3}" || /bin/cat "${1}" | ${INSERT} "${2}" - |
||||
|
} |
||||
|
|
||||
|
function insert_keypair() { |
||||
|
local DATASIG="$(/bin/sed '1p;d' "${HOME}/.ecryptfs/${2}.sig")" |
||||
|
local NAMESIG="$(/bin/sed '2p;d' "${HOME}/.ecryptfs/${2}.sig")" |
||||
|
local DPF="${2}-passphrase" |
||||
|
local NPF="${DPF}-fname" |
||||
|
|
||||
|
insert_key "${1}/${DPF}" "${HOME}/.ecryptfs/wrapped-${DPF}" "${DATASIG}" |
||||
|
insert_key "${1}/${NPF}" "${HOME}/.ecryptfs/wrapped-${NPF}" "${NAMESIG}" |
||||
|
} |
||||
|
|
||||
|
function is_ecryptfs() { |
||||
|
/usr/bin/test "$(/usr/bin/stat -f -c '%T' "${1}")" = "ecryptfs" |
||||
|
return $? |
||||
|
} |
||||
|
|
||||
|
function mount_crypt() { |
||||
|
local CONFIG="${HOME}/.ecryptfs/${1}.conf" |
||||
|
local MOUNTPOINT="$(/usr/bin/awk '1{print $2}' "${CONFIG}")" |
||||
|
|
||||
|
is_ecryptfs "${MOUNTPOINT}" || /sbin/mount.ecryptfs_private "${1}" |
||||
|
} |
||||
|
|
||||
|
function umount_crypt() { |
||||
|
local CONFIG="${HOME}/.ecryptfs/${1}.conf" |
||||
|
local MOUNTPOINT="$(/usr/bin/awk '1{print $2}' "${CONFIG}")" |
||||
|
|
||||
|
/bin/sync |
||||
|
is_ecryptfs "${MOUNTPOINT}" && /sbin/umount.ecryptfs_private -d "${1}" |
||||
|
} |
||||
|
|
||||
|
# vim: set ts=4 sw=4: |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue