about summary refs log tree commit diff
path: root/nixos/modules/tasks/filesystems
diff options
context:
space:
mode:
authorWill Fancher <elvishjerricco@gmail.com>2022-04-14 17:21:10 -0400
committerWill Fancher <elvishjerricco@gmail.com>2022-05-03 12:55:01 -0400
commit8555a7fdbfdf7d27096de9b23b650244d842780c (patch)
tree0a1b7d334ebdb5d77d521aee7a66ca6e1232458e /nixos/modules/tasks/filesystems
parent44a6882f55865b39f4ba9b9cb3ae3ddb661c1b24 (diff)
downloadnixlib-8555a7fdbfdf7d27096de9b23b650244d842780c.tar
nixlib-8555a7fdbfdf7d27096de9b23b650244d842780c.tar.gz
nixlib-8555a7fdbfdf7d27096de9b23b650244d842780c.tar.bz2
nixlib-8555a7fdbfdf7d27096de9b23b650244d842780c.tar.lz
nixlib-8555a7fdbfdf7d27096de9b23b650244d842780c.tar.xz
nixlib-8555a7fdbfdf7d27096de9b23b650244d842780c.tar.zst
nixlib-8555a7fdbfdf7d27096de9b23b650244d842780c.zip
zfs: Allow three tries to decrypt datasets
Diffstat (limited to 'nixos/modules/tasks/filesystems')
-rw-r--r--nixos/modules/tasks/filesystems/zfs.nix9
1 files changed, 8 insertions, 1 deletions
diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix
index 5890fe89cf4f..306bd2552177 100644
--- a/nixos/modules/tasks/filesystems/zfs.nix
+++ b/nixos/modules/tasks/filesystems/zfs.nix
@@ -146,7 +146,14 @@ let
                 none )
                   ;;
                 prompt )
-                  ${systemd}/bin/systemd-ask-password "Enter key for $ds:" | ${cfgZfs.package}/sbin/zfs load-key "$ds"
+                  tries=3
+                  success=false
+                  while [[ $success != true ]] && [[ $tries -gt 0 ]]; do
+                    ${systemd}/bin/systemd-ask-password "Enter key for $ds:" | ${cfgZfs.package}/sbin/zfs load-key "$ds" \
+                      && success=true \
+                      || tries=$((tries - 1))
+                  done
+                  [[ $success = true ]]
                   ;;
                 * )
                   ${cfgZfs.package}/sbin/zfs load-key "$ds"