From mboxrd@z Thu Jan 1 00:00:00 1970 From: Danny Milosavljevic Subject: Re: [PATCH v4] daemon: Set ownership of kept build directories to the calling user. Date: Fri, 23 Dec 2016 22:15:12 +0100 Message-ID: <20161223221512.5926b358@scratchpost.org> References: <20161223133331.GA2589@jocasta.intra> 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]:41124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cKXBU-0000Pl-LF for guix-devel@gnu.org; Fri, 23 Dec 2016 16:15:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cKXBQ-00031L-Ne for guix-devel@gnu.org; Fri, 23 Dec 2016 16:15:24 -0500 Received: from dd1012.kasserver.com ([85.13.128.8]:44274) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cKXBQ-0002yx-Gx for guix-devel@gnu.org; Fri, 23 Dec 2016 16:15:20 -0500 In-Reply-To: <20161223133331.GA2589@jocasta.intra> 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: John Darrington Cc: guix-devel , Vincent Legoll On Fri, 23 Dec 2016 14:33:31 +0100 John Darrington wrote: > On Fri, Dec 23, 2016 at 12:18:11PM +0100, Vincent Legoll wrote: > Hello, > > + // Change the ownership if clientUid is set. Never change the > + // ownership or the group to "root" for security reasons. > + if (settings.clientUid != (uid_t) -1 && settings.clientUid != 0) { > > Is "0" a magical value that don't need casting or am I missing something ? > > Presumably clientUid is an unsigned integral type. Hence -1 does need a cast, whereas > 0 does not. Technically I agree. If it was my code I'd cast it regardless. Also, why use the magical value 0 for gid? Why not likewise (gid_t) -1 ?