From mboxrd@z Thu Jan 1 00:00:00 1970 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 Message-ID: <20161201010110.2325efc9@scratchpost.org> References: <1479382225-25227-1-git-send-email-h.goebel@crazy-compilers.com> <87shqkvs3a.fsf@gnu.org> <58330253.60805@crazy-compilers.com> <87inr8ljm6.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCEoX-0003lk-S9 for guix-devel@gnu.org; Wed, 30 Nov 2016 19:01:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCEoU-0004S4-Qb for guix-devel@gnu.org; Wed, 30 Nov 2016 19:01:25 -0500 In-Reply-To: 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 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 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.