From c0ae0b249e3d03048dbbe04d6898edbecb45b788 Mon Sep 17 00:00:00 2001 From: Eric Allman Date: Mon, 1 Mar 1993 21:15:33 -0800 Subject: [PATCH] yet more logging 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 | 59 ++++++++++++++--------- usr/src/usr.sbin/sendmail/src/queue.c | 6 +-- usr/src/usr.sbin/sendmail/src/recipient.c | 6 +-- 3 files changed, 41 insertions(+), 30 deletions(-) diff --git a/usr/src/usr.sbin/sendmail/src/deliver.c b/usr/src/usr.sbin/sendmail/src/deliver.c index d9867eceeb..ccc0b020e5 100644 --- a/usr/src/usr.sbin/sendmail/src/deliver.c +++ b/usr/src/usr.sbin/sendmail/src/deliver.c @@ -7,7 +7,7 @@ */ #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" @@ -113,7 +113,7 @@ deliver(e, firstto) 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); @@ -268,13 +268,13 @@ deliver(e, firstto) { 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) { - giveresponse(rcode, m, e); + giveresponse(rcode, m, NULL, e); continue; } @@ -319,7 +319,7 @@ deliver(e, firstto) 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; @@ -449,7 +449,7 @@ deliver(e, firstto) if ((i = smtprcpt(to, m, mci, e)) != EX_OK) { markfailure(e, to, i); - giveresponse(i, m, e); + giveresponse(i, m, mci, e); } else { @@ -505,7 +505,7 @@ deliver(e, firstto) 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) @@ -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). -** 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. @@ -1034,9 +1037,10 @@ openmailer(m, pvp, ctladdr, clever, e) ** ExitStat may be set. */ -giveresponse(stat, m, e) +giveresponse(stat, m, mci, e) int stat; register MAILER *m; + register MCI *mci; ENVELOPE *e; { register char *statmsg; @@ -1048,11 +1052,6 @@ giveresponse(stat, m, e) #endif char buf[MAXLINE]; -#ifdef lint - if (m == NULL) - return; -#endif lint - /* ** Compute status message from code. */ @@ -1128,7 +1127,7 @@ giveresponse(stat, m, e) */ 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); @@ -1147,7 +1146,11 @@ giveresponse(stat, m, e) ** 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 @@ -1156,17 +1159,25 @@ giveresponse(stat, m, e) ** none */ -logdelivery(stat, e) +logdelivery(m, mci, stat, e) + MAILER *m; + register MCI *mci; char *stat; register ENVELOPE *e; { char *delay; + char *curhost; 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); - 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); @@ -1176,12 +1187,12 @@ logdelivery(stat, e) char *p1, *p2; extern char *macvalue(); - if (CurHostName[0] == '/') + if (curhost[0] == '/') { p1 = macvalue('h', e); if (p1 == NULL || p1[0] == '\0') p1 = "local"; - p2 = CurHostName; + p2 = curhost; } # ifdef DAEMON else @@ -1189,12 +1200,12 @@ logdelivery(stat, e) extern struct sockaddr_in CurHostAddr; extern char *inet_ntoa(); - p1 = CurHostName; + p1 = curhost; 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 */ } diff --git a/usr/src/usr.sbin/sendmail/src/queue.c b/usr/src/usr.sbin/sendmail/src/queue.c index 87031208b3..7750c9cd81 100644 --- a/usr/src/usr.sbin/sendmail/src/queue.c +++ b/usr/src/usr.sbin/sendmail/src/queue.c @@ -10,9 +10,9 @@ #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 -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 */ @@ -237,7 +237,7 @@ queueup(e, queueall, announce) 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)) diff --git a/usr/src/usr.sbin/sendmail/src/recipient.c b/usr/src/usr.sbin/sendmail/src/recipient.c index a076b16431..8bb311a780 100644 --- a/usr/src/usr.sbin/sendmail/src/recipient.c +++ b/usr/src/usr.sbin/sendmail/src/recipient.c @@ -7,7 +7,7 @@ */ #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" @@ -339,7 +339,7 @@ recipient(a, sendq, e) (*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; - giveresponse(EX_NOUSER, m, e); + giveresponse(EX_NOUSER, m, NULL, e); } else { -- 2.20.1