From fe314c0857d7782771b973fd32c5a9feaec06fba Mon Sep 17 00:00:00 2001 From: alterNERDtive Date: Tue, 19 Jul 2022 13:00:00 +0200 Subject: [PATCH] lock encrypted device after mount fail, _then_ abort --- gpgtool | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gpgtool b/gpgtool index 93a8b71..4277ba3 100755 --- a/gpgtool +++ b/gpgtool @@ -45,7 +45,7 @@ init () { if [[ ! -z "${dev}" ]] && udisksctl info -b ${dev} | grep -q org.freedesktop.UDisks2.Encrypted; then echo "Unlocking device ${dev} …" local mountdev=$(udisksctl unlock -b "${dev}") - [[ $? != 0 ]] && echo "Error unlocking device ${dev}." && exit 1 + [[ $? != 0 ]] && echo "Error unlocking device ${dev}, aborting …" && exit 1 mountdev="$(echo $mountdev | awk '{ print $4 }')" mountdev=${mountdev:0:-1} @@ -56,7 +56,11 @@ init () { if [[ ! -z ${mountdev} ]]; then echo "Mounting device ${mountdev} …" mountpath=$(udisksctl mount -b "${mountdev}") - [[ $? != 0 ]] && echo "Error mounting device ${mount}." && exit 1 + if [[ $? != 0 ]]; then + echo "Error mounting device ${mount}, aborting …" + [[ "${mountdev}" != "${dev}" ]] && udisksctl lock -b ${dev} + exit 1 + fi mountpath="$(echo $mountpath | awk '{ print $4 }')" fi