Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZFS: Ask for stage 2 encryption passwords using systemd-ask-password #91344

Merged

Conversation

@ElvishJerricco
Copy link
Contributor

ElvishJerricco commented Jun 23, 2020

Motivation for this change

Currently, ZFS pools that do not contain the system root file system can only have encrypted datasets that use key files. They cannot use keylocation=prompt. This PR fixes this by prompting for passphrases using systemd-ask-password.

This PR also ensures Plymouth users can take advantage of this by enabling systemd-ask-password-plymouth.service. I did have to steal one line from #84158, specifically mkdir /run/plymouth. This will have the added benefit of allowing other services to use systemd-ask-password during boot without breaking for plymouth users. Note that you need to set virtualisation.useBootLoader = true in order to test plymouth with nixos-rebuild build-vm.

Relevant: #84158, #88789

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
@ElvishJerricco ElvishJerricco changed the title ZFS: Ask for stage 2 encryption passwords using systemd-ask-password WIP: ZFS: Ask for stage 2 encryption passwords using systemd-ask-password Jun 23, 2020
@ElvishJerricco ElvishJerricco changed the title WIP: ZFS: Ask for stage 2 encryption passwords using systemd-ask-password ZFS: Ask for stage 2 encryption passwords using systemd-ask-password Jun 23, 2020
@ElvishJerricco
Copy link
Contributor Author

ElvishJerricco commented Jun 23, 2020

Having a bit of trouble testing this with legacy mountpoints. It asks for the passphrase during boot just fine, but I'm testing with (import ./nixos { ... }).vm, which wipes out fileSystems declarations. But keystatus says available, so I can't imagine it wouldn't work.

@@ -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 /run/plymouth

This comment has been minimized.

Copy link
@grahamc

grahamc Jul 2, 2020

Member

Is there any concern around this existing / should we make it -p just in case?

This comment has been minimized.

Copy link
@ElvishJerricco

ElvishJerricco Jul 2, 2020

Author Contributor

There's definitely no harm in -p but it's definitely not necessary. /run is created extremely early in stage 1.

ElvishJerricco and others added 3 commits Jun 23, 2020
Just in case something reads stdin, so that `while read ds kl` doesn't
miss anything
Co-authored-by: Graham Christensen <graham@grahamc.com>
@ElvishJerricco ElvishJerricco force-pushed the ElvishJerricco:zfs-encryption-systemd-ask-password branch from 4828e65 to e2f1594 Jul 2, 2020
@grahamc
grahamc approved these changes Jul 2, 2020
@grahamc grahamc merged commit 105e634 into NixOS:master Jul 2, 2020
15 checks passed
15 checks passed
Evaluation Performance Report Evaluator Performance Report
Details
grahamcofborg-eval ^.^!
Details
grahamcofborg-eval-check-meta config.nix: checkMeta = true
Details
grahamcofborg-eval-darwin nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="e2f1594"; rev="e2f1594695c3795c09f40ed7556af2bbc49b8fdc"; } ./pkgs/t
Details
grahamcofborg-eval-lib-tests nix-build --arg pkgs import ./. {} ./lib/tests/release.nix
Details
grahamcofborg-eval-nixos nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="e2f1594"; rev="e2f1594695c3795c09f40ed7556af2bbc49b8fdc"; } ./nixos/
Details
grahamcofborg-eval-nixos-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="e2f1594"; rev="e2f1594695c3795c09f40ed7556af2bbc49b8fdc"; } ./nixos/
Details
grahamcofborg-eval-nixos-options nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="e2f1594"; rev="e2f1594695c3795c09f40ed7556af2bbc49b8fdc"; } ./nixos/
Details
grahamcofborg-eval-nixpkgs-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="e2f1594"; rev="e2f1594695c3795c09f40ed7556af2bbc49b8fdc"; } ./pkgs/t
Details
grahamcofborg-eval-nixpkgs-tarball nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="e2f1594"; rev="e2f1594695c3795c09f40ed7556af2bbc49b8fdc"; } ./pkgs/t
Details
grahamcofborg-eval-nixpkgs-unstable-jobset nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="e2f1594"; rev="e2f1594695c3795c09f40ed7556af2bbc49b8fdc"; } ./pkgs/t
Details
grahamcofborg-eval-package-list nix-env -qa --json --file .
Details
grahamcofborg-eval-package-list-no-aliases nix-env -qa --json --file . --arg config { allowAliases = false; }
Details
plymouth, plymouth.passthru.tests on aarch64-linux Success
Details
plymouth, plymouth.passthru.tests on x86_64-linux Success
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.