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

nixos/tests/systemd-credentials-tpm2: Add tests for systemd credentials #217254

Merged
merged 1 commit into from
Feb 20, 2023

Conversation

hesiod
Copy link
Contributor

@hesiod hesiod commented Feb 20, 2023

Description of changes

Add a test that checks whether systemd can access the TPM in order access credentials requested via Load/SetCredentialEncrypted.

See discussion in #214383 (comment)

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Copy link
Contributor

@flokli flokli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! That's what I had in mind :-)

Can you undraft this, so it can be merged?

@hesiod
Copy link
Contributor Author

hesiod commented Feb 20, 2023

@flokli Sure, just let me remove some debugging leftovers and add a meta.maintainers entry.

@hesiod hesiod force-pushed the nixos-test-systemd-credentials-master branch from 2c23772 to f6bede1 Compare February 20, 2023 12:22
@hesiod
Copy link
Contributor Author

hesiod commented Feb 20, 2023

@flokli Should be good to go now. I've cleaned the commit up and also added an additional check whether the software TPM process started up correctly, making the test more robust.

@hesiod hesiod marked this pull request as ready for review February 20, 2023 12:24
@hesiod
Copy link
Contributor Author

hesiod commented Feb 20, 2023

Just to make sure, let's see if it works for ofborg as well:
@ofborg test systemd-credentials-tpm2

@hesiod
Copy link
Contributor Author

hesiod commented Feb 20, 2023

It fails on aarch64 because the TPM device is called tpm-tis-device instead of tpm-tis on aarch64. The existing TPM tests don't handle this, but it should be an easy fix. I'll try fixing it, and if it doesn't work out I'll simply mark the test as x86_64-linux-only.

Add a test that checks whether systemd can access the TPM in order
access credentials requested via Load/SetCredentialEncrypted.
@hesiod hesiod force-pushed the nixos-test-systemd-credentials-master branch from f6bede1 to e83babd Compare February 20, 2023 12:55
@hesiod
Copy link
Contributor Author

hesiod commented Feb 20, 2023

@ofborg test systemd-credentials-tpm2

@hesiod
Copy link
Contributor Author

hesiod commented Feb 20, 2023

The test now also runs on aarch64-linux. A similar fix should apply to systemd-cryptenroll and systemd-initrd-luks-tpm2.

@flokli
Copy link
Contributor

flokli commented Feb 20, 2023

Thanks!

@flokli flokli merged commit d7c89bf into NixOS:master Feb 20, 2023
@hesiod hesiod deleted the nixos-test-systemd-credentials-master branch February 20, 2023 20:57

let
tpmSocketPath = "/tmp/swtpm-sock";
tpmDeviceModels = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JJJollyjim would you be interested in backporting the aarch64 fixes into the other tpm-related tests? Maybe we can also move the Tpm class to a more central place, so less needs to be copypasted.

figsoda pushed a commit to figsoda/nixpkgs that referenced this pull request Feb 20, 2023
…tials-master

nixos/tests/systemd-credentials-tpm2: Add tests for systemd credentials
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants