crypt: skip crypttab entries with the same device

It was only checked, if the name of the crypttab entry matched.
This patch adds checking, if the device matches.
master
Harald Hoyer 2015-07-13 10:39:07 +02:00
parent 8c7dc032f8
commit 968280e370
2 changed files with 7 additions and 1 deletions

View File

@ -5,11 +5,17 @@ command -v getarg >/dev/null || . /lib/dracut-lib.sh
# check if the crypttab contains an entry for a LUKS UUID
crypttab_contains() {
local luks="$1"
local dev="$2"
local l d rest
if [ -f /etc/crypttab ]; then
while read l d rest || [ -n "$l" ]; do
strstr "${l##luks-}" "${luks##luks-}" && return 0
strstr "$d" "${luks##luks-}" && return 0
if [ -n "$dev" ]; then
for _dev in "$(devnames $d)"; do
[ "$dev" -ef "$_dev" ] && return 0
done
fi
done < /etc/crypttab
fi
return 1

View File

@ -6,7 +6,7 @@ type crypttab_contains >/dev/null 2>&1 || . /lib/dracut-crypt-lib.sh
dev=$1
luks=$2

crypttab_contains "$luks" && exit 0
crypttab_contains "$luks" "$dev" && exit 0

allowdiscards="-"