diff options
author | Erich Eckner <git@eckner.net> | 2021-09-19 10:29:51 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2021-09-19 10:29:51 +0200 |
commit | fafec575427d5dbac8333f6605e34f0384b73991 (patch) | |
tree | b4a300c0ca1095919fbd84dbdf05242bae7d34ef | |
parent | 68f89d031648a8d911efdf132cadc1e6fd01e653 (diff) | |
download | cryptfs-daemon-fafec575427d5dbac8333f6605e34f0384b73991.tar.xz |
cryptfs.bin: check, that raid is "clean" before mounting
-rw-r--r-- | cryptfs.bin.in | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/cryptfs.bin.in b/cryptfs.bin.in index 8465c70..4057651 100644 --- a/cryptfs.bin.in +++ b/cryptfs.bin.in @@ -189,22 +189,32 @@ do_mount() { fi inner_fs=$(inner_fs_to_mountorder "$1") + mount_dev=$(mount_details dev "$1") + + if md_dev=$(readlink -e "${mount_dev}" \ + | grep -x '/dev/md[0-9]\+'); then + if ! grep -qxF 'clean' '/sys/block/'"${md_dev##*/}"'/md/array_state'; then + >&2 printf '%s is not clean - will not mount\n' "${md_dev}" + exit 1 + fi + fi + case "$(mount_details fs "$1")" in 'ext'*) - if cryptsetup status $(mount_details dev "$1") \ + if cryptsetup status "${mount_dev}" \ | grep -q '^\s*mode:\s\+readonly$'; then e2fsck_option='-n' else e2fsck_option='-p' fi - e2fsck ${e2fsck_option} $(mount_details dev "$1") + e2fsck ${e2fsck_option} "${mount_dev}" ;; 'fuse.sshfs'|'fuse.ftps') local max_wait local host max_wait=$(($(date +%s)+120)) host=$( - mount_details dev "$1" | \ + echo "${mount_dev}" | \ sed 's>^\([^:@]*@\)\?\([^:@]\+\):\S*$>\2>' ) host=$(extract_ssh_host "${host}") |