split up FULLSMTP flag -- now have "X" (M_XDOT, use hidden dot algorithm),
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Fri, 7 Jan 1983 02:49:48 +0000 (18:49 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Fri, 7 Jan 1983 02:49:48 +0000 (18:49 -0800)
"p" (M_FROMPATH, use reverse-path in MAIL FROM:<> command), and "L"
(M_LIMITS, enforce SMTP line limits).  I would like to change the format
of the mail defn one more time to make named fields so that it would
be more extensible.

SCCS-mr: usr.sbin/sendmail/src/version.c 139
SCCS-vsn: usr.sbin/sendmail/src/deliver.c 3.145
SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 3.108
SCCS-vsn: usr.sbin/sendmail/src/savemail.c 3.56
SCCS-vsn: usr.sbin/sendmail/src/version.c 3.287
SCCS-vsn: usr.sbin/sendmail/src/util.c 3.39
SCCS-vsn: usr.sbin/sendmail/src/queue.c 3.67
SCCS-vsn: usr.sbin/sendmail/src/readcf.c 3.49
SCCS-vsn: usr.sbin/sendmail/src/usersmtp.c 3.36
SCCS-vsn: usr.sbin/sendmail/src/headers.c 3.46
SCCS-vsn: usr.sbin/sendmail/src/parseaddr.c 3.72

usr/src/usr.sbin/sendmail/src/deliver.c
usr/src/usr.sbin/sendmail/src/headers.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/savemail.c
usr/src/usr.sbin/sendmail/src/sendmail.h
usr/src/usr.sbin/sendmail/src/usersmtp.c
usr/src/usr.sbin/sendmail/src/util.c
usr/src/usr.sbin/sendmail/src/version.c

index 548c020..86cfe2c 100644 (file)
@@ -3,7 +3,7 @@
 # include "sendmail.h"
 # include <sys/stat.h>
 
 # include "sendmail.h"
 # include <sys/stat.h>
 
-SCCSID(@(#)deliver.c   3.144           %G%);
+SCCSID(@(#)deliver.c   3.145           %G%);
 
 /*
 **  DELIVER -- Deliver a message to a list of addresses.
 
 /*
 **  DELIVER -- Deliver a message to a list of addresses.
@@ -347,7 +347,7 @@ deliver(e, firstto)
        if (clever)
        {
                /* send the initial SMTP protocol */
        if (clever)
        {
                /* send the initial SMTP protocol */
-               rcode = smtpinit(m, pv, (ADDRESS *) NULL);
+               rcode = smtpinit(m, pv);
 
                if (rcode == EX_OK)
                {
 
                if (rcode == EX_OK)
                {
@@ -358,7 +358,7 @@ deliver(e, firstto)
                                int i;
 
                                e->e_to = to->q_paddr;
                                int i;
 
                                e->e_to = to->q_paddr;
-                               i = smtprcpt(to);
+                               i = smtprcpt(to, m);
                                if (i != EX_OK)
                                {
                                        markfailure(e, to, i);
                                if (i != EX_OK)
                                {
                                        markfailure(e, to, i);
@@ -377,16 +377,16 @@ deliver(e, firstto)
                        else
                        {
                                e->e_to = tobuf + 1;
                        else
                        {
                                e->e_to = tobuf + 1;
-                               rcode = smtpfinish(m, e);
+                               rcode = smtpdata(m, e);
                        }
 
                        /* now close the connection */
                        }
 
                        /* now close the connection */
-                       smtpquit(pv[0]);
+                       smtpquit(pv[0], m);
                }
        }
        else
 # endif SMTP
                }
        }
        else
 # endif SMTP
-               rcode = sendoff(e, m, pv, ctladdr, FALSE);
+               rcode = sendoff(e, m, pv, ctladdr);
 
        /*
        **  Do final status disposal.
 
        /*
        **  Do final status disposal.
@@ -525,7 +525,6 @@ dofork()
 **             pvp -- parameter vector to send to it.
 **             ctladdr -- an address pointer controlling the
 **                     user/groupid etc. of the mailer.
 **             pvp -- parameter vector to send to it.
 **             ctladdr -- an address pointer controlling the
 **                     user/groupid etc. of the mailer.
-**             crlf -- set if we want CRLF on the end of lines.
 **
 **     Returns:
 **             exit status of mailer.
 **
 **     Returns:
 **             exit status of mailer.
@@ -534,12 +533,11 @@ dofork()
 **             none.
 */
 
 **             none.
 */
 
-sendoff(e, m, pvp, ctladdr, crlf)
+sendoff(e, m, pvp, ctladdr)
        register ENVELOPE *e;
        MAILER *m;
        char **pvp;
        ADDRESS *ctladdr;
        register ENVELOPE *e;
        MAILER *m;
        char **pvp;
        ADDRESS *ctladdr;
-       bool crlf;
 {
        auto FILE *mfile;
        auto FILE *rfile;
 {
        auto FILE *mfile;
        auto FILE *rfile;
@@ -558,10 +556,10 @@ sendoff(e, m, pvp, ctladdr, crlf)
        **  Format and send message.
        */
 
        **  Format and send message.
        */
 
-       putfromline(mfile, m, crlf);
-       (*e->e_puthdr)(mfile, m, e, crlf);
-       fprintf(mfile, "\n");
-       (*e->e_putbody)(mfile, m, FALSE, e, crlf);
+       putfromline(mfile, m);
+       (*e->e_puthdr)(mfile, m, e);
+       putline("\n", mfile, m);
+       (*e->e_putbody)(mfile, m, e);
        (void) fclose(mfile);
 
        i = endmailer(pid, pvp[0]);
        (void) fclose(mfile);
 
        i = endmailer(pid, pvp[0]);
@@ -976,7 +974,6 @@ logdelivery(stat)
 **     Parameters:
 **             fp -- the file to output to.
 **             m -- the mailer describing this entry.
 **     Parameters:
 **             fp -- the file to output to.
 **             m -- the mailer describing this entry.
-**             crlf -- set if we want a CRLF at the end of the line.
 **
 **     Returns:
 **             none
 **
 **     Returns:
 **             none
@@ -985,7 +982,7 @@ logdelivery(stat)
 **             outputs some text to fp.
 */
 
 **             outputs some text to fp.
 */
 
-putfromline(fp, m, crlf)
+putfromline(fp, m)
        register FILE *fp;
        register MAILER *m;
 {
        register FILE *fp;
        register MAILER *m;
 {
@@ -1015,15 +1012,14 @@ putfromline(fp, m, crlf)
        else
 # endif UGLYUUCP
                expand("$l\n", buf, &buf[sizeof buf - 1], CurEnv);
        else
 # endif UGLYUUCP
                expand("$l\n", buf, &buf[sizeof buf - 1], CurEnv);
-       putline(buf, fp, crlf, bitset(M_FULLSMTP, m->m_flags));
+       putline(buf, fp, m);
 }
 \f/*
 **  PUTBODY -- put the body of a message.
 **
 **     Parameters:
 **             fp -- file to output onto.
 }
 \f/*
 **  PUTBODY -- put the body of a message.
 **
 **     Parameters:
 **             fp -- file to output onto.
-**             m -- a mailer descriptor.
-**             xdot -- if set, use SMTP hidden dot algorithm.
+**             m -- a mailer descriptor to control output format.
 **             e -- the envelope to put out.
 **
 **     Returns:
 **             e -- the envelope to put out.
 **
 **     Returns:
@@ -1033,14 +1029,12 @@ putfromline(fp, m, crlf)
 **             The message is written onto fp.
 */
 
 **             The message is written onto fp.
 */
 
-putbody(fp, m, xdot, e, crlf)
+putbody(fp, m, e)
        FILE *fp;
        MAILER *m;
        FILE *fp;
        MAILER *m;
-       bool xdot;
        register ENVELOPE *e;
 {
        register ENVELOPE *e;
 {
-       char buf[MAXLINE + 1];
-       bool fullsmtp = bitset(M_FULLSMTP, m->m_flags);
+       char buf[MAXLINE];
 
        /*
        **  Output the body of the message
 
        /*
        **  Output the body of the message
@@ -1055,17 +1049,13 @@ putbody(fp, m, xdot, e, crlf)
                                syserr("Cannot open %s", e->e_df);
                }
                else
                                syserr("Cannot open %s", e->e_df);
                }
                else
-                       putline("<<< No Message Collected >>>", fp, crlf, fullsmtp);
+                       putline("<<< No Message Collected >>>", fp, m);
        }
        if (e->e_dfp != NULL)
        {
                rewind(e->e_dfp);
        }
        if (e->e_dfp != NULL)
        {
                rewind(e->e_dfp);
-               buf[0] = '.';
-               while (!ferror(fp) &&
-                      fgets(&buf[1], sizeof buf - 1, e->e_dfp) != NULL)
-               {
-                       putline((xdot && buf[1] == '.') ? buf : &buf[1], fp, crlf, fullsmtp);
-               }
+               while (!ferror(fp) && fgets(buf, sizeof buf, e->e_dfp) != NULL)
+                       putline(buf, fp, m);
 
                if (ferror(e->e_dfp))
                {
 
                if (ferror(e->e_dfp))
                {
@@ -1158,11 +1148,11 @@ mailfile(filename, ctladdr)
                if (f == NULL)
                        exit(EX_CANTCREAT);
 
                if (f == NULL)
                        exit(EX_CANTCREAT);
 
-               putfromline(f, ProgMailer, FALSE);
-               (*CurEnv->e_puthdr)(f, ProgMailer, CurEnv, FALSE);
-               fputs("\n", f);
-               (*CurEnv->e_putbody)(f, ProgMailer, FALSE, CurEnv, FALSE);
-               fputs("\n", f);
+               putfromline(f, ProgMailer);
+               (*CurEnv->e_puthdr)(f, ProgMailer, CurEnv);
+               putline("\n", f, ProgMailer);
+               (*CurEnv->e_putbody)(f, ProgMailer, CurEnv);
+               putline("\n", f, ProgMailer);
                (void) fclose(f);
                (void) fflush(stdout);
 
                (void) fclose(f);
                (void) fflush(stdout);
 
index 4ef878d..ec984cd 100644 (file)
@@ -1,7 +1,7 @@
 # include <errno.h>
 # include "sendmail.h"
 
 # include <errno.h>
 # include "sendmail.h"
 
-SCCSID(@(#)headers.c   3.45            %G%);
+SCCSID(@(#)headers.c   3.46            %G%);
 
 /*
 **  CHOMPHEADER -- process and save a header line.
 
 /*
 **  CHOMPHEADER -- process and save a header line.
@@ -543,7 +543,6 @@ crackaddr(addr)
 **             fp -- file to put it on.
 **             m -- mailer to use.
 **             e -- envelope to use.
 **             fp -- file to put it on.
 **             m -- mailer to use.
 **             e -- envelope to use.
-**             crlf -- if set, output CRLF on the end of lines.
 **
 **     Returns:
 **             none.
 **
 **     Returns:
 **             none.
@@ -552,7 +551,7 @@ crackaddr(addr)
 **             none.
 */
 
 **             none.
 */
 
-putheader(fp, m, e, crlf)
+putheader(fp, m, e)
        register FILE *fp;
        register MAILER *m;
        register ENVELOPE *e;
        register FILE *fp;
        register MAILER *m;
        register ENVELOPE *e;
@@ -562,7 +561,6 @@ putheader(fp, m, e, crlf)
        extern char *arpadate();
        extern char *capitalize();
        char obuf[MAXLINE];
        extern char *arpadate();
        extern char *capitalize();
        char obuf[MAXLINE];
-       bool fullsmtp = bitset(M_FULLSMTP, m->m_flags);
 
        for (h = e->e_header; h != NULL; h = h->h_link)
        {
 
        for (h = e->e_header; h != NULL; h = h->h_link)
        {
@@ -589,13 +587,13 @@ putheader(fp, m, e, crlf)
 
                        if (bitset(H_FROM, h->h_flags))
                                oldstyle = FALSE;
 
                        if (bitset(H_FROM, h->h_flags))
                                oldstyle = FALSE;
-                       commaize(h, p, fp, oldstyle, m, crlf);
+                       commaize(h, p, fp, oldstyle, m);
                }
                else
                {
                        /* vanilla header line */
                        (void) sprintf(obuf, "%s: %s\n", capitalize(h->h_field), p);
                }
                else
                {
                        /* vanilla header line */
                        (void) sprintf(obuf, "%s: %s\n", capitalize(h->h_field), p);
-                       putline(obuf, fp, crlf, fullsmtp);
+                       putline(obuf, fp, m);
                }
        }
 }
                }
        }
 }
@@ -609,7 +607,6 @@ putheader(fp, m, e, crlf)
 **             oldstyle -- TRUE if this is an old style header.
 **             m -- a pointer to the mailer descriptor.  If NULL,
 **                     don't transform the name at all.
 **             oldstyle -- TRUE if this is an old style header.
 **             m -- a pointer to the mailer descriptor.  If NULL,
 **                     don't transform the name at all.
-**             crlf -- set if we want CRLF's on the end of lines.
 **
 **     Returns:
 **             none.
 **
 **     Returns:
 **             none.
@@ -618,17 +615,15 @@ putheader(fp, m, e, crlf)
 **             outputs "p" to file "fp".
 */
 
 **             outputs "p" to file "fp".
 */
 
-commaize(h, p, fp, oldstyle, m, crlf)
+commaize(h, p, fp, oldstyle, m)
        register HDR *h;
        register char *p;
        FILE *fp;
        bool oldstyle;
        register MAILER *m;
        register HDR *h;
        register char *p;
        FILE *fp;
        bool oldstyle;
        register MAILER *m;
-       bool crlf;
 {
        register char *obp;
        int opos;
 {
        register char *obp;
        int opos;
-       bool fullsmtp = FALSE;
        bool firstone = TRUE;
        char obuf[MAXLINE];
 
        bool firstone = TRUE;
        char obuf[MAXLINE];
 
@@ -642,9 +637,6 @@ commaize(h, p, fp, oldstyle, m, crlf)
                printf("commaize(%s: %s)\n", h->h_field, p);
 # endif DEBUG
 
                printf("commaize(%s: %s)\n", h->h_field, p);
 # endif DEBUG
 
-       if (m != NULL && bitset(M_FULLSMTP, m->m_flags))
-               fullsmtp = TRUE;
-
        obp = obuf;
        (void) sprintf(obp, "%s: ", capitalize(h->h_field));
        opos = strlen(h->h_field) + 2;
        obp = obuf;
        (void) sprintf(obp, "%s: ", capitalize(h->h_field));
        opos = strlen(h->h_field) + 2;
@@ -707,8 +699,7 @@ commaize(h, p, fp, oldstyle, m, crlf)
                *p = '\0';
 
                /* translate the name to be relative */
                *p = '\0';
 
                /* translate the name to be relative */
-               if (m != NULL)
-                       name = remotename(name, m, bitset(H_FROM, h->h_flags));
+               name = remotename(name, m, bitset(H_FROM, h->h_flags));
                if (*name == '\0')
                {
                        *p = savechar;
                if (*name == '\0')
                {
                        *p = savechar;
@@ -721,12 +712,8 @@ commaize(h, p, fp, oldstyle, m, crlf)
                        opos += 2;
                if (opos > 78 && !firstone)
                {
                        opos += 2;
                if (opos > 78 && !firstone)
                {
-                       *obp = '\0';
-                       putline(obuf, fp, crlf, fullsmtp);
-                       fputc(',', fp);
-                       if (crlf)
-                               fputc('\r', fp);
-                       fputc('\n', fp);
+                       (void) strcat(obp, ",\n");
+                       putline(obuf, fp, m);
                        obp = obuf;
                        (void) sprintf(obp, "        ");
                        opos = strlen(obp);
                        obp = obuf;
                        (void) sprintf(obp, "        ");
                        opos = strlen(obp);
@@ -750,7 +737,7 @@ commaize(h, p, fp, oldstyle, m, crlf)
                *p = savechar;
        }
        (void) strcpy(obp, "\n");
                *p = savechar;
        }
        (void) strcpy(obp, "\n");
-       putline(obuf, fp, crlf, fullsmtp);
+       putline(obuf, fp, m);
 }
 \f/*
 **  ISATWORD -- tell if the word we are pointing to is "at".
 }
 \f/*
 **  ISATWORD -- tell if the word we are pointing to is "at".
index c03f657..2afcc59 100644 (file)
@@ -1,6 +1,6 @@
 # include "sendmail.h"
 
 # include "sendmail.h"
 
-SCCSID(@(#)parseaddr.c 3.71            %G%);
+SCCSID(@(#)parseaddr.c 3.72            %G%);
 
 /*
 **  PARSEADDR -- Parse an address
 
 /*
 **  PARSEADDR -- Parse an address
@@ -986,6 +986,10 @@ remotename(name, m, senderaddress)
                printf("remotename(%s)\n", name);
 # endif DEBUG
 
                printf("remotename(%s)\n", name);
 # endif DEBUG
 
+       /* don't do anything if we are tagging it as special */
+       if ((senderaddress ? m->m_s_rwset : m->m_r_rwset) < 0)
+               return (name);
+
        /*
        **  Do a heuristic crack of this name to extract any comment info.
        **      This will leave the name as a comment and a $g macro.
        /*
        **  Do a heuristic crack of this name to extract any comment info.
        **      This will leave the name as a comment and a $g macro.
index 8b8ebe5..9e3ab60 100644 (file)
@@ -5,10 +5,10 @@
 # include <errno.h>
 
 # ifndef QUEUE
 # include <errno.h>
 
 # ifndef QUEUE
-SCCSID(@(#)queue.c     3.66            %G%     (no queueing));
+SCCSID(@(#)queue.c     3.67            %G%     (no queueing));
 # else QUEUE
 
 # else QUEUE
 
-SCCSID(@(#)queue.c     3.66            %G%);
+SCCSID(@(#)queue.c     3.67            %G%);
 
 /*
 **  Work queue.
 
 /*
 **  Work queue.
@@ -51,6 +51,7 @@ queueup(e, queueall, announce)
        register FILE *tfp;
        register HDR *h;
        register ADDRESS *q;
        register FILE *tfp;
        register HDR *h;
        register ADDRESS *q;
+       MAILER nullmailer;
 
        /*
        **  Create control file.
 
        /*
        **  Create control file.
@@ -88,7 +89,7 @@ queueup(e, queueall, announce)
                        return;
                }
                (void) chmod(e->e_df, FileMode);
                        return;
                }
                (void) chmod(e->e_df, FileMode);
-               (*e->e_putbody)(dfp, ProgMailer, FALSE, e, FALSE);
+               (*e->e_putbody)(dfp, ProgMailer, e);
                (void) fclose(dfp);
                e->e_putbody = putbody;
        }
                (void) fclose(dfp);
                e->e_putbody = putbody;
        }
@@ -145,8 +146,13 @@ queueup(e, queueall, announce)
        **      everything as absolute headers.
        **              All headers that must be relative to the recipient
        **              can be cracked later.
        **      everything as absolute headers.
        **              All headers that must be relative to the recipient
        **              can be cracked later.
+       **      We set up a "null mailer" -- i.e., a mailer that will have
+       **      no effect on the addresses as they are output.
        */
 
        */
 
+       bzero(&nullmailer, sizeof nullmailer);
+       nullmailer.m_r_rwset = nullmailer.m_s_rwset = -1;
+
        define('g', "$f", e);
        for (h = e->e_header; h != NULL; h = h->h_link)
        {
        define('g', "$f", e);
        for (h = e->e_header; h != NULL; h = h->h_link)
        {
@@ -163,7 +169,7 @@ queueup(e, queueall, announce)
                else if (bitset(H_FROM|H_RCPT, h->h_flags))
                {
                        commaize(h, h->h_value, tfp, bitset(EF_OLDSTYLE, e->e_flags),
                else if (bitset(H_FROM|H_RCPT, h->h_flags))
                {
                        commaize(h, h->h_value, tfp, bitset(EF_OLDSTYLE, e->e_flags),
-                                (MAILER *) NULL, FALSE);
+                                &nullmailer);
                }
                else
                        fprintf(tfp, "%s: %s\n", h->h_field, h->h_value);
                }
                else
                        fprintf(tfp, "%s: %s\n", h->h_field, h->h_value);
index 0f05e49..f9080f5 100644 (file)
@@ -1,6 +1,6 @@
 # include "sendmail.h"
 
 # include "sendmail.h"
 
-SCCSID(@(#)readcf.c    3.48            %G%);
+SCCSID(@(#)readcf.c    3.49            %G%);
 
 /*
 **  READCF -- read control file.
 
 /*
 **  READCF -- read control file.
@@ -483,26 +483,29 @@ struct optlist
 };
 struct optlist OptList[] =
 {
 };
 struct optlist OptList[] =
 {
+       'A',    M_ARPAFMT,
+       'C',    M_CANONICAL,
+       'D',    M_NEEDDATE,
+       'e',    M_EXPENSIVE,
+       'F',    M_NEEDFROM,
        'f',    M_FOPT,
        'f',    M_FOPT,
-       'r',    M_ROPT,
+       'h',    M_HST_UPPER,
+       'I',    M_INTERNAL,
+       'L',    M_LIMITS,
+       'l',    M_LOCAL,
+       'M',    M_MSGID,
+       'm',    M_MUSER,
+       'n',    M_NHDR,
        'P',    M_RPATH,
        'P',    M_RPATH,
+       'p',    M_FROMPATH,
+       'R',    M_CRLF,
+       'r',    M_ROPT,
        'S',    M_RESTR,
        'S',    M_RESTR,
-       'n',    M_NHDR,
-       'l',    M_LOCAL,
        's',    M_STRIPQ,
        's',    M_STRIPQ,
-       'm',    M_MUSER,
-       'F',    M_NEEDFROM,
-       'D',    M_NEEDDATE,
-       'M',    M_MSGID,
+       'U',    M_UGLYUUCP,
        'u',    M_USR_UPPER,
        'u',    M_USR_UPPER,
-       'h',    M_HST_UPPER,
        'x',    M_FULLNAME,
        'x',    M_FULLNAME,
-       'A',    M_ARPAFMT,
-       'U',    M_UGLYUUCP,
-       'e',    M_EXPENSIVE,
-       'X',    M_FULLSMTP,
-       'C',    M_CANONICAL,
-       'I',    M_INTERNAL,
+       'X',    M_XDOT,
        '\0',   0
 };
 
        '\0',   0
 };
 
index b060917..07603b1 100644 (file)
@@ -1,7 +1,7 @@
 # include <pwd.h>
 # include "sendmail.h"
 
 # include <pwd.h>
 # include "sendmail.h"
 
-SCCSID(@(#)savemail.c  3.55            %G%);
+SCCSID(@(#)savemail.c  3.56            %G%);
 
 /*
 **  SAVEMAIL -- Save mail on error
 
 /*
 **  SAVEMAIL -- Save mail on error
@@ -291,11 +291,9 @@ returntosender(msg, returnto, sendbody)
 **     original offending message.
 **
 **     Parameters:
 **     original offending message.
 **
 **     Parameters:
-**             xfile -- the transcript file.
 **             fp -- the output file.
 **             fp -- the output file.
-**             xdot -- if set, use the SMTP hidden dot algorithm.
+**             m -- the mailer to output to.
 **             e -- the envelope we are working in.
 **             e -- the envelope we are working in.
-**             crlf -- set if we want CRLF's at the end of lines.
 **
 **     Returns:
 **             none
 **
 **     Returns:
 **             none
@@ -304,16 +302,13 @@ returntosender(msg, returnto, sendbody)
 **             Outputs the body of an error message.
 */
 
 **             Outputs the body of an error message.
 */
 
-errbody(fp, m, xdot, e, crlf)
+errbody(fp, m, e)
        register FILE *fp;
        register struct mailer *m;
        register FILE *fp;
        register struct mailer *m;
-       bool xdot;
        register ENVELOPE *e;
        register ENVELOPE *e;
-       bool crlf;
 {
        register FILE *xfile;
        char buf[MAXLINE];
 {
        register FILE *xfile;
        char buf[MAXLINE];
-       bool fullsmtp = bitset(M_FULLSMTP, m->m_flags);
        char *p;
 
        /*
        char *p;
 
        /*
@@ -333,7 +328,7 @@ errbody(fp, m, xdot, e, crlf)
                if (e->e_xfp != NULL)
                        (void) fflush(e->e_xfp);
                while (fgets(buf, sizeof buf, xfile) != NULL)
                if (e->e_xfp != NULL)
                        (void) fflush(e->e_xfp);
                while (fgets(buf, sizeof buf, xfile) != NULL)
-                       putline(buf, fp, crlf, fullsmtp);
+                       putline(buf, fp, m);
                (void) fclose(xfile);
        }
        errno = 0;
                (void) fclose(xfile);
        }
        errno = 0;
@@ -348,21 +343,27 @@ errbody(fp, m, xdot, e, crlf)
        {
                if (SendBody)
                {
        {
                if (SendBody)
                {
-                       fprintf(fp, "\n   ----- Unsent message follows -----\n");
+                       putline("\n", fp, m);
+                       putline("   ----- Unsent message follows -----\n", fp, m);
                        (void) fflush(fp);
                        (void) fflush(fp);
-                       putheader(fp, m, e->e_parent, crlf);
-                       fprintf(fp, "\n");
-                       putbody(fp, m, xdot, e->e_parent, crlf);
+                       putheader(fp, m, e->e_parent);
+                       putline("\n", fp, m);
+                       putbody(fp, m, e->e_parent);
                }
                else
                {
                }
                else
                {
-                       fprintf(fp, "\n  ----- Message header follows -----\n");
+                       putline("\n", fp, m);
+                       putline("  ----- Message header follows -----\n", fp, m);
                        (void) fflush(fp);
                        (void) fflush(fp);
-                       putheader(fp, m, e->e_parent, crlf);
+                       putheader(fp, m, e->e_parent);
                }
        }
        else
                }
        }
        else
-               fprintf(fp, "\n  ----- No message was collected -----\n\n");
+       {
+               putline("\n", fp, m);
+               putline("  ----- No message was collected -----\n", fp, m);
+               putline("\n", fp, m);
+       }
 
        /*
        **  Cleanup and exit
 
        /*
        **  Cleanup and exit
index d298a77..b0abcfb 100644 (file)
@@ -7,7 +7,7 @@
 # ifdef _DEFINE
 # define EXTERN
 # ifndef lint
 # ifdef _DEFINE
 # define EXTERN
 # ifndef lint
-static char SmailSccsId[] =    "@(#)sendmail.h 3.107           %G%";
+static char SmailSccsId[] =    "@(#)sendmail.h 3.108           %G%";
 # endif lint
 # else  _DEFINE
 # define EXTERN extern
 # endif lint
 # else  _DEFINE
 # define EXTERN extern
@@ -109,9 +109,11 @@ typedef struct mailer      MAILER;
 # define M_FULLNAME    000040000L      /* want Full-Name field */
 # define M_UGLYUUCP    000100000L      /* this wants an ugly UUCP from line */
 # define M_EXPENSIVE   000200000L      /* it costs to use this mailer.... */
 # define M_FULLNAME    000040000L      /* want Full-Name field */
 # define M_UGLYUUCP    000100000L      /* this wants an ugly UUCP from line */
 # define M_EXPENSIVE   000200000L      /* it costs to use this mailer.... */
-# define M_FULLSMTP    000400000L      /* must run full SMTP, inc. limits */
+# define M_LIMITS      000400000L      /* must enforce SMTP line limits */
 # define M_INTERNAL    001000000L      /* SMTP to another sendmail site */
 # define M_CRLF                002000000L      /* use CRLF instead of NL as EOLine */
 # define M_INTERNAL    001000000L      /* SMTP to another sendmail site */
 # define M_CRLF                002000000L      /* use CRLF instead of NL as EOLine */
+# define M_FROMPATH    004000000L      /* use reverse-path in MAIL FROM: */
+# define M_XDOT                010000000L      /* use hidden-dot algorithm */
 
 # define M_ARPAFMT     (M_NEEDDATE|M_NEEDFROM|M_MSGID)
 
 
 # define M_ARPAFMT     (M_NEEDDATE|M_NEEDFROM|M_MSGID)
 
index bb1f4a0..27c17f4 100644 (file)
@@ -3,10 +3,10 @@
 # include "sendmail.h"
 
 # ifndef SMTP
 # include "sendmail.h"
 
 # ifndef SMTP
-SCCSID(@(#)usersmtp.c  3.35            %G%     (no SMTP));
+SCCSID(@(#)usersmtp.c  3.36            %G%     (no SMTP));
 # else SMTP
 
 # else SMTP
 
-SCCSID(@(#)usersmtp.c  3.35            %G%);
+SCCSID(@(#)usersmtp.c  3.36            %G%);
 
 
 
 
 
 
@@ -34,7 +34,6 @@ bool  SmtpClosing;                    /* set on a forced close */
 **             m -- mailer to create connection to.
 **             pvp -- pointer to parameter vector to pass to
 **                     the mailer.
 **             m -- mailer to create connection to.
 **             pvp -- pointer to parameter vector to pass to
 **                     the mailer.
-**             ctladdr -- controlling address for this mailer.
 **
 **     Returns:
 **             appropriate exit status -- EX_OK on success.
 **
 **     Returns:
 **             appropriate exit status -- EX_OK on success.
@@ -43,10 +42,9 @@ bool SmtpClosing;                    /* set on a forced close */
 **             creates connection and sends initial protocol.
 */
 
 **             creates connection and sends initial protocol.
 */
 
-smtpinit(m, pvp, ctladdr)
+smtpinit(m, pvp)
        struct mailer *m;
        char **pvp;
        struct mailer *m;
        char **pvp;
-       ADDRESS *ctladdr;
 {
        register int r;
        char buf[MAXNAME];
 {
        register int r;
        char buf[MAXNAME];
@@ -58,7 +56,7 @@ smtpinit(m, pvp, ctladdr)
 
        SmtpIn = SmtpOut = NULL;
        SmtpClosing = FALSE;
 
        SmtpIn = SmtpOut = NULL;
        SmtpClosing = FALSE;
-       SmtpPid = openmailer(m, pvp, ctladdr, TRUE, &SmtpOut, &SmtpIn);
+       SmtpPid = openmailer(m, pvp, (ADDRESS *) NULL, TRUE, &SmtpOut, &SmtpIn);
        if (SmtpPid < 0)
        {
 # ifdef DEBUG
        if (SmtpPid < 0)
        {
 # ifdef DEBUG
@@ -74,7 +72,7 @@ smtpinit(m, pvp, ctladdr)
        **      This should appear spontaneously.
        */
 
        **      This should appear spontaneously.
        */
 
-       r = reply();
+       r = reply(m);
        if (r < 0 || REPLYTYPE(r) != 2)
                return (EX_TEMPFAIL);
 
        if (r < 0 || REPLYTYPE(r) != 2)
                return (EX_TEMPFAIL);
 
@@ -83,8 +81,8 @@ smtpinit(m, pvp, ctladdr)
        **      My mother taught me to always introduce myself.
        */
 
        **      My mother taught me to always introduce myself.
        */
 
-       smtpmessage("HELO %s", HostName);
-       r = reply();
+       smtpmessage("HELO %s", m, HostName);
+       r = reply(m);
        if (r < 0)
                return (EX_TEMPFAIL);
        else if (REPLYTYPE(r) == 5)
        if (r < 0)
                return (EX_TEMPFAIL);
        else if (REPLYTYPE(r) == 5)
@@ -100,14 +98,14 @@ smtpinit(m, pvp, ctladdr)
        if (bitset(M_INTERNAL, m->m_flags))
        {
                /* tell it to be verbose */
        if (bitset(M_INTERNAL, m->m_flags))
        {
                /* tell it to be verbose */
-               smtpmessage("VERB");
-               r = reply();
+               smtpmessage("VERB", m);
+               r = reply(m);
                if (r < 0)
                        return (EX_TEMPFAIL);
 
                /* tell it we will be sending one transaction only */
                if (r < 0)
                        return (EX_TEMPFAIL);
 
                /* tell it we will be sending one transaction only */
-               smtpmessage("ONEX");
-               r = reply();
+               smtpmessage("ONEX", m);
+               r = reply(m);
                if (r < 0)
                        return (EX_TEMPFAIL);
        }
                if (r < 0)
                        return (EX_TEMPFAIL);
        }
@@ -127,16 +125,16 @@ smtpinit(m, pvp, ctladdr)
 
        expand("$g", buf, &buf[sizeof buf - 1], CurEnv);
        if (CurEnv->e_from.q_mailer == LocalMailer ||
 
        expand("$g", buf, &buf[sizeof buf - 1], CurEnv);
        if (CurEnv->e_from.q_mailer == LocalMailer ||
-           !bitset(M_FULLSMTP, m->m_flags))
+           !bitset(M_FROMPATH, m->m_flags))
        {
        {
-               smtpmessage("MAIL From:<%s>", canonname(buf, 1));
+               smtpmessage("MAIL From:<%s>", m, canonname(buf, 1));
        }
        else
        {
        }
        else
        {
-               smtpmessage("MAIL From:<@%s%c%s>", HostName,
-                           buf[0] == '@' ? ',' : ':', canonname(buf, 1));
+               smtpmessage("MAIL From:<@%s%c%s>", m, HostName,
+                       buf[0] == '@' ? ',' : ':', canonname(buf, 1));
        }
        }
-       r = reply();
+       r = reply(m);
        if (r < 0 || REPLYTYPE(r) == 4)
                return (EX_TEMPFAIL);
        else if (r == 250)
        if (r < 0 || REPLYTYPE(r) == 4)
                return (EX_TEMPFAIL);
        else if (r == 250)
@@ -150,6 +148,7 @@ smtpinit(m, pvp, ctladdr)
 **
 **     Parameters:
 **             to -- address of recipient.
 **
 **     Parameters:
 **             to -- address of recipient.
+**             m -- the mailer we are sending to.
 **
 **     Returns:
 **             exit status corresponding to recipient status.
 **
 **     Returns:
 **             exit status corresponding to recipient status.
@@ -158,15 +157,16 @@ smtpinit(m, pvp, ctladdr)
 **             Sends the mail via SMTP.
 */
 
 **             Sends the mail via SMTP.
 */
 
-smtprcpt(to)
+smtprcpt(to, m)
        ADDRESS *to;
        ADDRESS *to;
+       register MAILER *m;
 {
        register int r;
        extern char *canonname();
 
 {
        register int r;
        extern char *canonname();
 
-       smtpmessage("RCPT To:<%s>", canonname(to->q_user, 2));
+       smtpmessage("RCPT To:<%s>", m, canonname(to->q_user, 2));
 
 
-       r = reply();
+       r = reply(m);
        if (r < 0 || REPLYTYPE(r) == 4)
                return (EX_TEMPFAIL);
        else if (REPLYTYPE(r) == 2)
        if (r < 0 || REPLYTYPE(r) == 4)
                return (EX_TEMPFAIL);
        else if (REPLYTYPE(r) == 2)
@@ -178,7 +178,7 @@ smtprcpt(to)
        return (EX_PROTOCOL);
 }
 \f/*
        return (EX_PROTOCOL);
 }
 \f/*
-**  SMTPFINISH -- finish up sending all the SMTP protocol.
+**  SMTPDATA -- send the data and clean up the transaction.
 **
 **     Parameters:
 **             m -- mailer being sent to.
 **
 **     Parameters:
 **             m -- mailer being sent to.
@@ -191,7 +191,7 @@ smtprcpt(to)
 **             none.
 */
 
 **             none.
 */
 
-smtpfinish(m, e)
+smtpdata(m, e)
        struct mailer *m;
        register ENVELOPE *e;
 {
        struct mailer *m;
        register ENVELOPE *e;
 {
@@ -199,22 +199,33 @@ smtpfinish(m, e)
 
        /*
        **  Send the data.
 
        /*
        **  Send the data.
-       **      Dot hiding is done here.
+       **      First send the command and check that it is ok.
+       **      Then send the data.
+       **      Follow it up with a dot to terminate.
+       **      Finally get the results of the transaction.
        */
 
        */
 
-       smtpmessage("DATA");
-       r = reply();
+       /* send the command and check ok to proceed */
+       smtpmessage("DATA", m);
+       r = reply(m);
        if (r < 0 || REPLYTYPE(r) == 4)
                return (EX_TEMPFAIL);
        else if (r == 554)
                return (EX_UNAVAILABLE);
        else if (r != 354)
                return (EX_PROTOCOL);
        if (r < 0 || REPLYTYPE(r) == 4)
                return (EX_TEMPFAIL);
        else if (r == 554)
                return (EX_UNAVAILABLE);
        else if (r != 354)
                return (EX_PROTOCOL);
-       (*e->e_puthdr)(SmtpOut, m, CurEnv, TRUE);
-       fprintf(SmtpOut, "\r\n");
-       (*e->e_putbody)(SmtpOut, m, TRUE, CurEnv, TRUE);
-       smtpmessage(".");
-       r = reply();
+
+       /* now output the actual message */
+       (*e->e_puthdr)(SmtpOut, m, CurEnv);
+       putline("\n", SmtpOut, m);
+       (*e->e_putbody)(SmtpOut, m, CurEnv);
+
+       /* terminate the message */
+       fprintf(SmtpOut, ".%s\n", bitset(M_CRLF, m->m_flags) ? "\r" : "");
+       nmessage(Arpa_Info, ">>> .");
+
+       /* check for the results of the transaction */
+       r = reply(m);
        if (r < 0 || REPLYTYPE(r) == 4)
                return (EX_TEMPFAIL);
        else if (r == 250)
        if (r < 0 || REPLYTYPE(r) == 4)
                return (EX_TEMPFAIL);
        else if (r == 250)
@@ -236,8 +247,9 @@ smtpfinish(m, e)
 **             sends the final protocol and closes the connection.
 */
 
 **             sends the final protocol and closes the connection.
 */
 
-smtpquit(name)
+smtpquit(name, m)
        char *name;
        char *name;
+       register MAILER *m;
 {
        int i;
 
 {
        int i;
 
@@ -248,8 +260,8 @@ smtpquit(name)
        /* send the quit message if not a forced quit */
        if (!SmtpClosing)
        {
        /* send the quit message if not a forced quit */
        if (!SmtpClosing)
        {
-               smtpmessage("QUIT");
-               (void) reply();
+               smtpmessage("QUIT", m);
+               (void) reply(m);
                if (SmtpClosing)
                        return;
        }
                if (SmtpClosing)
                        return;
        }
@@ -268,7 +280,7 @@ smtpquit(name)
 **  REPLY -- read arpanet reply
 **
 **     Parameters:
 **  REPLY -- read arpanet reply
 **
 **     Parameters:
-**             none.
+**             m -- the mailer we are reading the reply from.
 **
 **     Returns:
 **             reply code it reads.
 **
 **     Returns:
 **             reply code it reads.
@@ -277,7 +289,7 @@ smtpquit(name)
 **             flushes the mail file.
 */
 
 **             flushes the mail file.
 */
 
-reply()
+reply(m)
 {
        (void) fflush(SmtpOut);
 
 {
        (void) fflush(SmtpOut);
 
@@ -313,7 +325,7 @@ reply()
                        syslog(LOG_ERR, "%s", &MsgBuf[4]);
 # endif LOG
                        SmtpClosing = TRUE;
                        syslog(LOG_ERR, "%s", &MsgBuf[4]);
 # endif LOG
                        SmtpClosing = TRUE;
-                       smtpquit("reply error");
+                       smtpquit("reply error", m);
                        return (-1);
                }
                fixcrlf(SmtpReplyBuffer, TRUE);
                        return (-1);
                }
                fixcrlf(SmtpReplyBuffer, TRUE);
@@ -339,7 +351,7 @@ reply()
                if (r == SMTPCLOSING)
                {
                        /* send the quit protocol */
                if (r == SMTPCLOSING)
                {
                        /* send the quit protocol */
-                       smtpquit("SMTP Shutdown");
+                       smtpquit("SMTP Shutdown", m);
                        SmtpClosing = TRUE;
                }
 
                        SmtpClosing = TRUE;
                }
 
@@ -351,6 +363,7 @@ reply()
 **
 **     Parameters:
 **             f -- format
 **
 **     Parameters:
 **             f -- format
+**             m -- the mailer to control formatting.
 **             a, b, c -- parameters
 **
 **     Returns:
 **             a, b, c -- parameters
 **
 **     Returns:
@@ -361,8 +374,9 @@ reply()
 */
 
 /*VARARGS1*/
 */
 
 /*VARARGS1*/
-smtpmessage(f, a, b, c)
+smtpmessage(f, m, a, b, c)
        char *f;
        char *f;
+       MAILER *m;
 {
        char buf[100];
 
 {
        char buf[100];
 
@@ -372,7 +386,7 @@ smtpmessage(f, a, b, c)
        else if (CurEnv->e_xfp != NULL)
                fprintf(CurEnv->e_xfp, ">>> %s\n", buf);
        if (!SmtpClosing)
        else if (CurEnv->e_xfp != NULL)
                fprintf(CurEnv->e_xfp, ">>> %s\n", buf);
        if (!SmtpClosing)
-               fprintf(SmtpOut, "%s\r\n", buf);
+               fprintf(SmtpOut, "%s%s\n", bitset(M_CRLF, m->m_flags) ? "\r" : "", buf);
 }
 
 # endif SMTP
 }
 
 # endif SMTP
index d5b834a..cc4e62c 100644 (file)
@@ -8,7 +8,7 @@
 # include "sendmail.h"
 # include "conf.h"
 
 # include "sendmail.h"
 # include "conf.h"
 
-SCCSID(@(#)util.c      3.38            %G%);
+SCCSID(@(#)util.c      3.39            %G%);
 
 /*
 **  STRIPQUOTES -- Strip quotes & quote bits from a string.
 
 /*
 **  STRIPQUOTES -- Strip quotes & quote bits from a string.
@@ -538,9 +538,7 @@ dfopen(filename, mode)
 **     Parameters:
 **             l -- line to put.
 **             fp -- file to put it onto.
 **     Parameters:
 **             l -- line to put.
 **             fp -- file to put it onto.
-**             crlf -- if set, output Carriage Return/Line Feed on lines
-**                     instead of newline.
-**             fullsmtp -- if set, obey strictest SMTP conventions.
+**             m -- the mailer used to control output.
 **
 **     Returns:
 **             none
 **
 **     Returns:
 **             none
@@ -551,14 +549,17 @@ dfopen(filename, mode)
 
 # define SMTPLINELIM   990     /* maximum line length */
 
 
 # define SMTPLINELIM   990     /* maximum line length */
 
-putline(l, fp, crlf, fullsmtp)
+putline(l, fp, m)
        register char *l;
        FILE *fp;
        register char *l;
        FILE *fp;
-       bool crlf;
-       bool fullsmtp;
+       MAILER *m;
 {
        register char *p;
        char svchar;
 {
        register char *p;
        char svchar;
+       char *crlfstring = "\r\n";
+
+       if (!bitset(M_CRLF, m->m_flags))
+               crlfstring++;
 
        do
        {
 
        do
        {
@@ -568,17 +569,17 @@ putline(l, fp, crlf, fullsmtp)
                        p = &l[strlen(l)];
 
                /* check for line overflow */
                        p = &l[strlen(l)];
 
                /* check for line overflow */
-               while (fullsmtp && (p - l) > SMTPLINELIM)
+               while (bitset(M_LIMITS, m->m_flags) && (p - l) > SMTPLINELIM)
                {
                        register char *q = &l[SMTPLINELIM - 1];
 
                        svchar = *q;
                        *q = '\0';
                {
                        register char *q = &l[SMTPLINELIM - 1];
 
                        svchar = *q;
                        *q = '\0';
+                       if (l[0] == '.' && bitset(M_XDOT, m->m_flags))
+                               fputc('.', fp);
                        fputs(l, fp);
                        fputc('!', fp);
                        fputs(l, fp);
                        fputc('!', fp);
-                       if (crlf)
-                               fputc('\r', fp);
-                       fputc('\n', fp);
+                       fputs(crlfstring, fp);
                        *q = svchar;
                        l = q;
                }
                        *q = svchar;
                        l = q;
                }
@@ -586,10 +587,10 @@ putline(l, fp, crlf, fullsmtp)
                /* output last part */
                svchar = *p;
                *p = '\0';
                /* output last part */
                svchar = *p;
                *p = '\0';
+               if (l[0] == '.' && bitset(M_XDOT, m->m_flags))
+                       fputc('.', fp);
                fputs(l, fp);
                fputs(l, fp);
-               if (crlf)
-                       fputc('\r', fp);
-               fputc('\n', fp);
+               fputs(crlfstring, fp);
                *p = svchar;
                l = p;
                if (*l == '\n')
                *p = svchar;
                l = p;
                if (*l == '\n')
index 7e701fc..eea537a 100644 (file)
@@ -1,5 +1,5 @@
 # ifndef lint
 # ifndef lint
-static char    SccsId[] = "@(#)SendMail version 3.286 of %G%";
+static char    SccsId[] = "@(#)SendMail version 3.287 of %G%";
 # endif lint
 
 # endif lint
 
-char   Version[] = "3.286 [%G%]";
+char   Version[] = "3.287 [%G%]";