change From: processing to reduce the number of Original-From:
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 13 Sep 1981 06:49:17 +0000 (22:49 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 13 Sep 1981 06:49:17 +0000 (22:49 -0800)
lines; change allocation of global variables.

SCCS-vsn: usr.sbin/sendmail/src/conf.c 3.30
SCCS-vsn: usr.sbin/sendmail/src/deliver.c 3.37
SCCS-vsn: usr.sbin/sendmail/src/collect.c 3.22
SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 3.39
SCCS-vsn: usr.sbin/sendmail/src/version.c 3.25
SCCS-vsn: usr.sbin/sendmail/src/main.c 3.35
SCCS-vsn: usr.sbin/sendmail/src/headers.c 3.7

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/main.c
usr/src/usr.sbin/sendmail/src/sendmail.h
usr/src/usr.sbin/sendmail/src/version.c

index 553a14e..786e0ab 100644 (file)
@@ -1,7 +1,7 @@
 # include <errno.h>
 # include "sendmail.h"
 
 # include <errno.h>
 # include "sendmail.h"
 
-static char    SccsId[] = "@(#)collect.c       3.21    %G%";
+static char    SccsId[] = "@(#)collect.c       3.22    %G%";
 
 /*
 **  COLLECT -- read & parse message header & make temp file.
 
 /*
 **  COLLECT -- read & parse message header & make temp file.
@@ -185,7 +185,7 @@ maketemp(from)
        /* from person */
        xfrom = hvalue("sender");
        if (xfrom == NULL)
        /* from person */
        xfrom = hvalue("sender");
        if (xfrom == NULL)
-               xfrom = hvalue("original-from");
+               xfrom = OrigFrom;
        if (ArpaMode != ARPA_NONE)
                setfrom(xfrom, (char *) NULL);
 
        if (ArpaMode != ARPA_NONE)
                setfrom(xfrom, (char *) NULL);
 
@@ -208,6 +208,8 @@ maketemp(from)
                */
 
                p = hvalue("original-from");
                */
 
                p = hvalue("original-from");
+               if (p == NULL)
+                       p = OrigFrom;
                q = index(p, '(');
                if (q != NULL)
                {
                q = index(p, '(');
                if (q != NULL)
                {
index a59e36c..b91338f 100644 (file)
@@ -36,7 +36,7 @@
 
 
 
 
 
 
-static char SccsId[] = "@(#)conf.c     3.29    %G%";
+static char SccsId[] = "@(#)conf.c     3.30    %G%";
 
 
 # include <whoami.h>           /* definitions of machine id's at berkeley */
 
 
 # include <whoami.h>           /* definitions of machine id's at berkeley */
@@ -56,7 +56,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_ACHECK,               0,              /* internal */
+       "original-from",        0,                      0,
        "sender",               0,                      0,
        "full-name",            H_ACHECK,               M_FULLNAME,
        "to",                   H_ADDR,                 0,
        "sender",               0,                      0,
        "full-name",            H_ACHECK,               M_FULLNAME,
        "to",                   H_ADDR,                 0,
index a0101b5..f64a3a7 100644 (file)
@@ -7,7 +7,7 @@
 # include <syslog.h>
 # endif LOG
 
 # include <syslog.h>
 # endif LOG
 
-static char SccsId[] = "@(#)deliver.c  3.36    %G%";
+static char SccsId[] = "@(#)deliver.c  3.37    %G%";
 
 /*
 **  DELIVER -- Deliver a message to a list of addresses.
 
 /*
 **  DELIVER -- Deliver a message to a list of addresses.
@@ -556,6 +556,8 @@ putmessage(fp, m)
        extern char *arpadate();
        bool anyheader = FALSE;
        extern char *capitalize();
        extern char *arpadate();
        bool anyheader = FALSE;
        extern char *capitalize();
+       extern char *hvalue();
+       extern bool samefrom();
        extern char SentDate[];
 
        /*
        extern char SentDate[];
 
        /*
@@ -575,13 +577,20 @@ putmessage(fp, m)
        for (h = Header; h != NULL; h = h->h_link)
        {
                register char *p;
        for (h = Header; h != NULL; h = h->h_link)
        {
                register char *p;
+               char *origfrom = OrigFrom;
 
                if (bitset(H_CHECK|H_ACHECK, h->h_flags) && !bitset(h->h_mflags, m->m_flags))
                {
                        p = ")><(";             /* can't happen (I hope) */
                        goto checkfrom;
                }
 
                if (bitset(H_CHECK|H_ACHECK, h->h_flags) && !bitset(h->h_mflags, m->m_flags))
                {
                        p = ")><(";             /* can't happen (I hope) */
                        goto checkfrom;
                }
-               if (bitset(H_DEFAULT, h->h_flags))
+               if (strcmp(h->h_field, "from") == 0 && origfrom != NULL &&
+                   strcmp(m->m_from, "$f") == 0)
+               {
+                       p = origfrom;
+                       origfrom = NULL;
+               }
+               else if (bitset(H_DEFAULT, h->h_flags))
                {
                        (void) expand(h->h_value, buf, &buf[sizeof buf]);
                        p = buf;
                {
                        (void) expand(h->h_value, buf, &buf[sizeof buf]);
                        p = buf;
@@ -596,13 +605,11 @@ putmessage(fp, m)
 
                /* hack, hack -- output Original-From field if different */
        checkfrom:
 
                /* hack, hack -- output Original-From field if different */
        checkfrom:
-               if (strcmp(h->h_field, "from") == 0)
+               if (strcmp(h->h_field, "from") == 0 && origfrom != NULL &&
+                   !samefrom(p, origfrom) && hvalue("original-from") == NULL)
                {
                {
-                       extern char *hvalue();
-                       char *ofrom = hvalue("original-from");
-
-                       if (ofrom != NULL && strcmp(p, ofrom) != 0)
-                               fprintf(fp, "Original-From: %s\n", ofrom);
+                       fprintf(fp, "Original-From: %s\n", origfrom);
+                       anyheader = TRUE;
                }
        }
        if (anyheader)
                }
        }
        if (anyheader)
@@ -624,6 +631,28 @@ putmessage(fp, m)
        errno = 0;
 }
 \f/*
        errno = 0;
 }
 \f/*
+**  SAMEFROM -- tell if two text addresses represent the same from address.
+**
+**     Parameters:
+**             ifrom -- internally generated form of from address.
+**             efrom -- external form of from address.
+**
+**     Returns:
+**             TRUE -- if they convey the same info.
+**             FALSE -- if any information has been lost.
+**
+**     Side Effects:
+**             none.
+*/
+
+bool
+samefrom(ifrom, efrom)
+       char *ifrom;
+       char *efrom;
+{
+       return (strcmp(ifrom, efrom) == 0);
+}
+\f/*
 **  MAILFILE -- Send a message to a file.
 **
 **     If the file has the setuid/setgid bits set, but NO execute
 **  MAILFILE -- Send a message to a file.
 **
 **     If the file has the setuid/setgid bits set, but NO execute
index e10e9ee..840124f 100644 (file)
@@ -1,7 +1,7 @@
 # include <errno.h>
 # include "sendmail.h"
 
 # include <errno.h>
 # include "sendmail.h"
 
-static char    SccsId[] = "@(#)headers.c       3.6     %G%";
+static char    SccsId[] = "@(#)headers.c       3.7     %G%";
 
 /*
 **  CHOMPHEADER -- process and save a header line.
 
 /*
 **  CHOMPHEADER -- process and save a header line.
@@ -46,14 +46,17 @@ 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++;
 
+       /* hack, hack -- save From: line specially */
+       if (!def && strcmp(fname, "from") == 0)
+       {
+               OrigFrom = newstr(fvalue);
+               return (0);
+       }
+
        /* search header list for this header */
        for (hp = &Header, h = Header; h != NULL; hp = &h->h_link, h = h->h_link)
        {
        /* search header list for this header */
        for (hp = &Header, h = Header; h != NULL; hp = &h->h_link, h = h->h_link)
        {
index 313e0a1..68f8391 100644 (file)
@@ -1,11 +1,12 @@
 # include <signal.h>
 # include <pwd.h>
 # include <signal.h>
 # include <pwd.h>
+# define  _DEFINE
 # include "sendmail.h"
 # ifdef LOG
 # include <syslog.h>
 # endif LOG
 
 # include "sendmail.h"
 # ifdef LOG
 # include <syslog.h>
 # endif LOG
 
-static char    SccsId[] = "@(#)main.c  3.34    %G%";
+static char    SccsId[] = "@(#)main.c  3.35    %G%";
 
 /*
 **  SENDMAIL -- Post mail to a set of destinations.
 
 /*
 **  SENDMAIL -- Post mail to a set of destinations.
@@ -100,36 +101,9 @@ static char        SccsId[] = "@(#)main.c  3.34    %G%";
 
 
 
 
 
 
-int    ArpaMode;       /* specifies the ARPANET mode */
-bool   FromFlag;       /* from person is explicitly specified */
-bool   MailBack;       /* mail back response on error */
-bool   BerkNet;        /* called from BerkNet */
-bool   WriteBack;      /* write back response on error */
-bool   HasXscrpt;      /* if set, the transcript file exists */
-bool   NoAlias;        /* don't do aliasing */
-bool   ForceMail;      /* mail even if already sent a copy */
-bool   MeToo;          /* send to the sender also if in a group expansion */
-bool   SaveFrom;       /* save From lines on the front of messages */
-bool   IgnrDot;        /* if set, ignore dot when collecting mail */
-bool   SuprErrs;       /* supress errors if set */
-bool   Verbose;        /* set if blow-by-blow desired */
-bool   GrabTo;         /* if set, read recipient addresses from msg */
-bool   DontSend;       /* mark recipients as QDONTSEND */
-bool   NoReturn;       /* don't return content of letter to sender */
-int    OldUmask;       /* umask when called */
-int    Debug;          /* debug level */
-int    Errors;         /* count of errors */
-int    AliasLevel;     /* current depth of aliasing */
 char   InFileName[] = "/tmp/mailtXXXXXX";
 char   Transcript[] = "/tmp/mailxXXXXXX";
 char   InFileName[] = "/tmp/mailtXXXXXX";
 char   Transcript[] = "/tmp/mailxXXXXXX";
-ADDRESS        From;           /* the from person */
-char   *To;            /* the target person */
-int    HopCount;       /* hop count */
-int    ExitStat;       /* the exit status byte */
-HDR    *Header;        /* header list */
-long   CurTime;        /* current time */
-int    NextMailer = 0; /* "free" index into Mailer struct */
-struct mailer  *Mailer[MAXMAILERS+1];  /* definition of mailers */
+int    NextMailer = 0;         /* "free" index into Mailer struct */
 
 
 
 
 
 
index 8feec39..9fe017d 100644 (file)
@@ -1,11 +1,16 @@
 /*
 **  SENDMAIL.H -- Global definitions for sendmail.
 **
 /*
 **  SENDMAIL.H -- Global definitions for sendmail.
 **
-**     @(#)sendmail.h  3.38    %G%
+**     @(#)sendmail.h  3.39    %G%
 */
 
 
 
 */
 
 
 
+# ifdef _DEFINE
+# define EXTERN
+# else  _DEFINE
+# define EXTERN extern
+# endif _DEFINE
 
 # include <stdio.h>
 # include <ctype.h>
 
 # include <stdio.h>
 # include <ctype.h>
@@ -113,7 +118,7 @@ typedef struct mailer       MAILER;
 
 # define M_ARPAFMT     (M_NEEDDATE|M_NEEDFROM|M_MSGID)
 
 
 # define M_ARPAFMT     (M_NEEDDATE|M_NEEDFROM|M_MSGID)
 
-extern MAILER *Mailer[];
+EXTERN MAILER *Mailer[MAXMAILERS+1];
 
 /* special mailer numbers */
 # define MN_LOCAL      0       /* local mailer */
 
 /* special mailer numbers */
 # define MN_LOCAL      0       /* local mailer */
@@ -138,7 +143,7 @@ struct header
 
 typedef struct header  HDR;
 
 
 typedef struct header  HDR;
 
-extern HDR     *Header;        /* head of header list */
+EXTERN HDR     *Header;        /* head of header list */
 
 /*
 **  Header information structure.
 
 /*
 **  Header information structure.
@@ -243,7 +248,7 @@ struct statistics
        long    stat_bt[MAXMAILERS];    /* kbytes to each mailer */
 };
 
        long    stat_bt[MAXMAILERS];    /* kbytes to each mailer */
 };
 
-extern struct statistics       Stat;
+EXTERN struct statistics       Stat;
 extern long                    kbytes();       /* for _bf, _bt */
 
 
 extern long                    kbytes();       /* for _bf, _bt */
 
 
@@ -253,33 +258,36 @@ extern long                       kbytes();       /* for _bf, _bt */
 **  Global variables.
 */
 
 **  Global variables.
 */
 
-extern bool    FromFlag;       /* if set, "From" person is explicit */
-extern bool    MailBack;       /* mail back response on error */
-extern bool    BerkNet;        /* called from BerkNet */
-extern bool    WriteBack;      /* write back response on error */
-extern bool    NoAlias;        /* if set, don't do any aliasing */
-extern bool    ForceMail;      /* if set, mail even if already got a copy */
-extern bool    MeToo;          /* send to the sender also */
-extern bool    IgnrDot;        /* don't let dot end messages */
-extern bool    SaveFrom;       /* save leading "From" lines */
-extern bool    Verbose;        /* set if blow-by-blow desired */
-extern bool    GrabTo;         /* if set, get recipients from msg */
-extern bool    DontSend;       /* mark recipients as QDONTSEND */
-extern bool    NoReturn;       /* don't return letter to sender */
-extern int     OldUmask;       /* umask when sendmail starts up */
-extern int     Debug;          /* debugging level */
-extern int     Errors;         /* set if errors */
-extern int     ExitStat;       /* exit status code */
-extern int     ArpaMode;       /* ARPANET handling mode */
-extern long    MsgSize;        /* size of the message in bytes */
+EXTERN bool    FromFlag;       /* if set, "From" person is explicit */
+EXTERN bool    MailBack;       /* mail back response on error */
+EXTERN bool    BerkNet;        /* called from BerkNet */
+EXTERN bool    WriteBack;      /* write back response on error */
+EXTERN bool    NoAlias;        /* if set, don't do any aliasing */
+EXTERN bool    ForceMail;      /* if set, mail even if already got a copy */
+EXTERN bool    MeToo;          /* send to the sender also */
+EXTERN bool    IgnrDot;        /* don't let dot end messages */
+EXTERN bool    SaveFrom;       /* save leading "From" lines */
+EXTERN bool    Verbose;        /* set if blow-by-blow desired */
+EXTERN bool    GrabTo;         /* if set, get recipients from msg */
+EXTERN bool    DontSend;       /* mark recipients as QDONTSEND */
+EXTERN bool    NoReturn;       /* don't return letter to sender */
+EXTERN int     OldUmask;       /* umask when sendmail starts up */
+EXTERN int     Debug;          /* debugging level */
+EXTERN int     Errors;         /* set if errors */
+EXTERN int     ExitStat;       /* exit status code */
+EXTERN int     ArpaMode;       /* ARPANET handling mode */
+EXTERN long    MsgSize;        /* size of the message in bytes */
 extern char    InFileName[];   /* input file name */
 extern char    Transcript[];   /* the transcript file name */
 extern char    InFileName[];   /* input file name */
 extern char    Transcript[];   /* the transcript file name */
-extern FILE    *TempFile;      /* mail temp file */
-extern ADDRESS From;           /* the person it is from */
-extern char    *To;            /* the target person */
-extern int     HopCount;       /* hop count */
-extern long    CurTime;        /* time of this message */
-extern int     AliasLevel;     /* depth of aliasing */
+EXTERN FILE    *TempFile;      /* mail temp file */
+EXTERN ADDRESS From;           /* the person it is from */
+EXTERN char    *To;            /* the target person */
+EXTERN int     HopCount;       /* hop count */
+EXTERN long    CurTime;        /* time of this message */
+EXTERN int     AliasLevel;     /* depth of aliasing */
+EXTERN char    *OrigFrom;      /* the From: line read from the message */
+EXTERN bool    SuprErrs;       /* set if we are suppressing errors */
+EXTERN bool    HasXscrpt;      /* set if we have a transcript */
 
 
 # include      <sysexits.h>
 
 
 # include      <sysexits.h>
index 7491247..1b8ee6a 100644 (file)
@@ -1,3 +1,3 @@
-static char    SccsId[] = "@(#)SendMail version 3.24 of %G%";
+static char    SccsId[] = "@(#)SendMail version 3.25 of %G%";
 
 
-char   Version[] = "3.24 [%G%]";
+char   Version[] = "3.25 [%G%]";