[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Patch v2] daemon: Set ownership of kept build directories to the ca
From: |
Danny Milosavljevic |
Subject: |
Re: [Patch v2] daemon: Set ownership of kept build directories to the calling user. |
Date: |
Thu, 1 Dec 2016 01:01:10 +0100 |
Hi Hartmut,
On Mon, 28 Nov 2016 22:31:44 +0100
Hartmut Goebel <address@hidden> 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 low2highuid(uid) ((uid) == (old_uid_t)-1 ? (uid_t)-1 : (uid_t)(uid))
So I'd say to compare with (uid_t)-1 would be fine
if (settings.clientUid != (uid_t) -1) {
...
}
... since they do something like it in Linux anyway - which is the one
implementing the chown operation in the first place :)
> And casting uid_t to unisgned int might return the same uid as "nobody".
What do you mean? uid_t is __uid_t - which in turn is implementation-defined -
but yes, it is unsigned. On Linux it changed size multiple time until now where
it is 32 bit unsigned.
On GuixSD, user "nobody" has uid 65534. That's one less than the maximum value
for 16 bit (!) uids (the maximum is hopefully invalid as uid since chown needs
it as a flag).
(-1) in two-complement 16 bit integral encoding (which is technically not
guaranteed to be used in C) would be 65535.