tech-userlevel archive

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

mail.local NSS awareness



Hello

mail.local assumes that if getpwnam(3) returns NULL, that means the 
recipient does not exists, and the message shall be dropped. Hence it
returns code EX_OK to the MTA.

This behaviour does not take NSS into account. NSS source others than 
file may fail, and they may fail for a temporary condition. In that 
situation, mail.local should exit with a status code different than
EX_OK, so that the MTA understands that delivery should be retried
at a later time.

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) {
+               case 0:
+                       err(EX_OK, "unknown name: %s", name);
+                       break;
+               case EAGAIN:
+               case ETIMEDOUT:
+                       err(EX_TEMPFAIL, "unknown name: %s", name);
+                       break;
+               default:
+                       err(EX_UNAVAILABLE, "unknown name: %s", name);
+                       break;
+               }
+               /* NOTREACHED */
                return(1);
        }
 
        (void)snprintf(path, sizeof path, "%s/%s", _PATH_MAILDIR, name);



-- 
Emmanuel Dreyfus
manu%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index