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

runInLinuxVM: Ensure tools requiring /etc/passwd work #80680

Merged
merged 1 commit into from Feb 23, 2020

Conversation

samueldr
Copy link
Member

This includes, but is not limited to:

  • whoami
  • nix >= 2.3.1

See

Motivation for this change

Fix a system regression in 19.09, where nixops will not work using libvirtd, as pointed out personally to me by @JoeDupuis.

This fix, though, is a much broader fix, and could fix any tool that tries to identify the user in this step.

Things done

Tested using this:

let
  pkgs = import <nixpkgs> {};
  script = name: cmd: pkgs.runCommand "runInLinuxVM--lack-of-user--${name}" {
    buildInputs = with pkgs; [
      utillinux
      shadow
    ];
  } ''
    (PS4=" $ "; set -x
      ${cmd}
    )
  '';
  test = name: cmd: pkgs.vmTools.runInLinuxVM (script name cmd);
in
  [
    (test "id" "id | grep root")
    (test "whoami" "whoami")
    # https://github.com/NixOS/nixpkgs/issues/71157
    (test "nix" "${pkgs.nix.out}/bin/nix-store --version")
  ]

You can verify that without this fix, both on unstable, and 19.09 this fails in three different, but coherent ways. With this fix applied, it works.

This should be backported to 19.09, in my opinion, as this is a system breakage from a minor bump from nix in the nixops ecosystem.

This has to be backported to 20.03 if accepted in master.

  • 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.

@samueldr samueldr added the 9.needs: port to stable A PR needs a backport to the stable release. label Feb 20, 2020
This includes, but is not limited to:

 * whoami
 * nix >= 2.3.1

See

 * NixOS#71157
 * NixOS/nixops#1216
 * nix-community/nixops-libvirtd#5
@samueldr samueldr changed the title runInLinuxVM: Ensure tools requiring /etc/passwd works runInLinuxVM: Ensure tools requiring /etc/passwd work Feb 20, 2020
@samueldr samueldr merged commit 972678e into NixOS:master Feb 23, 2020
@samueldr samueldr deleted the fix/71157 branch February 23, 2020 21:06
dtzWill pushed a commit to dtzWill/nixpkgs that referenced this pull request Feb 24, 2020
runInLinuxVM: Ensure tools requiring /etc/passwd work
(cherry picked from commit 972678e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant