restore e_sender as sending address sans decorations
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Fri, 19 Mar 1993 02:56:39 +0000 (18:56 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Fri, 19 Mar 1993 02:56:39 +0000 (18:56 -0800)
SCCS-vsn: usr.sbin/sendmail/src/headers.c 6.21
SCCS-vsn: usr.sbin/sendmail/src/main.c 6.40
SCCS-vsn: usr.sbin/sendmail/src/envelope.c 6.23
SCCS-vsn: usr.sbin/sendmail/src/savemail.c 6.23
SCCS-vsn: usr.sbin/sendmail/src/srvrsmtp.c 6.25
SCCS-vsn: usr.sbin/sendmail/src/deliver.c 6.47
SCCS-vsn: usr.sbin/sendmail/src/queue.c 6.30

usr/src/usr.sbin/sendmail/src/deliver.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/queue.c
usr/src/usr.sbin/sendmail/src/savemail.c
usr/src/usr.sbin/sendmail/src/srvrsmtp.c

index 4e471e8..dd1ba26 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)deliver.c  6.46 (Berkeley) %G%";
+static char sccsid[] = "@(#)deliver.c  6.47 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "sendmail.h"
 #endif /* not lint */
 
 #include "sendmail.h"
@@ -60,7 +60,7 @@ deliver(e, firstto)
        int rcode;                      /* response code */
        char *firstsig;                 /* signature of firstto */
        char *pv[MAXPV+1];
        int rcode;                      /* response code */
        char *firstsig;                 /* signature of firstto */
        char *pv[MAXPV+1];
-       char tobuf[MAXLINE-50];         /* text line of to people */
+       char tobuf[TOBUFSIZE];          /* text line of to people */
        char buf[MAXNAME];
        char rpathbuf[MAXNAME];         /* translated return path */
        extern int checkcompat();
        char buf[MAXNAME];
        char rpathbuf[MAXNAME];         /* translated return path */
        extern int checkcompat();
@@ -130,8 +130,6 @@ deliver(e, firstto)
        /* rewrite from address, using rewriting rules */
        (void) strcpy(rpathbuf, remotename(e->e_from.q_paddr, m, TRUE, FALSE,
                                           TRUE, FALSE, e));
        /* rewrite from address, using rewriting rules */
        (void) strcpy(rpathbuf, remotename(e->e_from.q_paddr, m, TRUE, FALSE,
                                           TRUE, FALSE, e));
-
-       define('f', e->e_from.q_paddr, e);      /* raw return path */
        define('g', rpathbuf, e);               /* translated return path */
        define('h', host, e);                   /* to host */
        Errors = 0;
        define('g', rpathbuf, e);               /* translated return path */
        define('h', host, e);                   /* to host */
        Errors = 0;
@@ -1623,7 +1621,7 @@ sendall(e, mode)
                        ee->e_sendqueue = copyqueue(e->e_sendqueue);
                        ee->e_errorqueue = copyqueue(e->e_errorqueue);
                        ee->e_flags = e->e_flags & ~(EF_INQUEUE|EF_CLRQUEUE);
                        ee->e_sendqueue = copyqueue(e->e_sendqueue);
                        ee->e_errorqueue = copyqueue(e->e_errorqueue);
                        ee->e_flags = e->e_flags & ~(EF_INQUEUE|EF_CLRQUEUE);
