Arrange to pull full name out of From line if found; includes
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 23 Aug 1981 08:52:16 +0000 (00:52 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 23 Aug 1981 08:52:16 +0000 (00:52 -0800)
Original-From: hacking (oh so ugly).  There's got to be a better way
to do this...

SCCS-vsn: usr.sbin/sendmail/src/conf.c 3.22
SCCS-vsn: usr.sbin/sendmail/src/deliver.c 3.28
SCCS-vsn: usr.sbin/sendmail/src/collect.c 3.18
SCCS-vsn: usr.sbin/sendmail/src/version.c 3.11
SCCS-vsn: usr.sbin/sendmail/src/headers.c 3.4

usr/src/usr.sbin/sendmail/src/collect.c
usr/src/usr.sbin/sendmail/src/conf.c
usr/src/usr.sbin/sendmail/src/deliver.c
usr/src/usr.sbin/sendmail/src/headers.c
usr/src/usr.sbin/sendmail/src/version.c

index 9809fe9..fcdb020 100644 (file)
@@ -1,7 +1,7 @@
 # include <errno.h>
 # include "sendmail.h"
 
 # include <errno.h>
 # include "sendmail.h"
 
-static char    SccsId[] = "@(#)collect.c       3.17    %G%";
+static char    SccsId[] = "@(#)collect.c       3.18    %G%";
 
 /*
 **  COLLECT -- read & parse message header & make temp file.
 
 /*
 **  COLLECT -- read & parse message header & make temp file.
@@ -170,7 +170,7 @@ maketemp(from)
        /* from person */
        xfrom = hvalue("sender");
        if (xfrom == NULL)
        /* from person */
        xfrom = hvalue("sender");
        if (xfrom == NULL)
-               xfrom = hvalue("from");
+               xfrom = hvalue("original-from");
        if (ArpaMode != ARPA_NONE)
                setfrom(xfrom, NULL);
 
        if (ArpaMode != ARPA_NONE)
                setfrom(xfrom, NULL);
 
@@ -178,6 +178,56 @@ maketemp(from)
        p = hvalue("full-name");
        if (p != NULL)
                define('x', p);
        p = hvalue("full-name");
        if (p != NULL)
                define('x', p);
+       else
+       {
+               register char *q;
+
+               /*
+               **  Try to extract the full name from a general From:
+               **  field.  We take anything which is a comment as a
+               **  first choice.  Failing in that, we see if there is
+               **  a "machine readable" name (in <angle brackets>); if
+               **  so we take anything preceeding that clause.
+               **
+               **  If we blow it here it's not all that serious.
+               */
+
+               p = hvalue("original-from");
+               q = index(p, '(');
+               if (q != NULL)
+               {
+                       int parenlev = 0;
+
+                       for (p = q; *p != '\0'; p++)
+                       {
+                               if (*p == '(')
+                                       parenlev++;
+                               else if (*p == ')' && --parenlev <= 0)
+                                       break;
+                       }
+                       if (*p == ')')
+                       {
+                               *p = '\0';
+                               if (*++q != '\0')
+                                       define('x', newstr(q));
+                               *p = ')';
+                       }
+               }
+               else if ((q = index(p, '<')) != NULL)
+               {
+                       char savec;
+
+                       while (*--q == ' ')
+                               continue;
+                       while (isspace(*p))
+                               p++;
+                       savec = *++q;
+                       *q = '\0';
+                       if (*p != '\0')
+                               define('x', newstr(p));
+                       *q = savec;
+               }
+       }
 
        /* date message originated */
        p = hvalue("posted-date");
 
        /* date message originated */
        p = hvalue("posted-date");
index 1b72887..d9327fa 100644 (file)
@@ -32,7 +32,7 @@
 
 
 
 
 
 
-static char SccsId[] = "@(#)conf.c     3.21    %G%";
+static char SccsId[] = "@(#)conf.c     3.22    %G%";
 
 
 # include <whoami.h>           /* definitions of machine id's at berkeley */
 
 
 # include <whoami.h>           /* definitions of machine id's at berkeley */
@@ -52,6 +52,7 @@ struct hdrinfo        HdrInfo[] =
 {
        "date",                 H_CHECK,                M_NEEDDATE,
        "from",                 H_CHECK,                M_NEEDFROM,
 {
        "date",                 H_CHECK,                M_NEEDDATE,
        "from",                 H_CHECK,                M_NEEDFROM,
+       "original-from",        H_DELETE,               0,              /* internal */
        "sender",               0,                      0,
        "full-name",            H_ACHECK,               M_FULLNAME,
        "to",                   0,                      0,
        "sender",               0,                      0,
        "full-name",            H_ACHECK,               M_FULLNAME,
        "to",                   0,                      0,
index 2eaa225..d147589 100644 (file)
@@ -5,7 +5,7 @@
 # include <syslog.h>
 # endif LOG
 
 # include <syslog.h>
 # endif LOG
 
-static char SccsId[] = "@(#)deliver.c  3.27    %G%";
+static char SccsId[] = "@(#)deliver.c  3.28    %G%";
 
 /*
 **  DELIVER -- Deliver a message to a particular address.
 
 /*
 **  DELIVER -- Deliver a message to a particular address.
@@ -522,7 +522,10 @@ putmessage(fp, m)
                if (bitset(H_DELETE, h->h_flags))
                        continue;
                if (bitset(H_CHECK|H_ACHECK, h->h_flags) && !bitset(h->h_mflags, m->m_flags))
                if (bitset(H_DELETE, h->h_flags))
                        continue;
                if (bitset(H_CHECK|H_ACHECK, h->h_flags) && !bitset(h->h_mflags, m->m_flags))
-                       continue;
+               {
+                       p = ")><(";             /* can't happen (I hope) */
+                       goto checkfrom;
+               }
                if (bitset(H_DEFAULT, h->h_flags))
                {
                        (void) expand(h->h_value, buf, &buf[sizeof buf]);
                if (bitset(H_DEFAULT, h->h_flags))
                {
                        (void) expand(h->h_value, buf, &buf[sizeof buf]);
@@ -535,6 +538,17 @@ putmessage(fp, m)
                fprintf(fp, "%s: %s\n", capitalize(h->h_field), p);
                h->h_flags |= H_USED;
                anyheader = TRUE;
                fprintf(fp, "%s: %s\n", capitalize(h->h_field), p);
                h->h_flags |= H_USED;
                anyheader = TRUE;
+
+               /* hack, hack -- output Original-From field if different */
+       checkfrom:
+               if (strcmp(h->h_field, "from") == 0)
+               {
+                       extern char *hvalue();
+                       char *ofrom = hvalue("original-from");
+
+                       if (ofrom != NULL && strcmp(p, ofrom) != 0)
+                               fprintf(fp, "Original-From: %s\n", ofrom);
+               }
        }
 
        if (anyheader)
        }
 
        if (anyheader)
index 7058739..066cc52 100644 (file)
@@ -1,7 +1,7 @@
 # include <errno.h>
 # include "sendmail.h"
 
 # include <errno.h>
 # include "sendmail.h"
 
-static char    SccsId[] = "@(#)headers.c       3.3     %G%";
+static char    SccsId[] = "@(#)headers.c       3.4     %G%";
 
 /*
 **  CHOMPHEADER -- process and save a header line.
 
 /*
 **  CHOMPHEADER -- process and save a header line.
@@ -45,6 +45,10 @@ chompheader(line, def)
        *++p = '\0';
        makelower(fname);
 
        *++p = '\0';
        makelower(fname);
 
+       /* hack, hack -- save the old From: address */
+       if (!def && strcmp(fname, "from") == 0)
+               fname = "original-from";
+
        /* strip field value on front */
        if (*fvalue == ' ')
                fvalue++;
        /* strip field value on front */
        if (*fvalue == ' ')
                fvalue++;
index a98ead4..9374c28 100644 (file)
@@ -1,3 +1,3 @@
-static char    SccsId[] = "@(#)SendMail version 3.10 of %G%";
+static char    SccsId[] = "@(#)SendMail version 3.11 of %G%";
 
 
-char   Version[] = "3.10 [%G%]";
+char   Version[] = "3.11 [%G%]";