fixes to properly compute priority, nrcpts, etc. on requeued delivery
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Fri, 2 Apr 1993 05:59:30 +0000 (21:59 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Fri, 2 Apr 1993 05:59:30 +0000 (21:59 -0800)
SCCS-vsn: usr.sbin/sendmail/src/headers.c 6.28
SCCS-vsn: usr.sbin/sendmail/src/main.c 6.51
SCCS-vsn: usr.sbin/sendmail/src/domain.c 6.18
SCCS-vsn: usr.sbin/sendmail/src/collect.c 6.13
SCCS-vsn: usr.sbin/sendmail/src/version.c 6.50
SCCS-vsn: usr.sbin/sendmail/src/savemail.c 6.28
SCCS-vsn: usr.sbin/sendmail/src/srvrsmtp.c 6.38
SCCS-vsn: usr.sbin/sendmail/src/deliver.c 6.59
SCCS-vsn: usr.sbin/sendmail/src/queue.c 6.44

usr/src/usr.sbin/sendmail/src/collect.c
usr/src/usr.sbin/sendmail/src/deliver.c
usr/src/usr.sbin/sendmail/src/domain.c
usr/src/usr.sbin/sendmail/src/headers.c
usr/src/usr.sbin/sendmail/src/main.c
usr/src/usr.sbin/sendmail/src/queue.c
usr/src/usr.sbin/sendmail/src/savemail.c
usr/src/usr.sbin/sendmail/src/srvrsmtp.c
usr/src/usr.sbin/sendmail/src/version.c

index 6108c61..5458ad7 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)collect.c  6.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)collect.c  6.13 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <errno.h>
 #endif /* not lint */
 
 # include <errno.h>
@@ -274,7 +274,7 @@ readerr:
        **      Examples are who is the from person & the date.
        */
 
        **      Examples are who is the from person & the date.
        */
 
-       eatheader(e);
+       eatheader(e, !requeueflag);
 
        /*
        **  Add an Apparently-To: line if we have no recipient lines.
 
        /*
        **  Add an Apparently-To: line if we have no recipient lines.
index b443b33..8b04163 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)deliver.c  6.58 (Berkeley) %G%";
+static char sccsid[] = "@(#)deliver.c  6.59 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "sendmail.h"
 #endif /* not lint */
 
 #include "sendmail.h"
@@ -47,6 +47,7 @@ sendall(e, mode)
        int otherowners;
        register ENVELOPE *ee;
        ENVELOPE *splitenv = NULL;
        int otherowners;
        register ENVELOPE *ee;
        ENVELOPE *splitenv = NULL;
+       bool announcequeueup;
        int pid;
 #ifdef LOCKF
        struct flock lfd;
        int pid;
 #ifdef LOCKF
        struct flock lfd;
@@ -61,7 +62,10 @@ sendall(e, mode)
                if (mode != SM_VERIFY &&
                    shouldqueue(e->e_msgpriority, e->e_ctime))
                        mode = SM_QUEUE;
                if (mode != SM_VERIFY &&
                    shouldqueue(e->e_msgpriority, e->e_ctime))
                        mode = SM_QUEUE;
+               announcequeueup = mode == SM_QUEUE;
        }
        }
+       else
+               announcequeueup = FALSE;
 
        if (tTd(13, 1))
        {
 
        if (tTd(13, 1))
        {
index 62b0662..dbb76e1 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef NAMED_BIND
 
 #ifndef lint
 #ifdef NAMED_BIND
-static char sccsid[] = "@(#)domain.c   6.17 (Berkeley) %G% (with name server)";
+static char sccsid[] = "@(#)domain.c   6.18 (Berkeley) %G% (with name server)";
 #else
 #else
-static char sccsid[] = "@(#)domain.c   6.17 (Berkeley) %G% (without name server)";
+static char sccsid[] = "@(#)domain.c   6.18 (Berkeley) %G% (without name server)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -191,46 +191,46 @@ punt:
                        *bp = '\0';
                }
                nmx = 1;
                        *bp = '\0';
                }
                nmx = 1;
-               prefer[0] = 0;
-               weight[0] = 0;
        }
        }
