forked from mirrors/nixpkgs
Merge pull request #91344 from ElvishJerricco/zfs-encryption-systemd-ask-password
ZFS: Ask for stage 2 encryption passwords using systemd-ask-password
This commit is contained in:
commit
105e63469d
|
@ -102,6 +102,8 @@ in
|
|||
systemd.services.plymouth-poweroff.wantedBy = [ "poweroff.target" ];
|
||||
systemd.services.plymouth-reboot.wantedBy = [ "reboot.target" ];
|
||||
systemd.services.plymouth-read-write.wantedBy = [ "sysinit.target" ];
|
||||
systemd.services.systemd-ask-password-plymouth.wantedBy = ["multi-user.target"];
|
||||
systemd.paths.systemd-ask-password-plymouth.wantedBy = ["multi-user.target"];
|
||||
|
||||
boot.initrd.extraUtilsCommands = ''
|
||||
copy_bin_and_libs ${pkgs.plymouth}/bin/plymouthd
|
||||
|
@ -146,6 +148,7 @@ in
|
|||
# We use `mkAfter` to ensure that LUKS password prompt would be shown earlier than the splash screen.
|
||||
boot.initrd.preLVMCommands = mkAfter ''
|
||||
mkdir -p /etc/plymouth
|
||||
mkdir -p /run/plymouth
|
||||
ln -s ${configFile} /etc/plymouth/plymouthd.conf
|
||||
ln -s $extraUtils/share/plymouth/plymouthd.defaults /etc/plymouth/plymouthd.defaults
|
||||
ln -s $extraUtils/share/plymouth/logo.png /etc/plymouth/logo.png
|
||||
|
|
|
@ -490,7 +490,11 @@ in
|
|||
description = "Import ZFS pool \"${pool}\"";
|
||||
# we need systemd-udev-settle until https://github.com/zfsonlinux/zfs/pull/4943 is merged
|
||||
requires = [ "systemd-udev-settle.service" ];
|
||||
after = [ "systemd-udev-settle.service" "systemd-modules-load.service" ];
|
||||
after = [
|
||||
"systemd-udev-settle.service"
|
||||
"systemd-modules-load.service"
|
||||
"systemd-ask-password-console.service"
|
||||
];
|
||||
wantedBy = (getPoolMounts pool) ++ [ "local-fs.target" ];
|
||||
before = (getPoolMounts pool) ++ [ "local-fs.target" ];
|
||||
unitConfig = {
|
||||
|
@ -515,7 +519,20 @@ in
|
|||
done
|
||||
poolImported "${pool}" || poolImport "${pool}" # Try one last time, e.g. to import a degraded pool.
|
||||
if poolImported "${pool}"; then
|
||||
${optionalString cfgZfs.requestEncryptionCredentials "\"${packages.zfsUser}/sbin/zfs\" load-key -r \"${pool}\""}
|
||||
${optionalString cfgZfs.requestEncryptionCredentials ''
|
||||
${packages.zfsUser}/sbin/zfs list -rHo name,keylocation ${pool} | while IFS=$'\t' read ds kl; do
|
||||
(case "$kl" in
|
||||
none )
|
||||
;;
|
||||
prompt )
|
||||
${config.systemd.package}/bin/systemd-ask-password "Enter key for $ds:" | ${packages.zfsUser}/sbin/zfs load-key "$ds"
|
||||
;;
|
||||
* )
|
||||
${packages.zfsUser}/sbin/zfs load-key "$ds"
|
||||
;;
|
||||
esac) < /dev/null # To protect while read ds kl in case anything reads stdin
|
||||
done
|
||||
''}
|
||||
echo "Successfully imported ${pool}"
|
||||
else
|
||||
exit 1
|
||||
|
|
Loading…
Reference in a new issue