summaryrefslogtreecommitdiff
path: root/nix/libutil/util.cc
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-12-01 15:00:14 +0100
committerLudovic Courtès <ludo@gnu.org>2020-12-08 22:30:07 +0100
commit2e308238ad09e9527f9b8c3ec4a90b6b05a93367 (patch)
tree14c23360eb1e419919daa5e3b1a596f9450bd97c /nix/libutil/util.cc
parent4a9873529758f07869aede8057099a0f23144f8b (diff)
daemon: 'Agent' constructor takes a list of environment variables.
* nix/libutil/util.hh (struct Agent)[Agent]: Add 'env' parameter. * nix/libutil/util.cc (Agent::Agent): Honor it.
Diffstat (limited to 'nix/libutil/util.cc')
-rw-r--r--nix/libutil/util.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc
index 59a2981359..69f1c634a9 100644
--- a/nix/libutil/util.cc
+++ b/nix/libutil/util.cc
@@ -1173,7 +1173,7 @@ void commonChildInit(Pipe & logPipe)
//////////////////////////////////////////////////////////////////////
-Agent::Agent(const string &command, const Strings &args)
+Agent::Agent(const string &command, const Strings &args, const std::map<string, string> &env)
{
debug(format("starting agent '%1%'") % command);
@@ -1191,6 +1191,10 @@ Agent::Agent(const string &command, const Strings &args)
commonChildInit(fromAgent);
+ for (auto pair: env) {
+ setenv(pair.first.c_str(), pair.second.c_str(), 1);
+ }
+
if (chdir("/") == -1) throw SysError("changing into `/");
/* Dup the communication pipes. */