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

Expose /etc/nsswitch.conf and /etc/protocols etc to sandboxed nix builds? #1238

Open
bennofs opened this issue Feb 18, 2017 · 13 comments
Open
Assignees
Labels
UX The way in which users interact with Nix. Higher level than UI.

Comments

@bennofs
Copy link
Contributor

bennofs commented Feb 18, 2017

Right now, the following derivation fails in the nix sandbox:

with (import <nixpkgs> { config = {}; });

stdenv.mkDerivation {
  name = "networking";
  buildCommand = ''
    ${strace}/bin/strace getent protocols tcp > $out
  '';
}

This means that even packages that run their own server on localhost for testing fail, because getprotobyname fails.

@bennofs
Copy link
Contributor Author

bennofs commented Feb 18, 2017

See alephcloud/hs-configuration-tools#40 for a package affected by this

@copumpkin
Copy link
Member

Seems reasonable to me. Would need to switch on host system since these don't exist on Darwin.

My inclination would be to have them contain super boring predefined values that Nix defines somewhere, rather than passing through the host. That improves determinism, and we likely don't need anything fancy someone might have added to nsswitch.conf (which even supports loadable libraries!) inside a test that wants to hit localhost.

@domenkozar
Copy link
Member

domenkozar commented Jan 3, 2018

+1, just being able to do reverse dns on /etc/hosts would be a good start for some tests. Essentially the only reverse lookup possible would be for 127.0.0.1

@domenkozar
Copy link
Member

domenkozar commented Jan 3, 2018

If I understand correctly this needs hosts: files entry for /etc/nsswitch.conf besides https://github.com/NixOS/nix/blob/master/src/libstore/build.cc#L1990

This is for my use case: reverse dns. For this issue specifically probably other services as well.

@bennofs
Copy link
Contributor Author

bennofs commented Jan 3, 2018

@domenkozar yes, and we should probably also use files for the other databases, like protocols and services.

@bennofs
Copy link
Contributor Author

bennofs commented Jan 3, 2018

(And add /etc/protocols + /etc/services)

@edolstra
Copy link
Member

edolstra commented Jan 3, 2018

I think this can already be done using --sandbox-paths /etc/protocols:....

@copumpkin
Copy link
Member

What I was proposing was for them to be dummy files though, much like how /etc/passwd doesn't actually contain real passwd entries but is populated in build.cc.

@edolstra
Copy link
Member

edolstra commented Jan 3, 2018

Yes, but especially for /etc/services it's not clear what the dummy contents should be.

@bennofs
Copy link
Contributor Author

bennofs commented Jan 3, 2018

@edolstra is there no standard /etc/services? Just use the IANA standard?

The fact that there is no standard even increases the need to put a dummy into the build env for determinism.

@Mic92
Copy link
Member

Mic92 commented Dec 23, 2018

On Linux I currently use libredirect as a workaround to bring /etc/protocols into scope: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/python-modules/celery/default.nix#L32

@jonringer
Copy link
Contributor

Just ran into another use case where this would have been incredibly helpful to have an /etc/protocols for the pythonPackages.eventlet package, which references it for the socket.getprotobyname('tcp') python command. (similar to @Mic92's example)

@stale
Copy link

stale bot commented Feb 15, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Feb 15, 2021
@fricklerhandwerk fricklerhandwerk added the UX The way in which users interact with Nix. Higher level than UI. label Sep 12, 2022
@stale stale bot removed the stale label Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UX The way in which users interact with Nix. Higher level than UI.
Projects
None yet
Development

No branches or pull requests

8 participants