-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
systemd: Fix systemd-{cryptenroll,cryptsetup} TPM2 and FIDO2 support #179823
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
Conversation
Update pkgs/os-specific/linux/systemd/default.nix Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
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 tried this with FIDO2, and the following changes are required:
- Since #167167, files in
${cfg.package}/lib
are only selectively copied. This meanslib/systemd/.systemd-cryptsetup-wrapped
doesn't exist andsystemd-cryptsetup@.service
simply crashes with255/EXCEPTION
. - The above problem also means that
lib/cryptsetup/libcryptsetup-token-systemd-{tpm2,fido2}.so
do not exist in initrd, causing immediate fallback to password. - A missing dependency means that FIDO2 support is not actually added into
systemdStage1
: #184510. libfido2
needs to be added to the initrd as well, otherwise the unlocking process will simply crash withFIDO2 support is not installed
.
I don't have enough compute to actually rebuild the world, so I used the following config to replicate the PR:
{ pkgs, lib, ... }:
let
cryptsetup' = pkgs.cryptsetup.overrideAttrs (old: {
patches = (old.patches or []) ++ [
./relative-token-path.patch
];
});
# https://github.com/NixOS/nixpkgs/pull/184510
libfido2' = pkgs.libfido2.overrideAttrs (old: {
propagatedBuildInputs = (old.propagatedBuildInputs or []) ++ [
pkgs.openssl
];
});
patchSystemd = systemd: (systemd.override {
cryptsetup = cryptsetup';
libfido2 = libfido2';
}).overrideAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or []) ++ [
pkgs.makeBinaryWrapper
];
postFixup = (old.postFixup or "") + ''
for f in lib/systemd/systemd-cryptsetup bin/systemd-cryptenroll; do
# This needs to be in LD_LIBRARY_PATH because rpath on a binary is not propagated to libraries using dlopen, in this case `libcryptsetup.so`
wrapProgram $out/$f --prefix LD_LIBRARY_PATH : ${placeholder "out"}/lib/cryptsetup
done
'';
});
systemdStage1' = patchSystemd pkgs.systemdStage1;
in {
boot.initrd.systemd = {
enable = true;
package = systemdStage1';
emergencyAccess = true;
initrdBin = with pkgs; [ gnugrep cryptsetup strace ]; # for debugging only
storePaths = [
# FIXME: Add to PR in a clean way
"${systemdStage1'}/lib/systemd/.systemd-cryptsetup-wrapped"
"${systemdStage1'}/lib/cryptsetup/libcryptsetup-token-systemd-tpm2.so"
"${systemdStage1'}/lib/cryptsetup/libcryptsetup-token-systemd-fido2.so"
libfido2'
];
};
}
FIDO2 unlocking works with the above changes, and I haven't tested TPM2.
Is there anything that could be done to speed up merge of this PR? It's the only thing that keeps me from installing NixOS on my laptop, and I would be glad to help with anything |
What needs to be done are:
@zhaofengli Do you mind further helping with this PR? |
I'll test out TPM2 and see how we can make those changes cleanly over the weekend. |
I opened #189676 with the required changes and instructions to test. |
Superseded by #189676 |
Description of changes
With this change it is now possible to decrypt LUKs protected partitions with a FIDO2 or TPM2 token.
Reviving #171242
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes