From 5642bb6fe16fccc2afb7b313c8fbef8a4d67efdf Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sun, 29 Oct 2017 21:00:06 +0100 Subject: cryptfs.bin: 10 Versuche zum Einhängen und luks-Öffnen, sowie beliebig viele Versuche zum Aushängen und luks-Schließen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cryptfs.bin.in | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/cryptfs.bin.in b/cryptfs.bin.in index 9e8e1e7..8bfa29a 100644 --- a/cryptfs.bin.in +++ b/cryptfs.bin.in @@ -147,6 +147,8 @@ is_unlocked() { do_mount() { local inner_fs + local max_tries + local mount_paramters if is_mounted "$1"; then return fi @@ -176,7 +178,15 @@ do_mount() { if [ -n "${inner_fs}" ]; then do_unmount -l "${inner_fs}" fi - mount $(mount_details all "$1") + max_tries=10 + mount_parameters=$(mount_details all "$1") + while ! mount ${mount_parameters}; do + max_tries=$((max_tries-1)) + if [ ${max_tries} -le 0 ]; then + exit 1 + fi + sleep 1 + done if [ -n "${inner_fs}" ]; then do_mount "${inner_fs}" fi @@ -185,6 +195,7 @@ do_mount() { do_unmount() { local inner_fs local lazy + local mount_point if [ "x$1" = 'x-l' ]; then lazy='-l' shift @@ -198,7 +209,11 @@ do_unmount() { if [ -n "${inner_fs}" ]; then do_unmount -l "${inner_fs}" fi - umount ${lazy} $(mount_details mp "$1") + mount_point=$(mount_details mp "$1") + while ! umount ${lazy} "${mount_point}"; do + fuser -k -M -m "${mount_point}" + sleep 1 + done if [ -n "${inner_fs}" ]; then do_mount "${inner_fs}" fi @@ -206,13 +221,23 @@ do_unmount() { do_crypt_close() { if is_unlocked "$1"; then - cryptsetup luksClose "$1" + while ! cryptsetup luksClose "$1"; do + sleep 1 + done fi } do_crypt_open() { + local max_tries if ! is_unlocked "$1"; then - cryptsetup luksOpen "$2" "$1" --key-file="$3" + max_tries=10 + while ! cryptsetup luksOpen "$2" "$1" --key-file="$3"; do + sleep 1 + max_tries=$((max_tries-1)) + if [ ${max_tries} -le 0 ]; then + exit 1 + fi + done fi } -- cgit v1.2.3-54-g00ecf