yet more logging
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Tue, 2 Mar 1993 05:15:33 +0000 (21:15 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Tue, 2 Mar 1993 05:15:33 +0000 (21:15 -0800)
SCCS-vsn: usr.sbin/sendmail/src/recipient.c 6.22
SCCS-vsn: usr.sbin/sendmail/src/deliver.c 6.33
SCCS-vsn: usr.sbin/sendmail/src/queue.c 6.23

usr/src/usr.sbin/sendmail/src/deliver.c
usr/src/usr.sbin/sendmail/src/queue.c
usr/src/usr.sbin/sendmail/src/recipient.c

index d9867ec..ccc0b02 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)deliver.c  6.32 (Berkeley) %G%";
+static char sccsid[] = "@(#)deliver.c  6.33 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "sendmail.h"
 #endif /* not lint */
 
 #include "sendmail.h"
@@ -113,7 +113,7 @@ deliver(e, firstto)
                        e->e_to = to->q_paddr;
                        message("queued");
                        if (LogLevel > 8)
                        e->e_to = to->q_paddr;
                        message("queued");
                        if (LogLevel > 8)
-                               logdelivery("queued", e);
+                               logdelivery(m, NULL, "queued", e);
                }
                e->e_to = NULL;
                return (0);
                }
                e->e_to = NULL;
                return (0);
@@ -268,13 +268,13 @@ deliver(e, firstto)
                {
                        NoReturn = TRUE;
                        usrerr("552 Message is too large; %ld bytes max", m->m_maxsize);
                {
                        NoReturn = TRUE;
                        usrerr("552 Message is too large; %ld bytes max", m->m_maxsize);
-                       giveresponse(EX_UNAVAILABLE, m, e);
+                       giveresponse(EX_UNAVAILABLE, m, NULL, e);
                        continue;
                }
                rcode = checkcompat(to, e);
                if (rcode != EX_OK)
                {
                        continue;
                }
                rcode = checkcompat(to, e);
                if (rcode != EX_OK)
                {
-                       giveresponse(rcode, m, e);
+                       giveresponse(rcode, m, NULL, e);
                        continue;
                }
 
                        continue;
                }
 
