From 8158cd6d5e6464adaea135ada586f11b9dfca766 Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Sat, 14 Oct 2017 18:08:25 +0200 Subject: nixos/luksroot.nix: fallback to interactive password entry when no keyfile found --- nixos/modules/system/boot/luksroot.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'nixos/modules/system') diff --git a/nixos/modules/system/boot/luksroot.nix b/nixos/modules/system/boot/luksroot.nix index 06f004fb06ec..19ca2a2c1bd6 100644 --- a/nixos/modules/system/boot/luksroot.nix +++ b/nixos/modules/system/boot/luksroot.nix @@ -43,8 +43,15 @@ let open_normally() { echo luksOpen ${device} ${name} ${optionalString allowDiscards "--allow-discards"} \ ${optionalString (header != null) "--header=${header}"} \ - ${optionalString (keyFile != null) "--key-file=${keyFile} ${optionalString (keyFileSize != null) "--keyfile-size=${toString keyFileSize}"}"} \ > /.luksopen_args + ${optionalString (keyFile != null) '' + if [ -e ${keyFile} ]; then + echo " --key-file=${keyFile} ${optionalString (keyFileSize != null) "--keyfile-size=${toString keyFileSize}"}" \ + >> /.luksopen_args + else + echo "keyfile ${keyFile} not found -- fallback to interactive unlocking" + fi + ''} cryptsetup-askpass rm /.luksopen_args } -- cgit 1.4.1