From owner-freebsd-standards@FreeBSD.ORG Mon Mar 31 05:47:40 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 CF28037B401 for ; Mon, 31 Mar 2003 05:47:37 -0800 (PST) Received: from smtp01.syd.iprimus.net.au (smtp01.syd.iprimus.net.au [210.50.30.52]) by mx1.FreeBSD.org (Postfix) with ESMTP id 03A6143FA3 for ; Mon, 31 Mar 2003 05:47:37 -0800 (PST) (envelope-from tim@robbins.dropbear.id.au) Received: from dilbert.robbins.dropbear.id.au (210.50.203.184) by smtp01.syd.iprimus.net.au (7.0.008) id 3E71077F0027D55D; Mon, 31 Mar 2003 23:47:35 +1000 Received: by dilbert.robbins.dropbear.id.au (Postfix, from userid 1000) id DC260C90D; Mon, 31 Mar 2003 23:47:17 +1000 (EST) Date: Mon, 31 Mar 2003 23:47:17 +1000 From: Tim Robbins To: David Leimbach Message-ID: <20030331234717.A5859@dilbert.robbins.dropbear.id.au> References: <99FC4F88-630C-11D7-8739-0003937E39E0@mac.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <99FC4F88-630C-11D7-8739-0003937E39E0@mac.com>; from leimy2k@mac.com on Sun, Mar 30, 2003 at 06:06:20PM -0600 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 13:47:45 -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. Tim