Skip to content

Commit

Permalink
Check if luks device is already open before trying to open it.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tails developers authored and daniel-baumann committed Apr 5, 2012
1 parent ad772f2 commit bb77d0e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions scripts/live-helpers
Expand Up @@ -721,6 +721,21 @@ open_luks_device ()
opts="${opts} --readonly"
fi

if /sbin/cryptsetup status "${name}" >/dev/null 2>&1
then
re="^[[:space:]]*device:[[:space:]]*\([^[:space:]]*\)$"
opened_dev=$(cryptsetup status ${name} 2>/dev/null | grep "${re}" | sed "s|${re}|\1|")
if [ "${opened_dev}" = "${dev}" ]
then
luks_device="/dev/mapper/${name}"
echo ${luks_device}
return 0
else
log_warning_msg "Cannot open luks device ${dev} since ${opened_dev} already is opened with its name"
return 1
fi
fi

load_keymap

while true
Expand Down

0 comments on commit bb77d0e

Please sign in to comment.