From owner-freebsd-hackers@FreeBSD.ORG Sun Jun 6 05:47:44 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3F30316A4CE for ; Sun, 6 Jun 2004 05:47:44 -0700 (PDT) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.173]) by mx1.FreeBSD.org (Postfix) with ESMTP id 053F143D2D for ; Sun, 6 Jun 2004 05:47:44 -0700 (PDT) (envelope-from se@freebsd.org) Received: from [212.227.126.208] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1BWx3r-0007mp-00 for hackers@freebsd.org; Sun, 06 Jun 2004 14:47:39 +0200 Received: from [80.132.228.215] (helo=Gatekeeper.FreeBSD.org) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1BWx3r-0000xL-00 for hackers@freebsd.org; Sun, 06 Jun 2004 14:47:39 +0200 Received: from StefanEsser.FreeBSD.org (StefanEsser [192.168.0.10]) by Gatekeeper.FreeBSD.org (Postfix) with ESMTP id A6B955F23; Sun, 6 Jun 2004 14:47:34 +0200 (CEST) Received: by StefanEsser.FreeBSD.org (Postfix, from userid 200) id 21CBD2306; Sun, 6 Jun 2004 14:47:34 +0200 (CEST) Date: Sun, 6 Jun 2004 14:47:34 +0200 From: Stefan =?iso-8859-1?Q?E=DFer?= To: hackers@freebsd.org Message-ID: <20040606124734.GA2687@StefanEsser.FreeBSD.org> Mail-Followup-To: Stefan =?iso-8859-1?Q?E=DFer?= , hackers@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6i X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:fa3fae9b6ca38d745862a668565919f6 Subject: Semantics of "seteuid(uid)" vs. "setreuid(-1,uid)" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jun 2004 12:47:44 -0000 Any reason, that there is a difference in semantics between: seteuid(id) vs. setreuid(-1, id) ??? The tests performed on the arguments are different (assuming a fixed arg of -1 for ruid) in that seteuid does not support the case of (euid == cr_uid): seteuid(euid): euid != oldcred->cr_ruid && euid != oldcred->cr_svuid setreuid(-1, euid): euid != oldcred->cr_uid && euid != oldcred->cr_ruid && euid != oldcred->cr_svuid So seteuid() may fail in cases where setreuid() with a first argument of -1 succeeds. The test obviously corresponds to POSIX appendix B.4.2.2 as mentioned in the comment in setuid(). Is the difference between seteuid() and setreuid() deliberate ? I'm asking because I have received a bug report for a port, and it appears that seteuid() on other systems is indeed equivalent to our setreuid(-1,). Regards, STefan