diff options
Diffstat (limited to 'cryptfs.bin.in')
-rw-r--r-- | cryptfs.bin.in | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/cryptfs.bin.in b/cryptfs.bin.in index a7a6ee1..cf4366f 100644 --- a/cryptfs.bin.in +++ b/cryptfs.bin.in @@ -284,6 +284,31 @@ do_crypt_open() { fi } +do_integrity_close() { + if is_unlocked "$1"; then + while ! integritysetup close "$1"; do + sleep 1 + done + fi +} + +do_integrity_open() { + local name + local raw + name="$1" + raw="$2" + if ! is_unlocked "${name}"; then + max_tries=10 + while ! integritysetup open "${raw}" "${name}"; do + sleep 1 + max_tries=$((max_tries-1)) + if [ ${max_tries} -le 0 ]; then + exit 1 + fi + done + fi +} + do_mdadm_stop() { device="$1" if mdadm --detail "${device}" | \ @@ -317,13 +342,21 @@ printf '%s\n' "${crypttab}" | \ if [ -n "${raid_device}" ]; then printf '1 do_mdadm_stop %s\n' "${raid_device}" fi - printf '2 do_crypt_close %s\n' "${name}" + if [ -n "${key}" ]; then + printf '3 do_crypt_close %s\n' "${name}" + else + printf '2 do_integrity_close %s\n' "${name}" + fi else - printf '0 do_mount %s\n' "${key_mount}" - printf '1 do_crypt_open %s\n' "${name} ${raw} ${key} ${key_slot_option}" - printf '2 do_unmount -l %s\n' "${key_mount}" + if [ -n "${key}" ]; then + printf '0 do_mount %s\n' "${key_mount}" + printf '1 do_crypt_open %s\n' "${name} ${raw} ${key} ${key_slot_option}" + printf '2 do_unmount -l %s\n' "${key_mount}" + else + printf '3 do_integrity_open %s\n' "${name} ${raw}" + fi if [ -n "${mount_order}" ]; then - printf '3 do_mount %s\n' "${mount_order}" + printf '4 do_mount %s\n' "${mount_order}" fi fi done | \ |