Skip to content
Permalink
Browse files

Systemd mount generator: Silence shellcheck warnings

Silences a warning about an intentionally unquoted variable.
Fixes a warning caused by strings split across lines by slightly
refactoring keyloadcmd.

Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
  • Loading branch information
InsanePrawn committed Jan 11, 2020
1 parent 4f4ddf9 commit a5a232cd43ee3a6eef92a183d4e478b6b889dcab
Showing with 14 additions and 11 deletions.
  1. +14 −11 etc/systemd/system-generators/zfs-mount-generator.in
@@ -60,6 +60,7 @@ process_line() {
IFS="$(printf '\t')"
# protect against special characters in, e.g., mountpoints
set -f
# shellcheck disable=SC2086
set -- $1
dataset="${1}"
p_mountpoint="${2}"
@@ -87,17 +88,19 @@ process_line() {
pathdep="RequiresMountsFor='${p_keyloc#file://}'"
keyloadcmd="@sbindir@/zfs load-key '${dataset}'"
elif [ "${p_keyloc}" = "prompt" ] ; then
keyloadcmd="/bin/sh -c 'set -eu;"\
"keystatus=\"\$\$(@sbindir@/zfs get -H -o value keystatus \"${dataset}\")\";"\
"[ \"\$\$keystatus\" = \"unavailable\" ] || exit 0;"\
"count=0;"\
"while [ \$\$count -lt 3 ];do"\
" systemd-ask-password --id=\"zfs:${dataset}\""\
" \"Enter passphrase for ${dataset}:\"|"\
" @sbindir@/zfs load-key \"${dataset}\" && exit 0;"\
" count=\$\$((count + 1));"\
"done;"\
"exit 1'"
keyloadcmd="\
/bin/sh -c '\
set -eu;\
keystatus=\"\$\$(@sbindir@/zfs get -H -o value keystatus \"${dataset}\")\";\
[ \"\$\$keystatus\" = \"unavailable\" ] || exit 0;\
count=0;\
while [ \$\$count -lt 3 ];do\
systemd-ask-password --id=\"zfs:${dataset}\"\
\"Enter passphrase for ${dataset}:\"|\
@sbindir@/zfs load-key \"${dataset}\" && exit 0;\
count=\$\$((count + 1));\
done;\
exit 1'"
else
printf 'zfs-mount-generator: (%s) invalid keylocation\n' \
"${dataset}" >/dev/kmsg

0 comments on commit a5a232c

Please sign in to comment.
You can’t perform that action at this time.