-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
nixos/unl0kr: fix tests, change default package to buffybox (bumps unl0kr to 3.2.0-unstable-2024-11-10) #362825
Draft
hustlerone
wants to merge
3
commits into
NixOS:master
Choose a base branch
from
hustlerone:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+124
−169
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,86 @@ | ||
import ./make-test-python.nix ({ lib, pkgs, ... }: let | ||
passphrase = "secret"; | ||
in { | ||
name = "systemd-initrd-luks-unl0kr"; | ||
meta = { | ||
maintainers = []; | ||
}; | ||
import ./make-test-python.nix ( | ||
{ lib, pkgs, ... }: | ||
let | ||
passphrase = "secret"; | ||
in | ||
{ | ||
name = "systemd-initrd-luks-unl0kr"; # How to run an interactive test: `nix run .#nixosTests.systemd-initrd-luks-unl0kr.driverInteractive' | ||
meta = { | ||
maintainers = [ ]; | ||
}; | ||
|
||
enableOCR = true; | ||
enableOCR = true; | ||
|
||
nodes.machine = { pkgs, ... }: { | ||
virtualisation = { | ||
emptyDiskImages = [ 512 512 ]; | ||
useBootLoader = true; | ||
mountHostNixStore = true; | ||
useEFIBoot = true; | ||
qemu.options = [ | ||
"-vga virtio" | ||
]; | ||
}; | ||
boot.loader.systemd-boot.enable = true; | ||
nodes.machine = | ||
{ pkgs, ... }: | ||
{ | ||
virtualisation = { | ||
emptyDiskImages = [ | ||
512 | ||
512 | ||
]; | ||
useBootLoader = true; | ||
mountHostNixStore = true; | ||
useEFIBoot = true; | ||
qemu.options = [ | ||
"-vga virtio" | ||
]; | ||
}; | ||
boot.loader.systemd-boot.enable = true; | ||
|
||
boot.initrd.availableKernelModules = [ | ||
"evdev" # for entering pw | ||
"bochs" | ||
]; | ||
boot.initrd.availableKernelModules = [ | ||
"bochs" # for debugging | ||
]; | ||
|
||
environment.systemPackages = with pkgs; [ cryptsetup ]; | ||
boot.initrd = { | ||
systemd = { | ||
enable = true; | ||
emergencyAccess = true; | ||
}; | ||
unl0kr.enable = true; | ||
}; | ||
environment.systemPackages = with pkgs; [ | ||
cryptsetup | ||
bintools | ||
]; # I need strings to debug buffybox | ||
boot.initrd = { | ||
systemd = { | ||
enable = true; | ||
emergencyAccess = true; | ||
}; | ||
unl0kr.enable = true; | ||
}; | ||
|
||
specialisation.boot-luks.configuration = { | ||
boot.initrd.luks.devices = lib.mkVMOverride { | ||
# We have two disks and only type one password - key reuse is in place | ||
cryptroot.device = "/dev/vdb"; | ||
cryptroot2.device = "/dev/vdc"; | ||
specialisation.boot-luks.configuration = { | ||
boot.initrd.luks.devices = lib.mkVMOverride { | ||
# We have two disks and only type one password - key reuse is in place | ||
cryptroot.device = "/dev/vdb"; | ||
cryptroot2.device = "/dev/vdc"; | ||
}; | ||
virtualisation.rootDevice = "/dev/mapper/cryptroot"; | ||
virtualisation.fileSystems."/".autoFormat = true; | ||
# test mounting device unlocked in initrd after switching root | ||
virtualisation.fileSystems."/cryptroot2".device = "/dev/mapper/cryptroot2"; | ||
}; | ||
}; | ||
virtualisation.rootDevice = "/dev/mapper/cryptroot"; | ||
virtualisation.fileSystems."/".autoFormat = true; | ||
# test mounting device unlocked in initrd after switching root | ||
virtualisation.fileSystems."/cryptroot2".device = "/dev/mapper/cryptroot2"; | ||
}; | ||
}; | ||
|
||
testScript = '' | ||
# Create encrypted volume | ||
machine.wait_for_unit("multi-user.target") | ||
machine.succeed("echo -n ${passphrase} | cryptsetup luksFormat -q --iter-time=1 /dev/vdb -") | ||
machine.succeed("echo -n ${passphrase} | cryptsetup luksFormat -q --iter-time=1 /dev/vdc -") | ||
machine.succeed("echo -n ${passphrase} | cryptsetup luksOpen -q /dev/vdc cryptroot2") | ||
machine.succeed("mkfs.ext4 /dev/mapper/cryptroot2") | ||
testScript = '' | ||
# Create encrypted volume | ||
machine.wait_for_unit("multi-user.target") | ||
machine.succeed("echo -n ${passphrase} | cryptsetup luksFormat -q --iter-time=1 /dev/vdb -") | ||
machine.succeed("echo -n ${passphrase} | cryptsetup luksFormat -q --iter-time=1 /dev/vdc -") | ||
machine.succeed("echo -n ${passphrase} | cryptsetup luksOpen -q /dev/vdc cryptroot2") | ||
machine.succeed("mkfs.ext4 /dev/mapper/cryptroot2") | ||
|
||
# Boot from the encrypted disk | ||
machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-luks.conf") | ||
machine.succeed("sync") | ||
machine.crash() | ||
# Boot from the encrypted disk | ||
machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-luks.conf") | ||
machine.succeed("sync") | ||
machine.crash() | ||
|
||
# Boot and decrypt the disk | ||
machine.start() | ||
machine.wait_for_text("Password required for booting") | ||
machine.screenshot("prompt") | ||
machine.send_chars("${passphrase}") | ||
machine.screenshot("pw") | ||
machine.send_chars("\n") | ||
machine.wait_for_unit("multi-user.target") | ||
# Boot and decrypt the disk. This part of the test is SLOW. | ||
machine.start() | ||
machine.wait_for_text("password") # This is the best keyword for such prompts. | ||
machine.screenshot("prompt") | ||
machine.send_chars("${passphrase}") | ||
machine.screenshot("pw") | ||
machine.send_chars("\n") | ||
machine.wait_for_unit("multi-user.target") | ||
|
||
assert "/dev/mapper/cryptroot on / type ext4" in machine.succeed("mount"), "/dev/mapper/cryptroot do not appear in mountpoints list" | ||
assert "/dev/mapper/cryptroot2 on /cryptroot2 type ext4" in machine.succeed("mount") | ||
''; | ||
}) | ||
assert "/dev/mapper/cryptroot on / type ext4" in machine.succeed("mount"), "/dev/mapper/cryptroot do not appear in mountpoints list" | ||
assert "/dev/mapper/cryptroot2 on /cryptroot2 type ext4" in machine.succeed("mount") | ||
''; | ||
} | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1325,6 +1325,7 @@ mapAliases { | |
unifi8 = unifi; # Added 2024-11-15 | ||
unifiLTS = throw "'unifiLTS' has been removed since UniFi no longer has LTS and stable releases. Use `pkgs.unifi` instead."; # Added 2024-04-11 | ||
unifiStable = throw "'unifiStable' has been removed since UniFi no longer has LTS and stable releases. Use `pkgs.unifi` instead."; # Converted to throw 2024-04-11 | ||
unl0kr = throw "'unl0kr' is now included with buffybox. Use `pkgs.buffybox` instead."; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a comment with the date at the end? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forgout about it |
||
untrunc = throw "'untrunc' has been renamed to/replaced by 'untrunc-anthwlock'"; # Converted to throw 2024-10-17 | ||
urxvt_autocomplete_all_the_things = throw "'urxvt_autocomplete_all_the_things' has been renamed to/replaced by 'rxvt-unicode-plugins.autocomplete-all-the-things'"; # Converted to throw 2024-10-17 | ||
urxvt_bidi = throw "'urxvt_bidi' has been renamed to/replaced by 'rxvt-unicode-plugins.bidi'"; # Converted to throw 2024-10-17 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try just adding
buffybox
toboot.initrd.systemd.packages
rather than duplicating the upstream systemd units? Would be a lot cleaner. Should just need to manually add the necessarywantedBy
to thepath
unit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm attempting to use the password agent from upstream, rewritten in C.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I currently don't know how to debug the systemd service, is there a manual entry for debugging stage 1 services?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a way to get a shell in stage 1, then you can manually run commands to check whatever you want to do. Would that be helpful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The buffybox package has upstream unit files that can be included in initrd automatically by setting
boot.initrd.systemd.packages = [ buffybox ];
so you don't have to reimplement the units yourself here.You can get a debug shell in systemd initrd by adding the
rd.systemd.debug_shell
kernel param and switching to VT9