-                       (void) parseaddr(owner, &ee->e_from, 1, '\0', NULL, ee);
+                       setsender(owner, ee, NULL, TRUE);
                        if (tTd(13, 5))
                        {
                                printf("sendall(split): QDONTSEND ");
                        if (tTd(13, 5))
                        {
                                printf("sendall(split): QDONTSEND ");
@@ -1672,7 +1670,7 @@ sendall(e, mode)
 
        if (owner != NULL)
        {
 
        if (owner != NULL)
        {
-               (void) parseaddr(owner, &e->e_from, 1, '\0', NULL, e);
+               setsender(owner, e, NULL, TRUE);
                if (tTd(13, 5))
                {
                        printf("sendall(owner): QDONTSEND ");
                if (tTd(13, 5))
                {
                        printf("sendall(owner): QDONTSEND ");
index 38056c3..26449ad 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)envelope.c 6.22 (Berkeley) %G%";
+static char sccsid[] = "@(#)envelope.c 6.23 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "sendmail.h"
 #endif /* not lint */
 
 #include "sendmail.h"
@@ -406,19 +406,21 @@ closexscript(e)
 **             e -- the envelope in which we would like the sender set.
 **             delimptr -- if non-NULL, set to the location of the
 **                     trailing delimiter.
 **             e -- the envelope in which we would like the sender set.
 **             delimptr -- if non-NULL, set to the location of the
 **                     trailing delimiter.
+**             internal -- set if this address is coming from an internal
+**                     source such as an owner alias.
 **
 **     Returns:
 **
 **     Returns:
-**             pointer to the delimiter terminating the from address.
+**             none.
 **
 **     Side Effects:
 **             sets sendmail's notion of who the from person is.
 */
 
 **
 **     Side Effects:
 **             sets sendmail's notion of who the from person is.
 */
 
-char *
-setsender(from, e, delimptr)
+setsender(from, e, delimptr, internal)
        char *from;
        register ENVELOPE *e;
        char **delimptr;
        char *from;
        register ENVELOPE *e;
        char **delimptr;
+       bool internal;
 {
        register char **pvp;
        char *realname = NULL;
 {
        register char **pvp;
        char *realname = NULL;
@@ -495,24 +497,27 @@ setsender(from, e, delimptr)
                extern char *udbsender();
 # endif
 
                extern char *udbsender();
 # endif
 
-               /* if the user has given fullname already, don't redefine */
-               if (FullName == NULL)
-                       FullName = macvalue('x', e);
-               if (FullName != NULL && FullName[0] == '\0')
-                       FullName = NULL;
+               if (!internal)
+               {
+                       /* if the user has given fullname already, don't redefine */
+                       if (FullName == NULL)
+                               FullName = macvalue('x', e);
+                       if (FullName != NULL && FullName[0] == '\0')
+                               FullName = NULL;
 
 # ifdef USERDB
 
 # ifdef USERDB
-               p = udbsender(from);
+                       p = udbsender(from);
 
 
-               if (p != NULL)
-               {
-                       /*
-                       **  We have an alternate address for the sender
-                       */
+                       if (p != NULL)
+                       {
+                               /*
+                               **  We have an alternate address for the sender
+                               */
 
 
-                       pvp = prescan(p, '\0', pvpbuf, NULL);
-               }
+                               pvp = prescan(p, '\0', pvpbuf, NULL);
+                       }
 # endif /* USERDB */
 # endif /* USERDB */
+               }
 
                if ((pw = getpwnam(e->e_from.q_user)) != NULL)
                {
 
                if ((pw = getpwnam(e->e_from.q_user)) != NULL)
                {
@@ -531,17 +536,18 @@ setsender(from, e, delimptr)
 
                        /* extract full name from passwd file */
                        if (FullName == NULL && pw->pw_gecos != NULL &&
 
                        /* extract full name from passwd file */
                        if (FullName == NULL && pw->pw_gecos != NULL &&
-                           strcmp(pw->pw_name, e->e_from.q_user) == 0)
+                           strcmp(pw->pw_name, e->e_from.q_user) == 0 &&
+                           !internal)
                        {
                                buildfname(pw->pw_gecos, e->e_from.q_user, buf);
                                if (buf[0] != '\0')
                                        FullName = newstr(buf);
                        }
                }
                        {
                                buildfname(pw->pw_gecos, e->e_from.q_user, buf);
                                if (buf[0] != '\0')
                                        FullName = newstr(buf);
                        }
                }
-               if (FullName != NULL)
+               if (FullName != NULL && !internal)
                        define('x', FullName, e);
        }
                        define('x', FullName, e);
        }
-       else
+       else if (!internal)
        {
                if (e->e_from.q_home == NULL)
                        e->e_from.q_home = getenv("HOME");
        {
                if (e->e_from.q_home == NULL)
                        e->e_from.q_home = getenv("HOME");
@@ -568,11 +574,12 @@ setsender(from, e, delimptr)
        rewrite(pvp, 3);
        rewrite(pvp, 1);
        rewrite(pvp, 4);
        rewrite(pvp, 3);
        rewrite(pvp, 1);
        rewrite(pvp, 4);
-
-       define('f', e->e_from.q_paddr, e);
+       cataddr(pvp, buf, sizeof buf, '\0');
+       e->e_sender = newstr(buf);
+       define('f', e->e_sender, e);
 
        /* save the domain spec if this mailer wants it */
 
        /* save the domain spec if this mailer wants it */
-       if (e->e_from.q_mailer != NULL &&
+       if (!internal && e->e_from.q_mailer != NULL &&
            bitnset(M_CANONICAL, e->e_from.q_mailer->m_flags))
        {
                extern char **copyplist();
            bitnset(M_CANONICAL, e->e_from.q_mailer->m_flags))
        {
                extern char **copyplist();
index 60b7ef1..545ad71 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)headers.c  6.20 (Berkeley) %G%";
+static char sccsid[] = "@(#)headers.c  6.21 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <errno.h>
 #endif /* not lint */
 
 # include <errno.h>
@@ -299,8 +299,8 @@ eatheader(e, queuejob)
        **  Set up macros for possible expansion in headers.
        */
 
        **  Set up macros for possible expansion in headers.
        */
 
-       define('f', e->e_from.q_paddr, e);
-       define('g', e->e_from.q_paddr, e);
+       define('f', e->e_sender, e);
+       define('g', e->e_sender, e);
 
        if (tTd(32, 1))
                printf("----- collected header -----\n");
 
        if (tTd(32, 1))
                printf("----- collected header -----\n");
index dd9e7ff..603748e 100644 (file)
@@ -13,7 +13,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     6.39 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     6.40 (Berkeley) %G%";
 #endif /* not lint */
 
 #define        _DEFINE
 #endif /* not lint */
 
 #define        _DEFINE
@@ -889,7 +889,7 @@ main(argc, argv, envp)
 # endif
 
        initsys(CurEnv);
 # endif
 
        initsys(CurEnv);
-       setsender(from, CurEnv, NULL);
+       setsender(from, CurEnv, NULL, FALSE);
 
        if (*av == NULL && !GrabTo)
        {
 
        if (*av == NULL && !GrabTo)
        {
index 190e81a..6cdeb6f 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef QUEUE
 
 #ifndef lint
 #ifdef QUEUE
-static char sccsid[] = "@(#)queue.c    6.29 (Berkeley) %G% (with queueing)";
+static char sccsid[] = "@(#)queue.c    6.30 (Berkeley) %G% (with queueing)";
 #else
 #else
-static char sccsid[] = "@(#)queue.c    6.29 (Berkeley) %G% (without queueing)";
+static char sccsid[] = "@(#)queue.c    6.30 (Berkeley) %G% (without queueing)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -74,21 +74,10 @@ queueup(e, queueall, announce)
        register char *p;
        MAILER nullmailer;
        ADDRESS *lastctladdr;
        register char *p;
        MAILER nullmailer;
        ADDRESS *lastctladdr;
-       static ADDRESS *nullctladdr = NULL;
        char buf[MAXLINE], tf[MAXLINE];
        extern char *macvalue();
        extern ADDRESS *getctladdr();
 
        char buf[MAXLINE], tf[MAXLINE];
        extern char *macvalue();
        extern ADDRESS *getctladdr();
 
-       /*
-       **  If we don't have nullctladdr, create one
-       */
-
-       if (nullctladdr == NULL)
-       {
-               nullctladdr = (ADDRESS *) xalloc(sizeof *nullctladdr);
-               bzero((char *) nullctladdr, sizeof nullctladdr);
-       }
-
        /*
        **  Create control file.
        */
        /*
        **  Create control file.
        */
@@ -185,8 +174,6 @@ queueup(e, queueall, announce)
                        ADDRESS *ctladdr;
 
                        ctladdr = getctladdr(q);
                        ADDRESS *ctladdr;
 
                        ctladdr = getctladdr(q);
-                       if (ctladdr == NULL && q->q_alias != NULL)
-                               ctladdr = nullctladdr;
                        if (ctladdr != lastctladdr)
                        {
                                printctladdr(ctladdr, tfp);
                        if (ctladdr != lastctladdr)
                        {
                                printctladdr(ctladdr, tfp);
@@ -205,8 +192,6 @@ queueup(e, queueall, announce)
                        ADDRESS *ctladdr;
 
                        ctladdr = getctladdr(q);
                        ADDRESS *ctladdr;
 
                        ctladdr = getctladdr(q);
-                       if (ctladdr == NULL && q->q_alias != NULL)
-                               ctladdr = nullctladdr;
                        if (ctladdr != lastctladdr)
                        {
                                printctladdr(ctladdr, tfp);
                        if (ctladdr != lastctladdr)
                        {
                                printctladdr(ctladdr, tfp);
@@ -940,7 +925,7 @@ readqf(e)
                        break;
 
                  case 'S':             /* sender */
                        break;
 
                  case 'S':             /* sender */
-                       setsender(newstr(&bp[1]), e, NULL);
+                       setsender(newstr(&bp[1]), e, NULL, TRUE);
                        break;
 
                  case 'D':             /* data file name */
                        break;
 
                  case 'D':             /* data file name */
@@ -1318,7 +1303,7 @@ setctluser(user)
        */
 
        if (user == NULL || *user == '\0')
        */
 
        if (user == NULL || *user == '\0')
-               return NULL;
+               user = DefUser;
 
        /*
        **  Set up addr fields for controlling user.
 
        /*
        **  Set up addr fields for controlling user.
index eba0b2c..f5d77e2 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)savemail.c 6.22 (Berkeley) %G%";
+static char sccsid[] = "@(#)savemail.c 6.23 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <pwd.h>
 #endif /* not lint */
 
 # include <pwd.h>
@@ -445,6 +445,7 @@ returntosender(msg, returnq, sendbody, e)
                returndepth--;
                return (-1);
        }
                returndepth--;
                return (-1);
        }
+       ee->e_sender = ee->e_from.q_paddr;
 
        /* push state into submessage */
        CurEnv = ee;
 
        /* push state into submessage */
        CurEnv = ee;
index abcd5f0..452cb27 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef SMTP
 
 #ifndef lint
 #ifdef SMTP
-static char sccsid[] = "@(#)srvrsmtp.c 6.24 (Berkeley) %G% (with SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 6.25 (Berkeley) %G% (with SMTP)";
 #else
 #else
-static char sccsid[] = "@(#)srvrsmtp.c 6.24 (Berkeley) %G% (without SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 6.25 (Berkeley) %G% (without SMTP)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -276,7 +276,7 @@ smtp(e)
 
                        /* must parse sender first */
                        delimptr = NULL;
 
                        /* must parse sender first */
                        delimptr = NULL;
-                       setsender(p, e, &delimptr);
+                       setsender(p, e, &delimptr, FALSE);
                        p = delimptr;
                        if (p != NULL && *p != '\0')
                                *p++ = '\0';
                        p = delimptr;
                        if (p != NULL && *p != '\0')
                                *p++ = '\0';