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

nscd works in fixed-output derivations #3693

Closed
dasJ opened this issue Jun 13, 2020 · 3 comments
Closed

nscd works in fixed-output derivations #3693

dasJ opened this issue Jun 13, 2020 · 3 comments
Labels

Comments

@dasJ
Copy link
Member

dasJ commented Jun 13, 2020

Describe the bug

When using a fixed-output derivation which calls getpwnam, the host's nscd responds to the request, resulting in wrong results.

Steps To Reproduce

{ stdenvNoCC }:
stdenvNoCC.mkDerivation {
  name = "example";

  dontUnpack = true;

  configurePhase = ''
    id
  '';

  outputHashMode = "flat";
  outputHashAlgo = "sha256";
  outputHash = "0000000000000000000000000000000000000000000000000000";
}

When building that derivation, your local user name is shown, while nixbld is shown when not building a FOD.

Expected behavior

Access to nscd should be disabled even with FODs.

nix-env --version output

nix-env (Nix) 2.4pre20200521_00b562c

Additional context

I was able to work around that problem by creating a LD_PRELOAD so file that calls __nss_disable_nscd() before running main().
Sources here: https://github.com/dasJ/nscd-disable/

@dasJ dasJ added the bug label Jun 13, 2020
@Ericson2314
Copy link
Member

Hmm https://github.com/NixOS/nix/pull/2975/files was supposed to fix this, CC @matthewbauer

@matthewbauer
Copy link
Member

Could you run a strace to see if nsswitch.conf is even being read? It’s possible there is some default for passwd that we need to explicitly disable.

Since we make the nscd socket available there’s nothing really blocking a program from manually talking to it.

@dasJ
Copy link
Member Author

dasJ commented Jun 14, 2020

Looks like id was a bad example. It doesn't seem to read anything from /etc:

configuring
++ /nix/store/yc52vh5nr3hddx7wvj6wmqj396669bs9-strace-5.5/bin/strace -fs5000 id
++ grep etc
access("/etc/ld-nix.so.preload", R_OK)  = -1 ENOENT (No such file or directory)

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

No branches or pull requests

3 participants