From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id yPL1Oq5VzV9FcQAA0tVLHw (envelope-from ) for ; Sun, 06 Dec 2020 22:05:34 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id KMO/Nq5VzV+IPgAA1q6Kng (envelope-from ) for ; Sun, 06 Dec 2020 22:05:34 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9848B9403AA for ; Sun, 6 Dec 2020 22:05:34 +0000 (UTC) Received: from localhost ([::1]:34254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1km29t-0001ex-JE for larch@yhetil.org; Sun, 06 Dec 2020 17:05:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1km29P-0001KC-M2 for guix-patches@gnu.org; Sun, 06 Dec 2020 17:05:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:40041) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1km29P-0003Jw-Eq for guix-patches@gnu.org; Sun, 06 Dec 2020 17:05:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1km29P-0006Rx-AM for guix-patches@gnu.org; Sun, 06 Dec 2020 17:05:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45018] [PATCH v2 1/6] daemon: 'Agent' constructor takes a list of environment variables. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 06 Dec 2020 22:05:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45018 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 45018@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 45018-submit@debbugs.gnu.org id=B45018.160729229524735 (code B ref 45018); Sun, 06 Dec 2020 22:05:03 +0000 Received: (at 45018) by debbugs.gnu.org; 6 Dec 2020 22:04:55 +0000 Received: from localhost ([127.0.0.1]:51577 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1km29G-0006Qs-R9 for submit@debbugs.gnu.org; Sun, 06 Dec 2020 17:04:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56386) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1km29B-0006Q0-QZ for 45018@debbugs.gnu.org; Sun, 06 Dec 2020 17:04:51 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:44341) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1km291-0003Do-UU; Sun, 06 Dec 2020 17:04:44 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=45440 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1km28o-00020D-IH; Sun, 06 Dec 2020 17:04:36 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Sun, 6 Dec 2020 23:04:10 +0100 Message-Id: <20201206220415.23279-2-ludo@gnu.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201206220415.23279-1-ludo@gnu.org> References: <87o8janf50.fsf@gnu.org> <20201206220415.23279-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 2.20 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 9848B9403AA X-Spam-Score: 2.20 X-Migadu-Scanner: ns3122888.ip-94-23-21.eu X-TUID: 0JUDYlJlHXuR * 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 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 &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 13cff44316..880b0e93b2 100644 --- a/nix/libutil/util.hh +++ b/nix/libutil/util.hh @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -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 &env = std::map()); ~Agent(); }; -- 2.29.2