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

fixed-output derivations: fix incorrect responses for getpwuid #5006

Merged
merged 1 commit into from
Jul 13, 2021

Conversation

illustris
Copy link
Contributor

Passing nscd socket into the build environment causes unexpected behavior in programs that make getpwuid and other related calls.

relevant threads:

Passing nscd socket into the build environment causes unexpected behavior in programs that make getpwuid and other related calls.

relevant threads:
- NixOS#4991
- https://discourse.nixos.org/t/haunted-nix-build-breaks-isolation/13869
@edolstra
Copy link
Member

No, we need the nscd socket to do DNS lookups etc. (see b6b142b).

@illustris
Copy link
Contributor Author

Yes, b6b142b was mentioned in the issue associated with this PR ( #4991 ). This was necessary back when you made this change because of

ss.push_back("/etc/nsswitch.conf");

DNS resolution was failing because your machine's /etc/nsswitch.conf could not be satisfied inside the build env.

This was changed to

writeFile(chrootRootDir + "/etc/nsswitch.conf", "hosts: files dns\nservices: files\n");
later, making the socket unnecessary.

As mentioned in #4991, the absence of this socket no longer breaks fixed output derivations (verified with nix master), and its presence breaks any program that makes getpwuid() calls, like git and maven.

@edolstra
Copy link
Member

Thanks, makes sense!

@edolstra edolstra merged commit eb47889 into NixOS:master Jul 13, 2021
@hmenke
Copy link
Member

hmenke commented Jul 13, 2021

This should also receive a backport to 2.3-maintenance. Possible patch:

--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -2841,8 +2841,6 @@ void DerivationGoal::runChild()
 
                 ss.push_back("/etc/services");
                 ss.push_back("/etc/hosts");
-                if (pathExists("/var/run/nscd/socket"))
-                    ss.push_back("/var/run/nscd/socket");
             }
 
             for (auto & i : ss) dirsInChroot.emplace(i, i);

@illustris
Copy link
Contributor Author

I was trying to do this, but nixStable is failing to build on nixpkgs master when I give it the repo as src. Tarball works. The contents of the repo and tarball release are not the same.

[illustris@illustris-thinkpad:~/src/nix]$ ls ~/src/nix-tarball/nix-2.3.12
bootstrap.sh  config  config.h.in  configure  configure.ac  contrib  COPYING  corepkgs  doc  local.mk  m4  maintainers  Makefile  Makefile.config.in  misc  mk  nix.spec  nix.spec.in  perl  README.md  release-common.nix  release.nix  scripts  shell.nix  src  tests
[illustris@illustris-thinkpad:~/src/nix]$ ls
bootstrap.sh  config  configure.ac  contrib  COPYING  corepkgs  doc  local.mk  m4  maintainers  Makefile  Makefile.config.in  misc  mk  nix.spec.in  perl  README.md  release-common.nix  release.nix  scripts  shell.nix  src  tests
[illustris@illustris-thinkpad:~/src/nix]$ git status
HEAD detached at 2.3.12
nothing to commit, working tree clean

Anyone know what's going on here?

@hmenke
Copy link
Member

hmenke commented Jul 14, 2021

I can't tell you exactly “what's going on here”, but for 2.3 you have to build the source tarball using

nix-build release.nix -A tarball

This essentially just runs autoreconf on the source tree to generate the configure scripts.

@illustris
Copy link
Contributor Author

illustris commented Jul 14, 2021

PR at #5013
tested the same default.nix mentioned in #4991. Are there any automated tests for nix? didn't find anything in nixpkgs.
EDIT: nvm... found tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants