From 36a4e21945796f1562fbe4382f5b9f6d8f37ab33 Mon Sep 17 00:00:00 2001 From: Eric Allman Date: Wed, 25 Aug 1982 02:41:45 -0800 Subject: [PATCH] log more info (on log level 11); try to detect wild accept loops; some minor cleanup and debugging checks; fix NoConnect option to; only apply to expensive mailers (regardless of sendqueue order) SCCS-vsn: usr.sbin/sendmail/src/main.c 3.100 SCCS-vsn: usr.sbin/sendmail/src/deliver.c 3.102 SCCS-vsn: usr.sbin/sendmail/src/version.c 3.167 SCCS-vsn: usr.sbin/sendmail/src/daemon.c 3.24 SCCS-vsn: usr.sbin/sendmail/src/queue.c 3.36 --- usr/src/usr.sbin/sendmail/src/daemon.c | 25 +++++++++++++++++++++++-- usr/src/usr.sbin/sendmail/src/deliver.c | 12 +++++------- usr/src/usr.sbin/sendmail/src/main.c | 15 ++++++++++++++- usr/src/usr.sbin/sendmail/src/queue.c | 13 +++++++++++-- usr/src/usr.sbin/sendmail/src/version.c | 4 ++-- 5 files changed, 55 insertions(+), 14 deletions(-) diff --git a/usr/src/usr.sbin/sendmail/src/daemon.c b/usr/src/usr.sbin/sendmail/src/daemon.c index 2da735d5c3..be35825340 100644 --- a/usr/src/usr.sbin/sendmail/src/daemon.c +++ b/usr/src/usr.sbin/sendmail/src/daemon.c @@ -3,14 +3,14 @@ # include #ifndef DAEMON -SCCSID(@(#)daemon.c 3.23 %G% (w/o daemon mode)); +SCCSID(@(#)daemon.c 3.24 %G% (w/o daemon mode)); #else # include # include # include -SCCSID(@(#)daemon.c 3.23 %G% (with daemon mode)); +SCCSID(@(#)daemon.c 3.24 %G% (with daemon mode)); /* ** DAEMON.C -- routines to use when running as a daemon. @@ -113,6 +113,8 @@ getconnection() for (;;) { + int acptcnt; + /* get a socket for the SMTP connection */ s = socket(SOCK_STREAM, 0, &SendmailAddress, SO_ACCEPTCONN); if (s < 0) @@ -128,10 +130,29 @@ getconnection() # endif DEBUG /* wait for a connection */ + (void) time(&CurTime); + acptcnt = 0; do { + long now; + errno = 0; (void) accept(s, &otherend); + (void) time(&now); + if (now == CurTime) + { + if(++acptcnt > 2) + { + syserr("wild accept"); + /* abort(); */ + break; + } + } + else + { + CurTime = now; + acptcnt = 0; + } } while (errno == ETIMEDOUT || errno == EINTR); if (errno == 0) break; diff --git a/usr/src/usr.sbin/sendmail/src/deliver.c b/usr/src/usr.sbin/sendmail/src/deliver.c index fec656c5e3..162c0b4b21 100644 --- a/usr/src/usr.sbin/sendmail/src/deliver.c +++ b/usr/src/usr.sbin/sendmail/src/deliver.c @@ -3,7 +3,7 @@ # include "sendmail.h" # include -SCCSID(@(#)deliver.c 3.101 %G%); +SCCSID(@(#)deliver.c 3.102 %G%); /* ** DELIVER -- Deliver a message to a list of addresses. @@ -75,7 +75,8 @@ deliver(firstto) if (NoConnect && !QueueRun && bitset(M_EXPENSIVE, m->m_flags)) { for (; to != NULL; to = to->q_next) - if (!bitset(QDONTSEND, to->q_flags)) + if (!bitset(QDONTSEND, to->q_flags) && + to->q_mailer == firstto->q_mailer) to->q_flags |= QQUEUEUP|QDONTSEND; return (0); } @@ -824,16 +825,13 @@ giveresponse(stat, force, m) statmsg = SysExMsg[i]; if (stat == 0) { - if (bitset(M_LOCAL, m->m_flags)) - statmsg = "delivered"; - else - statmsg = "queued"; + statmsg = "sent"; message(Arpa_Info, statmsg); } # ifdef QUEUE else if (stat == EX_TEMPFAIL) { - message(Arpa_Info, "transmission deferred"); + message(Arpa_Info, "deferred"); } # endif QUEUE else diff --git a/usr/src/usr.sbin/sendmail/src/main.c b/usr/src/usr.sbin/sendmail/src/main.c index e171289f2f..1531de25d1 100644 --- a/usr/src/usr.sbin/sendmail/src/main.c +++ b/usr/src/usr.sbin/sendmail/src/main.c @@ -6,7 +6,7 @@ # include "sendmail.h" # include -SCCSID(@(#)main.c 3.99 %G%); +SCCSID(@(#)main.c 3.100 %G%); /* ** SENDMAIL -- Post mail to a set of destinations. @@ -496,6 +496,11 @@ main(argc, argv) /* get our pid right */ MotherPid = getpid(); +# ifdef LOG + if (LogLevel > 11) + syslog(LOG_DEBUG, "background daemon, pid=%d", + MotherPid); +# endif LOG /* disconnect from our controlling tty */ i = open("/dev/tty", 2); @@ -610,6 +615,10 @@ main(argc, argv) /* parent -- quit */ exit(ExitStat); } +# ifdef LOG + if (LogLevel > 11) + syslog(LOG_DEBUG, "background delivery, pid=%d", getpid()); +# endif LOG } else if (Mode == MD_QUEUE) { @@ -831,6 +840,10 @@ finis() if (Transcript != NULL) xunlink(Transcript); dropenvelope(CurEnv); +# ifdef LOG + if (LogLevel > 11) + syslog(LOG_DEBUG, "finis, pid=%d", getpid()); +# endif LOG exit(ExitStat); } /* diff --git a/usr/src/usr.sbin/sendmail/src/queue.c b/usr/src/usr.sbin/sendmail/src/queue.c index 9f56f4d1fb..6c7ac9d094 100644 --- a/usr/src/usr.sbin/sendmail/src/queue.c +++ b/usr/src/usr.sbin/sendmail/src/queue.c @@ -5,10 +5,10 @@ # include # ifndef QUEUE -SCCSID(@(#)queue.c 3.35 %G% (no queueing)); +SCCSID(@(#)queue.c 3.36 %G% (no queueing)); # else QUEUE -SCCSID(@(#)queue.c 3.35 %G%); +SCCSID(@(#)queue.c 3.36 %G%); /* ** QUEUEUP -- queue a message up for future transmission. @@ -205,6 +205,10 @@ runqueue(forkflag) return; } } +# ifdef LOG + if (LogLevel > 11) + syslog(LOG_DEBUG, "runqueue, pid=%d", getpid()); +# endif LOG /* ** Start making passes through the queue. @@ -511,6 +515,11 @@ dowork(w) MailBack = TRUE; CurEnv->e_qf = w->w_name; CurEnv->e_id = &w->w_name[strlen(QueueDir) + 3]; +# ifdef LOG + if (LogLevel > 11) + syslog(LOG_DEBUG, "dowork, pid=%d, id=%s", getpid(), + CurEnv->e_id); +# endif LOG /* don't use the headers from sendmail.cf... */ CurEnv->e_header = NULL; diff --git a/usr/src/usr.sbin/sendmail/src/version.c b/usr/src/usr.sbin/sendmail/src/version.c index 8ce86ce210..73334beaab 100644 --- a/usr/src/usr.sbin/sendmail/src/version.c +++ b/usr/src/usr.sbin/sendmail/src/version.c @@ -1,5 +1,5 @@ # ifndef lint -static char SccsId[] = "@(#)SendMail version 3.166 of %G%"; +static char SccsId[] = "@(#)SendMail version 3.167 of %G%"; # endif lint -char Version[] = "3.166 [%G%]"; +char Version[] = "3.167 [%G%]"; -- 2.20.1