From 8c8e8e94a6dc46b7511b1df9dd992c28b37493a4 Mon Sep 17 00:00:00 2001 From: Eric Allman Date: Fri, 19 Mar 1993 16:51:06 -0800 Subject: [PATCH] move SendMode and ErrorMode into the envelope SCCS-vsn: usr.sbin/sendmail/src/main.c 6.43 SCCS-vsn: usr.sbin/sendmail/src/envelope.c 6.25 SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 6.30 SCCS-vsn: usr.sbin/sendmail/src/savemail.c 6.25 SCCS-vsn: usr.sbin/sendmail/src/srvrsmtp.c 6.27 SCCS-vsn: usr.sbin/sendmail/src/readcf.c 6.18 SCCS-vsn: usr.sbin/sendmail/src/deliver.c 6.51 SCCS-vsn: usr.sbin/sendmail/src/queue.c 6.36 SCCS-vsn: usr.sbin/sendmail/src/conf.c 6.38 --- usr/src/usr.sbin/sendmail/src/conf.c | 11 ++++---- usr/src/usr.sbin/sendmail/src/deliver.c | 8 +++--- usr/src/usr.sbin/sendmail/src/envelope.c | 5 ++-- usr/src/usr.sbin/sendmail/src/main.c | 32 ++++++++++++------------ usr/src/usr.sbin/sendmail/src/queue.c | 6 ++--- usr/src/usr.sbin/sendmail/src/readcf.c | 10 +++++--- usr/src/usr.sbin/sendmail/src/savemail.c | 8 +++--- usr/src/usr.sbin/sendmail/src/sendmail.h | 12 ++++----- usr/src/usr.sbin/sendmail/src/srvrsmtp.c | 10 ++++---- 9 files changed, 54 insertions(+), 48 deletions(-) diff --git a/usr/src/usr.sbin/sendmail/src/conf.c b/usr/src/usr.sbin/sendmail/src/conf.c index a92d0c965d..a9ce489793 100644 --- a/usr/src/usr.sbin/sendmail/src/conf.c +++ b/usr/src/usr.sbin/sendmail/src/conf.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)conf.c 6.37 (Berkeley) %G%"; +static char sccsid[] = "@(#)conf.c 6.38 (Berkeley) %G%"; #endif /* not lint */ # include @@ -130,7 +130,7 @@ int DtableSize = 50; /* max open files; reset in 4.2bsd */ ** using direct code. ** ** Parameters: -** none. +** e -- the default envelope. ** ** Returns: ** none. @@ -140,7 +140,8 @@ int DtableSize = 50; /* max open files; reset in 4.2bsd */ ** default values. */ -setdefaults() +setdefaults(e) + register ENVELOPE *e; { SpaceSub = ' '; /* option B */ QueueLA = 8; /* option x */ @@ -155,8 +156,8 @@ setdefaults() DefGid = 1; /* option g */ CheckpointInterval = 10; /* option C */ MaxHopCount = 25; /* option h */ - SendMode = SM_FORK; /* option d */ - ErrorMode = EM_PRINT; /* option e */ + e->e_sendmode = SM_FORK; /* option d */ + e->e_errormode = EM_PRINT; /* option e */ EightBit = FALSE; /* option 8 */ MaxMciCache = 1; /* option k */ MciCacheTimeout = 300; /* option K */ diff --git a/usr/src/usr.sbin/sendmail/src/deliver.c b/usr/src/usr.sbin/sendmail/src/deliver.c index 8593059155..3b0964b223 100644 --- a/usr/src/usr.sbin/sendmail/src/deliver.c +++ b/usr/src/usr.sbin/sendmail/src/deliver.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)deliver.c 6.50 (Berkeley) %G%"; +static char sccsid[] = "@(#)deliver.c 6.51 (Berkeley) %G%"; #endif /* not lint */ #include "sendmail.h" @@ -1466,7 +1466,7 @@ mailfile(filename, ctladdr, e) ** Parameters: ** e -- the envelope to send. ** mode -- the delivery mode to use. If SM_DEFAULT, use -** the current SendMode. +** the current e->e_sendmode. ** ** Returns: ** none. @@ -1493,7 +1493,7 @@ sendall(e, mode) { extern bool shouldqueue(); - mode = SendMode; + mode = e->e_sendmode; if (mode != SM_VERIFY && shouldqueue(e->e_msgpriority, e->e_ctime)) mode = SM_QUEUE; @@ -1628,6 +1628,7 @@ sendall(e, mode) ee->e_xfp = NULL; ee->e_lockfp = NULL; ee->e_df = NULL; + ee->e_errormode = EM_MAIL; ee->e_sibling = splitenv; splitenv = ee; @@ -1678,6 +1679,7 @@ sendall(e, mode) printaddr(&e->e_from, FALSE); } e->e_from.q_flags |= QDONTSEND; + e->e_errormode = EM_MAIL; } # ifdef QUEUE diff --git a/usr/src/usr.sbin/sendmail/src/envelope.c b/usr/src/usr.sbin/sendmail/src/envelope.c index dc18a9b828..e5180007f8 100644 --- a/usr/src/usr.sbin/sendmail/src/envelope.c +++ b/usr/src/usr.sbin/sendmail/src/envelope.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)envelope.c 6.24 (Berkeley) %G%"; +static char sccsid[] = "@(#)envelope.c 6.25 (Berkeley) %G%"; #endif /* not lint */ #include "sendmail.h" @@ -121,7 +121,8 @@ dropenvelope(e) ** Arrange to send error messages if there are fatal errors. */ - if (bitset(EF_FATALERRS|EF_TIMEOUT, e->e_flags) && ErrorMode != EM_QUIET) + if (bitset(EF_FATALERRS|EF_TIMEOUT, e->e_flags) && + e->e_errormode != EM_QUIET) savemail(e); /* diff --git a/usr/src/usr.sbin/sendmail/src/main.c b/usr/src/usr.sbin/sendmail/src/main.c index f232da6e9b..f967a687de 100644 --- a/usr/src/usr.sbin/sendmail/src/main.c +++ b/usr/src/usr.sbin/sendmail/src/main.c @@ -13,7 +13,7 @@ char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)main.c 6.42 (Berkeley) %G%"; +static char sccsid[] = "@(#)main.c 6.43 (Berkeley) %G%"; #endif /* not lint */ #define _DEFINE @@ -184,13 +184,6 @@ main(argc, argv, envp) openlog("sendmail", LOG_PID); #endif - /* - ** Set default values for variables. - ** These cannot be in initialized data space. - */ - - setdefaults(); - /* set up the blank envelope */ BlankEnvelope.e_puthdr = putheader; BlankEnvelope.e_putbody = putbody; @@ -199,6 +192,13 @@ main(argc, argv, envp) STRUCTCOPY(BlankEnvelope, MainEnvelope); CurEnv = &MainEnvelope; + /* + ** Set default values for variables. + ** These cannot be in initialized data space. + */ + + setdefaults(&BlankEnvelope); + RealUid = getuid(); RealGid = getgid(); @@ -451,7 +451,7 @@ main(argc, argv, envp) break; case 'o': /* set option */ - setoption(*optarg, optarg + 1, FALSE, TRUE); + setoption(*optarg, optarg + 1, FALSE, TRUE, CurEnv); break; case 'p': /* set protocol */ @@ -503,15 +503,15 @@ main(argc, argv, envp) case 'm': /* send to me too */ case 'T': /* set timeout interval */ case 'v': /* give blow-by-blow description */ - setoption(j, "T", FALSE, TRUE); + setoption(j, "T", FALSE, TRUE, CurEnv); break; case 'e': /* error message disposition */ - setoption(j, optarg, FALSE, TRUE); + setoption(j, optarg, FALSE, TRUE, CurEnv); break; case 's': /* save From lines in headers */ - setoption('f', "T", FALSE, TRUE); + setoption('f', "T", FALSE, TRUE, CurEnv); break; # ifdef DBM @@ -619,10 +619,10 @@ main(argc, argv, envp) if (Verbose) { /* turn off noconnect option */ - setoption('c', "F", TRUE, FALSE); + setoption('c', "F", TRUE, FALSE, CurEnv); /* turn on interactive delivery */ - setoption('d', "", TRUE, FALSE); + setoption('d', "", TRUE, FALSE, CurEnv); } /* our name for SMTP codes */ @@ -909,7 +909,7 @@ main(argc, argv, envp) finis(); } if (OpMode == MD_VERIFY) - SendMode = SM_VERIFY; + CurEnv->e_sendmode = SM_VERIFY; /* ** Scan argv and deliver the message to everyone. @@ -1297,7 +1297,7 @@ disconnect(fulldrop, e) /* we can't communicate with our caller, so.... */ HoldErrs = TRUE; - ErrorMode = EM_MAIL; + CurEnv->e_errormode = EM_MAIL; Verbose = FALSE; /* all input from /dev/null */ diff --git a/usr/src/usr.sbin/sendmail/src/queue.c b/usr/src/usr.sbin/sendmail/src/queue.c index 01c25b133e..33d71c69ec 100644 --- a/usr/src/usr.sbin/sendmail/src/queue.c +++ b/usr/src/usr.sbin/sendmail/src/queue.c @@ -10,9 +10,9 @@ #ifndef lint #ifdef QUEUE -static char sccsid[] = "@(#)queue.c 6.35 (Berkeley) %G% (with queueing)"; +static char sccsid[] = "@(#)queue.c 6.36 (Berkeley) %G% (with queueing)"; #else -static char sccsid[] = "@(#)queue.c 6.35 (Berkeley) %G% (without queueing)"; +static char sccsid[] = "@(#)queue.c 6.36 (Berkeley) %G% (without queueing)"; #endif #endif /* not lint */ @@ -777,7 +777,7 @@ dowork(w, e) (void) alarm(0); clearenvelope(e, FALSE); QueueRun = TRUE; - ErrorMode = EM_MAIL; + e->e_errormode = EM_MAIL; e->e_id = &w->w_name[2]; # ifdef LOG if (LogLevel > 76) diff --git a/usr/src/usr.sbin/sendmail/src/readcf.c b/usr/src/usr.sbin/sendmail/src/readcf.c index 3616394fd9..d4ad6d940d 100644 --- a/usr/src/usr.sbin/sendmail/src/readcf.c +++ b/usr/src/usr.sbin/sendmail/src/readcf.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)readcf.c 6.17 (Berkeley) %G%"; +static char sccsid[] = "@(#)readcf.c 6.18 (Berkeley) %G%"; #endif /* not lint */ # include "sendmail.h" @@ -914,6 +914,7 @@ printrules() ** val -- option value (as a text string). ** sticky -- if set, don't let other setoptions override ** this value. +** e -- the main envelope. ** ** Returns: ** none. @@ -951,6 +952,7 @@ setoption(opt, val, sticky) char opt; char *val; bool sticky; + register ENVELOPE *e; { register char *p; extern bool atobool(); @@ -1019,7 +1021,7 @@ setoption(opt, val, sticky) switch (*val) { case '\0': - SendMode = SM_DELIVER; + e->e_sendmode = SM_DELIVER; break; case SM_QUEUE: /* queue only */ @@ -1030,7 +1032,7 @@ setoption(opt, val, sticky) case SM_DELIVER: /* do everything */ case SM_FORK: /* fork after verification */ - SendMode = *val; + e->e_sendmode = *val; break; default: @@ -1059,7 +1061,7 @@ setoption(opt, val, sticky) /* fall through... */ case EM_PRINT: /* print errors normally (default) */ - ErrorMode = *val; + e->e_errormode = *val; break; } break; diff --git a/usr/src/usr.sbin/sendmail/src/savemail.c b/usr/src/usr.sbin/sendmail/src/savemail.c index 0d0186fe79..6557d7bae2 100644 --- a/usr/src/usr.sbin/sendmail/src/savemail.c +++ b/usr/src/usr.sbin/sendmail/src/savemail.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)savemail.c 6.24 (Berkeley) %G%"; +static char sccsid[] = "@(#)savemail.c 6.25 (Berkeley) %G%"; #endif /* not lint */ # include @@ -59,7 +59,7 @@ savemail(e) if (tTd(6, 1)) { - printf("\nsavemail, ErrorMode = %c\n e_from=", ErrorMode); + printf("\nsavemail, errormode = %c\n e_from=", e->e_errormode); printaddr(&e->e_from, FALSE); } @@ -99,7 +99,7 @@ savemail(e) */ /* determine starting state */ - switch (ErrorMode) + switch (e->e_errormode) { case EM_WRITE: state = ESM_REPORT; @@ -125,7 +125,7 @@ savemail(e) return; default: - syserr("554 savemail: ErrorMode x%x\n"); + syserr("554 savemail: bogus errormode x%x\n", e->e_errormode); state = ESM_MAIL; break; } diff --git a/usr/src/usr.sbin/sendmail/src/sendmail.h b/usr/src/usr.sbin/sendmail/src/sendmail.h index d8b6357a99..e2c73d7a3b 100644 --- a/usr/src/usr.sbin/sendmail/src/sendmail.h +++ b/usr/src/usr.sbin/sendmail/src/sendmail.h @@ -5,7 +5,7 @@ * * %sccs.include.redist.c% * - * @(#)sendmail.h 6.29 (Berkeley) %G% + * @(#)sendmail.h 6.30 (Berkeley) %G% */ /* @@ -15,7 +15,7 @@ # ifdef _DEFINE # define EXTERN # ifndef lint -static char SmailSccsId[] = "@(#)sendmail.h 6.29 %G%"; +static char SmailSccsId[] = "@(#)sendmail.h 6.30 %G%"; # endif lint # else /* _DEFINE */ # define EXTERN extern @@ -260,6 +260,8 @@ struct envelope short e_flags; /* flags, see below */ short e_hopcount; /* number of times processed */ short e_nsent; /* number of sends since checkpoint */ + short e_sendmode; /* message send mode */ + short e_errormode; /* error return mode */ int (*e_puthdr)(); /* function to put header of message */ int (*e_putbody)(); /* function to put body of message */ struct envelope *e_parent; /* the message this one encloses */ @@ -554,8 +556,7 @@ EXTERN char OpMode; /* operation mode, see below */ #define MD_FREEZE 'z' /* freeze the configuration file */ -EXTERN char SendMode; /* send mode, see below */ - +/* values for e_sendmode -- send modes */ #define SM_DELIVER 'i' /* interactive delivery */ #define SM_QUICKD 'j' /* deliver w/o queueing */ #define SM_FORK 'b' /* deliver in background */ @@ -566,8 +567,7 @@ EXTERN char SendMode; /* send mode, see below */ #define SM_DEFAULT '\0' /* unspecified, use SendMode */ -EXTERN char ErrorMode; /* error mode, see below */ - +/* values for e_errormode -- error handling modes */ #define EM_PRINT 'p' /* print errors */ #define EM_MAIL 'm' /* mail back errors */ #define EM_WRITE 'w' /* write back errors */ diff --git a/usr/src/usr.sbin/sendmail/src/srvrsmtp.c b/usr/src/usr.sbin/sendmail/src/srvrsmtp.c index d67cf1dc51..6cccbedd06 100644 --- a/usr/src/usr.sbin/sendmail/src/srvrsmtp.c +++ b/usr/src/usr.sbin/sendmail/src/srvrsmtp.c @@ -10,9 +10,9 @@ #ifndef lint #ifdef SMTP -static char sccsid[] = "@(#)srvrsmtp.c 6.26 (Berkeley) %G% (with SMTP)"; +static char sccsid[] = "@(#)srvrsmtp.c 6.27 (Berkeley) %G% (with SMTP)"; #else -static char sccsid[] = "@(#)srvrsmtp.c 6.26 (Berkeley) %G% (without SMTP)"; +static char sccsid[] = "@(#)srvrsmtp.c 6.27 (Berkeley) %G% (without SMTP)"; #endif #endif /* not lint */ @@ -354,7 +354,7 @@ smtp(e) LogUsrErrs = TRUE; /* optimization -- if queueing, don't expand aliases */ - if (SendMode == SM_QUEUE) + if (e->e_sendmode == SM_QUEUE) e->e_flags |= EF_VRFYONLY; p = skipword(p, "to"); @@ -422,7 +422,7 @@ smtp(e) if (e->e_nrcpts != 1) { HoldErrs = TRUE; - ErrorMode = EM_MAIL; + e->e_errormode = EM_MAIL; } e->e_flags &= ~EF_FATALERRS; e->e_xfp = freopen(queuename(e, 'x'), "w", e->e_xfp); @@ -508,7 +508,7 @@ smtp(e) case CMDVERB: /* set verbose mode */ Verbose = TRUE; - SendMode = SM_DELIVER; + e->e_sendmode = SM_DELIVER; message("200 Verbose mode"); break; -- 2.20.1