summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/src
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-01-12 12:26:57 +0000
committerpeter <peter@FreeBSD.org>1999-01-12 12:26:57 +0000
commitf1740d73405834993a04c94457b7041c62adf046 (patch)
tree775f707fdc0ccb7fc91ba4eb3db2852eb96cce77 /contrib/sendmail/src
parentf5da386ea6df2d5ad502acd643b6cd6ac6a129ab (diff)
parent2a7bd60222ce3c09208a265ad3a5f1490ccb6768 (diff)
downloadFreeBSD-src-f1740d73405834993a04c94457b7041c62adf046.zip
FreeBSD-src-f1740d73405834993a04c94457b7041c62adf046.tar.gz
This commit was generated by cvs2svn to compensate for changes in r42575,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/sendmail/src')
-rw-r--r--contrib/sendmail/src/Makefile.m411
-rw-r--r--contrib/sendmail/src/README17
-rw-r--r--contrib/sendmail/src/TRACEFLAGS2
-rw-r--r--contrib/sendmail/src/alias.c5
-rw-r--r--contrib/sendmail/src/arpadate.c2
-rw-r--r--contrib/sendmail/src/clock.c2
-rw-r--r--contrib/sendmail/src/collect.c14
-rw-r--r--contrib/sendmail/src/control.c356
-rw-r--r--contrib/sendmail/src/convtime.c2
-rw-r--r--contrib/sendmail/src/daemon.c177
-rw-r--r--contrib/sendmail/src/deliver.c64
-rw-r--r--contrib/sendmail/src/domain.c14
-rw-r--r--contrib/sendmail/src/envelope.c4
-rw-r--r--contrib/sendmail/src/ldap_map.h4
-rw-r--r--contrib/sendmail/src/macro.c6
-rw-r--r--contrib/sendmail/src/mailstats.h2
-rw-r--r--contrib/sendmail/src/main.c151
-rw-r--r--contrib/sendmail/src/map.c189
-rw-r--r--contrib/sendmail/src/mime.c28
-rw-r--r--contrib/sendmail/src/newaliases.12
-rw-r--r--contrib/sendmail/src/parseaddr.c18
-rw-r--r--contrib/sendmail/src/pathnames.h2
-rw-r--r--contrib/sendmail/src/queue.c47
-rw-r--r--contrib/sendmail/src/readcf.c80
-rw-r--r--contrib/sendmail/src/recipient.c18
-rw-r--r--contrib/sendmail/src/safefile.c16
-rw-r--r--contrib/sendmail/src/sendmail.h27
-rw-r--r--contrib/sendmail/src/sendmail.hf7
-rw-r--r--contrib/sendmail/src/snprintf.c10
-rw-r--r--contrib/sendmail/src/srvrsmtp.c52
-rw-r--r--contrib/sendmail/src/stab.c2
-rw-r--r--contrib/sendmail/src/stats.c2
-rw-r--r--contrib/sendmail/src/sysexits.c2
-rw-r--r--contrib/sendmail/src/trace.c2
-rw-r--r--contrib/sendmail/src/udb.c99
-rw-r--r--contrib/sendmail/src/useful.h2
-rw-r--r--contrib/sendmail/src/usersmtp.c25
-rw-r--r--contrib/sendmail/src/util.c309
-rw-r--r--contrib/sendmail/src/version.c4
39 files changed, 1443 insertions, 333 deletions
diff --git a/contrib/sendmail/src/Makefile.m4 b/contrib/sendmail/src/Makefile.m4
index f4229c2..ad9e1c9 100644
--- a/contrib/sendmail/src/Makefile.m4
+++ b/contrib/sendmail/src/Makefile.m4
@@ -2,7 +2,7 @@
# This Makefile is designed to work on any reasonably current version of
# "make" program.
#
-# @(#)Makefile.m4 8.23 (Berkeley) 6/16/98
+# @(#)Makefile.m4 8.25 (Berkeley) 10/5/1998
#
# C compiler
@@ -68,9 +68,9 @@ COPTS= -I. ${INCDIRS} ${MAPDEF} ${ENVDEF}
CFLAGS= $O ${COPTS}
BEFORE= confBEFORE
-OBJS= alias.o arpadate.o clock.o collect.o conf.o convtime.o daemon.o \
- deliver.o domain.o envelope.o err.o headers.o macro.o main.o \
- map.o mci.o mime.o parseaddr.o queue.o readcf.o recipient.o \
+OBJS= alias.o arpadate.o clock.o collect.o conf.o control.o convtime.o \
+ daemon.o deliver.o domain.o envelope.o err.o headers.o macro.o \
+ main.o map.o mci.o mime.o parseaddr.o queue.o readcf.o recipient.o \
safefile.o savemail.o snprintf.o srvrsmtp.o stab.o stats.o \
sysexits.o trace.o udb.o usersmtp.o util.o version.o ${OBJADD}
@@ -130,7 +130,8 @@ install: install-sendmail install-docs
install-sendmail: sendmail
${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} sendmail ${BINDIR}
for i in ${LINKS}; do rm -f $$i; ln -s ${BINDIR}/sendmail $$i; done
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 sendmail.hf ${HFDIR}
+ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 sendmail.hf \
+ ${HFDIR}/sendmail.hf
${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 sendmail.st \
${STDIR}/sendmail.st
diff --git a/contrib/sendmail/src/README b/contrib/sendmail/src/README
index a6f7dcf..817b3a4 100644
--- a/contrib/sendmail/src/README
+++ b/contrib/sendmail/src/README
@@ -8,7 +8,7 @@
# the sendmail distribution.
#
#
-# @(#)README 8.206 (Berkeley) 6/30/98
+# @(#)README 8.209 (Berkeley) 10/6/1998
#
This directory contains the source files for sendmail(TM).
@@ -844,6 +844,12 @@ Digital UNIX (formerly DEC OSF/1)
This warning can be ignored.
+ Digital UNIX's linker checks /usr/ccs/lib/ before /usr/lib/.
+ If you have installed a new version of BIND in /usr/include
+ and /usr/lib, you will experience difficulties as Digital ships
+ libresolv.a in /usr/ccs/lib/ as well. Be sure to replace both
+ copies of libresolv.a.
+
IRIX
The header files on SGI IRIX are completely prototyped, and as
a result you can sometimes get some warning messages during
@@ -1072,6 +1078,13 @@ Linux
to LIBS. Data structures may change and you'd be asking for a
core dump.
+AIX 4.2
+ The AIX m4 implements a different mechanism for ifdef which is
+ inconsistent with other versions of m4. Therefore, it will not
+ work properly with the sendmail Build architecture or m4
+ configuration method. To work around this problem, please use
+ GNU m4 from ftp://ftp.gnu.org/pub/gnu/.
+
AIX 3.x
This version of sendmail does not support MB, MG, and MR resource
records, which are supported by AIX sendmail.
@@ -1439,4 +1452,4 @@ version.c The version number and information about this
Eric Allman
-(Version 8.206, last update 6/30/98 22:08:36)
+(Version 8.209, last update 10/6/1998 17:10:21)
diff --git a/contrib/sendmail/src/TRACEFLAGS b/contrib/sendmail/src/TRACEFLAGS
index 588714d..04b9b3c 100644
--- a/contrib/sendmail/src/TRACEFLAGS
+++ b/contrib/sendmail/src/TRACEFLAGS
@@ -1,4 +1,4 @@
-# @(#)TRACEFLAGS 8.21 (Berkeley) 4/27/98
+# @(#)TRACEFLAGS 8.21 (Berkeley) 4/27/1998
0, 1 main.c main skip background fork
0, 4 main.c main canonical name, UUCP node name, a.k.a.s
0, 15 main.c main print configuration
diff --git a/contrib/sendmail/src/alias.c b/contrib/sendmail/src/alias.c
index 8da3317..a7149f2 100644
--- a/contrib/sendmail/src/alias.c
+++ b/contrib/sendmail/src/alias.c
@@ -13,7 +13,7 @@
# include "sendmail.h"
#ifndef lint
-static char sccsid[] = "@(#)alias.c 8.92 (Berkeley) 6/5/98";
+static char sccsid[] = "@(#)alias.c 8.96 (Berkeley) 12/18/1998";
#endif /* not lint */
@@ -382,7 +382,7 @@ aliaswait(map, ext, isopen)
/* database is out of date */
if (AutoRebuild && stb.st_ino != 0 &&
(stb.st_uid == geteuid() ||
- (geteuid() == 0 && stb.st_uid == TrustedFileUid)))
+ (geteuid() == 0 && stb.st_uid == TrustedUid)))
{
bool oldSuprErrs;
@@ -510,6 +510,7 @@ rebuildaliases(map, automatic)
username());
}
map->map_mflags |= MF_OPEN|MF_WRITABLE;
+ map->map_pid = getpid();
readaliases(map, af, !automatic, TRUE);
success = TRUE;
}
diff --git a/contrib/sendmail/src/arpadate.c b/contrib/sendmail/src/arpadate.c
index 7a9576b..1b539b6 100644
--- a/contrib/sendmail/src/arpadate.c
+++ b/contrib/sendmail/src/arpadate.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)arpadate.c 8.12 (Berkeley) 5/19/98";
+static char sccsid[] = "@(#)arpadate.c 8.12 (Berkeley) 5/19/1998";
#endif /* not lint */
# include "sendmail.h"
diff --git a/contrib/sendmail/src/clock.c b/contrib/sendmail/src/clock.c
index e81c972..aab301c 100644
--- a/contrib/sendmail/src/clock.c
+++ b/contrib/sendmail/src/clock.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)clock.c 8.34 (Berkeley) 6/4/98";
+static char sccsid[] = "@(#)clock.c 8.34 (Berkeley) 6/4/1998";
#endif /* not lint */
# include "sendmail.h"
diff --git a/contrib/sendmail/src/collect.c b/contrib/sendmail/src/collect.c
index 190e699..e334e96 100644
--- a/contrib/sendmail/src/collect.c
+++ b/contrib/sendmail/src/collect.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)collect.c 8.89 (Berkeley) 6/4/98";
+static char sccsid[] = "@(#)collect.c 8.91 (Berkeley) 8/19/1998";
#endif /* not lint */
# include <errno.h>
@@ -81,7 +81,6 @@ collect(fp, smtpmode, hdrp, e)
char dfname[MAXQFNAME];
char bufbuf[MAXLINE];
extern bool isheader __P((char *));
- extern void eatheader __P((ENVELOPE *, bool));
extern void tferror __P((FILE *volatile, ENVELOPE *));
headeronly = hdrp != NULL;
@@ -101,7 +100,7 @@ collect(fp, smtpmode, hdrp, e)
{
syserr("Cannot create %s", dfname);
e->e_flags |= EF_NO_BODY_RETN;
- finis();
+ finis(TRUE, ExitStat);
}
if (fstat(fileno(tf), &stbuf) < 0)
e->e_dfino = -1;
@@ -159,8 +158,6 @@ collect(fp, smtpmode, hdrp, e)
for (;;)
{
- extern int chompheader __P((char *, bool, HDR **, ENVELOPE *));
-
if (tTd(30, 35))
printf("top, istate=%d, mstate=%d\n", istate, mstate);
for (;;)
@@ -414,7 +411,7 @@ readerr:
{
tferror(tf, e);
flush_errors(TRUE);
- finis();
+ finis(TRUE, ExitStat);
}
/* An EOF when running SMTP is an error */
@@ -456,7 +453,7 @@ readerr:
/* and don't try to deliver the partial message either */
if (InChild)
ExitStat = EX_QUIT;
- finis();
+ finis(TRUE, ExitStat);
}
/*
@@ -504,7 +501,6 @@ readerr:
/* no valid recipient headers */
register ADDRESS *q;
char *hdr = NULL;
- extern void addheader __P((char *, char *, HDR **));
/* create an Apparently-To: field */
/* that or reject the message.... */
@@ -577,7 +573,7 @@ readerr:
{
/* we haven't acked receipt yet, so just chuck this */
syserr("Cannot reopen %s", dfname);
- finis();
+ finis(TRUE, ExitStat);
}
}
diff --git a/contrib/sendmail/src/control.c b/contrib/sendmail/src/control.c
new file mode 100644
index 0000000..157ca08
--- /dev/null
+++ b/contrib/sendmail/src/control.c
@@ -0,0 +1,356 @@
+/*
+ * Copyright (c) 1998 Sendmail, Inc. All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set
+ * forth in the LICENSE file which can be found at the top level of
+ * the sendmail distribution.
+ *
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)control.c 8.17 (Berkeley) 12/1/1998";
+#endif /* not lint */
+
+#include "sendmail.h"
+
+int ControlSocket = -1;
+
+ /*
+** OPENCONTROLSOCKET -- create/open the daemon control named socket
+**
+** Creates and opens a named socket for external control over
+** the sendmail daemon.
+**
+** Parameters:
+** none.
+**
+** Returns:
+** 0 if successful, -1 otherwise
+*/
+
+int
+opencontrolsocket()
+{
+#ifdef NETUNIX
+# if _FFR_CONTROL_SOCKET
+ int rval;
+ int sff = SFF_SAFEDIRPATH|SFF_OPENASROOT|SFF_NOLINK|SFF_CREAT|SFF_MUSTOWN;
+ struct sockaddr_un controladdr;
+
+ if (ControlSocketName == NULL)
+ return 0;
+
+ if (strlen(ControlSocketName) >= sizeof controladdr.sun_path)
+ {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+
+ rval = safefile(ControlSocketName, RunAsUid, RunAsGid, RunAsUserName,
+ sff, S_IRUSR|S_IWUSR, NULL);
+
+ /* if not safe, don't create */
+ if (rval != 0)
+ {
+ errno = rval;
+ return -1;
+ }
+
+ ControlSocket = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (ControlSocket < 0)
+ return -1;
+
+ unlink(ControlSocketName);
+ bzero(&controladdr, sizeof controladdr);
+ controladdr.sun_family = AF_UNIX;
+ strcpy(controladdr.sun_path, ControlSocketName);
+
+ if (bind(ControlSocket, (struct sockaddr *) &controladdr,
+ sizeof controladdr) < 0)
+ {
+ int save_errno = errno;
+
+ (void) close(ControlSocket);
+ ControlSocket = -1;
+ errno = save_errno;
+ return -1;
+ }
+
+# if _FFR_TRUSTED_USER
+ if (geteuid() == 0 && TrustedUid != 0)
+ {
+ if (chown(ControlSocketName, TrustedUid, -1) < 0)
+ {
+ int save_errno = errno;
+
+ sm_syslog(LOG_ALERT, NOQID,
+ "ownership change on %s failed: %s",
+ ControlSocketName, errstring(save_errno));
+ message("050 ownership change on %s failed: %s",
+ ControlSocketName, errstring(save_errno));
+ errno = save_errno;
+ return -1;
+ }
+ }
+# endif
+
+ if (chmod(ControlSocketName, S_IRUSR|S_IWUSR) < 0)
+ {
+ int save_errno = errno;
+
+ closecontrolsocket(TRUE);
+ errno = save_errno;
+ return -1;
+ }
+
+ if (listen(ControlSocket, 8) < 0)
+ {
+ int save_errno = errno;
+
+ closecontrolsocket(TRUE);
+ errno = save_errno;
+ return -1;
+ }
+# endif
+#endif
+ return 0;
+}
+ /*
+** CLOSECONTROLSOCKET -- close the daemon control named socket
+**
+** Close a named socket.
+**
+** Parameters:
+** fullclose -- if set, close the socket and remove it;
+** otherwise, just remove it
+**
+** Returns:
+** none.
+*/
+
+void
+closecontrolsocket(fullclose)
+ bool fullclose;
+{
+#ifdef NETUNIX
+# if _FFR_CONTROL_SOCKET
+ int sff = SFF_SAFEDIRPATH|SFF_OPENASROOT|SFF_NOLINK|SFF_CREAT|SFF_MUSTOWN;
+
+ if (ControlSocket >= 0)
+ {
+ int rval;
+
+ if (fullclose)
+ {
+ (void) close(ControlSocket);
+ ControlSocket = -1;
+ }
+
+ rval = safefile(ControlSocketName, RunAsUid, RunAsGid, RunAsUserName,
+ sff, S_IRUSR|S_IWUSR, NULL);
+
+ /* if not safe, don't unlink */
+ if (rval != 0)
+ return;
+
+ if (unlink(ControlSocketName) < 0)
+ {
+ sm_syslog(LOG_WARNING, NOQID,
+ "Could not remove control socket: %s",
+ errstring(errno));
+ return;
+ }
+ }
+# endif
+#endif
+ return;
+}
+ /*
+** CLRCONTROL -- reset the control connection
+**
+** Parameters:
+** none.
+**
+** Returns:
+** none.
+**
+** Side Effects:
+** releases any resources used by the control interface.
+*/
+
+void
+clrcontrol()
+{
+#ifdef NETUNIX
+# if _FFR_CONTROL_SOCKET
+ if (ControlSocket >= 0)
+ (void) close(ControlSocket);
+ ControlSocket = -1;
+# endif
+#endif
+}
+
+#ifndef NOT_SENDMAIL
+
+ /*
+** CONTROL_COMMAND -- read and process command from named socket
+**
+** Read and process the command from the opened socket.
+** Return the results down the same socket.
+**
+** Parameters:
+** sock -- the opened socket from getrequests()
+** e -- the current envelope
+**
+** Returns:
+** none.
+*/
+
+struct cmd
+{
+ char *cmdname; /* command name */
+ int cmdcode; /* internal code, see below */
+};
+
+/* values for cmdcode */
+# define CMDERROR 0 /* bad command */
+# define CMDRESTART 1 /* restart daemon */
+# define CMDSHUTDOWN 2 /* end daemon */
+# define CMDHELP 3 /* help */
+# define CMDSTATUS 4 /* daemon status */
+
+static struct cmd CmdTab[] =
+{
+ { "help", CMDHELP },
+ { "restart", CMDRESTART },
+ { "shutdown", CMDSHUTDOWN },
+ { "status", CMDSTATUS },
+ { NULL, CMDERROR }
+};
+
+void
+control_command(sock, e)
+ int sock;
+ ENVELOPE *e;
+{
+ FILE *s;
+ FILE *traffic;
+ FILE *oldout;
+ char *cmd;
+ char *p;
+ struct cmd *c;
+ char cmdbuf[MAXLINE];
+ char inp[MAXLINE];
+ extern char **SaveArgv;
+ extern void help __P((char *));
+
+ sm_setproctitle(FALSE, "control cmd read");
+
+ s = fdopen(sock, "r+");
+ if (s == NULL)
+ {
+ int save_errno = errno;
+
+ close(sock);
+ errno = save_errno;
+ return;
+ }
+ setbuf(s, NULL);
+
+ if (fgets(inp, sizeof inp, s) == NULL)
+ {
+ fclose(s);
+ return;
+ }
+ (void) fflush(s);
+
+ /* clean up end of line */
+ fixcrlf(inp, TRUE);
+
+ sm_setproctitle(FALSE, "control: %s", inp);
+
+ /* break off command */
+ for (p = inp; isascii(*p) && isspace(*p); p++)
+ continue;
+ cmd = cmdbuf;
+ while (*p != '\0' &&
+ !(isascii(*p) && isspace(*p)) &&
+ cmd < &cmdbuf[sizeof cmdbuf - 2])
+ *cmd++ = *p++;
+ *cmd = '\0';
+
+ /* throw away leading whitespace */
+ while (isascii(*p) && isspace(*p))
+ p++;
+
+ /* decode command */
+ for (c = CmdTab; c->cmdname != NULL; c++)
+ {
+ if (!strcasecmp(c->cmdname, cmdbuf))
+ break;
+ }
+
+ switch (c->cmdcode)
+ {
+ case CMDHELP: /* get help */
+ traffic = TrafficLogFile;
+ TrafficLogFile = NULL;
+ oldout = OutChannel;
+ OutChannel = s;
+ help("control");
+ TrafficLogFile = traffic;
+ OutChannel = oldout;
+ break;
+
+ case CMDRESTART: /* restart the daemon */
+ if (SaveArgv[0][0] != '/')
+ {
+ fprintf(s, "ERROR: could not restart: need full path\r\n");
+ break;
+ }
+ if (LogLevel > 3)
+ sm_syslog(LOG_INFO, NOQID,
+ "restarting %s on due to control command",
+ SaveArgv[0]);
+ closecontrolsocket(FALSE);
+ if (drop_privileges(TRUE) != EX_OK)
+ {
+ if (LogLevel > 0)
+ sm_syslog(LOG_ALERT, NOQID,
+ "could not set[ug]id(%d, %d): %m",
+ RunAsUid, RunAsGid);
+
+ fprintf(s, "ERROR: could not set[ug]id(%d, %d): %s, exiting...\r\n",
+ (int)RunAsUid, (int)RunAsGid, errstring(errno));
+ finis(FALSE, EX_OSERR);
+ }
+ fprintf(s, "OK\r\n");
+ clrcontrol();
+ (void) fcntl(sock, F_SETFD, 1);
+ execve(SaveArgv[0], (ARGV_T) SaveArgv, (ARGV_T) ExternalEnviron);
+ if (LogLevel > 0)
+ sm_syslog(LOG_ALERT, NOQID, "could not exec %s: %m",
+ SaveArgv[0]);
+ fprintf(s, "ERROR: could not exec %s: %s, exiting...\r\n",
+ SaveArgv[0], errstring(errno));
+ finis(FALSE, EX_OSFILE);
+ break;
+
+ case CMDSHUTDOWN: /* kill the daemon */
+ fprintf(s, "OK\r\n");
+ finis(FALSE, EX_OK);
+ break;
+
+ case CMDSTATUS: /* daemon status */
+ proc_list_probe();
+ fprintf(s, "%d/%d\r\n", CurChildren, MaxChildren);
+ proc_list_display(s);
+ break;
+
+ case CMDERROR: /* unknown command */
+ fprintf(s, "Bad command (%s)\r\n", cmdbuf);
+ break;
+ }
+ fclose(s);
+}
+#endif
diff --git a/contrib/sendmail/src/convtime.c b/contrib/sendmail/src/convtime.c
index 02c287b..ab8591d 100644
--- a/contrib/sendmail/src/convtime.c
+++ b/contrib/sendmail/src/convtime.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)convtime.c 8.14 (Berkeley) 5/19/98";
+static char sccsid[] = "@(#)convtime.c 8.14 (Berkeley) 5/19/1998";
#endif /* not lint */
# include "sendmail.h"
diff --git a/contrib/sendmail/src/daemon.c b/contrib/sendmail/src/daemon.c
index dc0b5b5..b74a7a7 100644
--- a/contrib/sendmail/src/daemon.c
+++ b/contrib/sendmail/src/daemon.c
@@ -15,9 +15,9 @@
#ifndef lint
#ifdef DAEMON
-static char sccsid[] = "@(#)daemon.c 8.220 (Berkeley) 6/24/98 (with daemon mode)";
+static char sccsid[] = "@(#)daemon.c 8.234 (Berkeley) 12/17/1998 (with daemon mode)";
#else
-static char sccsid[] = "@(#)daemon.c 8.220 (Berkeley) 6/24/98 (without daemon mode)";
+static char sccsid[] = "@(#)daemon.c 8.234 (Berkeley) 12/17/1998 (without daemon mode)";
#endif
#endif /* not lint */
@@ -103,15 +103,22 @@ getrequests(e)
ENVELOPE *e;
{
int t;
- bool refusingconnections = TRUE;
+ time_t refuse_connections_until = 0;
+ bool firsttime = TRUE;
FILE *pidf;
+ int sff;
int socksize;
u_short port;
#if XDEBUG
bool j_has_dot;
#endif
+ char status[MAXLINE];
extern void reapchild __P((int));
+#ifdef NETUNIX
+ extern int ControlSocket;
+#endif
extern int opendaemonsocket __P((bool));
+ extern int opencontrolsocket __P((void));
/*
** Set up the address for the mailer.
@@ -169,11 +176,18 @@ getrequests(e)
/* get a socket for the SMTP connection */
socksize = opendaemonsocket(TRUE);
+ if (opencontrolsocket() < 0)
+ sm_syslog(LOG_WARNING, NOQID,
+ "daemon could not open control socket: %s",
+ errstring(errno));
+
(void) setsignal(SIGCHLD, reapchild);
/* write the pid to the log file for posterity */
- pidf = safefopen(PidFile, O_WRONLY|O_TRUNC, 0644,
- SFF_NOLINK|SFF_ROOTOK|SFF_REGONLY|SFF_CREAT);
+ sff = SFF_NOLINK|SFF_ROOTOK|SFF_REGONLY|SFF_CREAT;
+ if (TrustedUid != 0 && RealUid == TrustedUid)
+ sff |= SFF_OPENASROOT;
+ pidf = safefopen(PidFile, O_WRONLY|O_TRUNC, 0644, sff);
if (pidf == NULL)
{
sm_syslog(LOG_ERR, NOQID, "unable to write %s", PidFile);
@@ -201,6 +215,9 @@ getrequests(e)
}
#endif
+ /* Add parent process as first item */
+ proc_list_add(getpid(), "Sendmail daemon");
+
if (tTd(15, 1))
printf("getrequests: %d\n", DaemonSocket);
@@ -208,30 +225,34 @@ getrequests(e)
{
register pid_t pid;
auto SOCKADDR_LEN_T lotherend;
+ bool timedout = FALSE;
+ bool control = FALSE;
int savederrno;
int pipefd[2];
extern bool refuseconnections __P((int));
/* see if we are rejecting connections */
(void) blocksignal(SIGALRM);
- if (refuseconnections(ntohs(port)))
+ if (curtime() >= refuse_connections_until)
{
- if (DaemonSocket >= 0)
+ if (refuseconnections(ntohs(port)))
{
- /* close socket so peer will fail quickly */
- (void) close(DaemonSocket);
- DaemonSocket = -1;
- }
- refusingconnections = TRUE;
- sleep(15);
- continue;
- }
+ if (DaemonSocket >= 0)
+ {
+ /* close socket so peer fails quickly */
+ (void) close(DaemonSocket);
+ DaemonSocket = -1;
+ }
- /* arrange to (re)open the socket if necessary */
- if (refusingconnections)
- {
- (void) opendaemonsocket(FALSE);
- refusingconnections = FALSE;
+ /* refuse connections for next 15 seconds */
+ refuse_connections_until = curtime() + 15;
+ }
+ else if (DaemonSocket < 0 || firsttime)
+ {
+ /* arrange to (re)open the socket if needed */
+ (void) opendaemonsocket(FALSE);
+ firsttime = FALSE;
+ }
}
#if XDEBUG
@@ -258,9 +279,6 @@ getrequests(e)
}
#endif
- /* wait for a connection */
- setproctitle("accepting connections on port %d",
- ntohs(port));
#if 0
/*
** Andrew Sun <asun@ieps-sun.ml.com> claims that this will
@@ -268,34 +286,97 @@ getrequests(e)
** so is it worth doing this?
*/
- if (SetNonBlocking(DaemonSocket, FALSE) < 0)
+ if (DaemonSocket >= 0 &&
+ SetNonBlocking(DaemonSocket, FALSE) < 0)
log an error here;
#endif
(void) releasesignal(SIGALRM);
for (;;)
{
+ int highest = -1;
fd_set readfds;
struct timeval timeout;
FD_ZERO(&readfds);
- FD_SET(DaemonSocket, &readfds);
- timeout.tv_sec = 60;
+
+ /* wait for a connection */
+ if (DaemonSocket >= 0)
+ {
+ sm_setproctitle(TRUE,
+ "accepting connections on port %d",
+ ntohs(port));
+ if (DaemonSocket > highest)
+ highest = DaemonSocket;
+ FD_SET(DaemonSocket, &readfds);
+ }
+#ifdef NETUNIX
+ if (ControlSocket >= 0)
+ {
+ if (ControlSocket > highest)
+ highest = ControlSocket;
+ FD_SET(ControlSocket, &readfds);
+ }
+#endif
+ if (DaemonSocket >= 0)
+ timeout.tv_sec = 60;
+ else
+ timeout.tv_sec = 5;
timeout.tv_usec = 0;
- t = select(DaemonSocket + 1, FDSET_CAST &readfds,
- NULL, NULL, &timeout);
+ t = select(highest + 1, FDSET_CAST &readfds,
+ NULL, NULL, &timeout);
+
if (DoQueueRun)
(void) runqueue(TRUE, FALSE);
- if (t <= 0 || !FD_ISSET(DaemonSocket, &readfds))
- continue;
+ if (t <= 0)
+ {
+ timedout = TRUE;
+ break;
+ }
+ control = FALSE;
errno = 0;
- lotherend = socksize;
- t = accept(DaemonSocket,
- (struct sockaddr *)&RealHostAddr, &lotherend);
+ if (DaemonSocket >= 0 &&
+ FD_ISSET(DaemonSocket, &readfds))
+ {
+ lotherend = socksize;
+ t = accept(DaemonSocket,
+ (struct sockaddr *)&RealHostAddr,
+ &lotherend);
+ }
+#ifdef NETUNIX
+ else if (ControlSocket >= 0 &&
+ FD_ISSET(ControlSocket, &readfds))
+ {
+ struct sockaddr_un sa_un;
+
+ lotherend = sizeof sa_un;
+ t = accept(ControlSocket,
+ (struct sockaddr *)&sa_un,
+ &lotherend);
+ control = TRUE;
+ }
+#endif
if (t >= 0 || errno != EINTR)
break;
}
+ if (timedout)
+ {
+ timedout = FALSE;
+ continue;
+ }
+ if (control)
+ {
+ if (t >= 0)
+ {
+ extern void control_command __P((int, ENVELOPE *));
+
+ control_command(t, e);
+ }
+ else
+ syserr("getrequests: control accept");
+ continue;
+ }
savederrno = errno;
(void) blocksignal(SIGALRM);
if (t < 0)
@@ -306,8 +387,6 @@ getrequests(e)
/* arrange to re-open the socket next time around */
(void) close(DaemonSocket);
DaemonSocket = -1;
- refusingconnections = TRUE;
- sleep(5);
continue;
}
@@ -360,12 +439,16 @@ getrequests(e)
(void) setsignal(SIGCHLD, SIG_DFL);
(void) setsignal(SIGHUP, intsig);
(void) close(DaemonSocket);
+ clrcontrol();
proc_list_clear();
+ /* Add parent process as first child item */
+ proc_list_add(getpid(), "daemon child");
+
/* don't schedule queue runs if we are told to ETRN */
QueueIntvl = 0;
- setproctitle("startup with %s",
+ sm_setproctitle(TRUE, "startup with %s",
anynet_ntoa(&RealHostAddr));
if (pipefd[0] != -1)
@@ -395,36 +478,34 @@ getrequests(e)
if (strlen(p) > (SIZE_T) MAXNAME)
p[MAXNAME] = '\0';
RealHostName = newstr(p);
- setproctitle("startup with %s", p);
+ sm_setproctitle(TRUE, "startup with %s", p);
if ((inchannel = fdopen(t, "r")) == NULL ||
(t = dup(t)) < 0 ||
(outchannel = fdopen(t, "w")) == NULL)
{
syserr("cannot open SMTP server channel, fd=%d", t);
- exit(EX_OK);
+ finis(FALSE, EX_OK);
}
InChannel = inchannel;
OutChannel = outchannel;
DisConnected = FALSE;
- /* open maps for check_relay ruleset */
- initmaps(FALSE, e);
-
#ifdef XLA
if (!xla_host_ok(RealHostName))
{
message("421 Too many SMTP sessions for this host");
- exit(EX_OK);
+ finis(FALSE, EX_OK);
}
#endif
-
break;
}
/* parent -- keep track of children */
- proc_list_add(pid);
+ snprintf(status, MAXLINE, "SMTP server child for %s",
+ anynet_ntoa(&RealHostAddr));
+ proc_list_add(pid, status);
(void) releasesignal(SIGCHLD);
/* close the read end of the synchronization pipe */
@@ -552,7 +633,7 @@ opendaemonsocket(firsttime)
return socksize;
} while (ntries++ < MAXOPENTRIES && transienterror(saveerrno));
syserr("!opendaemonsocket: server SMTP socket wedged: exiting");
- finis();
+ /*NOTREACHED*/
return -1; /* avoid compiler warning on IRIX */
}
/*
@@ -1280,7 +1361,7 @@ getauthinfo(fd, may_be_forged)
/* translate that to a host name */
RealHostName = newstr(hostnamebyanyaddr(&RealHostAddr));
if (strlen(RealHostName) > MAXNAME)
- RealHostName[MAXNAME - 1] = '\0';
+ RealHostName[MAXNAME] = '\0';
}
/* cross check RealHostName with forward DNS lookup */
@@ -1288,8 +1369,8 @@ getauthinfo(fd, may_be_forged)
RealHostName[0] == '[')
{
/*
- ** address is not a socket or have an
- ** IP address with no forward lookup
+ ** address is not a socket or have an
+ ** IP address with no forward lookup
*/
*may_be_forged = FALSE;
}
diff --git a/contrib/sendmail/src/deliver.c b/contrib/sendmail/src/deliver.c
index 0e5eb07..e70f17e 100644
--- a/contrib/sendmail/src/deliver.c
+++ b/contrib/sendmail/src/deliver.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)deliver.c 8.353 (Berkeley) 6/30/98";
+static char sccsid[] = "@(#)deliver.c 8.366 (Berkeley) 12/18/1998";
#endif /* not lint */
#include "sendmail.h"
@@ -360,7 +360,7 @@ sendall(e, mode)
if (mode != SM_VERIFY && bitset(EF_HAS_DF, e->e_flags))
dup_queue_file(e, ee, 'd');
openxscript(ee);
- if (LogLevel > 4)
+ if (mode != SM_VERIFY && LogLevel > 4)
sm_syslog(LOG_INFO, ee->e_id,
"clone %s, owner=%s",
e->e_id, owner);
@@ -552,7 +552,7 @@ sendall(e, mode)
# else
e->e_id = NULL;
# endif /* HASFLOCK */
- finis();
+ finis(TRUE, ExitStat);
}
/* be sure to give error messages in child */
@@ -570,6 +570,15 @@ sendall(e, mode)
mci_flush(FALSE, NULL);
+ /*
+ ** Since the delivery may happen in a child and the parent
+ ** does not wait, the parent may close the maps thereby
+ ** removing any shared memory used by the map. Therefore,
+ ** open a copy of the maps for the delivery process.
+ */
+
+ initmaps(FALSE, e);
+
# if HASFLOCK
break;
# else
@@ -586,7 +595,7 @@ sendall(e, mode)
ee->e_sibling = sibling;
}
(void) dowork(e->e_id, FALSE, FALSE, e);
- finis();
+ finis(TRUE, ExitStat);
# endif /* !HASFLOCK */
}
@@ -604,7 +613,7 @@ sendall(e, mode)
Verbose = oldverbose;
if (mode == SM_FORK)
- finis();
+ finis(TRUE, ExitStat);
}
void
@@ -1091,8 +1100,9 @@ deliver(e, firstto)
e->e_from.q_paddr, to->q_paddr, e);
if (rcode == EX_OK)
{
- /* do in-code checking */
- rcode = checkcompat(to, e);
+ /* do in-code checking if not discarding */
+ if (!bitset(EF_DISCARD, e->e_flags))
+ rcode = checkcompat(to, e);
}
if (rcode != EX_OK)
{
@@ -1100,6 +1110,22 @@ deliver(e, firstto)
giveresponse(rcode, m, NULL, ctladdr, xstart, e);
continue;
}
+ if (bitset(EF_DISCARD, e->e_flags))
+ {
+ if (tTd(10, 5))
+ {
+ printf("deliver: discarding recipient ");
+ printaddr(to, FALSE);
+ }
+
+ /*
+ ** Remove discard bit to prevent discard of
+ ** future recipients
+ */
+ e->e_flags &= ~EF_DISCARD;
+
+ continue;
+ }
/*
** Strip quote bits from names if the mailer is dumb
@@ -1409,7 +1435,7 @@ tryhost:
}
/* try the connection */
- setproctitle("%s %s: %s", e->e_id, hostbuf, "user open");
+ sm_setproctitle(TRUE, "%s %s: %s", e->e_id, hostbuf, "user open");
if (port == 0)
message("Connecting to %s via %s...",
hostbuf, m->m_name);
@@ -2096,7 +2122,7 @@ do_transfer:
rcode = smtpgetstat(m, mci, e);
if (rcode == EX_OK)
{
- if (strlen(to->q_paddr) + strlen(tobuf) + 2 >= sizeof tobuf)
+ if (strlen(to->q_paddr) + strlen(tobuf) + 2 > sizeof tobuf)
{
syserr("LMTP tobuf overflow");
}
@@ -2827,7 +2853,7 @@ putfromline(mci, e)
char hname[MAXNAME];
/*
- ** If we can construct a UUCP path, do so
+ ** If we can construct a UUCP path, do so
*/
at = strrchr(buf, '@');
@@ -2882,6 +2908,7 @@ putbody(mci, e, separator)
char *separator;
{
char buf[MAXLINE];
+ char *boundaries[MAXMIMENESTING + 1];
/*
** Output the body of the message
@@ -2923,8 +2950,6 @@ putbody(mci, e, separator)
#if MIME8TO7
if (bitset(MCIF_CVT8TO7, mci->mci_flags))
{
- char *boundaries[MAXMIMENESTING + 1];
-
/*
** Do 8 to 7 bit MIME conversion.
*/
@@ -2952,6 +2977,13 @@ putbody(mci, e, separator)
mime7to8(mci, e->e_header, e);
}
# endif
+ else if (MaxMimeHeaderLength > 0 || MaxMimeFieldLength > 0)
+ {
+ /* Use mime8to7 to check multipart for MIME header overflows */
+ boundaries[0] = NULL;
+ mci->mci_flags |= MCIF_INHEADER;
+ mime8to7(mci, e->e_header, e, boundaries, M87F_OUTER|M87F_NO8TO7);
+ }
else
#endif
{
@@ -2966,7 +2998,6 @@ putbody(mci, e, separator)
size_t eol_len;
char peekbuf[10];
- /* we can pass it through unmodified */
if (bitset(MCIF_INHEADER, mci->mci_flags))
{
putline("", mci);
@@ -3292,6 +3323,7 @@ mailfile(filename, mailer, ctladdr, sfflags, e)
/* child -- actually write to file */
struct stat stb;
MCI mcibuf;
+ int err;
volatile int oflags = O_WRONLY|O_APPEND;
if (e->e_lockfp != NULL)
@@ -3315,7 +3347,11 @@ mailfile(filename, mailer, ctladdr, sfflags, e)
ev = NULL;
#ifdef HASLSTAT
- if (lstat(filename, &stb) < 0)
+ if (bitset(DBS_FILEDELIVERYTOSYMLINK, DontBlameSendmail))
+ err = stat(filename, &stb);
+ else
+ err = lstat(filename, &stb);
+ if (err < 0)
#else
if (stat(filename, &stb) < 0)
#endif
diff --git a/contrib/sendmail/src/domain.c b/contrib/sendmail/src/domain.c
index e3a5500..a279c0e 100644
--- a/contrib/sendmail/src/domain.c
+++ b/contrib/sendmail/src/domain.c
@@ -14,9 +14,9 @@
#ifndef lint
#if NAMED_BIND
-static char sccsid[] = "@(#)domain.c 8.77 (Berkeley) 6/4/98 (with name server)";
+static char sccsid[] = "@(#)domain.c 8.80 (Berkeley) 12/17/1998 (with name server)";
#else
-static char sccsid[] = "@(#)domain.c 8.77 (Berkeley) 6/4/98 (without name server)";
+static char sccsid[] = "@(#)domain.c 8.80 (Berkeley) 12/17/1998 (without name server)";
#endif
#endif /* not lint */
@@ -451,7 +451,7 @@ bestmx_map_lookup(map, name, av, statp)
int i, len = 0;
char *p;
char *mxhosts[MAXMXHOSTS + 1];
- char buf[MXHOSTBUFSIZE + 1];
+ char buf[PSBUFSIZE / 2];
_res.options &= ~(RES_DNSRCH|RES_DEFNAMES);
nmx = getmxrr(name, mxhosts, FALSE, &rcode);
@@ -464,8 +464,8 @@ bestmx_map_lookup(map, name, av, statp)
return map_rewrite(map, mxhosts[0], strlen(mxhosts[0]), av);
/*
- ** We were given a -z flag (return all MXs) and there are multiple
- ** ones. We need to build them all into a list.
+ ** We were given a -z flag (return all MXs) and there are multiple
+ ** ones. We need to build them all into a list.
*/
p = buf;
for (i = 0; i < nmx; i++)
@@ -663,7 +663,7 @@ cnameloop:
qtype = T_A;
continue;
}
- else if (qtype == T_A && !gotmx && trymx)
+ else if (qtype == T_A && !gotmx && (trymx || **dp == '\0'))
{
qtype = T_MX;
continue;
@@ -824,7 +824,7 @@ cnameloop:
if (qtype == T_ANY)
qtype = T_A;
- else if (qtype == T_A && !gotmx && trymx)
+ else if (qtype == T_A && !gotmx && (trymx || **dp == '\0'))
qtype = T_MX;
else
{
diff --git a/contrib/sendmail/src/envelope.c b/contrib/sendmail/src/envelope.c
index 092148a..a17aa8c 100644
--- a/contrib/sendmail/src/envelope.c
+++ b/contrib/sendmail/src/envelope.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)envelope.c 8.117 (Berkeley) 6/4/98";
+static char sccsid[] = "@(#)envelope.c 8.121 (Berkeley) 12/18/1998";
#endif /* not lint */
#include "sendmail.h"
@@ -827,7 +827,7 @@ setsender(from, e, delimptr, delimchar, internal)
sm_syslog(LOG_NOTICE, e->e_id,
"cannot prescan from (%s)",
shortenstring(from, MAXSHORTSTR));
- finis();
+ finis(TRUE, ExitStat);
}
(void) rewrite(pvp, 3, 0, e);
(void) rewrite(pvp, 1, 0, e);
diff --git a/contrib/sendmail/src/ldap_map.h b/contrib/sendmail/src/ldap_map.h
index 9f6a679..97eb29e 100644
--- a/contrib/sendmail/src/ldap_map.h
+++ b/contrib/sendmail/src/ldap_map.h
@@ -14,7 +14,7 @@
** Please go to him for support -- since I (Eric) don't run LDAP, I
** can't help you at all.
**
-** @(#)ldap_map.h 8.9 (Berkeley) 5/19/98
+** @(#)ldap_map.h 8.10 (Berkeley) 9/14/1998
*/
#ifndef _LDAP_MAP_H
@@ -61,7 +61,7 @@ typedef struct ldap_map_struct LDAP_MAP_STRUCT;
#define DEFAULT_LDAP_MAP_DEREF LDAP_DEREF_NEVER
#define DEFAULT_LDAP_MAP_SIZELIMIT 0
#define DEFAULT_LDAP_MAP_ATTRSONLY 0
-#define LDAP_MAP_MAX_FILTER 256
+#define LDAP_MAP_MAX_FILTER 1024
#ifdef LDAP_REFERRALS
# define DEFAULT_LDAP_MAP_LDAP_OPTIONS LDAP_OPT_REFERRALS
#else /* LDAP_REFERRALS */
diff --git a/contrib/sendmail/src/macro.c b/contrib/sendmail/src/macro.c
index c1f9f7b..d45a0c7 100644
--- a/contrib/sendmail/src/macro.c
+++ b/contrib/sendmail/src/macro.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)macro.c 8.25 (Berkeley) 5/19/98";
+static char sccsid[] = "@(#)macro.c 8.26 (Berkeley) 11/8/1998";
#endif /* not lint */
# include "sendmail.h"
@@ -333,7 +333,7 @@ macid(p, ep)
{
int mid;
register char *bp;
- char mbuf[21];
+ char mbuf[MAXMACNAMELEN + 1];
if (tTd(35, 14))
{
@@ -361,7 +361,7 @@ macid(p, ep)
return *p;
}
bp = mbuf;
- while (*++p != '\0' && *p != '}' && bp < &mbuf[sizeof mbuf])
+ while (*++p != '\0' && *p != '}' && bp < &mbuf[sizeof mbuf - 1])
{
if (isascii(*p) && (isalnum(*p) || *p == '_'))
*bp++ = *p;
diff --git a/contrib/sendmail/src/mailstats.h b/contrib/sendmail/src/mailstats.h
index 2121e14..86390b3 100644
--- a/contrib/sendmail/src/mailstats.h
+++ b/contrib/sendmail/src/mailstats.h
@@ -9,7 +9,7 @@
* the sendmail distribution.
*
*
- * @(#)mailstats.h 8.8 (Berkeley) 5/19/98
+ * @(#)mailstats.h 8.8 (Berkeley) 5/19/1998
*/
#define STAT_VERSION 2
diff --git a/contrib/sendmail/src/main.c b/contrib/sendmail/src/main.c
index f014d83..cea9d15 100644
--- a/contrib/sendmail/src/main.c
+++ b/contrib/sendmail/src/main.c
@@ -19,7 +19,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)main.c 8.302 (Berkeley) 6/4/98";
+static char sccsid[] = "@(#)main.c 8.322 (Berkeley) 12/18/1998";
#endif /* not lint */
#define _DEFINE
@@ -129,6 +129,7 @@ main(argc, argv, envp)
extern char *getcfname __P((void));
extern SIGFUNC_DECL sigusr1 __P((int));
extern SIGFUNC_DECL sighup __P((int));
+ extern SIGFUNC_DECL quiesce __P((int));
extern void initmacros __P((ENVELOPE *));
extern void init_md __P((int, char **));
extern int getdtsize __P((void));
@@ -304,9 +305,7 @@ main(argc, argv, envp)
if (tTd(0, 101))
{
printf("Version %s\n", Version);
- endpwent();
- setuid(RealUid);
- exit(EX_OK);
+ finis(FALSE, EX_OK);
}
/*
@@ -419,8 +418,8 @@ main(argc, argv, envp)
environ = emptyenviron;
/*
- ** restore any original TZ setting until TimeZoneSpec has been
- ** determined - or early log messages may get bogus time stamps
+ ** restore any original TZ setting until TimeZoneSpec has been
+ ** determined - or early log messages may get bogus time stamps
*/
if ((p = getextenv("TZ")) != NULL)
{
@@ -549,7 +548,7 @@ main(argc, argv, envp)
QueueLimitId = (QUEUE_CHAR *) NULL;
/*
- ** Crack argv.
+ ** Crack argv.
*/
av = argv;
@@ -835,8 +834,7 @@ main(argc, argv, envp)
# endif
default:
- ExitStat = EX_USAGE;
- finis();
+ finis(TRUE, EX_USAGE);
break;
}
}
@@ -971,8 +969,11 @@ main(argc, argv, envp)
}
/* check for permissions */
- if ((OpMode == MD_DAEMON || OpMode == MD_FGDAEMON ||
- OpMode == MD_PURGESTAT) && RealUid != 0)
+ if ((OpMode == MD_DAEMON ||
+ OpMode == MD_FGDAEMON ||
+ OpMode == MD_PURGESTAT) &&
+ RealUid != 0 &&
+ RealUid != TrustedUid)
{
if (LogLevel > 1)
sm_syslog(LOG_ALERT, NOQID,
@@ -981,7 +982,7 @@ main(argc, argv, envp)
OpMode != MD_PURGESTAT ? "run daemon"
: "purge host status");
usrerr("Permission denied");
- exit(EX_USAGE);
+ finis(FALSE, EX_USAGE);
}
if (MeToo)
@@ -1083,6 +1084,17 @@ main(argc, argv, envp)
setoption('d', "", TRUE, FALSE, CurEnv);
}
+#ifdef VENDOR_CODE
+ /* check for vendor mismatch */
+ if (VendorCode != VENDOR_CODE)
+ {
+ extern char *getvendor __P((int));
+
+ message("Warning: .cf file vendor code mismatch: sendmail expects vendor %s, .cf file vendor is %s",
+ getvendor(VENDOR_CODE), getvendor(VendorCode));
+ }
+#endif
+
/* check for out of date configuration level */
if (ConfigLevel < MAXCONFIGLEVEL)
{
@@ -1199,6 +1211,22 @@ main(argc, argv, envp)
setclass('b', "application/octet-stream");
#endif
+#if _FFR_MAX_MIME_HEADER_LENGTH
+ /* MIME headers which have fields to check for overflow */
+ setclass(macid("{checkMIMEFieldHeaders}", NULL), "content-disposition");
+ setclass(macid("{checkMIMEFieldHeaders}", NULL), "content-type");
+
+ /* MIME headers to check for length overflow */
+ setclass(macid("{checkMIMETextHeaders}", NULL), "content-description");
+
+ /* MIME headers to check for overflow and rebalance */
+ setclass(macid("{checkMIMEHeaders}", NULL), "content-disposition");
+ setclass(macid("{checkMIMEHeaders}", NULL), "content-id");
+ setclass(macid("{checkMIMEHeaders}", NULL), "content-transfer-encoding");
+ setclass(macid("{checkMIMEHeaders}", NULL), "content-type");
+ setclass(macid("{checkMIMEHeaders}", NULL), "mime-version");
+#endif
+
/* operate in queue directory */
if (QueueDir == NULL)
{
@@ -1241,18 +1269,14 @@ main(argc, argv, envp)
{
/* nope, really a botch */
usrerr("You do not have permission to process the queue");
- exit (EX_NOPERM);
+ finis(FALSE, EX_NOPERM);
}
}
# endif /* QUEUE */
/* if we've had errors so far, exit now */
if (ExitStat != EX_OK && OpMode != MD_TEST)
- {
- endpwent();
- setuid(RealUid);
- exit(ExitStat);
- }
+ finis(FALSE, ExitStat);
#if XDEBUG
checkfd012("before main() initmaps");
@@ -1268,31 +1292,31 @@ main(argc, argv, envp)
/* print the queue */
#if QUEUE
dropenvelope(CurEnv, TRUE);
+ signal(SIGPIPE, quiesce);
printqueue();
- endpwent();
- setuid(RealUid);
- exit(EX_OK);
+ finis(FALSE, EX_OK);
#else /* QUEUE */
usrerr("No queue to print");
- finis();
+ finis(FALSE, ExitStat);
#endif /* QUEUE */
+ break;
case MD_HOSTSTAT:
+ signal(SIGPIPE, quiesce);
mci_traverse_persistent(mci_print_persistent, NULL);
- exit(EX_OK);
+ finis(FALSE, EX_OK);
break;
case MD_PURGESTAT:
mci_traverse_persistent(mci_purge_persistent, NULL);
- exit(EX_OK);
+ finis(FALSE, EX_OK);
break;
case MD_INITALIAS:
- /* initialize alias database */
+ /* initialize maps */
initmaps(TRUE, CurEnv);
- endpwent();
- setuid(RealUid);
- exit(ExitStat);
+ finis(FALSE, ExitStat);
+ break;
case MD_SMTP:
case MD_DAEMON:
@@ -1301,11 +1325,11 @@ main(argc, argv, envp)
CurEnv->e_envid = NULL;
CurEnv->e_flags &= ~(EF_RET_PARAM|EF_NO_BODY_RETN);
- /* don't open alias database -- done in srvrsmtp */
+ /* don't open maps for daemon -- done below in child */
break;
default:
- /* open the alias database */
+ /* open the maps */
initmaps(FALSE, CurEnv);
break;
}
@@ -1359,7 +1383,7 @@ main(argc, argv, envp)
printf("> ");
(void) fflush(stdout);
if (fgets(buf, sizeof buf, stdin) == NULL)
- finis();
+ finis(TRUE, ExitStat);
p = strchr(buf, '\n');
if (p != NULL)
*p = '\0';
@@ -1377,7 +1401,7 @@ main(argc, argv, envp)
if (queuemode && OpMode != MD_DAEMON && QueueIntvl == 0)
{
(void) runqueue(FALSE, Verbose);
- finis();
+ finis(TRUE, ExitStat);
}
# endif /* QUEUE */
@@ -1402,7 +1426,7 @@ main(argc, argv, envp)
if (i < 0)
syserr("daemon: cannot fork");
if (i != 0)
- exit(EX_OK);
+ finis(FALSE, EX_OK);
/* disconnect from our controlling tty */
disconnect(2, CurEnv);
@@ -1495,6 +1519,9 @@ main(argc, argv, envp)
snprintf(pbuf, sizeof pbuf, "0");
define(macid("{client_port}", NULL), newstr(pbuf), &BlankEnvelope);
+ /* initialize maps now for check_relay ruleset */
+ initmaps(FALSE, CurEnv);
+
if (OpMode == MD_DAEMON)
{
/* validate the connection */
@@ -1539,7 +1566,7 @@ main(argc, argv, envp)
/* collect body for UUCP return */
if (OpMode != MD_VERIFY)
collect(InChannel, FALSE, NULL, CurEnv);
- finis();
+ finis(TRUE, ExitStat);
}
/*
@@ -1583,7 +1610,7 @@ main(argc, argv, envp)
/* bail out if message too large */
if (bitset(EF_CLRQUEUE, CurEnv->e_flags))
{
- finis();
+ finis(TRUE, ExitStat);
/*NOTREACHED*/
return -1;
}
@@ -1615,11 +1642,18 @@ main(argc, argv, envp)
** Don't send return error message if in VERIFY mode.
*/
- finis();
+ finis(TRUE, ExitStat);
/*NOTREACHED*/
return -1;
}
+/* ARGSUSED */
+SIGFUNC_DECL
+quiesce(sig)
+ int sig;
+{
+ finis(FALSE, EX_OK);
+}
/* ARGSUSED */
SIGFUNC_DECL
@@ -1635,7 +1669,8 @@ intindebug(sig)
** FINIS -- Clean up and exit.
**
** Parameters:
-** none
+** drop -- whether or not to drop CurEnv envelope
+** exitstat -- exit status to use for exit() call
**
** Returns:
** never
@@ -1645,14 +1680,21 @@ intindebug(sig)
*/
void
-finis()
+finis(drop, exitstat)
+ bool drop;
+ volatile int exitstat;
{
+ extern void closemaps __P((void));
+#ifdef USERDB
+ extern void _udbx_close __P((void));
+#endif
+
if (tTd(2, 1))
{
extern void printenvflags __P((ENVELOPE *));
printf("\n====finis: stat %d e_id=%s e_flags=",
- ExitStat,
+ exitstat,
CurEnv->e_id == NULL ? "NOQUEUE" : CurEnv->e_id);
printenvflags(CurEnv);
}
@@ -1668,12 +1710,20 @@ finis()
/* clean up temp files */
CurEnv->e_to = NULL;
- if (CurEnv->e_id != NULL)
+ if (drop && CurEnv->e_id != NULL)
dropenvelope(CurEnv, TRUE);
/* flush any cached connections */
mci_flush(TRUE, NULL);
+ /* close maps belonging to this pid */
+ closemaps();
+
+#ifdef USERDB
+ /* close UserDatabase */
+ _udbx_close();
+#endif
+
# ifdef XLA
/* clean up extended load average stuff */
xla_all_end();
@@ -1685,14 +1735,14 @@ finis()
sm_syslog(LOG_DEBUG, CurEnv->e_id,
"finis, pid=%d",
getpid());
- if (ExitStat == EX_TEMPFAIL || CurEnv->e_errormode == EM_BERKNET)
- ExitStat = EX_OK;
+ if (exitstat == EX_TEMPFAIL || CurEnv->e_errormode == EM_BERKNET)
+ exitstat = EX_OK;
/* reset uid for process accounting */
endpwent();
setuid(RealUid);
- exit(ExitStat);
+ exit(exitstat);
}
/*
** INTSIG -- clean up on interrupt
@@ -1719,15 +1769,11 @@ intsig(sig)
sm_syslog(LOG_DEBUG, CurEnv->e_id, "interrupt");
FileName = NULL;
unlockqueue(CurEnv);
+ closecontrolsocket(TRUE);
#ifdef XLA
xla_all_end();
#endif
-
- /* reset uid for process accounting */
- endpwent();
- setuid(RealUid);
-
- exit(EX_OK);
+ finis(FALSE, EX_OK);
}
/*
** INITMACROS -- initialize the macro system
@@ -2157,23 +2203,24 @@ sighup(sig)
{
if (LogLevel > 3)
sm_syslog(LOG_INFO, NOQID, "could not restart: need full path");
- exit(EX_OSFILE);
+ finis(FALSE, EX_OSFILE);
}
if (LogLevel > 3)
sm_syslog(LOG_INFO, NOQID, "restarting %s on signal", SaveArgv[0]);
alarm(0);
releasesignal(SIGHUP);
+ closecontrolsocket(TRUE);
if (drop_privileges(TRUE) != EX_OK)
{
if (LogLevel > 0)
sm_syslog(LOG_ALERT, NOQID, "could not set[ug]id(%d, %d): %m",
RunAsUid, RunAsGid);
- exit(EX_OSERR);
+ finis(FALSE, EX_OSERR);
}
execve(SaveArgv[0], (ARGV_T) SaveArgv, (ARGV_T) ExternalEnviron);
if (LogLevel > 0)
sm_syslog(LOG_ALERT, NOQID, "could not exec %s: %m", SaveArgv[0]);
- exit(EX_OSFILE);
+ finis(FALSE, EX_OSFILE);
}
/*
** DROP_PRIVILEGES -- reduce privileges to those of the RunAsUser option
diff --git a/contrib/sendmail/src/map.c b/contrib/sendmail/src/map.c
index 4c95b7f..787ae07 100644
--- a/contrib/sendmail/src/map.c
+++ b/contrib/sendmail/src/map.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)map.c 8.239 (Berkeley) 6/5/98";
+static char sccsid[] = "@(#)map.c 8.256 (Berkeley) 11/15/1998";
#endif /* not lint */
#include "sendmail.h"
@@ -437,9 +437,9 @@ map_init(s, pass)
pass);
/*
- ** Pass 0 opens all non-rebuildable maps.
- ** Pass 1 opens all rebuildable maps for read.
- ** Pass 2 rebuilds all rebuildable maps.
+ ** Pass 0 opens all non-rebuildable maps.
+ ** Pass 1 opens all rebuildable maps for read.
+ ** Pass 2 rebuilds all rebuildable maps.
*/
rebuildable = (bitset(MF_ALIAS, map->map_mflags) &&
@@ -478,6 +478,7 @@ map_init(s, pass)
map->map_file == NULL ? "NULL" :
map->map_file);
map->map_mflags |= MF_OPEN;
+ map->map_pid = getpid();
}
else
{
@@ -496,10 +497,55 @@ map_init(s, pass)
map->map_class = &BogusMapClass;
map->map_mflags |= MF_OPEN;
+ map->map_pid = getpid();
}
}
}
/*
+** CLOSEMAPS -- close all open maps opened by the current pid.
+**
+** Parameters:
+** none
+**
+** Returns:
+** none.
+*/
+
+void
+closemaps()
+{
+ extern void map_close __P((STAB *, int));
+
+ stabapply(map_close, 0);
+}
+
+/* ARGSUSED1 */
+void
+map_close(s, unused)
+ register STAB *s;
+ int unused;
+{
+ MAP *map;
+
+ if (s->s_type != ST_MAP)
+ return;
+
+ map = &s->s_map;
+
+ if (!bitset(MF_VALID, map->map_mflags) ||
+ !bitset(MF_OPEN, map->map_mflags) ||
+ map->map_pid != getpid())
+ return;
+
+ if (tTd(38, 5))
+ printf("closemaps: closing %s (%s)\n",
+ map->map_mname == NULL ? "NULL" : map->map_mname,
+ map->map_file == NULL ? "NULL" : map->map_file);
+
+ map->map_class->map_close(map);
+ map->map_mflags &= ~(MF_OPEN|MF_WRITABLE);
+}
+ /*
** GETCANONNAME -- look up name using service switch
**
** Parameters:
@@ -953,10 +999,11 @@ ndbm_map_open(map, mode)
else
{
map->map_mflags |= MF_LOCKED;
- if (geteuid() == 0 && TrustedFileUid != 0)
+#if _FFR_TRUSTED_USER
+ if (geteuid() == 0 && TrustedUid != 0)
{
- if (fchown(dfd, TrustedFileUid, -1) < 0 ||
- fchown(pfd, TrustedFileUid, -1) < 0)
+ if (fchown(dfd, TrustedUid, -1) < 0 ||
+ fchown(pfd, TrustedUid, -1) < 0)
{
int err = errno;
@@ -967,6 +1014,7 @@ ndbm_map_open(map, mode)
map->map_file, errstring(err));
}
}
+#endif
}
if (fstat(dfd, &st) >= 0)
map->map_mtime = st.st_mtime;
@@ -1020,6 +1068,7 @@ lockdbm:
if (map->map_class->map_open(map, omode))
{
map->map_mflags |= MF_OPEN;
+ map->map_pid = getpid();
if ((omode && O_ACCMODE) == O_RDWR)
map->map_mflags |= MF_WRITABLE;
goto lockdbm;
@@ -1033,6 +1082,7 @@ lockdbm:
*statp = EX_TEMPFAIL;
map->map_class = &BogusMapClass;
map->map_mflags |= MF_OPEN;
+ map->map_pid = getpid();
syserr("Cannot reopen NDBM database %s",
map->map_file);
}
@@ -1159,7 +1209,7 @@ ndbm_map_close(map)
{
#ifdef NDBM_YP_COMPAT
bool inclnull;
- char buf[200];
+ char buf[MAXHOSTNAMELEN];
inclnull = bitset(MF_INCLNULL, map->map_mflags);
map->map_mflags &= ~MF_INCLNULL;
@@ -1500,9 +1550,10 @@ db_map_open(map, mode, mapclassname, dbtype, openinfo)
if (mode == O_RDWR)
{
(void) db->sync(db, 0);
- if (geteuid() == 0 && TrustedFileUid != 0)
+#if _FFR_TRUSTED_USER
+ if (geteuid() == 0 && TrustedUid != 0)
{
- if (fchown(fd, TrustedFileUid, -1) < 0)
+ if (fchown(fd, TrustedUid, -1) < 0)
{
int err = errno;
@@ -1513,6 +1564,7 @@ db_map_open(map, mode, mapclassname, dbtype, openinfo)
buf, errstring(err));
}
}
+#endif
}
if (fd >= 0 && fstat(fd, &st) >= 0)
@@ -1590,6 +1642,7 @@ db_map_lookup(map, name, av, statp)
if (map->map_class->map_open(map, omode))
{
map->map_mflags |= MF_OPEN;
+ map->map_pid = getpid();
if ((omode && O_ACCMODE) == O_RDWR)
map->map_mflags |= MF_WRITABLE;
db = (DB *) map->map_db2;
@@ -1604,6 +1657,7 @@ db_map_lookup(map, name, av, statp)
*statp = EX_TEMPFAIL;
map->map_class = &BogusMapClass;
map->map_mflags |= MF_OPEN;
+ map->map_pid = getpid();
syserr("Cannot reopen DB database %s",
map->map_file);
}
@@ -1817,9 +1871,31 @@ db_map_close(map)
#if DB_VERSION_MAJOR < 2
if (db->close(db) != 0)
#else
+ /*
+ ** Berkeley DB can use internal shared memory
+ ** locking for its memory pool. Closing a map
+ ** opened by another process will interfere
+ ** with the shared memory and locks of the parent
+ ** process leaving things in a bad state.
+ **
+ ** If this map was not opened by the current
+ ** process, do not close it here but recover
+ ** the file descriptor.
+ */
+ if (map->map_pid != getpid())
+ {
+ int fd = -1;
+
+ errno = db->fd(db, &fd);
+ if (fd >= 0)
+ (void) close(fd);
+ return;
+ }
+
if ((errno = db->close(db, 0)) != 0)
#endif
- syserr("readaliases: db close failure");
+ syserr("db_map_close(%s, %s, %lx): db close failure",
+ map->map_mname, map->map_file, map->map_mflags);
}
#endif
@@ -2250,7 +2326,10 @@ nisplus_map_lookup(map, name, av, statp)
if (!bitset(MF_OPEN, map->map_mflags))
{
if (nisplus_map_open(map, O_RDONLY))
+ {
map->map_mflags |= MF_OPEN;
+ map->map_pid = getpid();
+ }
else
{
*statp = EX_UNAVAILABLE;
@@ -2591,18 +2670,38 @@ ldap_map_start(map)
ev = setevent(lmap->timeout.tv_sec, ldaptimeout, 0);
}
- if ((ld = ldap_open(lmap->ldaphost,lmap->ldapport)) == NULL)
+#ifdef LDAP_VERSION3
+ ld = ldap_init(lmap->ldaphost,lmap->ldapport);
+#else
+ ld = ldap_open(lmap->ldaphost,lmap->ldapport);
+#endif
+
+ /* clear the event if it has not sprung */
+ if (lmap->timeout.tv_sec != 0)
+ clrevent(ev);
+
+ if (ld == NULL)
{
if (!bitset(MF_OPTIONAL, map->map_mflags))
{
- syserr("ldapopen failed to %s in map %s",
+ syserr("%sldapopen failed to %s in map %s",
+ bitset(MF_NODEFER, map->map_mflags) ? "" : "421 ",
lmap->ldaphost, map->map_mname);
}
return FALSE;
}
- /* clear the event if it has not sprung */
- clrevent(ev);
+#ifdef LDAP_VERSION3
+ ldap_set_option(ld, LDAP_OPT_DEREF, &lmap->deref);
+ ldap_set_option(ld, LDAP_OPT_TIMELIMIT, &lmap->timelimit);
+ ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &lmap->sizelimit);
+ ldap_set_option(ld, LDAP_OPT_REFERRALS, &lmap->ldap_options);
+
+ /* ld needs to be cast into the map struct */
+ lmap->ld = ld;
+ return TRUE;
+#else
+
/* From here on in we can use ldap internal timelimits */
ld->ld_deref = lmap->deref;
ld->ld_timelimit = lmap->timelimit;
@@ -2625,11 +2724,12 @@ ldap_map_start(map)
}
return FALSE;
+#endif
}
/*
-** LDAP_MAP_CLOSE -- close ldap map
+** LDAP_MAP_CLOSE -- close ldap map
*/
void
@@ -2645,8 +2745,8 @@ ldap_map_close(map)
#ifdef SUNET_ID
/*
-** SUNET_ID_HASH -- Convert a string to it's Sunet_id canonical form
-** This only makes sense at Stanford University.
+** SUNET_ID_HASH -- Convert a string to it's Sunet_id canonical form
+** This only makes sense at Stanford University.
*/
char *
@@ -2680,7 +2780,7 @@ sunet_id_hash(str)
#endif /* SUNET_ID */
/*
-** LDAP_MAP_LOOKUP -- look up a datum in a LDAP map
+** LDAP_MAP_LOOKUP -- look up a datum in a LDAP map
*/
char *
@@ -2699,6 +2799,7 @@ ldap_map_lookup(map, name, av, statp)
char **attr_values = NULL;
char *result;
int name_len;
+ char *fp, *p, *q;
if (tTd(38, 20))
printf("ldap_map_lookup(%s, %s)\n", map->map_mname, name);
@@ -2727,8 +2828,28 @@ ldap_map_lookup(map, name, av, statp)
makelower(keybuf);
#endif /*SUNET_ID */
- /* sprintf keybuf into filter */
- snprintf(filter, sizeof filter, lmap->filter, keybuf);
+ /* substitute keybuf into filter, perhaps multiple times */
+ fp = filter;
+ p = lmap->filter;
+ while ((q = strchr(p, '%')) != NULL)
+ {
+ if (q[1] == 's')
+ {
+ snprintf(fp, SPACELEFT(filter, fp), "%.*s%s",
+ q - p, p, keybuf);
+ p = q + 2;
+ }
+ else
+ {
+ snprintf(fp, SPACELEFT(filter, fp), "%.*s",
+ q - p + 1, p);
+ p = q + (q[1] == '%' ? 2 : 1);
+ }
+ fp += strlen(fp);
+ }
+ snprintf(fp, SPACELEFT(filter, fp), "%s", p);
+ if (tTd(38, 20))
+ printf("ldap search filter=%s\n", filter);
if (ldap_search_st(lmap->ld, lmap->base,lmap->scope,filter,
lmap->attr, lmap->attrsonly, &(lmap->timeout),
@@ -2749,7 +2870,8 @@ ldap_map_lookup(map, name, av, statp)
{
if (!bitset(MF_OPTIONAL, map->map_mflags))
{
- syserr("Error in ldap_search_st using %s in map %s",
+ syserr("%sError in ldap_search_st using %s in map %s",
+ bitset(MF_NODEFER, map->map_mflags) ? "" : "421 ",
filter, map->map_mname);
}
result = NULL;
@@ -2802,7 +2924,7 @@ ldap_map_lookup(map, name, av, statp)
/*
-** LDAP_MAP_DEQUOTE - helper routine for ldap_map_parseargs
+** LDAP_MAP_DEQUOTE - helper routine for ldap_map_parseargs
*/
char *
@@ -2832,7 +2954,7 @@ ldap_map_dequote(str)
}
/*
-** LDAP_MAP_PARSEARGS -- parse ldap map definition args.
+** LDAP_MAP_PARSEARGS -- parse ldap map definition args.
*/
bool
@@ -3036,8 +3158,8 @@ ldap_map_parseargs(map,args)
map->map_domain = newstr(ldap_map_dequote(map->map_domain));
/*
- ** We need to swallow up all the stuff into a struct
- ** and dump it into map->map_dbptr1
+ ** We need to swallow up all the stuff into a struct
+ ** and dump it into map->map_dbptr1
*/
if (lmap->ldaphost != NULL)
@@ -3095,7 +3217,7 @@ ldap_map_parseargs(map,args)
#endif /* LDAP Modules */
/*
-** syslog map
+** syslog map
*/
#if _FFR_MAP_SYSLOG
@@ -3103,7 +3225,7 @@ ldap_map_parseargs(map,args)
#define map_prio map_lockfd /* overload field */
/*
-** SYSLOG_MAP_PARSEARGS -- check for priority level to syslog messages.
+** SYSLOG_MAP_PARSEARGS -- check for priority level to syslog messages.
*/
bool
@@ -3185,7 +3307,7 @@ syslog_map_parseargs(map, args)
}
/*
-** SYSLOG_MAP_LOOKUP -- rewrite and syslog message. Always return empty string
+** SYSLOG_MAP_LOOKUP -- rewrite and syslog message. Always return empty string
*/
char *
@@ -3382,8 +3504,6 @@ ni_map_open(map, mode)
MAP *map;
int mode;
{
- char *p;
-
if (tTd(38, 2))
printf("ni_map_open(%s, %s, %d)\n",
map->map_mname, map->map_file, mode);
@@ -3666,7 +3786,7 @@ ni_propval(keydir, keyprop, keyval, valprop, sepchar)
return propval;
}
-#endif
+#endif /* NETINFO */
/*
** TEXT (unindexed text file) Modules
**
@@ -3842,6 +3962,11 @@ text_map_lookup(map, name, av, statp)
return NULL;
}
vp = get_column(linebuf, map->map_valcolno, delim, buf, sizeof buf);
+ if (vp == NULL)
+ {
+ *statp = EX_NOTFOUND;
+ return NULL;
+ }
vsize = strlen(vp);
*statp = EX_OK;
if (bitset(MF_MATCHONLY, map->map_mflags))
diff --git a/contrib/sendmail/src/mime.c b/contrib/sendmail/src/mime.c
index 11a141e..a1429cb 100644
--- a/contrib/sendmail/src/mime.c
+++ b/contrib/sendmail/src/mime.c
@@ -14,7 +14,7 @@
# include <string.h>
#ifndef lint
-static char sccsid[] = "@(#)mime.c 8.66 (Berkeley) 5/19/98";
+static char sccsid[] = "@(#)mime.c 8.70 (Berkeley) 11/10/1998";
#endif /* not lint */
/*
@@ -225,7 +225,8 @@ mime8to7(mci, header, e, boundaries, flags)
** Do a recursive descent into the message.
*/
- if (strcasecmp(type, "multipart") == 0 && !bitset(M87F_NO8BIT, flags))
+ if (strcasecmp(type, "multipart") == 0 &&
+ (!bitset(M87F_NO8BIT, flags) || bitset(M87F_NO8TO7, flags)))
{
int blen;
@@ -379,7 +380,7 @@ mime8to7(mci, header, e, boundaries, flags)
*/
sectionsize = sectionhighbits = 0;
- if (!bitset(M87F_NO8BIT, flags))
+ if (!bitset(M87F_NO8BIT|M87F_NO8TO7, flags))
{
/* remember where we were */
offset = ftell(e->e_dfp);
@@ -441,8 +442,13 @@ mime8to7(mci, header, e, boundaries, flags)
if (sectionhighbits == 0)
{
/* no encoding necessary */
- if (cte != NULL)
+ if (cte != NULL && bitset(MCIF_INMIME, mci->mci_flags))
{
+ /*
+ ** Skip _unless_ in MIME mode; see putheader() for the
+ ** counterpart where this is skipped _if_ in MIME mode.
+ */
+
snprintf(buf, sizeof buf,
"Content-Transfer-Encoding: %.200s", cte);
putline(buf, mci);
@@ -662,15 +668,22 @@ mime_getchar(fp, boundaries, btp)
static bool atbol = TRUE; /* at beginning of line */
static int bt = MBT_SYNTAX; /* boundary type of next EOF */
static u_char buf[128]; /* need not be a full line */
+ int start = 0; /* indicates position of - in buffer */
- if (buflen > 0)
+ if (buflen == 1 && *bp == '\n')
+ {
+ /* last \n in buffer may be part of next MIME boundary */
+ c = *bp;
+ }
+ else if (buflen > 0)
{
buflen--;
return *bp++;
}
+ else
+ c = getc(fp);
bp = buf;
buflen = 0;
- c = getc(fp);
if (c == '\n')
{
/* might be part of a MIME boundary */
@@ -682,6 +695,7 @@ mime_getchar(fp, boundaries, btp)
ungetc(c, fp);
return c;
}
+ start = 1;
}
if (c != EOF)
*bp++ = c;
@@ -710,7 +724,7 @@ mime_getchar(fp, boundaries, btp)
*bp++ = c;
}
*bp = '\0';
- bt = mimeboundary((char *) &buf[1], boundaries);
+ bt = mimeboundary((char *) &buf[start], boundaries);
switch (bt)
{
case MBT_FINAL:
diff --git a/contrib/sendmail/src/newaliases.1 b/contrib/sendmail/src/newaliases.1
index acf3245..b9673cd 100644
--- a/contrib/sendmail/src/newaliases.1
+++ b/contrib/sendmail/src/newaliases.1
@@ -8,7 +8,7 @@
.\" the sendmail distribution.
.\"
.\"
-.\" @(#)newaliases.1 8.10 (Berkeley) 5/19/98
+.\" @(#)newaliases.1 8.10 (Berkeley) 5/19/1998
.\"
.Dd May 19, 1998
.Dt NEWALIASES 1
diff --git a/contrib/sendmail/src/parseaddr.c b/contrib/sendmail/src/parseaddr.c
index c3c89b4..86762fd 100644
--- a/contrib/sendmail/src/parseaddr.c
+++ b/contrib/sendmail/src/parseaddr.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)parseaddr.c 8.153 (Berkeley) 6/24/98";
+static char sccsid[] = "@(#)parseaddr.c 8.156 (Berkeley) 10/27/1998";
#endif /* not lint */
# include "sendmail.h"
@@ -67,7 +67,6 @@ parseaddr(addr, a, flags, delim, delimptr, e)
auto char *delimptrbuf;
bool queueup;
char pvpbuf[PSBUFSIZE];
- extern ADDRESS *buildaddr __P((char **, ADDRESS *, int, ENVELOPE *));
extern bool invalidaddr __P((char *, char *));
extern void allocaddr __P((ADDRESS *, int, char *));
@@ -1450,8 +1449,17 @@ map_lookup(map, key, argvect, pstat, e)
/* XXX should try to auto-open the map here */
if (tTd(60, 1))
- printf("map_lookup(%s, %s) => ",
- map->s_name, key);
+ {
+ printf("map_lookup(%s, %s", map->s_name, key);
+ if (tTd(60, 5))
+ {
+ int i;
+
+ for (i = 0; argvect[i] != NULL; i++)
+ printf(", %%%d=%s", i, argvect[i]);
+ }
+ printf(") => ");
+ }
replac = (*map->s_map.map_class->map_lookup)(&map->s_map,
key, argvect, &stat);
if (tTd(60, 1))
@@ -1553,7 +1561,7 @@ buildaddr(tv, a, flags, e)
static MAILER errormailer;
static char *discardargv[] = { "DISCARD", NULL };
static char *errorargv[] = { "ERROR", NULL };
- static char ubuf[MAXNAME + 1];
+ static char ubuf[MAXNAME + 2];
if (tTd(24, 5))
{
diff --git a/contrib/sendmail/src/pathnames.h b/contrib/sendmail/src/pathnames.h
index e10387e..7a06b12 100644
--- a/contrib/sendmail/src/pathnames.h
+++ b/contrib/sendmail/src/pathnames.h
@@ -8,7 +8,7 @@
* the sendmail distribution.
*
*
- * @(#)pathnames.h 8.8 (Berkeley) 5/19/98
+ * @(#)pathnames.h 8.8 (Berkeley) 5/19/1998
*/
#ifndef _PATH_SENDMAILCF
diff --git a/contrib/sendmail/src/queue.c b/contrib/sendmail/src/queue.c
index 24b789a..65e777a 100644
--- a/contrib/sendmail/src/queue.c
+++ b/contrib/sendmail/src/queue.c
@@ -14,9 +14,9 @@
#ifndef lint
#if QUEUE
-static char sccsid[] = "@(#)queue.c 8.202 (Berkeley) 6/15/98 (with queueing)";
+static char sccsid[] = "@(#)queue.c 8.210 (Berkeley) 10/15/1998 (with queueing)";
#else
-static char sccsid[] = "@(#)queue.c 8.202 (Berkeley) 6/15/98 (without queueing)";
+static char sccsid[] = "@(#)queue.c 8.210 (Berkeley) 10/15/1998 (without queueing)";
#endif
#endif /* not lint */
@@ -611,7 +611,7 @@ runqueue(forkflag, verbose)
{
/* parent -- pick up intermediate zombie */
(void) blocksignal(SIGALRM);
- proc_list_add(pid);
+ proc_list_add(pid, "Queue runner");
(void) releasesignal(SIGALRM);
releasesignal(SIGCHLD);
if (QueueIntvl != 0)
@@ -619,13 +619,17 @@ runqueue(forkflag, verbose)
return TRUE;
}
/* child -- double fork and clean up signals */
+ clrcontrol();
proc_list_clear();
+
+ /* Add parent process as first child item */
+ proc_list_add(getpid(), "Queue runner child process");
releasesignal(SIGCHLD);
(void) setsignal(SIGCHLD, SIG_DFL);
(void) setsignal(SIGHUP, intsig);
}
- setproctitle("running queue: %s", QueueDir);
+ sm_setproctitle(TRUE, "running queue: %s", QueueDir);
if (LogLevel > 69)
sm_syslog(LOG_DEBUG, NOQID,
@@ -750,7 +754,6 @@ runqueue(forkflag, verbose)
else
{
pid_t pid;
- extern pid_t dowork __P((char *, bool, bool, ENVELOPE *));
if (Verbose)
{
@@ -771,7 +774,7 @@ runqueue(forkflag, verbose)
/* exit without the usual cleanup */
e->e_id = NULL;
- finis();
+ finis(TRUE, ExitStat);
/*NOTREACHED*/
return TRUE;
}
@@ -893,7 +896,16 @@ orderq(doall)
continue;
if (strlen(d->d_name) > MAXQFNAME)
+ {
+ if (Verbose)
+ printf("orderq: %s too long, %d max characters\n",
+ d->d_name, MAXQFNAME);
+ if (LogLevel > 0)
+ sm_syslog(LOG_ALERT, NOQID,
+ "orderq: %s too long, %d max characters",
+ d->d_name, MAXQFNAME);
continue;
+ }
check = QueueLimitId;
while (check != NULL)
@@ -1443,6 +1455,16 @@ dowork(id, forkflag, requeueflag, e)
{
/* child -- error messages to the transcript */
QuickAbort = OnlyOneError = FALSE;
+
+ /*
+ ** Since the delivery may happen in a child and the
+ ** parent does not wait, the parent may close the
+ ** maps thereby removing any shared memory used by
+ ** the map. Therefore, open a copy of the maps for
+ ** the delivery process.
+ */
+
+ initmaps(FALSE, e);
}
}
else
@@ -1474,7 +1496,7 @@ dowork(id, forkflag, requeueflag, e)
disconnect(1, e);
OpMode = MD_DELIVER;
}
- setproctitle("%s: from queue", id);
+ sm_setproctitle(TRUE, "%s: from queue", id);
if (LogLevel > 76)
sm_syslog(LOG_DEBUG, e->e_id,
"dowork, pid=%d",
@@ -1490,7 +1512,7 @@ dowork(id, forkflag, requeueflag, e)
printf("readqf(%s) failed\n", e->e_id);
e->e_id = NULL;
if (forkflag)
- exit(EX_OK);
+ finis(FALSE, EX_OK);
else
return 0;
}
@@ -1506,7 +1528,7 @@ dowork(id, forkflag, requeueflag, e)
/* finish up and exit */
if (forkflag)
- finis();
+ finis(TRUE, ExitStat);
else
dropenvelope(e, TRUE);
}
@@ -1777,7 +1799,6 @@ readqf(e)
curtime() < e->e_dtime + MinQueueAge)
{
char *howlong = pintvl(curtime() - e->e_dtime, TRUE);
- extern void unlockqueue __P((ENVELOPE *));
if (Verbose || tTd(40, 8))
printf("%s: too young (%s)\n",
@@ -2185,7 +2206,7 @@ queuename(e, type)
continue;
syserr("queuename: Cannot create \"%s\" in \"%s\" (euid=%d)",
qf, QueueDir, geteuid());
- exit(EX_UNAVAILABLE);
+ finis(FALSE, EX_UNAVAILABLE);
}
do
{
@@ -2212,7 +2233,7 @@ queuename(e, type)
{
syserr("queuename: Cannot lock \"%s\" in \"%s\" (euid=%d)",
qf, QueueDir, geteuid());
- exit(EX_OSERR);
+ finis(FALSE, EX_OSERR);
}
/* a reader got the file; abandon it and try again */
@@ -2222,7 +2243,7 @@ queuename(e, type)
{
syserr("queuename: Cannot create \"%s\" in \"%s\" (euid=%d)",
qf, QueueDir, geteuid());
- exit(EX_OSERR);
+ finis(FALSE, EX_OSERR);
}
e->e_id = newstr(&qf[2]);
define('i', e->e_id, e);
diff --git a/contrib/sendmail/src/readcf.c b/contrib/sendmail/src/readcf.c
index db71937..56aa825 100644
--- a/contrib/sendmail/src/readcf.c
+++ b/contrib/sendmail/src/readcf.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)readcf.c 8.230 (Berkeley) 6/5/98";
+static char sccsid[] = "@(#)readcf.c 8.235 (Berkeley) 8/18/1998";
#endif /* not lint */
# include "sendmail.h"
@@ -106,19 +106,19 @@ readcf(cfname, safe, e)
if (cf == NULL)
{
syserr("cannot open");
- exit(EX_OSFILE);
+ finis(FALSE, EX_OSFILE);
}
if (fstat(fileno(cf), &statb) < 0)
{
syserr("cannot fstat");
- exit(EX_OSFILE);
+ finis(FALSE, EX_OSFILE);
}
if (!S_ISREG(statb.st_mode))
{
syserr("not a plain file");
- exit(EX_OSFILE);
+ finis(FALSE, EX_OSFILE);
}
if (OpMode != MD_TEST && bitset(S_IWGRP|S_IWOTH, statb.st_mode))
@@ -518,7 +518,7 @@ readcf(cfname, safe, e)
if (ferror(cf))
{
syserr("I/O read error");
- exit(EX_OSFILE);
+ finis(FALSE, EX_OSFILE);
}
fclose(cf);
FileName = NULL;
@@ -1515,11 +1515,18 @@ struct optioninfo
#define O_CNCTONLYTO 0xa6
{ "ConnectOnlyTo", O_CNCTONLYTO, FALSE },
#endif
-#if _FFR_TRUSTED_FILE_OWNER
-#define O_TRUSTFILEOWN 0xa7
- { "TrustedFileOwner", O_TRUSTFILEOWN, FALSE },
+#if _FFR_TRUSTED_USER
+#define O_TRUSTUSER 0xa7
+ { "TrustedUser", O_TRUSTUSER, FALSE },
+#endif
+#if _FFR_MAX_MIME_HEADER_LENGTH
+#define O_MAXMIMEHDRLEN 0xa8
+ { "MaxMimeHeaderLength", O_MAXMIMEHDRLEN, FALSE },
+#endif
+#if _FFR_CONTROL_SOCKET
+#define O_CONTROLSOCKET 0xa9
+ { "ControlSocketName", O_CONTROLSOCKET, FALSE },
#endif
-
{ NULL, '\0', FALSE }
};
@@ -1707,7 +1714,7 @@ setoption(opt, val, safe, sticky, e)
default:
syserr("Unknown 8-bit mode %c", *val);
- exit(EX_USAGE);
+ finis(FALSE, EX_USAGE);
}
break;
#endif
@@ -1771,7 +1778,7 @@ setoption(opt, val, safe, sticky, e)
default:
syserr("Unknown delivery mode %c", *val);
- exit(EX_USAGE);
+ finis(FALSE, EX_USAGE);
}
buf[0] = (char)e->e_sendmode;
buf[1] = '\0';
@@ -2401,33 +2408,64 @@ setoption(opt, val, safe, sticky, e)
break;
#endif
-#if _FFR_TRUSTED_FILE_OWNER
- case O_TRUSTFILEOWN:
+#if _FFR_TRUSTED_USER
+ case O_TRUSTUSER:
if (isascii(*val) && isdigit(*val))
- TrustedFileUid = atoi(val);
+ TrustedUid = atoi(val);
else
{
register struct passwd *pw;
- TrustedFileUid = 0;
+ TrustedUid = 0;
pw = sm_getpwnam(val);
if (pw == NULL)
- syserr("readcf: option TrustedFileOwner: unknown user %s", val);
+ syserr("readcf: option TrustedUser: unknown user %s", val);
else
- TrustedFileUid = pw->pw_uid;
+ TrustedUid = pw->pw_uid;
}
#ifdef UID_MAX
- if (TrustedFileUid > UID_MAX)
+ if (TrustedUid > UID_MAX)
{
- syserr("readcf: option TrustedFileOwner: uid value (%ld) > UID_MAX (%ld)",
- TrustedFileUid, UID_MAX);
- TrustedFileUid = 0;
+ syserr("readcf: option TrustedUser: uid value (%ld) > UID_MAX (%ld)",
+ TrustedUid, UID_MAX);
+ TrustedUid = 0;
}
#endif
break;
#endif
+#if _FFR_MAX_MIME_HEADER_LENGTH
+ case O_MAXMIMEHDRLEN:
+ p = strchr(val, '/');
+ if (p != NULL)
+ *p++ = '\0';
+ MaxMimeHeaderLength = atoi(val);
+ if (p != NULL && *p != '\0')
+ MaxMimeFieldLength = atoi(p);
+ else
+ MaxMimeFieldLength = MaxMimeHeaderLength / 2;
+
+ if (MaxMimeHeaderLength < 0)
+ MaxMimeHeaderLength = 0;
+ else if (MaxMimeHeaderLength < 128)
+ printf("Warning: MaxMimeHeaderLength: header length limit set lower than 128\n");
+
+ if (MaxMimeFieldLength < 0)
+ MaxMimeFieldLength = 0;
+ else if (MaxMimeFieldLength < 40)
+ printf("Warning: MaxMimeHeaderLength: field length limit set lower than 40\n");
+ break;
+#endif
+
+#if _FFR_CONTROL_SOCKET
+ case O_CONTROLSOCKET:
+ if (ControlSocketName != NULL)
+ free(ControlSocketName);
+ ControlSocketName = newstr(val);
+ break;
+#endif
+
default:
if (tTd(37, 1))
{
diff --git a/contrib/sendmail/src/recipient.c b/contrib/sendmail/src/recipient.c
index 9a73b6a..59412a8 100644
--- a/contrib/sendmail/src/recipient.c
+++ b/contrib/sendmail/src/recipient.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)recipient.c 8.154 (Berkeley) 6/24/98";
+static char sccsid[] = "@(#)recipient.c 8.161 (Berkeley) 12/18/1998";
#endif /* not lint */
# include "sendmail.h"
@@ -331,8 +331,11 @@ recipient(a, sendq, aliaslevel, e)
}
/* add address on list */
- *pq = a;
- a->q_next = NULL;
+ if (pq != NULL)
+ {
+ *pq = a;
+ a->q_next = NULL;
+ }
/*
** Alias the name and handle special mailer types.
@@ -340,7 +343,10 @@ recipient(a, sendq, aliaslevel, e)
trylocaluser:
if (tTd(29, 7))
- printf("at trylocaluser %s\n", a->q_user);
+ {
+ printf("at trylocaluser: ");
+ printaddr(a, FALSE);
+ }
if (bitset(QDONTSEND|QBADADDR|QVERIFIED, a->q_flags))
goto testselfdestruct;
@@ -931,7 +937,7 @@ include(fname, forwarding, ctladdr, sendq, aliaslevel, e)
(int) getuid(), (int) geteuid());
if (forwarding)
- sfflags |= SFF_MUSTOWN|SFF_ROOTOK|SFF_NOSLINK;
+ sfflags |= SFF_MUSTOWN|SFF_ROOTOK|SFF_NOWLINK;
ca = getctladdr(ctladdr);
if (ca == NULL)
@@ -1195,7 +1201,7 @@ resetuid:
}
/*
- ** Check to see if some bad guy can write this file
+ ** Check to see if some bad guy can write this file
**
** Group write checking could be more clever, e.g.,
** guessing as to which groups are actually safe ("sys"
diff --git a/contrib/sendmail/src/safefile.c b/contrib/sendmail/src/safefile.c
index 16f3f39..ff94b3d2 100644
--- a/contrib/sendmail/src/safefile.c
+++ b/contrib/sendmail/src/safefile.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)safefile.c 8.40 (Berkeley) 6/5/98";
+static char sccsid[] = "@(#)safefile.c 8.43 (Berkeley) 10/13/1998";
#endif /* not lint */
# include "sendmail.h"
@@ -102,7 +102,7 @@ safefile(fn, uid, gid, uname, flags, mode, st)
if (bitset(S_ISUID, st->st_mode))
#else
if (bitset(S_ISUID, st->st_mode) && st->st_uid != 0 &&
- st->st_uid != TrustedFileUid)
+ st->st_uid != TrustedUid)
#endif
{
uid = st->st_uid;
@@ -206,7 +206,7 @@ safefile(fn, uid, gid, uname, flags, mode, st)
if (stbuf.st_uid == uid)
;
- else if (uid == 0 && TrustedFileUid != 0 && stbuf.st_uid == TrustedFileUid)
+ else if (uid == 0 && stbuf.st_uid == TrustedUid)
;
else
{
@@ -299,7 +299,7 @@ safefile(fn, uid, gid, uname, flags, mode, st)
mode >>= 6;
else if (st->st_uid == uid)
;
- else if (uid == 0 && TrustedFileUid != 0 && st->st_uid == TrustedFileUid)
+ else if (uid == 0 && st->st_uid == TrustedUid)
;
else
{
@@ -328,7 +328,7 @@ safefile(fn, uid, gid, uname, flags, mode, st)
(int) st->st_uid, (int) st->st_nlink,
(u_long) st->st_mode, (u_long) mode);
if ((st->st_uid == uid || st->st_uid == 0 ||
- st->st_uid == TrustedFileUid ||
+ st->st_uid == TrustedUid ||
!bitset(SFF_MUSTOWN, flags)) &&
(st->st_mode & mode) == mode)
{
@@ -429,9 +429,9 @@ safedirpath(fn, uid, gid, uname, flags)
}
/*
- ** Let OS determine access to file if we are not
- ** running as a privileged user. This allows ACLs
- ** to work.
+ ** Let OS determine access to file if we are not
+ ** running as a privileged user. This allows ACLs
+ ** to work.
*/
if (geteuid() != 0)
continue;
diff --git a/contrib/sendmail/src/sendmail.h b/contrib/sendmail/src/sendmail.h
index 7bfe11b..023799d 100644
--- a/contrib/sendmail/src/sendmail.h
+++ b/contrib/sendmail/src/sendmail.h
@@ -9,7 +9,7 @@
* the sendmail distribution.
*
*
- * @(#)sendmail.h 8.280 (Berkeley) 6/5/98
+ * @(#)sendmail.h 8.292 (Berkeley) 11/21/1998
*/
/*
@@ -19,7 +19,7 @@
# ifdef _DEFINE
# define EXTERN
# ifndef lint
-static char SmailSccsId[] = "@(#)sendmail.h 8.280 6/5/98";
+static char SmailSccsId[] = "@(#)sendmail.h 8.292 11/21/1998";
# endif
# else /* _DEFINE */
# define EXTERN extern
@@ -684,6 +684,7 @@ MAP
char *map_domain; /* the (nominal) NIS domain */
char *map_rebuild; /* program to run to do auto-rebuild */
time_t map_mtime; /* last database modification time */
+ pid_t map_pid; /* PID of process which opened map */
int map_lockfd; /* auxiliary lock file descriptor */
short map_specificity; /* specificity of aliases */
MAP *map_stack[MAXMAPSTACK]; /* list for stacked maps */
@@ -1008,6 +1009,7 @@ extern bool filechanged __P((char *, int, struct stat *));
#define M87F_OUTER 0 /* outer context */
#define M87F_NO8BIT 0x0001 /* can't have 8-bit in this section */
#define M87F_DIGEST 0x0002 /* processing multipart/digest */
+#define M87F_NO8TO7 0x0004 /* don't do 8->7 bit conversions */
/*
@@ -1077,6 +1079,7 @@ extern char *validate_connection __P((SOCKADDR *, char *, ENVELOPE *));
#define VENDOR_SUN 2 /* Sun-native configuration file */
#define VENDOR_HP 3 /* Hewlett-Packard specific config syntax */
#define VENDOR_IBM 4 /* IBM specific config syntax */
+#define VENDOR_SENDMAIL 5 /* Sendmail, Inc. specific config syntax */
EXTERN int VendorCode; /* vendor-specific operation enhancements */
@@ -1097,7 +1100,6 @@ extern void vendor_daemon_setup __P((ENVELOPE *));
#define DBS_GROUPWRITABLEALIASFILE 0x00000010
#define DBS_WORLDWRITABLEALIASFILE 0x00000020
#define DBS_FORWARDFILEINUNSAFEDIRPATH 0x00000040
-#define DBS_INCLUDEFILEINUNSAFEDIRPATH 0x00000060
#define DBS_MAPINUNSAFEDIRPATH 0x00000080
#define DBS_LINKEDALIASFILEINWRITABLEDIR 0x00000100
#define DBS_LINKEDCLASSFILEINWRITABLEDIR 0x00000200
@@ -1120,6 +1122,7 @@ extern void vendor_daemon_setup __P((ENVELOPE *));
#define DBS_INCLUDEFILEINUNSAFEDIRPATHSAFE 0x04000000
#define DBS_RUNPROGRAMINUNSAFEDIRPATH 0x08000000
#define DBS_RUNWRITABLEPROGRAM 0x10000000
+#define DBS_INCLUDEFILEINUNSAFEDIRPATH 0x20000000
/* struct defining such things */
struct dbsval
@@ -1183,7 +1186,7 @@ EXTERN gid_t RealGid; /* real gid of caller */
EXTERN uid_t DefUid; /* default uid to run as */
EXTERN gid_t DefGid; /* default gid to run as */
EXTERN char *DefUser; /* default user to run as (from DefUid) */
-EXTERN uid_t TrustedFileUid; /* uid of trusted owner of files and dirs */
+EXTERN uid_t TrustedUid; /* uid of trusted user for files and startup */
EXTERN MODE_T OldUmask; /* umask when sendmail starts up */
EXTERN int Verbose; /* set if blow-by-blow desired */
EXTERN int Errors; /* set if errors (local to single pass) */
@@ -1221,6 +1224,7 @@ EXTERN char SpaceSub; /* substitution for <lwsp> */
EXTERN int PrivacyFlags; /* privacy flags */
EXTERN char *ConfFile; /* location of configuration file [conf.c] */
EXTERN char *PidFile; /* location of proc id file [conf.c] */
+EXTERN char *ControlSocketName; /* control socket filename [control.c] */
extern ADDRESS NullAddress; /* a null (template) address [main.c] */
EXTERN long WkClassFact; /* multiplier for message class -> priority */
EXTERN long WkRecipFact; /* multiplier for # of recipients -> priority */
@@ -1285,10 +1289,13 @@ EXTERN char *DoubleBounceAddr; /* where to send double bounces */
EXTERN char **ExternalEnviron; /* input environment */
EXTERN char *UserEnviron[MAXUSERENVIRON + 1];
/* saved user environment */
+EXTERN int MaxMimeHeaderLength; /* maximum MIME header length */
+EXTERN int MaxMimeFieldLength; /* maximum MIME field length */
+
extern int errno;
/*
-** Queue Run Limitations
+** Queue Run Limitations
*/
struct queue_char
{
@@ -1400,7 +1407,7 @@ extern char *denlstring __P((char *, bool, bool));
extern void makelower __P((char *));
extern bool rebuildaliases __P((MAP *, bool));
extern void readaliases __P((MAP *, FILE *, bool, bool));
-extern void finis __P((void));
+extern void finis __P((bool, volatile int));
extern void setsender __P((char *, ENVELOPE *, char **, int, bool));
extern void xputs __P((const char *));
extern void logsender __P((ENVELOPE *, char *));
@@ -1428,9 +1435,12 @@ extern void xfclose __P((FILE *, char *, char *));
extern int switch_map_find __P((char *, char *[], short []));
extern void shorten_hostname __P((char []));
extern int waitfor __P((pid_t));
-extern void proc_list_add __P((pid_t));
+extern void proc_list_add __P((pid_t, char *));
+extern void proc_list_set __P((pid_t, char *));
extern void proc_list_drop __P((pid_t));
extern void proc_list_clear __P((void));
+extern void proc_list_display __P((FILE *));
+extern void proc_list_probe __P((void));
extern void buffer_errors __P((void));
extern void flush_errors __P((bool));
extern void putline __P((char *, MCI *));
@@ -1468,6 +1478,8 @@ extern bool path_is_dir __P((char *, bool));
extern pid_t dowork __P((char *, bool, bool, ENVELOPE *));
extern int drop_privileges __P((bool));
extern void fill_fd __P((int, char *));
+extern void closecontrolsocket __P((bool));
+extern void clrcontrol __P((void));
extern const char *errstring __P((int));
extern sigfunc_t setsignal __P((int, sigfunc_t));
@@ -1491,6 +1503,7 @@ extern void usrerr __P((const char *, ...));
extern void message __P((const char *, ...));
extern void nmessage __P((const char *, ...));
extern void setproctitle __P((const char *, ...));
+extern void sm_setproctitle __P((bool, const char *, ...));
extern void sm_syslog __P((int, const char *, const char *, ...));
#if !HASSNPRINTF
diff --git a/contrib/sendmail/src/sendmail.hf b/contrib/sendmail/src/sendmail.hf
index 12a3060..0952963 100644
--- a/contrib/sendmail/src/sendmail.hf
+++ b/contrib/sendmail/src/sendmail.hf
@@ -9,7 +9,7 @@ cpyr By using this file, you agree to the terms and conditions set
cpyr forth in the LICENSE file which can be found at the top level of
cpyr the sendmail distribution.
cpyr
-cpyr @(#)sendmail.hf 8.16 (Berkeley) 5/19/98
+cpyr @(#)sendmail.hf 8.18 (Berkeley) 11/19/1998
cpyr
smtp Topics:
smtp HELO EHLO MAIL RCPT DATA
@@ -117,3 +117,8 @@ dsn ORCPT Original recipient.
-bt /map mapname key :look up `key' in the indicated `mapname'.
-bt rules addr :run the indicated address through the named rules.
-bt Rules can be a comma separated list of rules.
+control Help for smcontrol:
+control help This message.
+control restart Restart sendmail.
+control shutdown Shutdown sendmail.
+control status Show sendmail status.
diff --git a/contrib/sendmail/src/snprintf.c b/contrib/sendmail/src/snprintf.c
index 9e0b6f1..3e07e1b 100644
--- a/contrib/sendmail/src/snprintf.c
+++ b/contrib/sendmail/src/snprintf.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)snprintf.c 8.11 (Berkeley) 6/4/98";
+static char sccsid[] = "@(#)snprintf.c 8.12 (Berkeley) 10/13/1998";
#endif /* not lint */
#include "sendmail.h"
@@ -367,10 +367,10 @@ quad_to_string(value)
static char buf[64];
/*
- ** Use sprintf() instead of snprintf() since snprintf()
- ** does not support %qu or %llu. The buffer is large enough
- ** to hold the string so there is no danger of buffer
- ** overflow.
+ ** Use sprintf() instead of snprintf() since snprintf()
+ ** does not support %qu or %llu. The buffer is large enough
+ ** to hold the string so there is no danger of buffer
+ ** overflow.
*/
#if NEED_PERCENTQ
diff --git a/contrib/sendmail/src/srvrsmtp.c b/contrib/sendmail/src/srvrsmtp.c
index fba103c..f4ffe8c 100644
--- a/contrib/sendmail/src/srvrsmtp.c
+++ b/contrib/sendmail/src/srvrsmtp.c
@@ -14,9 +14,9 @@
#ifndef lint
#if SMTP
-static char sccsid[] = "@(#)srvrsmtp.c 8.181 (Berkeley) 6/15/98 (with SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 8.187 (Berkeley) 10/23/1998 (with SMTP)";
#else
-static char sccsid[] = "@(#)srvrsmtp.c 8.181 (Berkeley) 6/15/98 (without SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 8.187 (Berkeley) 10/23/1998 (without SMTP)";
#endif
#endif /* not lint */
@@ -127,7 +127,7 @@ smtp(nullserver, e)
char *id;
volatile int nrcpts = 0; /* number of RCPT commands */
bool doublequeue;
- bool discard;
+ volatile bool discard;
volatile int badcommands = 0; /* count of bad commands */
volatile int nverifies = 0; /* count of VRFY/EXPN commands */
volatile int n_etrn = 0; /* count of ETRN commands */
@@ -163,7 +163,7 @@ smtp(nullserver, e)
/* check_relay may have set discard bit, save for later */
discard = bitset(EF_DISCARD, e->e_flags);
- setproctitle("server %s startup", CurSmtpClient);
+ sm_setproctitle(TRUE, "server %s startup", CurSmtpClient);
#if DAEMON
if (LogLevel > 11)
{
@@ -222,7 +222,7 @@ smtp(nullserver, e)
/* read the input line */
SmtpPhase = "server cmd read";
- setproctitle("server %s cmd read", CurSmtpClient);
+ sm_setproctitle(TRUE, "server %s cmd read", CurSmtpClient);
p = sfgets(inp, sizeof inp, InChannel, TimeOuts.to_nextcommand,
SmtpPhase);
@@ -243,15 +243,15 @@ smtp(nullserver, e)
CurSmtpClient);
/*
- ** If have not accepted mail (DATA), do not bounce
- ** bad addresses back to sender.
+ ** If have not accepted mail (DATA), do not bounce
+ ** bad addresses back to sender.
*/
if (bitset(EF_CLRQUEUE, e->e_flags))
e->e_sendqueue = NULL;
if (InChild)
ExitStat = EX_QUIT;
- finis();
+ finis(TRUE, ExitStat);
}
/* clean up end of line */
@@ -267,9 +267,9 @@ smtp(nullserver, e)
inp);
if (e->e_id == NULL)
- setproctitle("%s: %.80s", CurSmtpClient, inp);
+ sm_setproctitle(TRUE, "%s: %.80s", CurSmtpClient, inp);
else
- setproctitle("%s %s: %.80s", e->e_id, CurSmtpClient, inp);
+ sm_setproctitle(TRUE, "%s %s: %.80s", e->e_id, CurSmtpClient, inp);
/* break off command */
for (p = inp; isascii(*p) && isspace(*p); p++)
@@ -457,7 +457,7 @@ smtp(nullserver, e)
{
errno = 0;
syserr("503 Nested MAIL command: MAIL %s", p);
- finis();
+ finis(TRUE, ExitStat);
}
/* make sure we know who the sending host is */
@@ -498,7 +498,7 @@ smtp(nullserver, e)
goto undo_subproc_no_pm;
nrcpts = 0;
e->e_flags |= EF_LOGSENDER|EF_CLRQUEUE;
- setproctitle("%s %s: %.80s", e->e_id, CurSmtpClient, inp);
+ sm_setproctitle(TRUE, "%s %s: %.80s", e->e_id, CurSmtpClient, inp);
/* child -- go do the processing */
if (setjmp(TopFrame) > 0)
@@ -512,7 +512,7 @@ smtp(nullserver, e)
QuickAbort = FALSE;
SuprErrs = TRUE;
e->e_flags &= ~EF_FATALERRS;
- finis();
+ finis(TRUE, ExitStat);
}
break;
}
@@ -633,8 +633,14 @@ smtp(nullserver, e)
if (p == NULL)
break;
a = parseaddr(p, NULLADDR, RF_COPYALL, ' ', &delimptr, e);
- if (a == NULL || Errors > 0)
+ if (Errors > 0)
+ break;
+ if (a == NULL)
+ {
+ usrerr("501 Missing recipient");
break;
+ }
+
if (delimptr != NULL && *delimptr != '\0')
*delimptr++ = '\0';
@@ -808,8 +814,6 @@ smtp(nullserver, e)
if (!shouldqueue(e->e_msgpriority, e->e_ctime))
{
- extern pid_t dowork __P((char *, bool, bool, ENVELOPE *));
-
unlockqueue(e);
(void) dowork(id, TRUE, TRUE, e);
}
@@ -818,7 +822,7 @@ smtp(nullserver, e)
abortmessage:
/* if in a child, pop back to our parent */
if (InChild)
- finis();
+ finis(TRUE, ExitStat);
/* clean up a bit */
gotmail = FALSE;
@@ -837,7 +841,7 @@ smtp(nullserver, e)
e->e_sendqueue = NULL;
e->e_flags |= EF_CLRQUEUE;
if (InChild)
- finis();
+ finis(TRUE, ExitStat);
/* clean up a bit */
gotmail = FALSE;
@@ -916,7 +920,7 @@ smtp(nullserver, e)
vrfyqueue = vrfyqueue->q_next;
}
if (InChild)
- finis();
+ finis(TRUE, ExitStat);
break;
case CMDETRN: /* etrn -- force queue flush */
@@ -992,7 +996,7 @@ doquit:
sm_syslog(LOG_INFO, NULL,
"Null connection from %.100s",
CurSmtpClient);
- finis();
+ finis(TRUE, ExitStat);
case CMDVERB: /* set verbose mode */
if (bitset(PRIV_NOEXPN, PrivacyFlags) ||
@@ -1417,7 +1421,7 @@ runinchild(label, e)
auto int st;
/* parent -- wait for child to complete */
- setproctitle("server %s child wait", CurSmtpClient);
+ sm_setproctitle(TRUE, "server %s child wait", CurSmtpClient);
st = waitfor(childpid);
if (st == -1)
syserr("451 %s: lost child", label);
@@ -1429,7 +1433,7 @@ runinchild(label, e)
if (WEXITSTATUS(st) == EX_QUIT)
{
disconnect(1, e);
- finis();
+ finis(TRUE, ExitStat);
}
/* restore the child signal */
@@ -1447,10 +1451,6 @@ runinchild(label, e)
(void) releasesignal(SIGCHLD);
}
}
-
- /* open alias database */
- initmaps(FALSE, e);
-
return (0);
}
diff --git a/contrib/sendmail/src/stab.c b/contrib/sendmail/src/stab.c
index 1ffc7cb..37b87a3 100644
--- a/contrib/sendmail/src/stab.c
+++ b/contrib/sendmail/src/stab.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)stab.c 8.19 (Berkeley) 5/19/98";
+static char sccsid[] = "@(#)stab.c 8.19 (Berkeley) 5/19/1998";
#endif /* not lint */
# include "sendmail.h"
diff --git a/contrib/sendmail/src/stats.c b/contrib/sendmail/src/stats.c
index 767a55e..b1162ff 100644
--- a/contrib/sendmail/src/stats.c
+++ b/contrib/sendmail/src/stats.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)stats.c 8.22 (Berkeley) 5/19/98";
+static char sccsid[] = "@(#)stats.c 8.22 (Berkeley) 5/19/1998";
#endif /* not lint */
# include "sendmail.h"
diff --git a/contrib/sendmail/src/sysexits.c b/contrib/sendmail/src/sysexits.c
index 10d7c85..c7934c7 100644
--- a/contrib/sendmail/src/sysexits.c
+++ b/contrib/sendmail/src/sysexits.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)sysexits.c 8.13 (Berkeley) 5/24/98";
+static char sccsid[] = "@(#)sysexits.c 8.13 (Berkeley) 5/24/1998";
#endif /* not lint */
#include "sendmail.h"
diff --git a/contrib/sendmail/src/trace.c b/contrib/sendmail/src/trace.c
index 5ff9795..5ab6032 100644
--- a/contrib/sendmail/src/trace.c
+++ b/contrib/sendmail/src/trace.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)trace.c 8.12 (Berkeley) 5/19/98";
+static char sccsid[] = "@(#)trace.c 8.12 (Berkeley) 5/19/1998";
#endif /* not lint */
# include "sendmail.h"
diff --git a/contrib/sendmail/src/udb.c b/contrib/sendmail/src/udb.c
index e7f42af..a279aff 100644
--- a/contrib/sendmail/src/udb.c
+++ b/contrib/sendmail/src/udb.c
@@ -14,9 +14,9 @@
#ifndef lint
#if USERDB
-static char sccsid [] = "@(#)udb.c 8.66 (Berkeley) 6/18/98 (with USERDB)";
+static char sccsid [] = "@(#)udb.c 8.70 (Berkeley) 12/21/1998 (with USERDB)";
#else
-static char sccsid [] = "@(#)udb.c 8.66 (Berkeley) 6/18/98 (without USERDB)";
+static char sccsid [] = "@(#)udb.c 8.70 (Berkeley) 12/21/1998 (without USERDB)";
#endif
#endif
@@ -49,6 +49,7 @@ struct udbent
{
char *udb_spec; /* string version of spec */
int udb_type; /* type of entry */
+ pid_t udb_pid; /* PID of process which opened db */
char *udb_default; /* default host for outgoing mail */
union
{
@@ -91,7 +92,7 @@ struct udbent
#define MAXUDBENT 10 /* maximum number of UDB entries */
-struct option
+struct udb_option
{
char *name;
char *val;
@@ -140,6 +141,7 @@ udbexpand(a, sendq, aliaslevel, e)
register struct udbent *up;
int keylen;
int naddrs;
+ char *user;
char keybuf[MAXKEY];
bzero(&key, sizeof key);
@@ -164,20 +166,24 @@ udbexpand(a, sendq, aliaslevel, e)
if (UdbSpec == NULL || UdbSpec[0] == '\0')
return EX_OK;
+ /* extract user to do userdb matching on */
+ user = a->q_user;
+
/* short circuit name begins with '\\' since it can't possibly match */
- if (a->q_user[0] == '\\')
+ /* (might want to treat this as unquoted instead) */
+ if (user[0] == '\\')
return EX_OK;
/* if name is too long, assume it won't match */
- if (strlen(a->q_user) > (SIZE_T) sizeof keybuf - 12)
+ if (strlen(user) > (SIZE_T) sizeof keybuf - 12)
return EX_OK;
/* if name begins with a colon, it indicates our metadata */
- if (a->q_user[0] == ':')
+ if (user[0] == ':')
return EX_OK;
/* build actual database key */
- (void) strcpy(keybuf, a->q_user);
+ (void) strcpy(keybuf, user);
(void) strcat(keybuf, ":maildrop");
keylen = strlen(keybuf);
@@ -222,8 +228,13 @@ udbexpand(a, sendq, aliaslevel, e)
#else
i = 0;
if (dbc == NULL &&
+# if DB_VERSION_MAJOR > 2 || DB_VERSION_MINOR >=6
+ (errno = (*up->udb_dbp->cursor)(up->udb_dbp,
+ NULL, &dbc, 0)) != 0)
+# else
(errno = (*up->udb_dbp->cursor)(up->udb_dbp,
NULL, &dbc)) != 0)
+# endif
i = -1;
if (i != 0 || dbc == NULL ||
(errno = dbc->c_get(dbc, &key,
@@ -892,8 +903,8 @@ _udbx_init(e)
register struct hostent *h;
char *mxhosts[MAXMXHOSTS + 1];
# endif
- struct option opts[MAXUDBOPTS + 1];
- extern int _udb_parsespec __P((char *, struct option [], int));
+ struct udb_option opts[MAXUDBOPTS + 1];
+ extern int _udb_parsespec __P((char *, struct udb_option [], int));
while (*p == ' ' || *p == '\t' || *p == ',')
p++;
@@ -972,6 +983,7 @@ _udbx_init(e)
if (h == NULL)
continue;
up->udb_type = UDB_REMOTE;
+ up->udb_pid = getpid();
up->udb_addr.sin_family = h->h_addrtype;
bcopy(h->h_addr_list[0],
(char *) &up->udb_addr.sin_addr,
@@ -993,6 +1005,7 @@ _udbx_init(e)
case '@': /* forward to remote host */
up->udb_type = UDB_FORWARD;
+ up->udb_pid = getpid();
up->udb_fwdhost = spec + 1;
ents++;
up++;
@@ -1004,6 +1017,7 @@ _udbx_init(e)
if (strcasecmp(spec, "hesiod") != 0)
goto badspec;
up->udb_type = UDB_HESIOD;
+ up->udb_pid = getpid();
ents++;
up++;
break;
@@ -1066,7 +1080,17 @@ _udbx_init(e)
free(up->udb_dbname);
break;
}
+ if (tTd(28, 1))
+ {
+#if DB_VERSION_MAJOR < 2
+ printf("_udbx_init: dbopen(%s)\n",
+#else
+ printf("_udbx_init: db_open(%s)\n",
+#endif
+ up->udb_dbname);
+ }
up->udb_type = UDB_DBFETCH;
+ up->udb_pid = getpid();
ents++;
up++;
break;
@@ -1138,6 +1162,15 @@ badspec:
#else
errno = (*up->udb_dbp->close)(up->udb_dbp, 0);
#endif
+ if (tTd(28, 1))
+ {
+#if DB_VERSION_MAJOR < 2
+ printf("_udbx_init: db->close(%s)\n",
+#else
+ printf("_udbx_init: db->close(%s)\n",
+#endif
+ up->udb_dbname);
+ }
}
}
#endif
@@ -1147,7 +1180,7 @@ badspec:
int
_udb_parsespec(udbspec, opt, maxopts)
char *udbspec;
- struct option opt[];
+ struct udb_option opt[];
int maxopts;
{
register char *spec;
@@ -1173,6 +1206,52 @@ _udb_parsespec(udbspec, opt, maxopts)
}
return optnum;
}
+ /*
+** _UDBX_CLOSE -- close all file based UDB entries.
+**
+** Parameters:
+** none
+**
+** Returns:
+** none
+*/
+void
+_udbx_close()
+{
+ pid_t pid;
+ struct udbent *up;
+
+ if (!UdbInitialized)
+ return;
+
+ pid = getpid();
+
+ for (up = UdbEnts; up->udb_type != UDB_EOLIST; up++)
+ {
+ if (up->udb_pid != pid)
+ continue;
+
+#ifdef NEWDB
+ if (up->udb_type == UDB_DBFETCH)
+ {
+#if DB_VERSION_MAJOR < 2
+ (*up->udb_dbp->close)(up->udb_dbp);
+#else
+ errno = (*up->udb_dbp->close)(up->udb_dbp, 0);
+#endif
+ }
+ if (tTd(28, 1))
+ {
+#if DB_VERSION_MAJOR < 2
+ printf("_udbx_init: db->close(%s)\n",
+#else
+ printf("_udbx_init: db->close(%s)\n",
+#endif
+ up->udb_dbname);
+ }
+#endif
+ }
+}
#ifdef HESIOD
diff --git a/contrib/sendmail/src/useful.h b/contrib/sendmail/src/useful.h
index 2a283ab..a19dd9e 100644
--- a/contrib/sendmail/src/useful.h
+++ b/contrib/sendmail/src/useful.h
@@ -9,7 +9,7 @@
* the sendmail distribution.
*
*
- * @(#)useful.h 8.12 (Berkeley) 5/19/98
+ * @(#)useful.h 8.12 (Berkeley) 5/19/1998
*/
# include <sys/types.h>
diff --git a/contrib/sendmail/src/usersmtp.c b/contrib/sendmail/src/usersmtp.c
index 23e4d02..99ea646 100644
--- a/contrib/sendmail/src/usersmtp.c
+++ b/contrib/sendmail/src/usersmtp.c
@@ -14,9 +14,9 @@
#ifndef lint
#if SMTP
-static char sccsid[] = "@(#)usersmtp.c 8.104 (Berkeley) 6/30/98 (with SMTP)";
+static char sccsid[] = "@(#)usersmtp.c 8.108 (Berkeley) 10/6/1998 (with SMTP)";
#else
-static char sccsid[] = "@(#)usersmtp.c 8.104 (Berkeley) 6/30/98 (without SMTP)";
+static char sccsid[] = "@(#)usersmtp.c 8.108 (Berkeley) 10/6/1998 (without SMTP)";
#endif
#endif /* not lint */
@@ -118,7 +118,7 @@ smtpinit(m, mci, e)
*/
SmtpPhase = mci->mci_phase = "client greeting";
- setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
+ sm_setproctitle(TRUE, "%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
r = reply(m, mci, e, TimeOuts.to_initial, esmtp_check);
if (r < 0)
goto tempfail1;
@@ -151,7 +151,7 @@ tryhelo:
smtpmessage("HELO %s", m, mci, MyHostName);
SmtpPhase = mci->mci_phase = "client HELO";
}
- setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
+ sm_setproctitle(TRUE, "%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
r = reply(m, mci, e, TimeOuts.to_helo, helo_options);
if (r < 0)
goto tempfail1;
@@ -439,7 +439,7 @@ smtpmailfrom(m, mci, e)
*bufp == '@' ? ',' : ':', bufp, optbuf);
}
SmtpPhase = mci->mci_phase = "client MAIL";
- setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
+ sm_setproctitle(TRUE, "%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
r = reply(m, mci, e, TimeOuts.to_mail, NULL);
if (r < 0)
{
@@ -580,7 +580,7 @@ smtprcpt(to, m, mci, e)
smtpmessage("RCPT To:<%s>%s", m, mci, to->q_user, optbuf);
SmtpPhase = mci->mci_phase = "client RCPT";
- setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
+ sm_setproctitle(TRUE, "%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
r = reply(m, mci, e, TimeOuts.to_rcpt, NULL);
to->q_rstatus = newstr(SmtpReplyBuffer);
to->q_status = smtptodsn(r);
@@ -661,7 +661,7 @@ smtpdata(m, mci, e)
/* send the command and check ok to proceed */
smtpmessage("DATA", m, mci);
SmtpPhase = mci->mci_phase = "client DATA 354";
- setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
+ sm_setproctitle(TRUE, "%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
r = reply(m, mci, e, TimeOuts.to_datainit, NULL);
if (r < 0 || REPLYTYPE(r) == 4)
{
@@ -741,7 +741,7 @@ smtpdata(m, mci, e)
/* check for the results of the transaction */
SmtpPhase = mci->mci_phase = "client DATA status";
- setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
+ sm_setproctitle(TRUE, "%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
if (bitnset(M_LMTP, m->m_flags))
return EX_OK;
r = reply(m, mci, e, TimeOuts.to_datafinal, NULL);
@@ -974,7 +974,6 @@ reply(m, mci, e, timeout, pfunc)
for (;;)
{
register char *p;
- extern time_t curtime __P((void));
/* actually do the read */
if (e->e_xfp != NULL)
@@ -1008,7 +1007,10 @@ reply(m, mci, e, timeout, pfunc)
oldholderrs = HoldErrs;
HoldErrs = TRUE;
usrerr("451 reply: read error from %s", CurHostName);
- mci_setstat(mci, EX_TEMPFAIL, "4.4.2", MsgBuf);
+
+ /* errors on QUIT should not be persistent */
+ if (strncmp(SmtpMsgBuffer, "QUIT", 4) != 0)
+ mci_setstat(mci, EX_TEMPFAIL, "4.4.2", MsgBuf);
/* if debugging, pause so we can see state */
if (tTd(18, 100))
@@ -1032,7 +1034,8 @@ reply(m, mci, e, timeout, pfunc)
wbufleft -= plen;
}
snprintf(p, wbufleft, "reply(%.100s) during %s",
- CurHostName, SmtpPhase);
+ CurHostName == NULL ? "NO_HOST" : CurHostName,
+ SmtpPhase);
checkfd012(wbuf);
}
#endif
diff --git a/contrib/sendmail/src/util.c b/contrib/sendmail/src/util.c
index ba35dcd..785d362 100644
--- a/contrib/sendmail/src/util.c
+++ b/contrib/sendmail/src/util.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)util.c 8.159 (Berkeley) 7/1/98";
+static char sccsid[] = "@(#)util.c 8.167 (Berkeley) 12/1/1998";
#endif /* not lint */
# include "sendmail.h"
@@ -174,6 +174,182 @@ rfc822_string(s)
return TRUE;
}
/*
+** SHORTEN_RFC822_STRING -- Truncate and rebalance an RFC822 string
+**
+** Arbitratily shorten (in place) an RFC822 string and rebalance
+** comments and quotes.
+**
+** Parameters:
+** string -- the string to shorten
+** length -- the maximum size, 0 if no maximum
+**
+** Returns:
+** TRUE if string is changed, FALSE otherwise
+**
+** Side Effects:
+** Changes string in place, possibly resulting
+** in a shorter string.
+*/
+
+bool
+shorten_rfc822_string(string, length)
+ char *string;
+ size_t length;
+{
+ bool backslash = FALSE;
+ bool modified = FALSE;
+ bool quoted = FALSE;
+ size_t slen;
+ int parencount = 0;
+ char *ptr = string;
+
+ /*
+ ** If have to rebalance an already short enough string,
+ ** need to do it within allocated space.
+ */
+ slen = strlen(string);
+ if (length == 0 || slen < length)
+ length = slen;
+
+ while (*ptr != '\0')
+ {
+ if (backslash)
+ {
+ backslash = FALSE;
+ goto increment;
+ }
+
+ if (*ptr == '\\')
+ backslash = TRUE;
+ else if (*ptr == '(')
+ {
+ if (!quoted)
+ parencount++;
+ }
+ else if (*ptr == ')')
+ {
+ if (--parencount < 0)
+ parencount = 0;
+ }
+
+ /* Inside a comment, quotes don't matter */
+ if (parencount <= 0 && *ptr == '"')
+ quoted = !quoted;
+
+increment:
+ /* Check for sufficient space for next character */
+ if (length - (ptr - string) <= ((backslash ? 1 : 0) +
+ parencount +
+ (quoted ? 1 : 0)))
+ {
+ /* Not enough, backtrack */
+ if (*ptr == '\\')
+ backslash = FALSE;
+ else if (*ptr == '(' && !quoted)
+ parencount--;
+ else if (*ptr == '"' && parencount == 0)
+ quoted = FALSE;
+ break;
+ }
+ ptr++;
+ }
+
+ /* Rebalance */
+ while (parencount-- > 0)
+ {
+ if (*ptr != ')')
+ {
+ modified = TRUE;
+ *ptr = ')';
+ }
+ ptr++;
+ }
+ if (quoted)
+ {
+ if (*ptr != '"')
+ {
+ modified = TRUE;
+ *ptr = '"';
+ }
+ ptr++;
+ }
+ if (*ptr != '\0')
+ {
+ modified = TRUE;
+ *ptr = '\0';
+ }
+ return modified;
+}
+ /*
+** FIND_CHARACTER -- find an unquoted character in an RFC822 string
+**
+** Find an unquoted, non-commented character in an RFC822
+** string and return a pointer to its location in the
+** string.
+**
+** Parameters:
+** string -- the string to search
+** character -- the character to find
+**
+** Returns:
+** pointer to the character, or
+** a pointer to the end of the line if character is not found
+*/
+
+char *
+find_character(string, character)
+ char *string;
+ char character;
+{
+ bool backslash = FALSE;
+ bool quoted = FALSE;
+ int parencount = 0;
+
+ while (string != NULL && *string != '\0')
+ {
+ if (backslash)
+ {
+ backslash = FALSE;
+ if (!quoted && character == '\\' && *string == '\\')
+ break;
+ string++;
+ continue;
+ }
+ switch (*string)
+ {
+ case '\\':
+ backslash = TRUE;
+ break;
+
+ case '(':
+ if (!quoted)
+ parencount++;
+ break;
+
+ case ')':
+ if (--parencount < 0)
+ parencount = 0;
+ break;
+ }
+
+ /* Inside a comment, nothing matters */
+ if (parencount > 0)
+ {
+ string++;
+ continue;
+ }
+
+ if (*string == '"')
+ quoted = !quoted;
+ else if (*string == character && !quoted)
+ break;
+ string++;
+ }
+
+ /* Return pointer to the character */
+ return string;
+}
+ /*
** XALLOC -- Allocate memory and bitch wildly on failure.
**
** THIS IS A CLUDGE. This should be made to give a proper
@@ -1846,7 +2022,13 @@ path_is_dir(pathname, createflag)
** none
*/
-static pid_t *ProcListVec = NULL;
+struct procs
+{
+ pid_t proc_pid;
+ char *proc_task;
+};
+
+static struct procs *ProcListVec = NULL;
static int ProcListSize = 0;
#define NO_PID ((pid_t) 0)
@@ -1855,15 +2037,15 @@ static int ProcListSize = 0;
#endif
void
-proc_list_add(pid)
+proc_list_add(pid, task)
pid_t pid;
+ char *task;
{
int i;
- extern void proc_list_probe __P((void));
for (i = 0; i < ProcListSize; i++)
{
- if (ProcListVec[i] == NO_PID)
+ if (ProcListVec[i].proc_pid == NO_PID)
break;
}
if (i >= ProcListSize)
@@ -1874,29 +2056,66 @@ proc_list_add(pid)
/* now scan again */
for (i = 0; i < ProcListSize; i++)
{
- if (ProcListVec[i] == NO_PID)
+ if (ProcListVec[i].proc_pid == NO_PID)
break;
}
}
if (i >= ProcListSize)
{
/* grow process list */
- pid_t *npv;
+ struct procs *npv;
- npv = (pid_t *) xalloc(sizeof (pid_t) * (ProcListSize + PROC_LIST_SEG));
+ npv = (struct procs *) xalloc(sizeof (struct procs) * (ProcListSize + PROC_LIST_SEG));
if (ProcListSize > 0)
{
- bcopy(ProcListVec, npv, ProcListSize * sizeof (pid_t));
+ bcopy(ProcListVec, npv, ProcListSize *
+ sizeof (struct procs));
free(ProcListVec);
}
for (i = ProcListSize; i < ProcListSize + PROC_LIST_SEG; i++)
- npv[i] = NO_PID;
+ {
+ npv[i].proc_pid = NO_PID;
+ npv[i].proc_task = NULL;
+ }
i = ProcListSize;
ProcListSize += PROC_LIST_SEG;
ProcListVec = npv;
}
- ProcListVec[i] = pid;
- CurChildren++;
+ ProcListVec[i].proc_pid = pid;
+ ProcListVec[i].proc_task = newstr(task);
+
+ /* if process adding itself, it's not a child */
+ if (pid != getpid())
+ CurChildren++;
+}
+ /*
+** PROC_LIST_SET -- set pid task in process list
+**
+** Parameters:
+** pid -- pid to set
+** task -- task of pid
+**
+** Returns:
+** none.
+*/
+
+void
+proc_list_set(pid, task)
+ pid_t pid;
+ char *task;
+{
+ int i;
+
+ for (i = 0; i < ProcListSize; i++)
+ {
+ if (ProcListVec[i].proc_pid == pid)
+ {
+ if (ProcListVec[i].proc_task != NULL)
+ free(ProcListVec[i].proc_task);
+ ProcListVec[i].proc_task = newstr(task);
+ break;
+ }
+ }
}
/*
** PROC_LIST_DROP -- drop pid from process list
@@ -1916,9 +2135,14 @@ proc_list_drop(pid)
for (i = 0; i < ProcListSize; i++)
{
- if (ProcListVec[i] == pid)
+ if (ProcListVec[i].proc_pid == pid)
{
- ProcListVec[i] = NO_PID;
+ ProcListVec[i].proc_pid = NO_PID;
+ if (ProcListVec[i].proc_task != NULL)
+ {
+ free(ProcListVec[i].proc_task);
+ ProcListVec[i].proc_task = NULL;
+ }
break;
}
}
@@ -1940,8 +2164,16 @@ proc_list_clear()
{
int i;
- for (i = 0; i < ProcListSize; i++)
- ProcListVec[i] = NO_PID;
+ /* start from 1 since 0 is the daemon itself */
+ for (i = 1; i < ProcListSize; i++)
+ {
+ ProcListVec[i].proc_pid = NO_PID;
+ if (ProcListVec[i].proc_task != NULL)
+ {
+ free(ProcListVec[i].proc_task);
+ ProcListVec[i].proc_task = NULL;
+ }
+ }
CurChildren = 0;
}
/*
@@ -1959,17 +2191,23 @@ proc_list_probe()
{
int i;
- for (i = 0; i < ProcListSize; i++)
+ /* start from 1 since 0 is the daemon itself */
+ for (i = 1; i < ProcListSize; i++)
{
- if (ProcListVec[i] == NO_PID)
+ if (ProcListVec[i].proc_pid == NO_PID)
continue;
- if (kill(ProcListVec[i], 0) < 0)
+ if (kill(ProcListVec[i].proc_pid, 0) < 0)
{
if (LogLevel > 3)
sm_syslog(LOG_DEBUG, CurEnv->e_id,
"proc_list_probe: lost pid %d",
- ProcListVec[i]);
- ProcListVec[i] = NO_PID;
+ (int) ProcListVec[i].proc_pid);
+ ProcListVec[i].proc_pid = NO_PID;
+ if (ProcListVec[i].proc_task != NULL)
+ {
+ free(ProcListVec[i].proc_task);
+ ProcListVec[i].proc_task = NULL;
+ }
CurChildren--;
}
}
@@ -1977,6 +2215,35 @@ proc_list_probe()
CurChildren = 0;
}
/*
+** PROC_LIST_DISPLAY -- display the process list
+**
+** Parameters:
+** out -- output file pointer
+**
+** Returns:
+** none.
+*/
+
+void
+proc_list_display(out)
+ FILE *out;
+{
+ int i;
+
+ for (i = 0; i < ProcListSize; i++)
+ {
+ if (ProcListVec[i].proc_pid == NO_PID)
+ continue;
+
+ fprintf(out, "%d %s%s\n", (int) ProcListVec[i].proc_pid,
+ ProcListVec[i].proc_task != NULL ?
+ ProcListVec[i].proc_task : "(unknown)",
+ (OpMode == MD_SMTP ||
+ OpMode == MD_DAEMON ||
+ OpMode == MD_ARPAFTP) ? "\r" : "");
+ }
+}
+ /*
** SM_STRCASECMP -- 8-bit clean version of strcasecmp
**
** Thank you, vendors, for making this all necessary.
diff --git a/contrib/sendmail/src/version.c b/contrib/sendmail/src/version.c
index bf0b391..8e8707b 100644
--- a/contrib/sendmail/src/version.c
+++ b/contrib/sendmail/src/version.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)version.c 8.9.1.1 (Berkeley) 7/2/98";
+static char sccsid[] = "@(#)version.c 8.9.2.1 (Berkeley) 12/29/1998";
#endif /* not lint */
-char Version[] = "8.9.1";
+char Version[] = "8.9.2";
OpenPOWER on IntegriCloud