changes for ESMTP; mostly better delimiter character pointer passing
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Tue, 2 Mar 1993 04:44:08 +0000 (20:44 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Tue, 2 Mar 1993 04:44:08 +0000 (20:44 -0800)
SCCS-vsn: usr.sbin/sendmail/src/headers.c 6.14
SCCS-vsn: usr.sbin/sendmail/src/recipient.c 6.21
SCCS-vsn: usr.sbin/sendmail/src/main.c 6.32
SCCS-vsn: usr.sbin/sendmail/src/envelope.c 6.18
SCCS-vsn: usr.sbin/sendmail/src/parseaddr.c 6.21
SCCS-vsn: usr.sbin/sendmail/src/savemail.c 6.18
SCCS-vsn: usr.sbin/sendmail/src/srvrsmtp.c 6.21
SCCS-vsn: usr.sbin/sendmail/src/readcf.c 6.16
SCCS-vsn: usr.sbin/sendmail/src/queue.c 6.22
SCCS-vsn: usr.sbin/sendmail/src/conf.c 6.31
SCCS-vsn: usr.sbin/sendmail/src/alias.c 6.21

usr/src/usr.sbin/sendmail/src/alias.c
usr/src/usr.sbin/sendmail/src/conf.c
usr/src/usr.sbin/sendmail/src/envelope.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/savemail.c
usr/src/usr.sbin/sendmail/src/srvrsmtp.c

index 517d956..6ddddba 100644 (file)
@@ -28,15 +28,15 @@ ERROR: DBM is no longer supported -- use NDBM instead.
 #ifndef lint
 #ifdef NEWDB
 #ifdef NDBM
 #ifndef lint
 #ifdef NEWDB
 #ifdef NDBM
-static char sccsid[] = "@(#)alias.c    6.20 (Berkeley) %G% (with NEWDB and NDBM)";
+static char sccsid[] = "@(#)alias.c    6.21 (Berkeley) %G% (with NEWDB and NDBM)";
 #else
 #else
-static char sccsid[] = "@(#)alias.c    6.20 (Berkeley) %G% (with NEWDB)";
+static char sccsid[] = "@(#)alias.c    6.21 (Berkeley) %G% (with NEWDB)";
 #endif
 #else
 #ifdef NDBM
 #endif
 #else
 #ifdef NDBM
-static char sccsid[] = "@(#)alias.c    6.20 (Berkeley) %G% (with NDBM)";
+static char sccsid[] = "@(#)alias.c    6.21 (Berkeley) %G% (with NDBM)";
 #else
 #else
-static char sccsid[] = "@(#)alias.c    6.20 (Berkeley) %G% (without NEWDB or NDBM)";
+static char sccsid[] = "@(#)alias.c    6.21 (Berkeley) %G% (without NEWDB or NDBM)";
 #endif
 #endif
 #endif /* not lint */
 #endif
 #endif
 #endif /* not lint */
@@ -700,16 +700,16 @@ readaliases(aliasfile, init, e)
                                /* do parsing & compression of addresses */
                                while (*p != '\0')
                                {
                                /* do parsing & compression of addresses */
                                while (*p != '\0')
                                {
-                                       extern char *DelimChar;
+                                       auto char *delimptr;
 
                                        while ((isascii(*p) && isspace(*p)) ||
                                                                *p == ',')
                                                p++;
                                        if (*p == '\0')
                                                break;
 
                                        while ((isascii(*p) && isspace(*p)) ||
                                                                *p == ',')
                                                p++;
                                        if (*p == '\0')
                                                break;
-                                       if (parseaddr(p, &bl, -1, ',', e) == NULL)
+                                       if (parseaddr(p, &bl, -1, ',', &delimptr, e) == NULL)
                                                usrerr("553 %s... bad address", p);
                                                usrerr("553 %s... bad address", p);
-                                       p = DelimChar;
+                                       p = delimptr;
                                }
                        }
                        else
                                }
                        }
                        else
index 6c9d3ea..7f4298d 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)conf.c     6.30 (Berkeley) %G%";
+static char sccsid[] = "@(#)conf.c     6.31 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <sys/ioctl.h>
 #endif /* not lint */
 
 # include <sys/ioctl.h>
@@ -1019,7 +1019,9 @@ initgroups(name, basegid)
 **     Only implemented if you have statfs.
 **
 **     Parameters:
 **     Only implemented if you have statfs.
 **
 **     Parameters:
-**             none.
+**             msize -- the size to check against.  If zero, we don't yet
+**                     know how big the message will be, so just check for
+**                     a "reasonable" amount.
 **
 **     Returns:
 **             TRUE if there is enough space.
 **
 **     Returns:
 **             TRUE if there is enough space.
@@ -1054,7 +1056,8 @@ initgroups(name, basegid)
 #endif
 
 bool
 #endif
 
 bool
-enoughspace()
+enoughspace(msize)
+       long msize;
 {
 #if defined(HASSTATFS) || defined(HASUSTAT)
 # if defined(HASUSTAT)
 {
 #if defined(HASSTATFS) || defined(HASUSTAT)
 # if defined(HASUSTAT)
@@ -1069,15 +1072,17 @@ enoughspace()
        struct statfs fs;
 #  endif
 # endif
        struct statfs fs;
 #  endif
 # endif
+       long blocksneeded;
        extern int errno;
        extern char *errstring();
 
        extern int errno;
        extern char *errstring();
 
-       if (MinBlocksFree <= 0)
+       if (MinBlocksFree <= 0 && msize <= 0)
        {
                if (tTd(4, 80))
                        printf("enoughspace: no threshold\n");
                return TRUE;
        }
        {
                if (tTd(4, 80))
                        printf("enoughspace: no threshold\n");
                return TRUE;
        }
+
 # if defined(HASUSTAT)
        if (stat(QueueDir, &statbuf) == 0 && ustat(statbuf.st_dev, &fs) == 0)
 # else
 # if defined(HASUSTAT)
        if (stat(QueueDir, &statbuf) == 0 && ustat(statbuf.st_dev, &fs) == 0)
 # else
@@ -1093,21 +1098,27 @@ enoughspace()
 # endif
        {
                if (tTd(4, 80))
 # endif
        {
                if (tTd(4, 80))
-                       printf("enoughspace: bavail=%ld, min=%ld\n",
-                               fs.f_bavail, MinBlocksFree);
-               if (fs.f_bavail < MinBlocksFree)
+                       printf("enoughspace: bavail=%ld, need=%ld\n",
+                               fs.f_bavail, msize);
+
+               /* convert msize to block count */
+               msize = msize / fs.f_bsize + 1;
+               if (MinBlocksFree >= 0)
+                       msize += MinBlocksFree;
+
+               if (fs.f_bavail < msize)
                {
 #ifdef LOG
                        if (LogLevel > 0)
                                syslog(LOG_ALERT, "%s: low on space (have %ld, need %ld)",
                {
 #ifdef LOG
                        if (LogLevel > 0)
                                syslog(LOG_ALERT, "%s: low on space (have %ld, need %ld)",
-                                       QueueDir, fs.f_bavail, MinBlocksFree);
+                                       QueueDir, fs.f_bavail, msize);
 #endif
                        return FALSE;
                }
        }
        else if (tTd(4, 80))
 #endif
                        return FALSE;
                }
        }
        else if (tTd(4, 80))
-               printf("enoughspace: min=%ld: %s\n",
-                       MinBlocksFree, errstring(errno));
+               printf("enoughspace failure: min=%ld, need=%ld: %s\n",
+                       MinBlocksFree, msize, errstring(errno));
 #endif
        return TRUE;
 }
 #endif
        return TRUE;
 }
index 9b3fbaf..926d69d 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)envelope.c 6.17 (Berkeley) %G%";
+static char sccsid[] = "@(#)envelope.c 6.18 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "sendmail.h"
 #endif /* not lint */
 
 #include "sendmail.h"
@@ -407,21 +407,26 @@ closexscript(e)
 **             from -- the person we would like to believe this message
 **                     is from, as specified on the command line.
 **             e -- the envelope in which we would like the sender set.
 **             from -- the person we would like to believe this message
 **                     is from, as specified on the command line.
 **             e -- the envelope in which we would like the sender set.
+**             delimptr -- if non-NULL, set to the location of the
+**                     trailing delimiter.
 **
 **     Returns:
 **
 **     Returns:
-**             none.
+**             pointer to the delimiter terminating the from address.
 **
 **     Side Effects:
 **             sets sendmail's notion of who the from person is.
 */
 
 **
 **     Side Effects:
 **             sets sendmail's notion of who the from person is.
 */
 
-setsender(from, e)
+char *
+setsender(from, e, delimptr)
        char *from;
        register ENVELOPE *e;
        char *from;
        register ENVELOPE *e;
+       char **delimptr;
 {
        register char **pvp;
        char *realname = NULL;
        register struct passwd *pw;
 {
        register char **pvp;
        char *realname = NULL;
        register struct passwd *pw;
+       char *delimchar = NULL;
        char buf[MAXNAME];
        char pvpbuf[PSBUFSIZE];
        extern struct passwd *getpwnam();
        char buf[MAXNAME];
        char pvpbuf[PSBUFSIZE];
        extern struct passwd *getpwnam();
@@ -449,7 +454,8 @@ setsender(from, e)
 /*
        SuprErrs = TRUE;
 */
 /*
        SuprErrs = TRUE;
 */
-       if (from == NULL || parseaddr(from, &e->e_from, 1, ' ', e) == NULL)
+       if (from == NULL ||
+           parseaddr(from, &e->e_from, 1, ' ', delimptr, e) == NULL)
        {
                /* log garbage addresses for traceback */
 # ifdef LOG
        {
                /* log garbage addresses for traceback */
 # ifdef LOG
@@ -467,10 +473,10 @@ setsender(from, e)
                if (from != NULL)
                        SuprErrs = TRUE;
                if (from == realname ||
                if (from != NULL)
                        SuprErrs = TRUE;
                if (from == realname ||
-                   parseaddr(from = newstr(realname), &e->e_from, 1, ' ', e) == NULL)
+                   parseaddr(from = newstr(realname), &e->e_from, 1, ' ', NULL, e) == NULL)
                {
                        SuprErrs = TRUE;
                {
                        SuprErrs = TRUE;
-                       if (parseaddr("postmaster", &e->e_from, 1, ' ', e) == NULL)
+                       if (parseaddr("postmaster", &e->e_from, 1, ' ', NULL, e) == NULL)
                                syserr("553 setsender: can't even parse postmaster!");
                }
        }
                                syserr("553 setsender: can't even parse postmaster!");
                }
        }
@@ -508,7 +514,7 @@ setsender(from, e)
                        **  We have an alternate address for the sender
                        */
 
                        **  We have an alternate address for the sender
                        */
 
-                       pvp = prescan(p, '\0', pvpbuf);
+                       pvp = prescan(p, '\0', pvpbuf, NULL);
                }
 # endif /* USERDB */
 
                }
 # endif /* USERDB */
 
@@ -553,7 +559,7 @@ setsender(from, e)
        */
 
        if (pvp == NULL)
        */
 
        if (pvp == NULL)
-               pvp = prescan(from, '\0', pvpbuf);
+               pvp = prescan(from, '\0', pvpbuf, NULL);
        if (pvp == NULL)
        {
 # ifdef LOG
        if (pvp == NULL)
        {
 # ifdef LOG
index 6264ff3..676b14f 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)headers.c  6.13 (Berkeley) %G%";
+static char sccsid[] = "@(#)headers.c  6.14 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <errno.h>
 #endif /* not lint */
 
 # include <errno.h>
@@ -819,7 +819,6 @@ commaize(h, p, fp, oldstyle, m, e)
                register int c;
                char savechar;
                extern char *remotename();
                register int c;
                char savechar;
                extern char *remotename();
-               extern char *DelimChar;         /* defined in prescan */
 
                /*
                **  Find the end of the name.  New style names
 
                /*
                **  Find the end of the name.  New style names
@@ -835,15 +834,14 @@ commaize(h, p, fp, oldstyle, m, e)
                name = p;
                for (;;)
                {
                name = p;
                for (;;)
                {
-                       char *oldp;
+                       auto char *oldp;
                        char pvpbuf[PSBUFSIZE];
                        extern char **prescan();
 
                        char pvpbuf[PSBUFSIZE];
                        extern char **prescan();
 
-                       (void) prescan(p, oldstyle ? ' ' : ',', pvpbuf);
-                       p = DelimChar;
+                       (void) prescan(p, oldstyle ? ' ' : ',', pvpbuf, &oldp);
+                       p = oldp;
 
                        /* look to see if we have an at sign */
 
                        /* look to see if we have an at sign */
-                       oldp = p;
                        while (*p != '\0' && isascii(*p) && isspace(*p))
                                p++;
 
                        while (*p != '\0' && isascii(*p) && isspace(*p))
                                p++;
 
index 6330105..d672bba 100644 (file)
@@ -13,7 +13,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     6.31 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     6.32 (Berkeley) %G%";
 #endif /* not lint */
 
 #define        _DEFINE
 #endif /* not lint */
 
 #define        _DEFINE
@@ -740,7 +740,7 @@ main(argc, argv, envp)
                {
                        register char **pvp;
                        char *q;
                {
                        register char **pvp;
                        char *q;
-                       extern char *DelimChar;
+                       auto char *delimptr;
                        extern bool invalidaddr();
 
                        if (Verbose)
                        extern bool invalidaddr();
 
                        if (Verbose)
@@ -770,7 +770,7 @@ main(argc, argv, envp)
                                extern char **prescan();
                                char pvpbuf[PSBUFSIZE];
 
                                extern char **prescan();
                                char pvpbuf[PSBUFSIZE];
 
-                               pvp = prescan(++p, ',', pvpbuf);
+                               pvp = prescan(++p, ',', pvpbuf, &delimptr);
                                if (pvp == NULL)
                                        continue;
                                p = q;
                                if (pvp == NULL)
                                        continue;
                                p = q;
@@ -780,7 +780,7 @@ main(argc, argv, envp)
                                        while (*p != '\0' && *p++ != ',')
                                                continue;
                                }
                                        while (*p != '\0' && *p++ != ',')
                                                continue;
                                }
-                       } while (*(p = DelimChar) != '\0');
+                       } while (*(p = delimptr) != '\0');
                }
        }
 
                }
        }
 
@@ -888,7 +888,7 @@ main(argc, argv, envp)
        (void) setpgrp(0, getpid());
 
        initsys(CurEnv);
        (void) setpgrp(0, getpid());
 
        initsys(CurEnv);
-       setsender(from, CurEnv);
+       setsender(from, CurEnv, NULL);
 
        if (*av == NULL && !GrabTo)
        {
 
        if (*av == NULL && !GrabTo)
        {
index c3cdbcf..031fac4 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)parseaddr.c        6.20 (Berkeley) %G%";
+static char sccsid[] = "@(#)parseaddr.c        6.21 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "sendmail.h"
 #endif /* not lint */
 
 #include "sendmail.h"
@@ -52,6 +52,8 @@ char  *DelimChar;             /* set to point to the delimiter */
 **                     +1 -- copy everything.
 **             delim -- the character to terminate the address, passed
 **                     to prescan.
 **                     +1 -- copy everything.
 **             delim -- the character to terminate the address, passed
 **                     to prescan.
+**             delimptr -- if non-NULL, set to the location of the
+**                     delim character that was found.
 **             e -- the envelope that will contain this address.
 **
 **     Returns:
 **             e -- the envelope that will contain this address.
 **
 **     Returns:
@@ -67,14 +69,16 @@ char        *DelimChar;             /* set to point to the delimiter */
 # define DELIMCHARS    "\201()<>,;\\\"\r\n"    /* word delimiters */
 
 ADDRESS *
 # define DELIMCHARS    "\201()<>,;\\\"\r\n"    /* word delimiters */
 
 ADDRESS *
-parseaddr(addr, a, copyf, delim, e)
+parseaddr(addr, a, copyf, delim, delimptr, e)
        char *addr;
        register ADDRESS *a;
        int copyf;
        char delim;
        char *addr;
        register ADDRESS *a;
        int copyf;
        char delim;
+       char **delimptr;
        register ENVELOPE *e;
 {
        register char **pvp;
        register ENVELOPE *e;
 {
        register char **pvp;
+       auto char *delimptrbuf;
        char pvpbuf[PSBUFSIZE];
 
        /*
        char pvpbuf[PSBUFSIZE];
 
        /*
@@ -108,7 +112,10 @@ parseaddr(addr, a, copyf, delim, e)
                        return (NULL);
        }
 
                        return (NULL);
        }
 
-       pvp = prescan(addr, delim, pvpbuf);
+       if (delimptr == NULL)
+               delimptr = &delimptrbuf;
+
+       pvp = prescan(addr, delim, pvpbuf, delimptr);
        if (pvp == NULL)
        {
                if (tTd(20, 1))
        if (pvp == NULL)
        {
                if (tTd(20, 1))
@@ -148,7 +155,7 @@ parseaddr(addr, a, copyf, delim, e)
        **  transport them out.
        */
 
        **  transport them out.
        */
 
-       allocaddr(a, copyf, addr);
+       allocaddr(a, copyf, addr, *delimptr);
 
        /*
        **  Compute return value.
 
        /*
        **  Compute return value.
@@ -196,6 +203,7 @@ invalidaddr(addr)
 **             a -- the address to reallocate.
 **             copyf -- the copy flag (see parseaddr for description).
 **             paddr -- the printname of the address.
 **             a -- the address to reallocate.
 **             copyf -- the copy flag (see parseaddr for description).
 **             paddr -- the printname of the address.
+**             delimptr -- a pointer to the address delimiter.  Must be set.
 **
 **     Returns:
 **             none.
 **
 **     Returns:
 **             none.
@@ -204,20 +212,21 @@ invalidaddr(addr)
 **             Copies portions of a into local buffers as requested.
 */
 
 **             Copies portions of a into local buffers as requested.
 */
 
-allocaddr(a, copyf, paddr)
+allocaddr(a, copyf, paddr, delimptr)
        register ADDRESS *a;
        int copyf;
        char *paddr;
        register ADDRESS *a;
        int copyf;
        char *paddr;
+       char *delimptr;
 {
        register MAILER *m = a->q_mailer;
 
        if (copyf > 0 && paddr != NULL)
        {
 {
        register MAILER *m = a->q_mailer;
 
        if (copyf > 0 && paddr != NULL)
        {
-               char savec = *DelimChar;
+               char savec = *delimptr;
 
 
-               *DelimChar = '\0';
+               *delimptr = '\0';
                a->q_paddr = newstr(paddr);
                a->q_paddr = newstr(paddr);
-               *DelimChar = savec;
+               *delimptr = savec;
        }
        else
                a->q_paddr = paddr;
        }
        else
                a->q_paddr = paddr;
@@ -329,13 +338,12 @@ invalidaddr(addr)
 **                     If '\t' then we are reading the .cf file.
 **             pvpbuf -- place to put the saved text -- note that
 **                     the pointers are static.
 **                     If '\t' then we are reading the .cf file.
 **             pvpbuf -- place to put the saved text -- note that
 **                     the pointers are static.
+**             delimptr -- if non-NULL, set to the location of the
+**                     terminating delimiter.
 **
 **     Returns:
 **             A pointer to a vector of tokens.
 **             NULL on error.
 **
 **     Returns:
 **             A pointer to a vector of tokens.
 **             NULL on error.
-**
-**     Side Effects:
-**             sets DelimChar to point to the character matching 'delim'.
 */
 
 /* states and character types */
 */
 
 /* states and character types */
@@ -366,10 +374,11 @@ static short StateTab[NSTATES][NSTATES] =
 # define NOCHAR                -1      /* signal nothing in lookahead token */
 
 char **
 # define NOCHAR                -1      /* signal nothing in lookahead token */
 
 char **
-prescan(addr, delim, pvpbuf)
+prescan(addr, delim, pvpbuf, delimptr)
        char *addr;
        char delim;
        char pvpbuf[];
        char *addr;
        char delim;
        char pvpbuf[];
+       char **delimptr;
 {
        register char *p;
        register char *q;
 {
        register char *p;
        register char *q;
@@ -414,7 +423,8 @@ prescan(addr, delim, pvpbuf)
                                if (q >= &pvpbuf[PSBUFSIZE - 5])
                                {
                                        usrerr("553 Address too long");
                                if (q >= &pvpbuf[PSBUFSIZE - 5])
                                {
                                        usrerr("553 Address too long");
-                                       DelimChar = p;
+                                       if (delimptr != NULL)
+                                               *delimptr = p;
                                        return (NULL);
                                }
 
                                        return (NULL);
                                }
 
@@ -489,7 +499,8 @@ prescan(addr, delim, pvpbuf)
                                if (cmntcnt <= 0)
                                {
                                        usrerr("553 Unbalanced ')'");
                                if (cmntcnt <= 0)
                                {
                                        usrerr("553 Unbalanced ')'");
-                                       DelimChar = p;
+                                       if (delimptr != NULL)
+                                               *delimptr = p;
                                        return (NULL);
                                }
                                else
                                        return (NULL);
                                }
                                else
@@ -504,7 +515,8 @@ prescan(addr, delim, pvpbuf)
                                if (anglecnt <= 0)
                                {
                                        usrerr("553 Unbalanced '>'");
                                if (anglecnt <= 0)
                                {
                                        usrerr("553 Unbalanced '>'");
-                                       DelimChar = p;
+                                       if (delimptr != NULL)
+                                               *delimptr = p;
                                        return (NULL);
                                }
                                anglecnt--;
                                        return (NULL);
                                }
                                anglecnt--;
@@ -556,14 +568,17 @@ prescan(addr, delim, pvpbuf)
                        if (avp >= &av[MAXATOM])
                        {
                                syserr("553 prescan: too many tokens");
                        if (avp >= &av[MAXATOM])
                        {
                                syserr("553 prescan: too many tokens");
-                               DelimChar = p;
+                               if (delimptr != NULL)
+                                       *delimptr = p;
                                return (NULL);
                        }
                        *avp++ = tok;
                }
        } while (c != '\0' && (c != delim || anglecnt > 0));
        *avp = NULL;
                                return (NULL);
                        }
                        *avp++ = tok;
                }
        } while (c != '\0' && (c != delim || anglecnt > 0));
        *avp = NULL;
-       DelimChar = --p;
+       p--;
+       if (delimptr != NULL)
+               *delimptr = p;
        if (tTd(22, 12))
        {
                printf("prescan==>");
        if (tTd(22, 12))
        {
                printf("prescan==>");
@@ -1845,7 +1860,7 @@ remotename(name, m, senderaddress, header, canonical, e)
        **      domain will be appended.
        */
 
        **      domain will be appended.
        */
 
-       pvp = prescan(name, '\0', pvpbuf);
+       pvp = prescan(name, '\0', pvpbuf, NULL);
        if (pvp == NULL)
                return (name);
        rewrite(pvp, 3);
        if (pvp == NULL)
                return (name);
        rewrite(pvp, 3);
@@ -1992,6 +2007,7 @@ maplocaluser(a, sendq, e)
 {
        register char **pvp;
        register ADDRESS *a1 = NULL;
 {
        register char **pvp;
        register ADDRESS *a1 = NULL;
+       auto char *delimptr;
        char pvpbuf[PSBUFSIZE];
 
        if (tTd(29, 1))
        char pvpbuf[PSBUFSIZE];
 
        if (tTd(29, 1))
@@ -1999,7 +2015,7 @@ maplocaluser(a, sendq, e)
                printf("maplocaluser: ");
                printaddr(a, FALSE);
        }
                printf("maplocaluser: ");
                printaddr(a, FALSE);
        }
-       pvp = prescan(a->q_user, '\0', pvpbuf);
+       pvp = prescan(a->q_user, '\0', pvpbuf, &delimptr);
        if (pvp == NULL)
                return;
 
        if (pvp == NULL)
                return;
 
@@ -2020,6 +2036,6 @@ maplocaluser(a, sendq, e)
                printaddr(a, FALSE);
        }
        a1->q_alias = a;
                printaddr(a, FALSE);
        }
        a1->q_alias = a;
-       allocaddr(a1, 1, NULL);
+       allocaddr(a1, 1, NULL, delimptr);
        (void) recipient(a1, sendq, e);
 }
        (void) recipient(a1, sendq, e);
 }
index d5684e2..8703120 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef QUEUE
 
 #ifndef lint
 #ifdef QUEUE
-static char sccsid[] = "@(#)queue.c    6.21 (Berkeley) %G% (with queueing)";
+static char sccsid[] = "@(#)queue.c    6.22 (Berkeley) %G% (with queueing)";
 #else
 #else
-static char sccsid[] = "@(#)queue.c    6.21 (Berkeley) %G% (without queueing)";
+static char sccsid[] = "@(#)queue.c    6.22 (Berkeley) %G% (without queueing)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -974,7 +974,7 @@ readqf(e)
                        break;
 
                  case 'S':             /* sender */
                        break;
 
                  case 'S':             /* sender */
-                       setsender(newstr(&bp[1]), e);
+                       setsender(newstr(&bp[1]), e, NULL);
                        break;
 
                  case 'D':             /* data file name */
                        break;
 
                  case 'D':             /* data file name */
index a783a87..e44ccee 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)readcf.c   6.15 (Berkeley) %G%";
+static char sccsid[] = "@(#)readcf.c   6.16 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -218,7 +218,7 @@ readcf(cfname)
                        /* expand and save the LHS */
                        *p = '\0';
                        expand(&bp[1], exbuf, &exbuf[sizeof exbuf], e);
                        /* expand and save the LHS */
                        *p = '\0';
                        expand(&bp[1], exbuf, &exbuf[sizeof exbuf], e);
