From owner-freebsd-standards@FreeBSD.ORG Mon Mar 31 15:15:13 2003 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CC32437B401; Mon, 31 Mar 2003 15:15:13 -0800 (PST) Received: from smtpout.mac.com (smtpout.mac.com [17.250.248.89]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3668443F3F; Mon, 31 Mar 2003 15:15:13 -0800 (PST) (envelope-from leimy2k@mac.com) Received: from asmtp02.mac.com (asmtp02-qfe3 [10.13.10.66]) by smtpout.mac.com (Xserve/MantshX 2.0) with ESMTP id h2VNFCcR025609; Mon, 31 Mar 2003 15:15:12 -0800 (PST) Received: from mac.com ([67.33.226.223]) by asmtp02.mac.com (Netscape Messaging Server 4.15) with ESMTP id HCMZ9C00.CGD; Mon, 31 Mar 2003 15:15:12 -0800 Date: Mon, 31 Mar 2003 17:15:12 -0600 Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) To: Tim Robbins From: David Leimbach In-Reply-To: <20030331234717.A5859@dilbert.robbins.dropbear.id.au> Message-Id: <9F997B26-63CE-11D7-A778-0003937E39E0@mac.com> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) cc: freebsd-standards@FreeBSD.ORG Subject: Re: implementation of getpwnam_r X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Mar 2003 23:15:15 -0000 > On Sun, Mar 30, 2003 at 06:06:20PM -0600, David Leimbach wrote: > >> It seems this already exists in src/contrib/bind/lib/getpwent_r.c >> >> int getpwnam_r(const char * login, struct passwd *pwptr, char * buf, >> size_t buflen, >> struct passwd ** result) >> { >> >> struct passwd *pw = getpwnam(login); >> int res; >> >> if (pw == NULL) { >> *result = NULL; >> return (0); >> } >> >> res = copy_passwd(pw,pwptr,buf,buflen); >> *result = res ? NULL : pwptr; >> return (res); >> } >> >> Is this sufficient? copy_passwd is also in the bind library? > > There is a race between the getpwnam() call and when the data is > copied to the user-supplied buffer. In addition to this, I don't > think that getpwnam_r() is allowed to modify the static storage > used by getpwnam(). The current passwd code is truly awful, and > I think someone is working on a replacement for it. It might be > worth waiting to see what happens there before investing too much > energy in implementing the *_r() functions in the current code. > Yeah... I was just thinking... in order for the above to be re-entrant the actual implementation of getpwnam is going to have to be a lot cleaner and with much less static state. To replace the whole set of calls seems the correct way to do it now. Someone did contact me a while back about working on this problem but he doesn't appear to be subscribed to this list. I remember asking this fellow to sync up with the other developers but I don't know that he ever did. Dave > > Tim