mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 03:09:34 +03:00
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 <aerusso@aerusso.net> Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: InsanePrawn <insane.prawny@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Issue #11915 Closes #11917
This commit is contained in:
parent
5a1fb060fd
commit
5611bdc8f0
@ -281,7 +281,7 @@ line_worker(char *line, const char *cachefile)
|
|||||||
|
|
||||||
if (strcmp(p_encroot, "-") != 0) {
|
if (strcmp(p_encroot, "-") != 0) {
|
||||||
char *keyloadunit =
|
char *keyloadunit =
|
||||||
systemd_escape(p_encroot, "zfs-load-key-", ".service");
|
systemd_escape(p_encroot, "zfs-load-key@", ".service");
|
||||||
|
|
||||||
if (strcmp(dataset, p_encroot) == 0) {
|
if (strcmp(dataset, p_encroot) == 0) {
|
||||||
const char *keymountdep = NULL;
|
const char *keymountdep = NULL;
|
||||||
@ -360,33 +360,27 @@ line_worker(char *line, const char *cachefile)
|
|||||||
"# dataset is a parent of the root filesystem.\n"
|
"# dataset is a parent of the root filesystem.\n"
|
||||||
"StandardOutput=null\n"
|
"StandardOutput=null\n"
|
||||||
"StandardError=null\n"
|
"StandardError=null\n"
|
||||||
"ExecStart=/bin/sh -c '"
|
"ExecStart=/bin/sh -euc '"
|
||||||
"set -eu;"
|
"[ \"$$(" ZFS " get -H -o value keystatus \"%s\")\" = \"unavailable\" ] || exit 0;",
|
||||||
"keystatus=\"$$(" ZFS " get -H -o value keystatus \"%s\")\";"
|
|
||||||
"[ \"$$keystatus\" = \"unavailable\" ] || exit 0;",
|
|
||||||
dataset);
|
dataset);
|
||||||
if (is_prompt)
|
if (is_prompt)
|
||||||
fprintf(keyloadunit_f,
|
fprintf(keyloadunit_f,
|
||||||
"count=0;"
|
"for i in 1 2 3; do "
|
||||||
"while [ $$count -lt 3 ]; do "
|
|
||||||
"systemd-ask-password --id=\"zfs:%s\" \"Enter passphrase for %s:\" |"
|
"systemd-ask-password --id=\"zfs:%s\" \"Enter passphrase for %s:\" |"
|
||||||
"" ZFS " load-key \"%s\" && exit 0;"
|
"" ZFS " load-key \"%s\" && exit 0;"
|
||||||
"count=$$((count + 1));"
|
|
||||||
"done;"
|
"done;"
|
||||||
"exit 1",
|
"exit 1",
|
||||||
dataset, dataset, dataset);
|
dataset, dataset, dataset);
|
||||||
else
|
else
|
||||||
fprintf(keyloadunit_f,
|
fprintf(keyloadunit_f,
|
||||||
"" ZFS " load-key \"%s\"",
|
"exec " ZFS " load-key \"%s\"",
|
||||||
dataset);
|
dataset);
|
||||||
|
|
||||||
fprintf(keyloadunit_f,
|
fprintf(keyloadunit_f,
|
||||||
"'\n"
|
"'\n"
|
||||||
"ExecStop=/bin/sh -c '"
|
"ExecStop=/bin/sh -euc '"
|
||||||
"set -eu;"
|
"[ \"$$(" ZFS " get -H -o value keystatus \"%s\")\" = \"available\" ] || exit 0;"
|
||||||
"keystatus=\"$$(" ZFS " get -H -o value keystatus \"%s\")\";"
|
"exec " ZFS " unload-key \"%s\""
|
||||||
"[ \"$$keystatus\" = \"available\" ] || exit 0;"
|
|
||||||
"" ZFS " unload-key \"%s\""
|
|
||||||
"'\n",
|
"'\n",
|
||||||
dataset, dataset);
|
dataset, dataset);
|
||||||
/* END CSTYLED */
|
/* END CSTYLED */
|
||||||
|
Loading…
Reference in New Issue
Block a user