You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
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="${2}-fname-passphrase"
|
|
|
|
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:
|