-
-       /* sort the records */
-       for (i = 0; i < nmx; i++)
+       else
        {
        {
-               for (j = i + 1; j < nmx; j++)
+               /* sort the records */
+               for (i = 0; i < nmx; i++)
                {
                {
-                       if (prefer[i] > prefer[j] ||
-                           (prefer[i] == prefer[j] && weight[i] > weight[j]))
+                       for (j = i + 1; j < nmx; j++)
                        {
                        {
-                               register int temp;
-                               register char *temp1;
-
-                               temp = prefer[i];
-                               prefer[i] = prefer[j];
-                               prefer[j] = temp;
-                               temp1 = mxhosts[i];
-                               mxhosts[i] = mxhosts[j];
-                               mxhosts[j] = temp1;
-                               temp = weight[i];
-                               weight[i] = weight[j];
-                               weight[j] = temp;
+                               if (prefer[i] > prefer[j] ||
+                                   (prefer[i] == prefer[j] && weight[i] > weight[j]))
+                               {
+                                       register int temp;
+                                       register char *temp1;
+
+                                       temp = prefer[i];
+                                       prefer[i] = prefer[j];
+                                       prefer[j] = temp;
+                                       temp1 = mxhosts[i];
+                                       mxhosts[i] = mxhosts[j];
+                                       mxhosts[j] = temp1;
+                                       temp = weight[i];
+                                       weight[i] = weight[j];
+                                       weight[j] = temp;
+                               }
                        }
                        }
-               }
-               if (seenlocal && prefer[i] >= localpref)
-               {
-                       /*
-                        * truncate higher pref part of list; if we're
-                        * the best choice left, we should have realized
-                        * awhile ago that this was a local delivery.
-                        */
-                       if (i == 0)
+                       if (seenlocal && prefer[i] >= localpref)
                        {
                        {
-                               *rcode = EX_CONFIG;
-                               return (-1);
+                               /*
+                                * truncate higher pref part of list; if we're
+                                * the best choice left, we should have realized
+                                * awhile ago that this was a local delivery.
+                                */
+                               if (i == 0)
+                               {
+                                       *rcode = EX_CONFIG;
+                                       return (-1);
+                               }
+                               nmx = i;
+                               break;
                        }
                        }
-                       nmx = i;
-                       break;
                }
        }
 
                }
        }
 
index c4e2df4..eb16bdf 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)headers.c  6.27 (Berkeley) %G%";
+static char sccsid[] = "@(#)headers.c  6.28 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <errno.h>
 #endif /* not lint */
 
 # include <errno.h>
@@ -275,6 +275,8 @@ isheader(s)
 **
 **     Parameters:
 **             e -- the envelope to process.
 **
 **     Parameters:
 **             e -- the envelope to process.
+**             full -- if set, do full processing (e.g., compute
+**                     message priority).
 **
 **     Returns:
 **             none.
 **
 **     Returns:
 **             none.
@@ -285,8 +287,9 @@ isheader(s)
 **             Aborts the message if the hop count is exceeded.
 */
 
 **             Aborts the message if the hop count is exceeded.
 */
 
-eatheader(e)
+eatheader(e, full)
        register ENVELOPE *e;
        register ENVELOPE *e;
+       bool full;
 {
        register HDR *h;
        register char *p;
 {
        register HDR *h;
        register char *p;
@@ -336,7 +339,7 @@ eatheader(e)
                }
 
                /* save the message-id for logging */
                }
 
                /* save the message-id for logging */
-               if (!bitset(EF_QUEUERUN, e->e_flags) && h->h_value != NULL &&
+               if (full && h->h_value != NULL &&
                    strcmp(h->h_field, "message-id") == 0)
                {
                        msgid = h->h_value;
                    strcmp(h->h_field, "message-id") == 0)
                {
                        msgid = h->h_value;
@@ -366,7 +369,7 @@ eatheader(e)
        p = hvalue("precedence", e);
        if (p != NULL)
                e->e_class = priencode(p);
        p = hvalue("precedence", e);
        if (p != NULL)
                e->e_class = priencode(p);
-       if (!bitset(EF_QUEUERUN, e->e_flags))
+       if (full)
                e->e_msgpriority = e->e_msgsize
                                 - e->e_class * WkClassFact
                                 + e->e_nrcpts * WkRecipFact;
                e->e_msgpriority = e->e_msgsize
                                 - e->e_class * WkClassFact
                                 + e->e_nrcpts * WkRecipFact;
@@ -388,7 +391,7 @@ eatheader(e)
        */
 
 # ifdef LOG
        */
 
 # ifdef LOG
-       if (!bitset(EF_QUEUERUN, e->e_flags) && LogLevel > 4)
+       if (full && LogLevel > 4)
        {
                char *name;
                char hbuf[MAXNAME];
        {
                char *name;
                char hbuf[MAXNAME];
index 5ee3c12..8aa34ff 100644 (file)
@@ -13,7 +13,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     6.50 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     6.51 (Berkeley) %G%";
 #endif /* not lint */
 
 #define        _DEFINE
 #endif /* not lint */
 
 #define        _DEFINE
@@ -930,7 +930,7 @@ main(argc, argv, envp)
 
                /* collect body for UUCP return */
                if (OpMode != MD_VERIFY)
 
                /* collect body for UUCP return */
                if (OpMode != MD_VERIFY)
-                       collect(FALSE, CurEnv);
+                       collect(FALSE, FALSE, CurEnv);
                finis();
        }
        if (OpMode == MD_VERIFY)
                finis();
        }
        if (OpMode == MD_VERIFY)
@@ -952,7 +952,7 @@ main(argc, argv, envp)
 
        CurEnv->e_to = NULL;
        if (OpMode != MD_VERIFY || GrabTo)
 
        CurEnv->e_to = NULL;
        if (OpMode != MD_VERIFY || GrabTo)
-               collect(FALSE, CurEnv);
+               collect(FALSE, FALSE, CurEnv);
        errno = 0;
 
        /* collect statistics */
        errno = 0;
 
        /* collect statistics */
index 9bedea5..ab189e8 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef QUEUE
 
 #ifndef lint
 #ifdef QUEUE
-static char sccsid[] = "@(#)queue.c    6.43 (Berkeley) %G% (with queueing)";
+static char sccsid[] = "@(#)queue.c    6.44 (Berkeley) %G% (with queueing)";
 #else
 #else
-static char sccsid[] = "@(#)queue.c    6.43 (Berkeley) %G% (without queueing)";
+static char sccsid[] = "@(#)queue.c    6.44 (Berkeley) %G% (without queueing)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -825,7 +825,7 @@ dowork(id, forkflag, requeueflag, e)
                }
 
                e->e_flags |= EF_INQUEUE;
                }
 
                e->e_flags |= EF_INQUEUE;
-               eatheader(e);
+               eatheader(e, requeueflag);
 
                if (requeueflag)
                        queueup(e, TRUE, FALSE);
 
                if (requeueflag)
                        queueup(e, TRUE, FALSE);
index e058338..eebd92c 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)savemail.c 6.27 (Berkeley) %G%";
+static char sccsid[] = "@(#)savemail.c 6.28 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <pwd.h>
 #endif /* not lint */
 
 # include <pwd.h>
@@ -451,7 +451,7 @@ returntosender(msg, returnq, sendbody, e)
        CurEnv = ee;
        define('f', "\201n", ee);
        define('x', "Mail Delivery Subsystem", ee);
        CurEnv = ee;
        define('f', "\201n", ee);
        define('x', "Mail Delivery Subsystem", ee);
-       eatheader(ee);
+       eatheader(ee, TRUE);
 
        /* actually deliver the error message */
        sendall(ee, SM_DEFAULT);
 
        /* actually deliver the error message */
        sendall(ee, SM_DEFAULT);
index 520d26a..96124b1 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef SMTP
 
 #ifndef lint
 #ifdef SMTP
-static char sccsid[] = "@(#)srvrsmtp.c 6.37 (Berkeley) %G% (with SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 6.38 (Berkeley) %G% (with SMTP)";
 #else
 #else
-static char sccsid[] = "@(#)srvrsmtp.c 6.37 (Berkeley) %G% (without SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 6.38 (Berkeley) %G% (without SMTP)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -409,10 +409,17 @@ smtp(e)
                                break;
                        }
 
                                break;
                        }
 
+                       /* check to see if we need to re-expand aliases */
+                       for (a = e->e_sendqueue; a != NULL; a = a->q_next)
+                       {
+                               if (bitset(QVERIFIED, a->q_flags))
+                                       break;
+                       }
+
                        /* collect the text of the message */
                        SmtpPhase = "collect";
                        setproctitle("%s %s: %s", e->e_id, CurHostName, inp);
                        /* collect the text of the message */
                        SmtpPhase = "collect";
                        setproctitle("%s %s: %s", e->e_id, CurHostName, inp);
-                       collect(TRUE, e);
+                       collect(TRUE, a != NULL, e);
                        if (Errors != 0)
                                break;
 
                        if (Errors != 0)
                                break;
 
@@ -444,13 +451,6 @@ smtp(e)
                        e->e_xfp = freopen(queuename(e, 'x'), "w", e->e_xfp);
                        id = e->e_id;
 
                        e->e_xfp = freopen(queuename(e, 'x'), "w", e->e_xfp);
                        id = e->e_id;
 
-                       /* check to see if we need to re-expand aliases */
-                       for (a = e->e_sendqueue; a != NULL; a = a->q_next)
-                       {
-                               if (bitset(QVERIFIED, a->q_flags))
-                                       break;
-                       }
-
                        /* send to all recipients */
                        sendall(e, Verbose ? SM_DELIVER : SM_QUEUE);
                        e->e_to = NULL;
                        /* send to all recipients */
                        sendall(e, Verbose ? SM_DELIVER : SM_QUEUE);
                        e->e_to = NULL;
index 7a9ed24..d53dc1f 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)version.c  6.49 (Berkeley) %G%";
+static char sccsid[] = "@(#)version.c  6.50 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
-char   Version[] = "ALPHA-6.49";
+char   Version[] = "ALPHA-6.50";