[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: hold messages for unknown users



Do you think it may be worth encapsulating getpw*() into some zgetpw*()
and at the very least keep all black magic in one place? Otherwise, it
happens that mailbox and router have different idea of the user existence.

Eugene

On 16-Jan-01 at 17:32, Matti Aarnio (mea@nic.funet.fi) wrote:
> On Mon, Dec 04, 2000 at 10:16:32PM +0300, Eugene Crosser wrote:
> > The problem was not *exactly* what I expected.
> > My custom getpwnam() returns NULL and errno==0 if there is no such user.
> > I think that errno==0 may very well be indication of "user does not
> > exist" condition in "real" unices as well.
> 
>   Actually my non-custom Solaris 2.6 getpwnam() doing some door_xxx() calls
>   will do exactly same errno returning - but seems to be sensitive on
>   incoming errno value as well!

I think this is semi-standard behavior: if library function succeeds,
don't touch errno, otherwise set it appropriately.  So, the most
reasonable thing seems to be:

	errno=0;
	pw=getpw...(...);
	if (pw == NULL) {
	  if (errno == 0 || errno == ENOENT || errno == ENVAL) {
	    /* no user */;
	  } else {
	    /* password/NIS/PAM/LDAP/whatever failure */;
	  }

>   The  run_homedir()  function at the router of course didn't accept
>   errno == 0   as "all clear, no user" indication :-/
> 
> > My observation on various versions of Solaris show this: depending on
> > whether MT-safe or non-MT-safe versions of getpwnam[_r]() are used, you
> > can get for a non-existing user EINVAL or EBADF (sic!).  "Common sense"
> > tells me that ENOENT and zero might be used to indicate "no error, user
> > does not exist" condition on other systems.
> > 
> > Of course, all of this is pure black magic...
> 
>   If you look into Single UNIX Specifications (and POSIX work), you
>   will see that they won't define errnos all that specific either!
> 
> > Eugene
> 
> -- 
> /Matti Aarnio     <mea@nic.funet.fi>