tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: mail.local NSS awareness



On Tue, Apr 29, 2008 at 09:16:06AM +0000, Emmanuel Dreyfus wrote:
> [...]
> As I understand, sendmail expects EX_OK, EX_TEMPFAIL, or EX_UNAVAILABLE,
> so I propose the patch included below. I don't know how well that cope
> with other MTA, or if there are other errno like EAGAIN and ETIMEDOUT
> that should cause EX_TEMPFAIL (temporary failure) instead of EX_UNAVAILABLE
> (permanent failure). Opinions?
> 
> --- mail.local.c.orig   2008-04-29 10:47:43.000000000 +0200
> +++ mail.local.c        2008-04-29 10:55:45.000000000 +0200
> @@ -190,9 +190,21 @@
>          * Disallow delivery to unknown names -- special mailboxes can be
>          * handled in the sendmail aliases file.
>          */
>         if (!(pw = getpwnam(name))) {
> -               err(NOTFATAL, "unknown name: %s", name);
> +               switch (errno) {

If getpwnam() returns no user, but no error, then errno may not have
been updated, and you're testing the errno from whatever function or
syscall failed before. You should set errno to 0 before calling getpwnam(),
at last.

A better patch may be to use getpwnam_r(), which explicitely
"return 0 on success or entry not found, and non-zero on failure".

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--


Home | Main Index | Thread Index | Old Index