Systemd mount generator: don't fail keyload from file if already loaded
Previously the generated keyload units for encryption roots with keylocation=file://* didn't contain the code to detect if the key was already loaded and would be marked failed in such situations. Move the code to check whether the key is already loaded from keylocation=prompt handling to general key loading code. Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: InsanePrawn <insane.prawny@gmail.com> Closes #10103
This commit is contained in:
parent
2b95e91132
commit
ff2f960b24
@ -151,13 +151,9 @@ process_line() {
|
|||||||
else
|
else
|
||||||
keymountdep="RequiresMountsFor='${p_keyloc#file://}'"
|
keymountdep="RequiresMountsFor='${p_keyloc#file://}'"
|
||||||
fi
|
fi
|
||||||
keyloadcmd="@sbindir@/zfs load-key '${dataset}'"
|
keyloadscript="@sbindir@/zfs load-key \"${dataset}\""
|
||||||
elif [ "${p_keyloc}" = "prompt" ] ; then
|
elif [ "${p_keyloc}" = "prompt" ] ; then
|
||||||
keyloadcmd="\
|
keyloadscript="\
|
||||||
/bin/sh -c '\
|
|
||||||
set -eu;\
|
|
||||||
keystatus=\"\$\$(@sbindir@/zfs get -H -o value keystatus \"${dataset}\")\";\
|
|
||||||
[ \"\$\$keystatus\" = \"unavailable\" ] || exit 0;\
|
|
||||||
count=0;\
|
count=0;\
|
||||||
while [ \$\$count -lt 3 ];do\
|
while [ \$\$count -lt 3 ];do\
|
||||||
systemd-ask-password --id=\"zfs:${dataset}\"\
|
systemd-ask-password --id=\"zfs:${dataset}\"\
|
||||||
@ -165,11 +161,19 @@ while [ \$\$count -lt 3 ];do\
|
|||||||
@sbindir@/zfs load-key \"${dataset}\" && exit 0;\
|
@sbindir@/zfs load-key \"${dataset}\" && exit 0;\
|
||||||
count=\$\$((count + 1));\
|
count=\$\$((count + 1));\
|
||||||
done;\
|
done;\
|
||||||
exit 1'"
|
exit 1"
|
||||||
else
|
else
|
||||||
printf 'zfs-mount-generator: (%s) invalid keylocation\n' \
|
printf 'zfs-mount-generator: (%s) invalid keylocation\n' \
|
||||||
"${dataset}" >/dev/kmsg
|
"${dataset}" >/dev/kmsg
|
||||||
fi
|
fi
|
||||||
|
keyloadcmd="\
|
||||||
|
/bin/sh -c '\
|
||||||
|
set -eu;\
|
||||||
|
keystatus=\"\$\$(@sbindir@/zfs get -H -o value keystatus \"${dataset}\")\";\
|
||||||
|
[ \"\$\$keystatus\" = \"unavailable\" ] || exit 0;\
|
||||||
|
${keyloadscript}'"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Generate the key-load .service unit
|
# Generate the key-load .service unit
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user