Re: [Patch v2] daemon: Set ownership of kept build directories to the calling user.

2016-12-05 Thread Hartmut Goebel
Am 01.12.2016 um 01:01 schrieb Danny Milosavljevic: > So I'd say to compare with (uid_t)-1 would be fine > > if (settings.clientUid != (uid_t) -1) { > ... > } Thanks for this tip, Danny. This made it work and I just posted the updated patch. > > And casting uid_t to unisgned int m

Re: [Patch v2] daemon: Set ownership of kept build directories to the calling user.

2016-11-30 Thread Danny Milosavljevic
Hi Hartmut, On Mon, 28 Nov 2016 22:31:44 +0100 Hartmut Goebel wrote: > I just need some C programming hint: uid_t is an unsigned int, so > comparing with -1 raises a warning (which IMO is the same as en error). The system call handler in the Linux kernel does this, among other things: #define l

Re: [Patch v2] daemon: Set ownership of kept build directories to the calling user.

2016-11-28 Thread Hartmut Goebel
Am 27.11.2016 um 22:04 schrieb Ludovic Courtès: > The problem is that 0 also means “root”, so I’d prefer a different value > to denote that “unset” status, -1 if you want, and explicit checks (and > a comment explaining that ‘clientUid’ and ‘clientGid’ can be either a > valid UID/GID or -1, in whic

Re: [Patch v2] daemon: Set ownership of kept build directories to the calling user.

2016-11-27 Thread Ludovic Courtès
Hi! Hartmut Goebel skribis: > Am 21.11.2016 um 15:13 schrieb Ludovic Courtès: >> I don’t like the idea of passing those via the big ‘Settings’ >> singleton. > > Well, the Settings are already used to pass options like --keep-going to > the build process. So the "Singleton" is mutable per-process

Re: [Patch v2] daemon: Set ownership of kept build directories to the calling user.

2016-11-21 Thread Hartmut Goebel
Am 21.11.2016 um 15:13 schrieb Ludovic Courtès: > Could we instead pass them via the ‘LocalStore’ constructor, I started implementing this, but adding clientUid/Gid as a attribute (property) of 'LocalStore' feels wrong. The LocalStore is about the store: files being there, querying and such. Even

Re: [Patch v2] daemon: Set ownership of kept build directories to the calling user.

2016-11-21 Thread Hartmut Goebel
Am 21.11.2016 um 15:13 schrieb Ludovic Courtès: > Could we instead pass them via the ‘LocalStore’ constructor, with their > default values taken from ‘getuid’ and ‘getgid’ (rather than 0)? WDYT? Regarding the default values: I'm using zero as "not set" marker here. The files will already have own

Re: [Patch v2] daemon: Set ownership of kept build directories to the calling user.

2016-11-21 Thread Hartmut Goebel
Am 21.11.2016 um 15:13 schrieb Ludovic Courtès: > I don’t like the idea of passing those via the big ‘Settings’ > singleton. Well, the Settings are already used to pass options like --keep-going to the build process. So the "Singleton" is mutable per-process anyway. This is why I've put these here

Re: [Patch v2] daemon: Set ownership of kept build directories to the calling user.

2016-11-21 Thread Ludovic Courtès
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:

[Patch v2] daemon: Set ownership of kept build directories to the calling user.

2016-11-17 Thread Hartmut Goebel
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 ownershi