Handle messages with "Resent-xxx:" header lines properly (basically mark
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Mon, 7 Mar 1983 08:31:01 +0000 (00:31 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Mon, 7 Mar 1983 08:31:01 +0000 (00:31 -0800)
the message as being resent); ignore incoming From: lines if their text
exactly matches our machine-readable address exactly -- this causes the
full name to be added when called from (e.g.) MH.  Both of these mode are
to improve interaction with MH.

SCCS-mr: usr.sbin/sendmail/src/headers.c 201
SCCS-mr: usr.sbin/sendmail/src/version.c 201
SCCS-mr: usr.sbin/sendmail/src/sendmail.h 201
SCCS-mr: usr.sbin/sendmail/src/conf.c 201
SCCS-vsn: usr.sbin/sendmail/src/headers.c 3.53
SCCS-vsn: usr.sbin/sendmail/src/version.c 3.322
SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 3.116
SCCS-vsn: usr.sbin/sendmail/src/conf.c 3.70

usr/src/usr.sbin/sendmail/src/conf.c
usr/src/usr.sbin/sendmail/src/headers.c
usr/src/usr.sbin/sendmail/src/sendmail.h
usr/src/usr.sbin/sendmail/src/version.c

index 7141ccd..dda0af3 100644 (file)
@@ -32,7 +32,7 @@
 
 
 
 
 
 
-SCCSID(@(#)conf.c      3.69            %G%);
+SCCSID(@(#)conf.c      3.70            %G%);
 \f/*
 **  Header info table
 **     Final (null) entry contains the flags used for any other field.
 \f/*
 **  Header info table
 **     Final (null) entry contains the flags used for any other field.
@@ -46,8 +46,8 @@ SCCSID(@(#)conf.c     3.69            %G%);
 struct hdrinfo HdrInfo[] =
 {
                /* originator fields, most to least significant  */
 struct hdrinfo HdrInfo[] =
 {
                /* originator fields, most to least significant  */
-       "resent-sender",        H_FROM,
-       "resent-from",          H_FROM,
+       "resent-sender",        H_FROM|H_RESENT,
+       "resent-from",          H_FROM|H_RESENT,
        "sender",               H_FROM,
        "from",                 H_FROM,
        "full-name",            H_ACHECK,
        "sender",               H_FROM,
        "from",                 H_FROM,
        "full-name",            H_ACHECK,
@@ -55,14 +55,19 @@ struct hdrinfo      HdrInfo[] =
        "errors-to",            H_FROM,
                /* destination fields */
        "to",                   H_RCPT,
        "errors-to",            H_FROM,
                /* destination fields */
        "to",                   H_RCPT,
-       "resent-to",            H_RCPT,
+       "resent-to",            H_RCPT|H_RESENT,
        "cc",                   H_RCPT,
        "cc",                   H_RCPT,
-       "resent-cc",            H_RCPT,
+       "resent-cc",            H_RCPT|H_RESENT,
        "bcc",                  H_RCPT|H_ACHECK,
        "bcc",                  H_RCPT|H_ACHECK,
-       "resent-bcc",           H_RCPT|H_ACHECK,
+       "resent-bcc",           H_RCPT|H_ACHECK|H_RESENT,
                /* message identification and control */
                /* message identification and control */
+       "message-id",           0,
+       "resent-message-id",    H_RESENT,
        "message",              H_EOH,
        "text",                 H_EOH,
        "message",              H_EOH,
        "text",                 H_EOH,
+               /* date fields */
+       "date",                 0,
+       "resent-date",          H_RESENT,
                /* trace fields */
        "received",             H_TRACE|H_FORCE,
        "via",                  H_TRACE|H_FORCE,
                /* trace fields */
        "received",             H_TRACE|H_FORCE,
        "via",                  H_TRACE|H_FORCE,
index c7b9997..93023db 100644 (file)
@@ -1,7 +1,7 @@
 # include <errno.h>
 # include "sendmail.h"
 
 # include <errno.h>
 # include "sendmail.h"
 
-SCCSID(@(#)headers.c   3.52            %G%);
+SCCSID(@(#)headers.c   3.53            %G%);
 
 /*
 **  CHOMPHEADER -- process and save a header line.
 
 /*
 **  CHOMPHEADER -- process and save a header line.
@@ -93,10 +93,24 @@ chompheader(line, def)
                        break;
        }
 
                        break;
        }
 
+       /* see if this is a resent message */
+       if (!def && bitset(H_RESENT, h->h_flags))
+               CurEnv->e_flags |= EF_RESENT;
+
        /* if this means "end of header" quit now */
        if (bitset(H_EOH, hi->hi_flags))
                return (hi->hi_flags);
 
        /* if this means "end of header" quit now */
        if (bitset(H_EOH, hi->hi_flags))
                return (hi->hi_flags);
 
+       /* drop explicit From: if same as what we would generate -- for MH */
+       if (!def && strcmp(fvalue, CurEnv->e_from.q_paddr) == 0)
+       {
+               p = "resent-from";
+               if (!bitset(EF_RESENT, CurEnv->e_flags))
+                       p += 7;
+               if (strcmp(fname, p) == 0)
+                       return (hi->hi_flags);
+       }
+
        /* create/fill in a new node */
        if (h == NULL || bitset(H_FORCE, h->h_flags))
        {
        /* create/fill in a new node */
        if (h == NULL || bitset(H_FORCE, h->h_flags))
        {
@@ -125,10 +139,6 @@ chompheader(line, def)
                CurEnv->e_flags &= ~EF_OLDSTYLE;
        }
 
                CurEnv->e_flags &= ~EF_OLDSTYLE;
        }
 
-       /* send to this person if we so desire */
-       if (!def && GrabTo && bitset(H_RCPT, h->h_flags))
-               sendtolist(h->h_value, (ADDRESS *) NULL, &CurEnv->e_sendqueue);
-
        return (h->h_flags);
 }
 \f/*
        return (h->h_flags);
 }
 \f/*
@@ -274,8 +284,19 @@ eatheader(e)
                if (tTd(32, 1))
                        printf("%s: %s\n", capitalize(h->h_field), h->h_value);
 #endif DEBUG
                if (tTd(32, 1))
                        printf("%s: %s\n", capitalize(h->h_field), h->h_value);
 #endif DEBUG
+               /* count the number of times it has been processed */
                if (bitset(H_TRACE, h->h_flags))
                        hopcnt++;
                if (bitset(H_TRACE, h->h_flags))
                        hopcnt++;
+
+               /* send to this person if we so desire */
+               if (GrabTo && bitset(H_RCPT, h->h_flags) &&
+                   !bitset(H_DEFAULT, h->h_flags) &&
+                   (!bitset(EF_RESENT, CurEnv->e_flags) || bitset(H_RESENT, h->h_flags)))
+               {
+                       sendtolist(h->h_value, (ADDRESS *) NULL, &CurEnv->e_sendqueue);
+               }
+
+               /* log the message-id */
 #ifdef LOG
                if (!QueueRun && LogLevel > 8 &&
                    strcmp(h->h_field, "message-id") == 0)
 #ifdef LOG
                if (!QueueRun && LogLevel > 8 &&
                    strcmp(h->h_field, "message-id") == 0)
@@ -599,6 +620,10 @@ putheader(fp, m, e)
                    !bitintersect(h->h_mflags, m->m_flags))
                        continue;
 
                    !bitintersect(h->h_mflags, m->m_flags))
                        continue;
 
+               /* handle Resent-... headers specially */
+               if (bitset(H_RESENT, h->h_flags) && !bitset(EF_RESENT, e->e_flags))
+                       continue;
+
                p = h->h_value;
                if (bitset(H_DEFAULT, h->h_flags))
                {
                p = h->h_value;
                if (bitset(H_DEFAULT, h->h_flags))
                {
index 5de3d53..aa5623b 100644 (file)
@@ -7,7 +7,7 @@
 # ifdef _DEFINE
 # define EXTERN
 # ifndef lint
 # ifdef _DEFINE
 # define EXTERN
 # ifndef lint
-static char SmailSccsId[] =    "@(#)sendmail.h 3.115           %G%";
+static char SmailSccsId[] =    "@(#)sendmail.h 3.116           %G%";
 # endif lint
 # else  _DEFINE
 # define EXTERN extern
 # endif lint
 # else  _DEFINE
 # define EXTERN extern
@@ -178,7 +178,7 @@ extern struct hdrinfo       HdrInfo[];
 # define H_EOH         00001   /* this field terminates header */
 # define H_RCPT                00002   /* contains recipient addresses */
 # define H_DEFAULT     00004   /* if another value is found, drop this */
 # define H_EOH         00001   /* this field terminates header */
 # define H_RCPT                00002   /* contains recipient addresses */
 # define H_DEFAULT     00004   /* if another value is found, drop this */
-# define H_RESENT      00010   /* this address is a "resent-..." address */
+# define H_RESENT      00010   /* this address is a "Resent-..." address */
 # define H_CHECK       00020   /* check h_mflags against m_flags */
 # define H_ACHECK      00040   /* ditto, but always (not just default) */
 # define H_FORCE       00100   /* force this field, even if default */
 # define H_CHECK       00020   /* check h_mflags against m_flags */
 # define H_ACHECK      00040   /* ditto, but always (not just default) */
 # define H_FORCE       00100   /* force this field, even if default */
@@ -232,6 +232,7 @@ typedef struct envelope     ENVELOPE;
 #define EF_FATALERRS   000040          /* fatal errors occured */
 #define EF_KEEPQUEUE   000100          /* keep queue files always */
 #define EF_RESPONSE    000200          /* this is an error or return receipt */
 #define EF_FATALERRS   000040          /* fatal errors occured */
 #define EF_KEEPQUEUE   000100          /* keep queue files always */
 #define EF_RESPONSE    000200          /* this is an error or return receipt */
+#define EF_RESENT      000400          /* this message is being forwarded */
 
 EXTERN ENVELOPE        *CurEnv;        /* envelope currently being processed */
 \f/*
 
 EXTERN ENVELOPE        *CurEnv;        /* envelope currently being processed */
 \f/*
index af2b831..b2d631e 100644 (file)
@@ -1,5 +1,5 @@
 # ifndef lint
 # ifndef lint
-static char    SccsId[] = "@(#)SendMail version 3.321 of %G%";
+static char    SccsId[] = "@(#)SendMail version 3.322 of %G%";
 # endif lint
 
 # endif lint
 
-char   Version[] = "3.321";
+char   Version[] = "3.322";