[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/09: daemon: 'Agent' constructor takes a list of environment variables
From: |
guix-commits |
Subject: |
03/09: daemon: 'Agent' constructor takes a list of environment variables. |
Date: |
Tue, 8 Dec 2020 17:00:13 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit 2e308238ad09e9527f9b8c3ec4a90b6b05a93367
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Tue Dec 1 15:00:14 2020 +0100
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.
---
nix/libutil/util.cc | 6 +++++-
nix/libutil/util.hh | 7 +++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc
index 59a2981..69f1c63 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. */
diff --git a/nix/libutil/util.hh b/nix/libutil/util.hh
index 13cff44..880b0e9 100644
--- a/nix/libutil/util.hh
+++ b/nix/libutil/util.hh
@@ -7,6 +7,7 @@
#include <dirent.h>
#include <unistd.h>
#include <signal.h>
+#include <map>
#include <functional>
#include <cstdio>
@@ -281,8 +282,10 @@ struct Agent
/* The process ID of the agent. */
Pid pid;
- /* The command and arguments passed to the agent. */
- Agent(const string &command, const Strings &args);
+ /* The command and arguments passed to the agent along with a list of
+ environment variable name/value pairs. */
+ Agent(const string &command, const Strings &args,
+ const std::map<string, string> &env = std::map<string, string>());
~Agent();
};
- branch master updated (20e5658 -> 799f066), guix-commits, 2020/12/08
- 06/09: daemon: Run 'guix substitute --substitute' as an agent., guix-commits, 2020/12/08
- 09/09: import: opam: Adjust test to latest 'opam->guix-package' changes., guix-commits, 2020/12/08
- 04/09: daemon: Use 'Agent' to spawn 'guix substitute --query'., guix-commits, 2020/12/08
- 05/09: daemon: Factorize substituter agent spawning., guix-commits, 2020/12/08
- 01/09: database: Remove unnecessary module imports., guix-commits, 2020/12/08
- 08/09: daemon: Raise an error if substituter doesn't send the expected hash., guix-commits, 2020/12/08
- 07/09: substitute: Cache and reuse connections while substituting., guix-commits, 2020/12/08
- 03/09: daemon: 'Agent' constructor takes a list of environment variables.,
guix-commits <=
- 02/09: gnu: autotools: Add version 2.70., guix-commits, 2020/12/08