change the send queue to be only one queue instead of one per mailer.
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 22 Nov 1981 10:45:11 +0000 (02:45 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 22 Nov 1981 10:45:11 +0000 (02:45 -0800)
this is slightly inefficient but simpler.  also, pass this queue
around so we can have multiple send queues.  this makes VRFY work.

SCCS-vsn: usr.sbin/sendmail/src/alias.c 3.27
SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 3.54
SCCS-vsn: usr.sbin/sendmail/src/parseaddr.c 3.35
SCCS-vsn: usr.sbin/sendmail/src/version.c 3.65
SCCS-vsn: usr.sbin/sendmail/src/main.c 3.54
SCCS-vsn: usr.sbin/sendmail/src/srvrsmtp.c 3.10
SCCS-vsn: usr.sbin/sendmail/src/readcf.c 3.17
SCCS-vsn: usr.sbin/sendmail/src/headers.c 3.11
SCCS-vsn: usr.sbin/sendmail/src/recipient.c 3.30
SCCS-vsn: usr.sbin/sendmail/src/queue.c 3.5
SCCS-vsn: usr.sbin/sendmail/src/deliver.c 3.55

usr/src/usr.sbin/sendmail/src/alias.c
usr/src/usr.sbin/sendmail/src/deliver.c
usr/src/usr.sbin/sendmail/src/headers.c
usr/src/usr.sbin/sendmail/src/main.c
usr/src/usr.sbin/sendmail/src/parseaddr.c
usr/src/usr.sbin/sendmail/src/queue.c
usr/src/usr.sbin/sendmail/src/readcf.c
usr/src/usr.sbin/sendmail/src/recipient.c
usr/src/usr.sbin/sendmail/src/sendmail.h
usr/src/usr.sbin/sendmail/src/srvrsmtp.c
usr/src/usr.sbin/sendmail/src/version.c

index af0742b..dd221d6 100644 (file)
@@ -4,9 +4,9 @@
 # include "sendmail.h"
 
 # ifdef DBM
 # include "sendmail.h"
 
 # ifdef DBM
-static char SccsId[] = "@(#)alias.c    3.26.1.1        %G%     (with DBM)";
+static char SccsId[] = "@(#)alias.c    3.27    %G%     (with DBM)";
 # else DBM
 # else DBM
-static char SccsId[] = "@(#)alias.c    3.26.1.1        %G%     (without DBM)";
+static char SccsId[] = "@(#)alias.c    3.27    %G%     (without DBM)";
 # endif DBM
 
 /*
 # endif DBM
 
 /*
@@ -18,6 +18,8 @@ static char SccsId[] = "@(#)alias.c   3.26.1.1        %G%     (without DBM)";
 **
 **     Parameters:
 **             a -- address to alias.
 **
 **     Parameters:
 **             a -- address to alias.
+**             sendq -- a pointer to the head of the send queue
+**                     to put the aliases in.
 **
 **     Returns:
 **             none
 **
 **     Returns:
 **             none
@@ -57,8 +59,9 @@ DATUM lhs, rhs;
 extern DATUM fetch();
 #endif DBM
 
 extern DATUM fetch();
 #endif DBM
 
-alias(a)
+alias(a, sendq)
        register ADDRESS *a;
        register ADDRESS *a;
+       ADDRESS **sendq;
 {
        register char *p;
        extern ADDRESS *sendto();
 {
        register char *p;
        extern ADDRESS *sendto();
@@ -416,6 +419,8 @@ readaliases(aliasfile, init)
 **                     to forward to.  It must have been verified --
 **                     i.e., the q_home field must have been filled
 **                     in.
 **                     to forward to.  It must have been verified --
 **                     i.e., the q_home field must have been filled
 **                     in.
+**             sendq -- a pointer to the head of the send queue to
+**                     put this user's aliases in.
 **
 **     Returns:
 **             none.
 **
 **     Returns:
 **             none.
@@ -424,8 +429,9 @@ readaliases(aliasfile, init)
 **             New names are added to send queues.
 */
 
 **             New names are added to send queues.
 */
 
-forward(user)
+forward(user, sendq)
        ADDRESS *user;
        ADDRESS *user;
+       ADDRESS **sendq;
 {
        char buf[60];
        extern bool safefile();
 {
        char buf[60];
        extern bool safefile();
@@ -449,5 +455,5 @@ forward(user)
                return;
 
        /* we do have an address to forward to -- do it */
                return;
 
        /* we do have an address to forward to -- do it */
-       include(buf, "forwarding", user);
+       include(buf, "forwarding", user, sendq);
 }
 }
index 81e13a0..ac106ff 100644 (file)
@@ -6,7 +6,7 @@
 # include <syslog.h>
 # endif LOG
 
 # include <syslog.h>
 # endif LOG
 
-static char SccsId[] = "@(#)deliver.c  3.54.1.1        %G%";
+static char SccsId[] = "@(#)deliver.c  3.55    %G%";
 
 /*
 **  DELIVER -- Deliver a message to a list of addresses.
 
 /*
 **  DELIVER -- Deliver a message to a list of addresses.
@@ -163,7 +163,7 @@ deliver(firstto, editfcn)
 
                /* if already sent or not for this host, don't send */
                if ((!ForceMail && bitset(QDONTSEND|QPSEUDO, to->q_flags)) ||
 
                /* if already sent or not for this host, don't send */
                if ((!ForceMail && bitset(QDONTSEND|QPSEUDO, to->q_flags)) ||
-                   strcmp(to->q_host, host) != 0)
+                   strcmp(to->q_host, host) != 0 || to->q_mailer != firstto->q_mailer)
                        continue;
 
                /* compute effective uid/gid when sending */
                        continue;
 
                /* compute effective uid/gid when sending */
@@ -1072,28 +1072,24 @@ mailfile(filename, ctladdr)
 sendall(verifyonly)
        bool verifyonly;
 {
 sendall(verifyonly)
        bool verifyonly;
 {
-       register int i;
+       register ADDRESS *q;
        typedef int (*fnptr)();
 
        typedef int (*fnptr)();
 
-       for (i = 0; Mailer[i] != NULL; i++)
-       {
-               ADDRESS *q;
 
 
-               for (q = Mailer[i]->m_sendq; q != NULL; q = q->q_next)
+       for (q = SendQueue; q != NULL; q = q->q_next)
+       {
+               if (verifyonly)
                {
                {
-                       if (verifyonly)
+                       To = q->q_paddr;
+                       if (!bitset(QDONTSEND|QBADADDR, q->q_flags))
                        {
                        {
-                               To = q->q_paddr;
-                               if (!bitset(QDONTSEND|QBADADDR|QPSEUDO, q->q_flags))
-                               {
-                                       if (bitset(M_LOCAL, q->q_mailer->m_flags))
-                                               message(Arpa_Info, "deliverable");
-                                       else
-                                               message(Arpa_Info, "queueable");
-                               }
+                               if (bitset(M_LOCAL, q->q_mailer->m_flags))
+                                       message(Arpa_Info, "deliverable");
+                               else
+                                       message(Arpa_Info, "queueable");
                        }
                        }
-                       else
-                               (void) deliver(q, (fnptr) NULL);
                }
                }
+               else
+                       (void) deliver(q, (fnptr) NULL);
        }
 }
        }
 }
index edc588d..4acfef9 100644 (file)
@@ -1,7 +1,7 @@
 # include <errno.h>
 # include "sendmail.h"
 
 # include <errno.h>
 # include "sendmail.h"
 
-static char    SccsId[] = "@(#)headers.c       3.10.1.1        %G%";
+static char    SccsId[] = "@(#)headers.c       3.11    %G%";
 
 /*
 **  CHOMPHEADER -- process and save a header line.
 
 /*
 **  CHOMPHEADER -- process and save a header line.
index 277aae5..dcc5537 100644 (file)
@@ -7,7 +7,7 @@
 # include <syslog.h>
 # endif LOG
 
 # include <syslog.h>
 # endif LOG
 
-static char    SccsId[] = "@(#)main.c  3.53.1.1        %G%";
+static char    SccsId[] = "@(#)main.c  3.54    %G%";
 
 /*
 **  SENDMAIL -- Post mail to a set of destinations.
 
 /*
 **  SENDMAIL -- Post mail to a set of destinations.
index 9b445d3..db92776 100644 (file)
@@ -1,6 +1,6 @@
 # include "sendmail.h"
 
 # include "sendmail.h"
 
-static char    SccsId[] = "@(#)parseaddr.c     3.34    %G%";
+static char    SccsId[] =      "@(#)parseaddr.c        3.35    %G%";
 
 /*
 **  PARSE -- Parse an address
 
 /*
 **  PARSE -- Parse an address
@@ -899,11 +899,14 @@ printaddr(a, follow)
        register ADDRESS *a;
        bool follow;
 {
        register ADDRESS *a;
        bool follow;
 {
+       bool first = TRUE;
+
        static int indent;
        register int i;
 
        while (a != NULL)
        {
        static int indent;
        register int i;
 
        while (a != NULL)
        {
+               first = FALSE;
                for (i = indent; i > 0; i--)
                        printf("\t");
                printf("%x=", a);
                for (i = indent; i > 0; i--)
                        printf("\t");
                printf("%x=", a);
@@ -925,7 +928,7 @@ printaddr(a, follow)
                indent--;
                a = a->q_sibling;
        }
                indent--;
                a = a->q_sibling;
        }
-       if (!follow)
+       if (first)
                printf("[NULL]\n");
 }
 
                printf("[NULL]\n");
 }
 
index c3a0629..a16745a 100644 (file)
@@ -4,7 +4,7 @@
 # include <signal.h>
 # include <errno.h>
 
 # include <signal.h>
 # include <errno.h>
 
-static char    SccsId[] =      "@(#)queue.c    3.4.1.1 %G%";
+static char    SccsId[] =      "@(#)queue.c    3.5     %G%";
 
 /*
 **  QUEUEUP -- queue a message up for future transmission.
 
 /*
 **  QUEUEUP -- queue a message up for future transmission.
@@ -32,6 +32,7 @@ queueup(df)
        register int i;
        register HDR *h;
        register char *p;
        register int i;
        register HDR *h;
        register char *p;
+       register ADDRESS *q;
 
        /* create control file name from data file name */
        strcpy(cf, df);
 
        /* create control file name from data file name */
        strcpy(cf, df);
@@ -73,16 +74,11 @@ queueup(df)
        fprintf(f, "P%d\n", MsgPriority);
 
        /* output list of recipient addresses */
        fprintf(f, "P%d\n", MsgPriority);
 
        /* output list of recipient addresses */
-       for (i = 0; Mailer[i] != NULL; i++)
+       for (q = SendQueue; q != NULL; q = q->q_next)
        {
        {
-               register ADDRESS *q;
-
-               for (q = Mailer[i]->m_sendq; q != NULL; q = q->q_next)
-               {
-                       if (!bitset(QQUEUEUP, q->q_flags))
-                               continue;
-                       fprintf(f, "R%s\n", q->q_paddr);
-               }
+               if (!bitset(QQUEUEUP, q->q_flags))
+                       continue;
+               fprintf(f, "R%s\n", q->q_paddr);
        }
 
        /* output headers for this message */
        }
 
        /* output headers for this message */
index 1ef9568..22f7b8d 100644 (file)
@@ -1,6 +1,6 @@
 # include "sendmail.h"
 
 # include "sendmail.h"
 
-static char SccsId[] = "@(#)readcf.c   3.16    %G%";
+static char SccsId[] = "@(#)readcf.c   3.17    %G%";
 
 /*
 **  READCF -- read control file.
 
 /*
 **  READCF -- read control file.
@@ -314,7 +314,6 @@ makemailer(line, safe)
        m->m_flags = mopts;
        m->m_from = newstr(mfrom);
        m->m_badstat = EX_UNAVAILABLE;
        m->m_flags = mopts;
        m->m_from = newstr(mfrom);
        m->m_badstat = EX_UNAVAILABLE;
-       m->m_sendq = NULL;
        m->m_mno = NextMailer;
        Mailer[NextMailer++] = m;
 
        m->m_mno = NextMailer;
        Mailer[NextMailer++] = m;
 
index 839c507..d562048 100644 (file)
@@ -2,7 +2,7 @@
 # include "sendmail.h"
 # include <sys/stat.h>
 
 # include "sendmail.h"
 # include <sys/stat.h>
 
-static char SccsId[] = "@(#)recipient.c        3.29    %G%";
+static char SccsId[] = "@(#)recipient.c        3.30    %G%";
 
 /*
 **  SENDTO -- Designate a send list.
 
 /*
 **  SENDTO -- Designate a send list.
@@ -21,6 +21,10 @@ static char SccsId[] = "@(#)recipient.c      3.29    %G%";
 **             copyf -- the copy flag; passed to parse.
 **             ctladdr -- the address template for the person to
 **                     send to -- effective uid/gid are important.
 **             copyf -- the copy flag; passed to parse.
 **             ctladdr -- the address template for the person to
 **                     send to -- effective uid/gid are important.
+**                     This is typically the alias that caused this
+**                     expansion.
+**             sendq -- a pointer to the head of a queue to put
+**                     these people into.
 **             qflags -- special flags to set in the q_flags field.
 **
 **     Returns:
 **             qflags -- special flags to set in the q_flags field.
 **
 **     Returns:
@@ -178,6 +182,9 @@ addrref(a, r)
 **
 **     Parameters:
 **             a -- the (preparsed) address header for the recipient.
 **
 **     Parameters:
 **             a -- the (preparsed) address header for the recipient.
+**             sendq -- a pointer to the head of a queue to put the
+**                     recipient in.  Duplicate supression is done
+**                     in this queue.
 **
 **     Returns:
 **             pointer to address actually inserted in send list.
 **
 **     Returns:
 **             pointer to address actually inserted in send list.
@@ -187,8 +194,9 @@ addrref(a, r)
 */
 
 ADDRESS *
 */
 
 ADDRESS *
-recipient(a)
+recipient(a, sendq)
        register ADDRESS *a;
        register ADDRESS *a;
+       register ADDRESS **sendq;
 {
        register ADDRESS *q;
        ADDRESS **pq;
 {
        register ADDRESS *q;
        ADDRESS **pq;
@@ -244,7 +252,7 @@ recipient(a)
        **      [Please note: the emphasis is on "hack."]
        */
 
        **      [Please note: the emphasis is on "hack."]
        */
 
-       for (pq = &m->m_sendq; (q = *pq) != NULL; pq = &q->q_next)
+       for (pq = sendq; (q = *pq) != NULL; pq = &q->q_next)
        {
                if (!ForceMail && sameaddr(q, a, FALSE))
                {
        {
                if (!ForceMail && sameaddr(q, a, FALSE))
                {
@@ -286,11 +294,11 @@ recipient(a)
                        {
                                if (Verbose)
                                        message(Arpa_Info, "including file %s", &a->q_user[9]);
                        {
                                if (Verbose)
                                        message(Arpa_Info, "including file %s", &a->q_user[9]);
-                               include(&a->q_user[9], " sending", a);
+                               include(&a->q_user[9], " sending", a, sendq);
                        }
                }
                else
                        }
                }
                else
-                       alias(a);
+                       alias(a, sendq);
        }
 
        /*
        }
 
        /*
@@ -367,7 +375,7 @@ recipient(a)
                                if (nbuf[0] != '\0')
                                        a->q_fullname = newstr(nbuf);
                                if (!quoted)
                                if (nbuf[0] != '\0')
                                        a->q_fullname = newstr(nbuf);
                                if (!quoted)
-                                       forward(a);
+                                       forward(a, sendq);
                        }
                }
        }
                        }
                }
        }
@@ -489,6 +497,8 @@ writable(s)
 **             ctladdr -- address template to use to fill in these
 **                     addresses -- effective user/group id are
 **                     the important things.
 **             ctladdr -- address template to use to fill in these
 **                     addresses -- effective user/group id are
 **                     the important things.
+**             sendq -- a pointer to the head of the send queue
+**                     to put these addresses in.
 **
 **     Returns:
 **             none.
 **
 **     Returns:
 **             none.
@@ -498,10 +508,11 @@ writable(s)
 **             listed in that file.
 */
 
 **             listed in that file.
 */
 
-include(fname, msg, ctladdr)
+include(fname, msg, ctladdr, sendq)
        char *fname;
        char *msg;
        ADDRESS *ctladdr;
        char *fname;
        char *msg;
        ADDRESS *ctladdr;
+       ADDRESS **sendq;
 {
        char buf[MAXLINE];
        register FILE *fp;
 {
        char buf[MAXLINE];
        register FILE *fp;
index 13eea02..dde2115 100644 (file)
@@ -6,7 +6,7 @@
 
 # ifdef _DEFINE
 # define EXTERN
 
 # ifdef _DEFINE
 # define EXTERN
-static char SmailSccsId[] =    "@(#)sendmail.h 3.53    %G%";
+static char SmailSccsId[] =    "@(#)sendmail.h 3.54    %G%";
 # else  _DEFINE
 # define EXTERN extern
 # endif _DEFINE
 # else  _DEFINE
 # define EXTERN extern
 # endif _DEFINE
@@ -96,13 +96,6 @@ typedef struct address ADDRESS;
 **     flags associated with it, and the argument vector to
 **     pass to it.  The flags are defined in conf.c
 **
 **     flags associated with it, and the argument vector to
 **     pass to it.  The flags are defined in conf.c
 **
-**     The host map is a list of lists of strings.  Within each
-**     list, any host is mapped to the last host in the list.
-**     This allows multiple names, as well as doing clever
-**     mail grouping in point-to-point networks.  Note: this
-**     is only used internally, so the apparent host is still
-**     kept around.
-**
 **     The argument vector is expanded before actual use.  All
 **     words except the first are passed through the macro
 **     processor.
 **     The argument vector is expanded before actual use.  All
 **     words except the first are passed through the macro
 **     processor.
@@ -117,7 +110,6 @@ struct mailer
        short   m_mno;          /* mailer number internally */
        char    *m_from;        /* pattern for From: header */
        char    **m_argv;       /* template argument vector */
        short   m_mno;          /* mailer number internally */
        char    *m_from;        /* pattern for From: header */
        char    **m_argv;       /* template argument vector */
-       ADDRESS *m_sendq;       /* list of addresses to send to */
 };
 
 typedef struct mailer  MAILER;
 };
 
 typedef struct mailer  MAILER;
@@ -356,6 +348,7 @@ extern char *ConfFile;      /* location of configuration file */
 extern char    *StatFile;      /* location of statistics summary */
 extern char    *QueueDir;      /* location of queue directory */
 EXTERN ADDRESS From;           /* the person it is from */
 extern char    *StatFile;      /* location of statistics summary */
 extern char    *QueueDir;      /* location of queue directory */
 EXTERN ADDRESS From;           /* the person it is from */
+EXTERN ADDRESS *SendQueue;     /* list of message recipients */
 EXTERN long    MsgSize;        /* size of the message in bytes */
 EXTERN time_t  CurTime;        /* time of this message */
 
 EXTERN long    MsgSize;        /* size of the message in bytes */
 EXTERN time_t  CurTime;        /* time of this message */
 
index 9dff476..dcd130d 100644 (file)
@@ -1,6 +1,6 @@
 # include "sendmail.h"
 
 # include "sendmail.h"
 
-static char    SccsId[] =      "@(#)srvrsmtp.c 3.    %G%";
+static char    SccsId[] =      "@(#)srvrsmtp.c 3.10    %G%";
 
 /*
 **  SMTP -- run the SMTP protocol.
 
 /*
 **  SMTP -- run the SMTP protocol.
@@ -34,6 +34,7 @@ struct cmd
 # define CMDQUIT       9       /* quit -- close connection and die */
 # define CMDMRSQ       10      /* mrsq -- for old mtp compat only */
 # define CMDHELO       11      /* helo -- be polite */
 # define CMDQUIT       9       /* quit -- close connection and die */
 # define CMDMRSQ       10      /* mrsq -- for old mtp compat only */
 # define CMDHELO       11      /* helo -- be polite */
+# define CMDDBGSHOWQ   12      /* showq -- show send queue (DEBUG) */
 
 static struct cmd      CmdTab[] =
 {
 
 static struct cmd      CmdTab[] =
 {
@@ -49,6 +50,9 @@ static struct cmd     CmdTab[] =
        "quit",         CMDQUIT,
        "mrsq",         CMDMRSQ,
        "helo",         CMDHELO,
        "quit",         CMDQUIT,
        "mrsq",         CMDMRSQ,
        "helo",         CMDHELO,
+# ifdef DEBUG
+       "showq",        CMDDBGSHOWQ,
+# endif DEBUG
        NULL,           CMDERROR,
 };
 
        NULL,           CMDERROR,
 };
 
@@ -231,6 +235,13 @@ smtp()
                        }
                        break;
 
                        }
                        break;
 
+# ifdef DEBUG
+                 case CMDDBGSHOWQ:     /* show queues */
+                       printf("SendQueue=");
+                       printaddr(SendQueue, TRUE);
+                       break;
+# endif DEBUG
+
                  case CMDERROR:        /* unknown command */
                        message("500", "Command unrecognized");
                        break;
                  case CMDERROR:        /* unknown command */
                        message("500", "Command unrecognized");
                        break;
index 42f03e1..ae225c9 100644 (file)
@@ -1,3 +1,3 @@
-static char    SccsId[] = "@(#)SendMail version 3.64 of %G%";
+static char    SccsId[] = "@(#)SendMail version 3.65 of %G%";
 
 
-char   Version[] = "3.64 [%G%]";
+char   Version[] = "3.65 [%G%]";