-                       rwp->r_lhs = prescan(exbuf, '\t', pvpbuf);
+                       rwp->r_lhs = prescan(exbuf, '\t', pvpbuf, NULL);
                        nfuzzy = 0;
                        if (rwp->r_lhs != NULL)
                        {
                        nfuzzy = 0;
                        if (rwp->r_lhs != NULL)
                        {
@@ -303,7 +303,7 @@ readcf(cfname)
                                p++;
                        *p = '\0';
                        expand(q, exbuf, &exbuf[sizeof exbuf], e);
                                p++;
                        *p = '\0';
                        expand(q, exbuf, &exbuf[sizeof exbuf], e);
-                       rwp->r_rhs = prescan(exbuf, '\t', pvpbuf);
+                       rwp->r_rhs = prescan(exbuf, '\t', pvpbuf, NULL);
                        if (rwp->r_rhs != NULL)
                        {
                                register char **ap;
                        if (rwp->r_rhs != NULL)
                        {
                                register char **ap;
@@ -367,7 +367,7 @@ readcf(cfname)
                        break;
 
                  case 'D':             /* macro definition */
                        break;
 
                  case 'D':             /* macro definition */
-                       define(bp[1], newstr(munchstring(&bp[2])), e);
+                       define(bp[1], newstr(munchstring(&bp[2], NULL)), e);
                        break;
 
                  case 'H':             /* required header line */
                        break;
 
                  case 'H':             /* required header line */
@@ -625,7 +625,6 @@ makemailer(line)
        extern int NextMailer;
        extern char **makeargv();
        extern char *munchstring();
        extern int NextMailer;
        extern char **makeargv();
        extern char *munchstring();
-       extern char *DelimChar;
        extern long atol();
 
        /* allocate a mailer and set up defaults */
        extern long atol();
 
        /* allocate a mailer and set up defaults */
@@ -643,6 +642,8 @@ makemailer(line)
        /* now scan through and assign info from the fields */
        while (*p != '\0')
        {
        /* now scan through and assign info from the fields */
        while (*p != '\0')
        {
+               auto char *delimptr;
+
                while (*p != '\0' && (*p == ',' || (isascii(*p) && isspace(*p))))
                        p++;
 
                while (*p != '\0' && (*p == ',' || (isascii(*p) && isspace(*p))))
                        p++;
 
@@ -659,7 +660,7 @@ makemailer(line)
                        p++;
 
                /* p now points to the field body */
                        p++;
 
                /* p now points to the field body */
-               p = munchstring(p);
+               p = munchstring(p, &delimptr);
 
                /* install the field into the mailer struct */
                switch (fcode)
 
                /* install the field into the mailer struct */
                switch (fcode)
@@ -721,7 +722,7 @@ makemailer(line)
                        break;
                }
 
                        break;
                }
 
-               p = DelimChar;
+               p = delimptr;
        }
 
        /* do some heuristic cleanup for back compatibility */
        }
 
        /* do some heuristic cleanup for back compatibility */
@@ -769,24 +770,22 @@ makemailer(line)
 **
 **     Parameters:
 **             p -- the string to munch.
 **
 **     Parameters:
 **             p -- the string to munch.
+**             delimptr -- if non-NULL, set to the pointer of the
+**                     field delimiter character.
 **
 **     Returns:
 **             the munched string.
 **
 **     Returns:
 **             the munched string.
-**
-**     Side Effects:
-**             Sets "DelimChar" to point to the string that caused us
-**             to stop.
 */
 
 char *
 */
 
 char *
-munchstring(p)
+munchstring(p, delimptr)
        register char *p;
        register char *p;
+       char **delimptr;
 {
        register char *q;
        bool backslash = FALSE;
        bool quotemode = FALSE;
        static char buf[MAXLINE];
 {
        register char *q;
        bool backslash = FALSE;
        bool quotemode = FALSE;
        static char buf[MAXLINE];
-       extern char *DelimChar;
 
        for (q = buf; *p != '\0'; p++)
        {
 
        for (q = buf; *p != '\0'; p++)
        {
@@ -827,7 +826,8 @@ munchstring(p)
                }
        }
 
                }
        }
 
-       DelimChar = p;
+       if (delimptr != NULL)
+               *delimptr = p;
        *q++ = '\0';
        return (buf);
 }
        *q++ = '\0';
        return (buf);
 }
