Skip to content

Fix systemd-ssh changes#390565

Merged
ElvishJerricco merged 2 commits intoNixOS:stagingfrom
ElvishJerricco:push-trtvxzqmkplv
Mar 17, 2025
Merged

Fix systemd-ssh changes#390565
ElvishJerricco merged 2 commits intoNixOS:stagingfrom
ElvishJerricco:push-trtvxzqmkplv

Conversation

@ElvishJerricco
Copy link
Contributor

#372979 Introduced a few major problems.

  1. The test required building a new ISO on every iteration. This is a significant storage cost for Hydra.
  2. The test required nested virtualisation to work, which is not a given on our builder hardware.
  3. Most importantly, it broke sshd@.service, because every SSH connection that closed resulted in its corresponding systemd unit entering a failed state. Not fatal to functionality, but makes the system considered degraded. There may have been an avenue for a DoS attack, though we didn't get that far examining it.

This no longer tests systemd-ssh's AF_VSOCK functionality. Unfortunately, without nested virtualisation, I'm not sure this is possible. In theory, you could use the host's vsock space, but /dev/vhost-vsock is not available in the sandbox, and you have to hard code a cid for the guest which will clash with others. I think you really do need nested virtualisation, unless qemu has a way to create a unix socket on the host that presents as vsock to the guest.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • 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/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 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.

Add a 👍 reaction to pull requests you find important.

In afeb76d, sshd.service and
sshd@.service were switched to Type=notify. This apparently works for
sshd.service, but not for sshd@.service. Given that the reason for
this working with sshd.service isn't exactly clear, let's revert it
for both of them for now, and revisit Type=notify later.
@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Mar 17, 2025
Copy link
Contributor

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

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

Definitely want the fix for the notify business if that's not supported by the openssh service.

The test changes to make the test do less and test less because of Hydra and specific present limitations makes me sad. Isn't there a way to mark something as not to be run in Hydra? I'd rather rely on those with beefy machines to test it out rather than just missing the coverage, especially when the test was as clear (in my view) as @NyCodeGHG's test was.

environment.LD_LIBRARY_PATH = nssModulesPath;

serviceConfig = {
Type = "notify";
Copy link
Contributor

Choose a reason for hiding this comment

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

Pretty sure this was my curiosity leading @NyCodeGHG astray. Sorry!

@ElvishJerricco
Copy link
Contributor Author

Isn't there a way to mark something as not to be run in Hydra?

@philiptaron Even if we did that, we still shouldn't be using an ISO for it. That's a really heavyweight way to start a VM. I don't think we can afford to resolve this right now. If someone wants to write a better test in the future, they may.

FWIW, we're not just testing less here. We're also testing more, because we weren't testing the container path before.

restartTriggers = [ config.environment.etc."ssh/sshd_config".source ];

serviceConfig = {
Type = "notify";
Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty sure this should work fine, but it's also fine for me to re-introduce this later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@NyCodeGHG Yea, I'm pretty sure you're right that non-socket-activated sshd.service now supports sd_notify, which it didn't in the past. But I want to introduce that improvement in a separate PR where we can more seriously test and check it.

Copy link
Member

@NyCodeGHG NyCodeGHG left a comment

Choose a reason for hiding this comment

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

successfully built nixosTests.{systemd-ssh-proxy,openssh} on x86_64-linux

@ElvishJerricco ElvishJerricco merged commit bbf66d5 into NixOS:staging Mar 17, 2025
25 of 27 checks passed
@ElvishJerricco ElvishJerricco deleted the push-trtvxzqmkplv branch March 17, 2025 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants