diff options
author | Jean-Baptiste Lallement <[email protected]> | 2020-06-18 19:15:10 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2020-07-19 10:04:14 -0700 |
commit | ceadc0dbbd5594db153a61c3d82a6d98e1adca7d (patch) | |
tree | 77b3dab537a0e731cddb2020e81cf8b36ffb708c /etc/systemd | |
parent | b717f9b95e6b85ea502318f6350a6b6b6a237ebd (diff) |
Make unloading the key more robust
The unit was failing instead of stopping if someone manually unloaded
the key before stopping the unit (zfs unload-key is failing on an
unavailable key).
Follow a similar logic than for loading the key, checking for the key
status before unloading it.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Richard Laager <[email protected]>
Co-authored-by: Didier Roche <[email protected]>
Signed-off-by: Didier Roche <[email protected]>
Closes #10477
Diffstat (limited to 'etc/systemd')
-rwxr-xr-x | etc/systemd/system-generators/zfs-mount-generator.in | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/etc/systemd/system-generators/zfs-mount-generator.in b/etc/systemd/system-generators/zfs-mount-generator.in index f7a5161ec..fdef13cfa 100755 --- a/etc/systemd/system-generators/zfs-mount-generator.in +++ b/etc/systemd/system-generators/zfs-mount-generator.in @@ -173,6 +173,12 @@ set -eu;\ keystatus=\"\$\$(@sbindir@/zfs get -H -o value keystatus \"${dataset}\")\";\ [ \"\$\$keystatus\" = \"unavailable\" ] || exit 0;\ ${keyloadscript}'" + keyunloadcmd="\ +/bin/sh -c '\ +set -eu;\ +keystatus=\"\$\$(@sbindir@/zfs get -H -o value keystatus \"${dataset}\")\";\ +[ \"\$\$keystatus\" = \"available\" ] || exit 0;\ +@sbindir@/zfs unload-key \"${dataset}\"'" @@ -199,7 +205,7 @@ ${keymountdep} Type=oneshot RemainAfterExit=yes ExecStart=${keyloadcmd} -ExecStop=@sbindir@/zfs unload-key '${dataset}'" > "${dest_norm}/${keyloadunit}" +ExecStop=${keyunloadcmd}" > "${dest_norm}/${keyloadunit}" fi # Update the dependencies for the mount file to want the # key-loading unit. |