diff options
author | Ludovic Courtès <ludo@gnu.org> | 2025-02-24 17:29:25 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2025-03-26 17:57:43 +0100 |
commit | 5c0b93b2441c338ad8dda97c64a54832be76840d (patch) | |
tree | e9aafa2cd6c62f9db22e11d4b5bf8578f4105fd9 | |
parent | 7bad04fac09173f63800464ca0868225f6a99bd1 (diff) | |
download | guix-5c0b93b2441c338ad8dda97c64a54832be76840d.tar.gz guix-5c0b93b2441c338ad8dda97c64a54832be76840d.zip |
daemon: Bind-mount /etc/nsswitch.conf & co. only if it exists.
Those files may be missing in some contexts, for instance within the
build environment.
* nix/libstore/build.cc (DerivationGoal::runChild): Add /etc/resolv.conf
and related files to ‘ss’ only if they exist.
Change-Id: Ie19664a86c8101a1dc82cf39ad4b7abb10f8250a
-rw-r--r-- | nix/libstore/build.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc index edd01bab34..8ca5e5b732 100644 --- a/nix/libstore/build.cc +++ b/nix/libstore/build.cc @@ -2093,10 +2093,11 @@ void DerivationGoal::runChild() network, so give them access to /etc/resolv.conf and so on. */ if (fixedOutput) { - ss.push_back("/etc/resolv.conf"); - ss.push_back("/etc/nsswitch.conf"); - ss.push_back("/etc/services"); - ss.push_back("/etc/hosts"); + auto files = { "/etc/resolv.conf", "/etc/nsswitch.conf", + "/etc/services", "/etc/hosts" }; + for (auto & file: files) { + if (pathExists(file)) ss.push_back(file); + } } for (auto & i : ss) dirsInChroot[i] = i; |