From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26017 invoked from network); 3 Nov 1999 19:58:48 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 3 Nov 1999 19:58:48 -0000 Received: (qmail 3862 invoked by alias); 3 Nov 1999 19:58:43 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8529 Received: (qmail 3854 invoked from network); 3 Nov 1999 19:58:40 -0000 To: zsh-workers@sunsite.auc.dk Path: mason From: mason@primenet.com.au (Geoff Wing) X-Newsgroups: lists.zsh.workers Subject: Re: Bad configure test for getpwent() ? Date: 3 Nov 1999 19:58:35 GMT Organization: PrimeNet Computer Consultants Distribution: local Message-ID: References: <991103103452.ZM19665@candle.brasslantern.com>; from schaefer@candle.brasslantern.com on Wed, Nov 03, 1999 at 10:34:52AM +0000 <19991103133904.A6549@dman.com> Reply-To: mason@primenet.com.au NNTP-Posting-Host: coral.primenet.com.au X-Trace: coral.primenet.com.au 941659115 25978 203.43.15.2 (3 Nov 1999 19:58:35 GMT) X-Complaints-To: usenet@coral.primenet.com.au NNTP-Posting-Date: 3 Nov 1999 19:58:35 GMT User-Agent: slrn/0.9.5.7 (UNIX) Clint Adams typed: :> pw1=getpwnam(buf); :> sprintf(buf, "%d:%d", rand(), getpid()); :> pw2=getpwnam(buf); :> exit(pw1!=0 && pw2!=0 && !strcmp(pw1->pw_name, pw2->pw_name)); : :It's not comparing the pointers; it's comparing the names. : :> I don't think getpwent() is required to return a unique pointer each time; :> that is, I think it's allowed to re-use an internal static buffer for each :> entry that it returns. That would mean that this test always succeeds ... My man page says: BUGS The functions getpwent(), getpwnam(), and getpwuid(), leave their results in an internal static object and return a pointer to that object. Subse- quent calls to any of these functions will modify the same object. On my system then, pw2 will be the same as pw1. Bart typed: :I think the only right way is to test the first pointer for nonzero, copy :the entry into a local struct passwd, then call getpwent() again and do :the comparison. I'd say this is correct. Regards, -- Geoff Wing : Work URL: http://www.primenet.com.au/ Rxvt Stuff : Ego URL : http://pobox.com/~gcw/ Zsh Stuff : Phone : (Australia) 0413 431 874