Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bad configure test for getpwent() ?



On Nov 3,  1:39pm, Clint Adams wrote:
> Subject: Re: Bad configure test for getpwent() ?
> >     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.

If pw1 == pw2, always, then strcmp(pw1->pw_name, pw2->pw_name) == 0, always.

> > 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 ...
>-- End of excerpt from Clint Adams



Messages sorted by: Reverse Date, Date, Thread, Author