@@ -319,7 +319,7 @@ deliver(e, firstto)
                if (m == FileMailer)
                {
                        rcode = mailfile(user, getctladdr(to), e);
                if (m == FileMailer)
                {
                        rcode = mailfile(user, getctladdr(to), e);
-                       giveresponse(rcode, m, e);
+                       giveresponse(rcode, m, NULL, e);
                        if (rcode == EX_OK)
                                to->q_flags |= QSENT;
                        continue;
                        if (rcode == EX_OK)
                                to->q_flags |= QSENT;
                        continue;
@@ -449,7 +449,7 @@ deliver(e, firstto)
                                if ((i = smtprcpt(to, m, mci, e)) != EX_OK)
                                {
                                        markfailure(e, to, i);
                                if ((i = smtprcpt(to, m, mci, e)) != EX_OK)
                                {
                                        markfailure(e, to, i);
-                                       giveresponse(i, m, e);
+                                       giveresponse(i, m, mci, e);
                                }
                                else
                                {
                                }
                                else
                                {
@@ -505,7 +505,7 @@ deliver(e, firstto)
 
   give_up:
        if (tobuf[0] != '\0')
 
   give_up:
        if (tobuf[0] != '\0')
-               giveresponse(rcode, m, e);
+               giveresponse(rcode, m, mci, e);
        for (to = tochain; to != NULL; to = to->q_tchain)
        {
                if (rcode != EX_OK)
        for (to = tochain; to != NULL; to = to->q_tchain)
        {
                if (rcode != EX_OK)
@@ -1024,7 +1024,10 @@ openmailer(m, pvp, ctladdr, clever, e)
 **             stat -- the status code from the mailer (high byte
 **                     only; core dumps must have been taken care of
 **                     already).
 **             stat -- the status code from the mailer (high byte
 **                     only; core dumps must have been taken care of
 **                     already).
-**             m -- the mailer descriptor for this mailer.
+**             m -- the mailer info for this mailer.
+**             mci -- the mailer connection info -- can be NULL if the
+**                     response is given before the connection is made.
+**             e -- the current envelope.
 **
 **     Returns:
 **             none.
 **
 **     Returns:
 **             none.
@@ -1034,9 +1037,10 @@ openmailer(m, pvp, ctladdr, clever, e)
 **             ExitStat may be set.
 */
 
 **             ExitStat may be set.
 */
 
-giveresponse(stat, m, e)
+giveresponse(stat, m, mci, e)
        int stat;
        register MAILER *m;
        int stat;
        register MAILER *m;
+       register MCI *mci;
        ENVELOPE *e;
 {
        register char *statmsg;
        ENVELOPE *e;
 {
        register char *statmsg;
@@ -1048,11 +1052,6 @@ giveresponse(stat, m, e)
 #endif
        char buf[MAXLINE];
 
 #endif
        char buf[MAXLINE];
 
-#ifdef lint
-       if (m == NULL)
-               return;
-#endif lint
-
        /*
        **  Compute status message from code.
        */
        /*
        **  Compute status message from code.
        */
@@ -1128,7 +1127,7 @@ giveresponse(stat, m, e)
        */
 
        if (LogLevel > ((stat == EX_TEMPFAIL) ? 8 : (stat == EX_OK) ? 7 : 6))
        */
 
        if (LogLevel > ((stat == EX_TEMPFAIL) ? 8 : (stat == EX_OK) ? 7 : 6))
-               logdelivery(&statmsg[4], e);
+               logdelivery(m, mci, &statmsg[4], e);
 
        if (stat != EX_TEMPFAIL)
                setstat(stat);
 
        if (stat != EX_TEMPFAIL)
                setstat(stat);
@@ -1147,7 +1146,11 @@ giveresponse(stat, m, e)
 **  LOGDELIVERY -- log the delivery in the system log
 **
 **     Parameters:
 **  LOGDELIVERY -- log the delivery in the system log
 **
 **     Parameters:
-**             stat -- the message to print for the status
+**             m -- the mailer info.  Can be NULL for initial queue.
+**             mci -- the mailer connection info -- can be NULL if the
+**                     log is occuring when no connection is active.
+**             stat -- the message to print for the status.
+**             e -- the current envelope.
 **
 **     Returns:
 **             none
 **
 **     Returns:
 **             none
@@ -1156,17 +1159,25 @@ giveresponse(stat, m, e)
 **             none
 */
 
 **             none
 */
 
-logdelivery(stat, e)
+logdelivery(m, mci, stat, e)
+       MAILER *m;
+       register MCI *mci;
        char *stat;
        register ENVELOPE *e;
 {
        char *delay;
        char *stat;
        register ENVELOPE *e;
 {
        char *delay;
+       char *curhost;
        extern char *pintvl();
 
 # ifdef LOG
        extern char *pintvl();
 
 # ifdef LOG
+       if (mci != NULL && mci->mci_host != NULL)
+               curhost = mci->mci_host;
+       else
+               curhost = CurHostName;
+
        delay = pintvl(curtime() - e->e_ctime, TRUE);
        delay = pintvl(curtime() - e->e_ctime, TRUE);
-       if (strcmp(stat, "Sent") != 0 || CurHostName == NULL ||
-           strcmp(CurHostName, "localhost") == 0)
+       if (strcmp(stat, "Sent") != 0 || m == NULL || curhost == NULL ||
+           strcmp(curhost, "localhost") == 0)
        {
                syslog(LOG_INFO, "%s: to=%s, delay=%s, stat=%s",
                       e->e_id, e->e_to, delay, stat);
        {
                syslog(LOG_INFO, "%s: to=%s, delay=%s, stat=%s",
                       e->e_id, e->e_to, delay, stat);
@@ -1176,12 +1187,12 @@ logdelivery(stat, e)
                char *p1, *p2;
                extern char *macvalue();
 
                char *p1, *p2;
                extern char *macvalue();
 
-               if (CurHostName[0] == '/')
+               if (curhost[0] == '/')
                {
                        p1 = macvalue('h', e);
                        if (p1 == NULL || p1[0] == '\0')
                                p1 = "local";
                {
                        p1 = macvalue('h', e);
                        if (p1 == NULL || p1[0] == '\0')
                                p1 = "local";
-                       p2 = CurHostName;
+                       p2 = curhost;
                }
 # ifdef DAEMON
                else
                }
 # ifdef DAEMON
                else
@@ -1189,12 +1200,12 @@ logdelivery(stat, e)
                        extern struct sockaddr_in CurHostAddr;
                        extern char *inet_ntoa();
 
                        extern struct sockaddr_in CurHostAddr;
                        extern char *inet_ntoa();
 
-                       p1 = CurHostName;
+                       p1 = curhost;
                        p2 = inet_ntoa(CurHostAddr.sin_addr);
                }
 # endif
                        p2 = inet_ntoa(CurHostAddr.sin_addr);
                }
 # endif
-               syslog(LOG_INFO, "%s: to=%s, delay=%s, stat=Sent to %s (%s)",
-                      e->e_id, e->e_to, delay, p1, p2);
+               syslog(LOG_INFO, "%s: to=%s, delay=%s, mailer=%s, stat=Sent to %s (%s)",
+                      e->e_id, e->e_to, delay, m->m_name, p1, p2);
        }
 # endif /* LOG */
 }
        }
 # endif /* LOG */
 }
index 8703120..7750c9c 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef QUEUE
 
 #ifndef lint
 #ifdef QUEUE
-static char sccsid[] = "@(#)queue.c    6.22 (Berkeley) %G% (with queueing)";
+static char sccsid[] = "@(#)queue.c    6.23 (Berkeley) %G% (with queueing)";
 #else
 #else
-static char sccsid[] = "@(#)queue.c    6.22 (Berkeley) %G% (without queueing)";
+static char sccsid[] = "@(#)queue.c    6.23 (Berkeley) %G% (without queueing)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -237,7 +237,7 @@ queueup(e, queueall, announce)
                                e->e_to = q->q_paddr;
                                message("queued");
                                if (LogLevel > 8)
                                e->e_to = q->q_paddr;
                                message("queued");
                                if (LogLevel > 8)
-                                       logdelivery("queued", e);
+                                       logdelivery(NULL, NULL, "queued", e);
                                e->e_to = NULL;
                        }
                        if (tTd(40, 1))
                                e->e_to = NULL;
                        }
                        if (tTd(40, 1))
index a076b16..8bb311a 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)recipient.c        6.21 (Berkeley) %G%";
+static char sccsid[] = "@(#)recipient.c        6.22 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -339,7 +339,7 @@ recipient(a, sendq, e)
                    (*p = '\0', safefile(buf, getruid(), S_IWRITE|S_IEXEC) != 0))
                {
                        a->q_flags |= QBADADDR;
                    (*p = '\0', safefile(buf, getruid(), S_IWRITE|S_IEXEC) != 0))
                {
                        a->q_flags |= QBADADDR;
-                       giveresponse(EX_CANTCREAT, m, e);
+                       giveresponse(EX_CANTCREAT, m, NULL, e);
                }
        }
 
                }
        }
 
@@ -415,7 +415,7 @@ recipient(a, sendq, e)
                if (pw == NULL)
                {
                        a->q_flags |= QBADADDR;
                if (pw == NULL)
                {
                        a->q_flags |= QBADADDR;
-                       giveresponse(EX_NOUSER, m, e);
+                       giveresponse(EX_NOUSER, m, NULL, e);
                }
                else
                {
                }
                else
                {