]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Systemd mount generator: Silence shellcheck warnings
authorInsanePrawn <insane.prawny@gmail.com>
Sat, 11 Jan 2020 18:14:23 +0000 (19:14 +0100)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 14 Feb 2020 23:32:33 +0000 (15:32 -0800)
Silences a warning about an intentionally unquoted variable.
Fixes a warning caused by strings split across lines by slightly
refactoring keyloadcmd.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Closes #9649

etc/systemd/system-generators/zfs-mount-generator.in

index b79ce5482e598f3191e3a298dc185045cbba7f23..411b3f955349f1cf826717aca12407f0dde3ef36 100755 (executable)
@@ -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