index f731806..a076b16 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)recipient.c        6.20 (Berkeley) %G%";
+static char sccsid[] = "@(#)recipient.c        6.21 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -84,14 +84,14 @@ sendto(list, copyf, ctladdr, qflags)
 
        for (p = list; *p != '\0'; )
        {
 
        for (p = list; *p != '\0'; )
        {
+               auto char *delimptr;
                register ADDRESS *a;
                register ADDRESS *a;
-               extern char *DelimChar;         /* defined in prescan */
 
                /* parse the address */
                while ((isascii(*p) && isspace(*p)) || *p == ',')
                        p++;
 
                /* parse the address */
                while ((isascii(*p) && isspace(*p)) || *p == ',')
                        p++;
-               a = parseaddr(p, (ADDRESS *) NULL, 1, delimiter, e);
-               p = DelimChar;
+               a = parseaddr(p, (ADDRESS *) NULL, 1, delimiter, &delimptr, e);
+               p = delimptr;
                if (a == NULL)
                        continue;
                a->q_next = al;
                if (a == NULL)
                        continue;
                a->q_next = al;
index 56e1187..66fc60b 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)savemail.c 6.17 (Berkeley) %G%";
+static char sccsid[] = "@(#)savemail.c 6.18 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <pwd.h>
 #endif /* not lint */
 
 # include <pwd.h>
@@ -232,7 +232,7 @@ savemail(e)
                        }
                        else
                        {
                        }
                        else
                        {
-                               if (parseaddr("postmaster", q, 0, '\0', e) == NULL)
+                               if (parseaddr("postmaster", q, 0, '\0', NULL, e) == NULL)
                                {
                                        syserr("553 cannot parse postmaster!");
                                        ExitStat = EX_SOFTWARE;
                                {
                                        syserr("553 cannot parse postmaster!");
                                        ExitStat = EX_SOFTWARE;
@@ -410,7 +410,7 @@ returntosender(msg, returnq, sendbody, e)
        for (q = returnq; q != NULL; q = q->q_next)
        {
                if (!DontPruneRoutes && pruneroute(q->q_paddr))
        for (q = returnq; q != NULL; q = q->q_next)
        {
                if (!DontPruneRoutes && pruneroute(q->q_paddr))
-                       parseaddr(q->q_paddr, q, 0, '\0', e);
+                       parseaddr(q->q_paddr, q, 0, '\0', NULL, e);
 
                if (q->q_alias == NULL)
                        addheader("to", q->q_paddr, ee);
 
                if (q->q_alias == NULL)
                        addheader("to", q->q_paddr, ee);
@@ -432,7 +432,7 @@ returntosender(msg, returnq, sendbody, e)
                ee->e_returnpath = "<>";
        else
                ee->e_returnpath = ee->e_sender;
                ee->e_returnpath = "<>";
        else
                ee->e_returnpath = ee->e_sender;
-       if (parseaddr(buf, &ee->e_from, -1, '\0', e) == NULL)
+       if (parseaddr(buf, &ee->e_from, -1, '\0', NULL, e) == NULL)
        {
                syserr("553 Can't parse myself!");
                ExitStat = EX_SOFTWARE;
        {
                syserr("553 Can't parse myself!");
                ExitStat = EX_SOFTWARE;
index e125bc2..ab50730 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef SMTP
 
 #ifndef lint
 #ifdef SMTP
-static char sccsid[] = "@(#)srvrsmtp.c 6.20 (Berkeley) %G% (with SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 6.21 (Berkeley) %G% (with SMTP)";
 #else
 #else
-static char sccsid[] = "@(#)srvrsmtp.c 6.20 (Berkeley) %G% (without SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 6.21 (Berkeley) %G% (without SMTP)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -248,11 +248,6 @@ smtp(e)
                                syserr("503 Nested MAIL command: MAIL %s", p);
                                finis();
                        }
                                syserr("503 Nested MAIL command: MAIL %s", p);
                                finis();
                        }
-                       if (!enoughspace())
-                       {
-                               message("452 Insufficient disk space; try again later");
-                               break;
-                       }
 
                        /* fork a subprocess to process this command */
                        if (runinchild("SMTP-MAIL", e) > 0)
 
                        /* fork a subprocess to process this command */
                        if (runinchild("SMTP-MAIL", e) > 0)
@@ -277,7 +272,71 @@ smtp(e)
                                break;
                        }
                        QuickAbort = TRUE;
                                break;
                        }
                        QuickAbort = TRUE;
-                       setsender(p, e);
+
+                       /* must parse sender first */
+                       delimptr = NULL;
+                       setsender(p, e, &delimptr);
+                       p = delimptr;
+                       if (p != NULL && *p != '\0')
+                               *p++ = '\0';
+
+                       /* now parse ESMTP arguments */
+                       msize = 0;
+                       for (; p != NULL && *p != '\0'; p++)
+                       {
+                               char *kp;
+                               char *vp;
+
+                               /* locate the beginning of the keyword */
+                               while (isascii(*p) && isspace(*p))
+                                       p++;
+                               if (*p == '\0')
+                                       break;
+                               kp = p;
+
+                               /* skip to the value portion */
+                               while (isascii(*p) && isalnum(*p) || *p == '-')
+                                       p++;
+                               if (*p == '=')
+                               {
+                                       *p++ = '\0';
+                                       vp = p;
+
+                                       /* skip to the end of the value */
+                                       while (*p != '\0' && *p != ' ' &&
+                                              !(isascii(*p) && iscntrl(*p)) &&
+                                              *p != '=')
+                                               p++;
+                               }
+
+                               if (*p != '\0')
+                                       *p++ = '\0';
+
+                               if (tTd(19, 1))
+                                       printf("MAIL: got arg %s=%s\n", kp,
+                                               vp == NULL ? "<null>" : vp);
+
+                               if (strcasecmp(kp, "size") == 0)
+                               {
+                                       if (kp == NULL)
+                                       {
+                                               usrerr("501 SIZE requires a value");
+                                               /* NOTREACHED */
+                                       }
+                                       msize = atol(vp);
+                               }
+                               else
+                               {
+                                       usrerr("501 %s parameter unrecognized", kp);
+                                       /* NOTREACHED */
+                               }
+                       }
+                               
+                       if (!enoughspace(msize))
+                       {
+                               message("452 Insufficient disk space; try again later");
+                               break;
+                       }
                        message("250 Sender ok");
                        gotmail = TRUE;
                        break;
                        message("250 Sender ok");
                        gotmail = TRUE;
                        break;