From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [Patch v2] daemon: Set ownership of kept build directories to the calling user. Date: Mon, 21 Nov 2016 15:13:29 +0100 Message-ID: <87shqkvs3a.fsf@gnu.org> References: <1479382225-25227-1-git-send-email-h.goebel@crazy-compilers.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c8pLr-0000SX-Kp for guix-devel@gnu.org; Mon, 21 Nov 2016 09:13:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c8pLl-0000yr-4e for guix-devel@gnu.org; Mon, 21 Nov 2016 09:13:43 -0500 In-Reply-To: <1479382225-25227-1-git-send-email-h.goebel@crazy-compilers.com> (Hartmut Goebel's message of "Thu, 17 Nov 2016 12:30:25 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Hartmut Goebel Cc: guix-devel@gnu.org Hartmut Goebel skribis: > Fixes . > > * nix/libstore/globals.hh (Settings) Add clientUid and clientGid. > * nix/nix-daemon/nix-daemon.cc (pdaemonLoop] Store UID and GID of the > caller in settings. > * nix/libstore/build.cc (_chown): New function. > (DerivationGoal::deleteTmpDir): Use it, change ownership of build > directory if it is kept. [...] > +static void _chown(const Path & path, uid_t uid, gid_t gid) > +{ > + checkInterrupt(); > + > + printMsg(lvlVomit, format("%1%") % path); > + > + if (chown(path.c_str(), uid, gid) =3D=3D -1) { I think this should use =E2=80=98lchown=E2=80=99. > --- a/nix/libstore/globals.hh > +++ b/nix/libstore/globals.hh > @@ -70,6 +70,12 @@ struct Settings { > subgoal of the same goal) fails. */ > bool keepGoing; >=20=20 > + /* User and groud id of the client issuing the buld request. Used t= o set > + the owner and group of the keept temporary directories of failed > + builds. */ > + uid_t clientUid; > + gid_t clientGid; I don=E2=80=99t like the idea of passing those via the big =E2=80=98Setting= s=E2=80=99 singleton. Could we instead pass them via the =E2=80=98LocalStore=E2=80=99 constructor= , with their default values taken from =E2=80=98getuid=E2=80=99 and =E2=80=98getgid=E2= =80=99 (rather than 0)? WDYT? Thank you! Ludo=E2=80=99.