diff options
author | наб <[email protected]> | 2021-04-19 21:28:27 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2021-06-08 14:50:42 -0700 |
commit | ec3b25825e64f37f74605c451cfc026c28920715 (patch) | |
tree | c3c62570f8d6e595dccccfc9cee2326ea2c62667 /etc | |
parent | 0382362ce06a5514a97bbbf11dfe55e7e408898a (diff) |
etc/systemd/zfs-mount-generator: output tweaks
git-diff--w-dirty, but:
* zfs-load-key-$DSET.service -> zfs-load-key@$DSET.service
* flattened set -eu into other /bin/sh flags
* simpler (for 1 2 3 vs while [ counter ]; counter+=1) prompt loop
* exec $ZFS where applicable
Reviewed-by: Antonio Russo <[email protected]>
Reviewed-by: Richard Laager <[email protected]>
Reviewed-by: InsanePrawn <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Issue #11915
Closes #11917
Diffstat (limited to 'etc')
-rw-r--r-- | etc/systemd/system-generators/zfs-mount-generator.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/etc/systemd/system-generators/zfs-mount-generator.c b/etc/systemd/system-generators/zfs-mount-generator.c index 8deeed9df..b806339de 100644 --- a/etc/systemd/system-generators/zfs-mount-generator.c +++ b/etc/systemd/system-generators/zfs-mount-generator.c @@ -281,7 +281,7 @@ line_worker(char *line, const char *cachefile) if (strcmp(p_encroot, "-") != 0) { char *keyloadunit = - systemd_escape(p_encroot, "zfs-load-key-", ".service"); + systemd_escape(p_encroot, "zfs-load-key@", ".service"); if (strcmp(dataset, p_encroot) == 0) { const char *keymountdep = NULL; @@ -360,33 +360,27 @@ line_worker(char *line, const char *cachefile) "# dataset is a parent of the root filesystem.\n" "StandardOutput=null\n" "StandardError=null\n" - "ExecStart=/bin/sh -c '" - "set -eu;" - "keystatus=\"$$(" ZFS " get -H -o value keystatus \"%s\")\";" - "[ \"$$keystatus\" = \"unavailable\" ] || exit 0;", + "ExecStart=/bin/sh -euc '" + "[ \"$$(" ZFS " get -H -o value keystatus \"%s\")\" = \"unavailable\" ] || exit 0;", dataset); if (is_prompt) fprintf(keyloadunit_f, - "count=0;" - "while [ $$count -lt 3 ]; do " + "for i in 1 2 3; do " "systemd-ask-password --id=\"zfs:%s\" \"Enter passphrase for %s:\" |" "" ZFS " load-key \"%s\" && exit 0;" - "count=$$((count + 1));" "done;" "exit 1", dataset, dataset, dataset); else fprintf(keyloadunit_f, - "" ZFS " load-key \"%s\"", + "exec " ZFS " load-key \"%s\"", dataset); fprintf(keyloadunit_f, "'\n" - "ExecStop=/bin/sh -c '" - "set -eu;" - "keystatus=\"$$(" ZFS " get -H -o value keystatus \"%s\")\";" - "[ \"$$keystatus\" = \"available\" ] || exit 0;" - "" ZFS " unload-key \"%s\"" + "ExecStop=/bin/sh -euc '" + "[ \"$$(" ZFS " get -H -o value keystatus \"%s\")\" = \"available\" ] || exit 0;" + "exec " ZFS " unload-key \"%s\"" "'\n", dataset, dataset); /* END CSTYLED */ |