Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bad configure test for getpwent() ?
- X-seq: zsh-workers 8529
- From: mason@xxxxxxxxxxxxxxx (Geoff Wing)
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: Bad configure test for getpwent() ?
- Date: 3 Nov 1999 19:58:35 GMT
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- Organization: PrimeNet Computer Consultants
- References: <991103103452.ZM19665@xxxxxxxxxxxxxxxxxxxxxxx>; from schaefer@xxxxxxxxxxxxxxxxxxxxxxx on Wed, Nov 03, 1999 at 10:34:52AM +0000 <19991103133904.A6549@xxxxxxxx>
- Reply-to: mason@xxxxxxxxxxxxxxx
Clint Adams <schizo@xxxxxxxxxx> 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 : <gcw@xxxxxxxxx> Work URL: http://www.primenet.com.au/
Rxvt Stuff : <gcw@xxxxxxxx> Ego URL : http://pobox.com/~gcw/
Zsh Stuff : <gcw@xxxxxxx> Phone : (Australia) 0413 431 874
Messages sorted by:
Reverse Date,
Date,
Thread,
Author