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
commit2a7bd60222ce3c09208a265ad3a5f1490ccb6768 (patch)
tree8d45e99e5e320ab4e55408b355a04b2be475a0ed /contrib/sendmail/src
parent329949050501501c130d09efc3aee7c78c6d4f9c (diff)
downloadFreeBSD-src-2a7bd60222ce3c09208a265ad3a5f1490ccb6768.zip
FreeBSD-src-2a7bd60222ce3c09208a265ad3a5f1490ccb6768.tar.gz
Import sendmail-8.9.2 onto vendor branch (update from 8.9.1)
Obtained from: ftp.sendamil.org
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/aliases.52
-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/conf.c265
-rw-r--r--contrib/sendmail/src/conf.h97
-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/err.c2
-rw-r--r--contrib/sendmail/src/headers.c125
-rw-r--r--contrib/sendmail/src/ldap_map.h4
-rw-r--r--contrib/sendmail/src/macro.c6
-rw-r--r--contrib/sendmail/src/mailq.12
-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/mci.c12
-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/savemail.c5
-rw-r--r--contrib/sendmail/src/sendmail.87
-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
48 files changed, 1870 insertions, 423 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/aliases.5 b/contrib/sendmail/src/aliases.5
index 8c73ac3..bf45838 100644
--- a/contrib/sendmail/src/aliases.5
+++ b/contrib/sendmail/src/aliases.5
@@ -8,7 +8,7 @@
.\" the sendmail distribution.
.\"
.\"
-.\" @(#)aliases.5 8.8 (Berkeley) 5/19/98
+.\" @(#)aliases.5 8.8 (Berkeley) 5/19/1998
.\"
.Dd May 19, 1998
.Dt ALIASES 5
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/conf.c b/contrib/sendmail/src/conf.c
index 838cd17..2668f9f 100644
--- a/contrib/sendmail/src/conf.c
+++ b/contrib/sendmail/src/conf.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)conf.c 8.431 (Berkeley) 6/25/98";
+static char sccsid[] = "@(#)conf.c 8.450 (Berkeley) 12/17/1998";
#endif /* not lint */
# include "sendmail.h"
@@ -217,7 +217,6 @@ setdefaults(e)
int i;
struct passwd *pw;
char buf[MAXNAME];
- extern void inittimeouts __P((char *));
extern void setdefuser __P((void));
extern void setupmaps __P((void));
extern void setupmailers __P((void));
@@ -247,7 +246,7 @@ setdefaults(e)
DefGid = 1; /* option g */
setdefuser();
}
- TrustedFileUid = 0;
+ TrustedUid = 0;
if (tTd(37, 4))
printf("setdefaults: DefUser=%s, DefUid=%d, DefGid=%d\n",
DefUser != NULL ? DefUser : "<1:1>",
@@ -292,6 +291,7 @@ setdefaults(e)
#ifdef HESIOD_INIT
HesiodContext = NULL;
#endif
+ ControlSocketName = NULL;
setupmaps();
setupmailers();
setupheaders();
@@ -324,7 +324,6 @@ void
setupmailers()
{
char buf[100];
- extern void makemailer __P((char *));
strcpy(buf, "prog, P=/bin/sh, F=lsoDq9, T=DNS/RFC822/X-Unix, A=sh -c \201u");
makemailer(buf);
@@ -838,6 +837,14 @@ switch_map_find(service, maptype, mapreturn)
*p++ = '\0';
if (buf[0] == '\0')
continue;
+ if (p == NULL)
+ {
+ sm_syslog(LOG_ERR, NOQID,
+ "Bad line on %.100s: %.100s",
+ ServiceSwitchFile,
+ buf);
+ continue;
+ }
while (isspace(*p))
p++;
if (*p == '\0')
@@ -1280,10 +1287,10 @@ init_md(argc, argv)
#endif
#ifdef __QNX__
/*
- ** Due to QNX's network distributed nature, you can target a tcpip
- ** stack on a different node in the qnx network; this patch lets
- ** this feature work. The __sock_locate() must be done before the
- ** environment is clear.
+ ** Due to QNX's network distributed nature, you can target a tcpip
+ ** stack on a different node in the qnx network; this patch lets
+ ** this feature work. The __sock_locate() must be done before the
+ ** environment is clear.
*/
__sock_locate();
#endif
@@ -2047,7 +2054,7 @@ refuseconnections(port)
else if (conncnt++ > ConnRateThrottle && ConnRateThrottle > 0)
{
/* sleep to flatten out connection load */
- setproctitle("deferring connections on port %d: %d per second",
+ sm_setproctitle(TRUE, "deferring connections on port %d: %d per second",
port, ConnRateThrottle);
if (LogLevel >= 14)
sm_syslog(LOG_INFO, NOQID,
@@ -2059,7 +2066,7 @@ refuseconnections(port)
CurrentLA = getla();
if (CurrentLA >= refusela)
{
- setproctitle("rejecting connections on port %d: load average: %d",
+ sm_setproctitle(TRUE, "rejecting connections on port %d: load average: %d",
port, CurrentLA);
if (LogLevel >= 14)
sm_syslog(LOG_INFO, NOQID,
@@ -2070,7 +2077,7 @@ refuseconnections(port)
if (!enoughdiskspace(MinBlocksFree + 1))
{
- setproctitle("rejecting connections on port %d: min free: %d",
+ sm_setproctitle(TRUE, "rejecting connections on port %d: min free: %d",
port, MinBlocksFree);
if (LogLevel >= 14)
sm_syslog(LOG_INFO, NOQID,
@@ -2081,12 +2088,10 @@ refuseconnections(port)
if (MaxChildren > 0 && CurChildren >= MaxChildren)
{
- extern void proc_list_probe __P((void));
-
proc_list_probe();
if (CurChildren >= MaxChildren)
{
- setproctitle("rejecting connections on port %d: %d children, max %d",
+ sm_setproctitle(TRUE, "rejecting connections on port %d: %d children, max %d",
port, CurChildren, MaxChildren);
if (LogLevel >= 14)
sm_syslog(LOG_INFO, NOQID,
@@ -2170,12 +2175,12 @@ typedef unsigned int *pt_entry_t;
# define SPT_PADCHAR ' '
# endif
+#endif /* SPT_TYPE != SPT_NONE && SPT_TYPE != SPT_BUILTIN */
+
# ifndef SPT_BUFSIZE
# define SPT_BUFSIZE MAXLINE
# endif
-#endif /* SPT_TYPE != SPT_NONE && SPT_TYPE != SPT_BUILTIN */
-
/*
** Pointers for setproctitle.
** This allows "ps" listings to give more useful information.
@@ -2320,6 +2325,44 @@ setproctitle(fmt, va_alist)
#endif /* SPT_TYPE != SPT_BUILTIN */
/*
+** SM_SETPROCTITLE -- set process task and set process title for ps
+**
+** Possibly set process status and call setproctitle() to
+** change the ps display.
+**
+** Parameters:
+** status -- whether or not to store as process status
+** fmt -- a printf style format string.
+** a, b, c -- possible parameters to fmt.
+**
+** Returns:
+** none.
+*/
+
+/*VARARGS2*/
+void
+# ifdef __STDC__
+sm_setproctitle(bool status, const char *fmt, ...)
+# else
+sm_setproctitle(status, fmt, va_alist)
+ bool status;
+ const char *fmt;
+ va_dcl
+#endif
+{
+ char buf[SPT_BUFSIZE];
+
+ VA_LOCAL_DECL
+ /* print the argument string */
+ VA_START(fmt);
+ (void) vsnprintf(buf, SPT_BUFSIZE, fmt, ap);
+ VA_END;
+
+ if (status)
+ proc_list_set(getpid(), buf);
+ setproctitle("%s", buf);
+}
+ /*
** WAITFOR -- wait for a particular process id.
**
** Parameters:
@@ -2789,8 +2832,8 @@ dgux_inet_addr(host)
/*
-** this version hacked to add `atend' flag to allow state machine
-** to reset if invoked by the program to scan args for a 2nd time
+** this version hacked to add `atend' flag to allow state machine
+** to reset if invoked by the program to scan args for a 2nd time
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -2962,7 +3005,7 @@ char *DefaultUserShells[] =
"/bin/bsh", /* Bourne shell */
"/usr/bin/bsh",
#endif
-#ifdef __svr4__
+#if defined(__svr4__) || defined(__svr5__)
"/bin/ksh", /* Korn shell */
"/usr/bin/ksh",
#endif
@@ -3665,9 +3708,63 @@ setvendor(vendor)
}
#endif
+#if defined(VENDOR_NAME) && defined(VENDOR_CODE)
+ if (strcasecmp(vendor, VENDOR_NAME) == 0)
+ {
+ VendorCode = VENDOR_CODE;
+ return TRUE;
+ }
+#endif
+
return FALSE;
}
/*
+** GETVENDOR -- return vendor name based on vendor code
+**
+** Parameters:
+** vendorcode -- numeric representation of vendor.
+**
+** Returns:
+** string containing vendor name.
+*/
+
+char *
+getvendor(vendorcode)
+ int vendorcode;
+{
+#if defined(VENDOR_NAME) && defined(VENDOR_CODE)
+ /*
+ ** Can't have the same switch case twice so need to
+ ** handle VENDOR_CODE outside of switch. It might
+ ** match one of the existing VENDOR_* codes.
+ */
+
+ if (vendorcode == VENDOR_CODE)
+ return VENDOR_NAME;
+#endif
+
+ switch (vendorcode)
+ {
+ case VENDOR_BERKELEY:
+ return "Berkeley";
+
+ case VENDOR_SUN:
+ return "Sun";
+
+ case VENDOR_HP:
+ return "HP";
+
+ case VENDOR_IBM:
+ return "IBM";
+
+ case VENDOR_SENDMAIL:
+ return "Sendmail";
+
+ default:
+ return "Unknown";
+ }
+}
+ /*
** VENDOR_PRE_DEFAULTS, VENDOR_POST_DEFAULTS -- set vendor-specific defaults
**
** Vendor_pre_defaults is called before reading the configuration
@@ -3730,7 +3827,7 @@ vendor_daemon_setup(e)
if (getluid() != -1)
{
usrerr("Daemon cannot have LUID");
- exit(EX_USAGE);
+ finis(FALSE, EX_USAGE);
}
#endif /* SECUREWARE */
}
@@ -4173,11 +4270,88 @@ secureware_setup_secure(uid)
rc, uid);
break;
}
- exit(EX_NOPERM);
+ finis(FALSE, EX_NOPERM);
}
}
#endif /* SECUREWARE */
/*
+** ADD_LOCAL_HOST_NAMES -- Add a hostname to class 'w' based on IP address
+**
+** Add hostnames to class 'w' based on the IP address read from
+** the network interface.
+**
+** Parameters:
+** sa -- a pointer to a SOCKADDR containing the address
+**
+** Returns:
+** 0 if successful, -1 if host lookup fails.
+*/
+
+int
+add_hostnames(sa)
+ SOCKADDR *sa;
+{
+ struct hostent *hp;
+
+ /* lookup name with IP address */
+ switch (sa->sa.sa_family)
+ {
+ case AF_INET:
+ hp = sm_gethostbyaddr((char *) &sa->sin.sin_addr,
+ sizeof(sa->sin.sin_addr), sa->sa.sa_family);
+ break;
+
+ default:
+#if _FFR_LOG_UNSUPPORTED_FAMILIES
+ /* XXX: Give warning about unsupported family */
+ if (LogLevel > 3)
+ sm_syslog(LOG_WARNING, NOQID,
+ "Unsupported address family %d: %.100s",
+ sa->sa.sa_family, anynet_ntoa(sa));
+#endif
+ return -1;
+ }
+
+ if (hp == NULL)
+ {
+ int save_errno = errno;
+
+ if (LogLevel > 3)
+ sm_syslog(LOG_WARNING, NOQID,
+ "gethostbyaddr(%.100s) failed: %d\n",
+ anynet_ntoa(sa),
+#if NAMED_BIND
+ h_errno
+#else
+ -1
+#endif
+ );
+ errno = save_errno;
+ return -1;
+ }
+
+ /* save its cname */
+ if (!wordinclass((char *) hp->h_name, 'w'))
+ {
+ setclass('w', (char *) hp->h_name);
+ if (tTd(0, 4))
+ printf("\ta.k.a.: %s\n", hp->h_name);
+ }
+
+ /* save all it aliases name */
+ while (*hp->h_aliases)
+ {
+ if (!wordinclass(*hp->h_aliases, 'w'))
+ {
+ setclass('w', *hp->h_aliases);
+ if (tTd(0, 4))
+ printf("\ta.k.a.: %s\n", *hp->h_aliases);
+ }
+ hp->h_aliases++;
+ }
+ return 0;
+}
+ /*
** LOAD_IF_NAMES -- load interface-specific names into $=w
**
** Parameters:
@@ -4254,9 +4428,8 @@ load_if_names()
for (i = 0; i < ifc.ifc_len; )
{
struct ifreq *ifr = (struct ifreq *) &ifc.ifc_buf[i];
- struct sockaddr *sa = &ifr->ifr_addr;
+ SOCKADDR *sa = (SOCKADDR *) &ifr->ifr_addr;
struct in_addr ia;
- struct hostent *hp;
#ifdef SIOCGIFFLAGS
struct ifreq ifrf;
#endif
@@ -4264,14 +4437,14 @@ load_if_names()
extern char *inet_ntoa();
#ifdef BSD4_4_SOCKADDR
- if (sa->sa_len > sizeof ifr->ifr_addr)
- i += sizeof ifr->ifr_name + sa->sa_len;
+ if (sa->sa.sa_len > sizeof ifr->ifr_addr)
+ i += sizeof ifr->ifr_name + sa->sa.sa_len;
else
#endif
i += sizeof *ifr;
if (tTd(0, 20))
- printf("%s\n", anynet_ntoa((SOCKADDR *) sa));
+ printf("%s\n", anynet_ntoa(sa));
if (ifr->ifr_addr.sa_family != AF_INET)
continue;
@@ -4290,7 +4463,7 @@ load_if_names()
continue;
/* extract IP address from the list*/
- ia = (((struct sockaddr_in *) sa)->sin_addr);
+ ia = sa->sin.sin_addr;
if (ia.s_addr == INADDR_ANY || ia.s_addr == INADDR_NONE)
{
message("WARNING: interface %s is UP with %s address",
@@ -4313,41 +4486,7 @@ load_if_names()
if (bitset(IFF_LOOPBACK, IFRFREF.ifr_flags))
continue;
- /* lookup name with IP address */
- hp = sm_gethostbyaddr((char *) &ia, sizeof(ia), AF_INET);
- if (hp == NULL)
- {
- if (LogLevel > 3)
- sm_syslog(LOG_WARNING, NOQID,
- "gethostbyaddr(%.100s) failed: %d\n",
- inet_ntoa(ia),
-#if NAMED_BIND
- h_errno);
-#else
- -1);
-#endif
- continue;
- }
-
- /* save its cname */
- if (!wordinclass((char *) hp->h_name, 'w'))
- {
- setclass('w', (char *) hp->h_name);
- if (tTd(0, 4))
- printf("\ta.k.a.: %s\n", hp->h_name);
- }
-
- /* save all it aliases name */
- while (*hp->h_aliases)
- {
- if (!wordinclass(*hp->h_aliases, 'w'))
- {
- setclass('w', *hp->h_aliases);
- if (tTd(0, 4))
- printf("\ta.k.a.: %s\n", *hp->h_aliases);
- }
- hp->h_aliases++;
- }
+ (void) add_hostnames(sa);
}
free(ifc.ifc_buf);
close(s);
@@ -4412,7 +4551,7 @@ sm_syslog(level, id, fmt, va_alist)
extern int SyslogErrno;
extern char *DoprEnd;
VA_LOCAL_DECL
- extern void sm_dopr __P((char *, const char *, ...));
+ extern void sm_dopr __P((char *, const char *, va_list));
SyslogErrno = errno;
if (id == NULL)
diff --git a/contrib/sendmail/src/conf.h b/contrib/sendmail/src/conf.h
index fd14d5a..b9cdc68 100644
--- a/contrib/sendmail/src/conf.h
+++ b/contrib/sendmail/src/conf.h
@@ -9,7 +9,7 @@
* the sendmail distribution.
*
*
- * @(#)conf.h 8.372 (Berkeley) 6/4/98
+ * @(#)conf.h 8.380 (Berkeley) 11/9/1998
*/
/*
@@ -64,6 +64,11 @@ struct rusage; /* forward declaration to get gcc to shut up in wait.h */
# define MACBUFSIZE 4096 /* max expanded macro buffer size */
# define TOBUFSIZE 512 /* max buffer to hold address list */
# define MAXSHORTSTR 203 /* max short string length */
+# if _FFR_MAX_MIME_HEADER_LENGTH
+# define MAXMACNAMELEN 25 /* max macro name length */
+# else
+# define MAXMACNAMELEN 20 /* max macro name length */
+# endif
/**********************************************************************
** Compilation options.
@@ -344,12 +349,12 @@ typedef int pid_t;
# define GIDSET_T gid_t
# define SFS_TYPE SFS_4ARGS /* four argument statfs() call */
# define SFS_BAVAIL f_bfree /* alternate field name */
+# define SYSLOG_BUFSIZE 512
# ifdef IRIX6
# define STAT64 1
# define QUAD_T unsigned long long
# define LA_TYPE LA_IRIX6 /* figure out at run time */
# define SAFENFSPATHCONF 0 /* pathconf(2) lies on NFS filesystems */
-# define SYSLOG_BUFSIZE 512
# else
# define LA_TYPE LA_INT
@@ -674,6 +679,41 @@ typedef int pid_t;
#endif
+/*
+** Apple Rhapsody
+** Contributed by Wilfredo Sanchez <wsanchez@apple.com>
+*/
+
+#ifdef __APPLE__
+# define HASFCHMOD 1 /* has fchmod(2) syscall */
+# define HASFLOCK 1 /* has flock(2) syscall */
+# define HASUNAME 1 /* has uname(2) syscall */
+# define HASUNSETENV 1
+# define HASSETSID 1 /* has the setsid(2) POSIX syscall */
+# define HASINITGROUPS 1
+# define HASSETVBUF 1
+# define HASSETREUID 1
+# define USESETEUID 1 /* has useable seteuid(2) call */
+# define HASLSTAT 1
+# define HASSETRLIMIT 1
+# define HASWAITPID 1
+# define HASSTRERROR 1 /* has strerror(3) */
+# define HASSNPRINTF 1 /* has snprintf(3) and vsnprintf(3) */
+# define USESTRERROR 1 /* has strerror(3) */
+# define HASGETDTABLESIZE 1
+# define HASGETUSERSHELL 1
+# define NEEDGETOPT 1 /* need a replacement for getopt(3) */
+# define BSD4_4_SOCKADDR /* has sa_len */
+# define NETLINK 1 /* supports AF_LINK */
+# define HAS_ST_GEN 1 /* has st_gen field in stat struct */
+# define GIDSET_T gid_t
+# define LA_TYPE LA_SUBR /* use getloadavg(3) */
+# define SFS_TYPE SFS_MOUNT /* use <sys/mount.h> statfs() impl */
+# define SPT_TYPE SPT_PSSTRINGS
+# define SPT_PADCHAR '\0' /* pad process title with nulls */
+# define ERRLIST_PREDEFINED /* don't declare sys_errlist */
+#endif
+
/*
** 4.4 BSD
@@ -814,12 +854,15 @@ typedef int pid_t;
# endif
# if defined(__FreeBSD__)
# undef SPT_TYPE
-# if __FreeBSD__ == 2
-# include <osreldate.h> /* and this works */
-# if __FreeBSD_version >= 199512 /* 2.2-current right now */
+# if __FreeBSD__ >= 2
+# include <osreldate.h>
+# if __FreeBSD_version >= 199512 /* 2.2-current when it appeared */
# include <libutil.h>
# define SPT_TYPE SPT_BUILTIN
# endif
+# if __FreeBSD_version >= 222000 /* 2.2.2-release and later */
+# define HASSETUSERCONTEXT 1 /* BSDI-style login classes */
+# endif
# endif
# ifndef SPT_TYPE
# define SPT_TYPE SPT_REUSEARGV
@@ -1216,9 +1259,9 @@ extern void *malloc();
** Florian La Roche <rzsfl@rz.uni-sb.de>
** Karl London <karl@borg.demon.co.uk>
**
-** Last compiled against: [06/10/96 @ 09:21:40 PM (Monday)]
-** sendmail 8.8-a4 named bind-4.9.4-T4B db-1.85
-** gcc 2.7.2 libc-5.3.12 linux 2.0.0
+** Last compiled against: [07/21/98 @ 11:47:34 AM (Tuesday)]
+** sendmail 8.9.1 bind-8.1.2 db-2.4.14
+** gcc-2.8.1 glibc-2.0.94 linux-2.1.109
**
** NOTE: Override HASFLOCK as you will but, as of 1.99.6, mixed-style
** file locking is no longer allowed. In particular, make sure
@@ -1228,6 +1271,7 @@ extern void *malloc();
#ifdef __linux__
# define BSD 1 /* include BSD defines */
+# define USESETEUID 0 /* Have it due to POSIX, but doesn't work */
# define NEEDGETOPT 1 /* need a replacement for getopt(3) */
# define HASUNAME 1 /* use System V uname(2) system call */
# define HASUNSETENV 1 /* has unsetenv(3) call */
@@ -1255,7 +1299,7 @@ extern void *malloc();
# ifndef _PATH_SENDMAILPID
# define _PATH_SENDMAILPID "/var/run/sendmail.pid"
# endif
-# define TZ_TYPE TZ_TNAME
+# define TZ_TYPE TZ_TZNAME
# include <sys/sysmacros.h>
# undef atol /* wounded in <stdlib.h> */
#endif
@@ -1484,6 +1528,37 @@ typedef int pid_t;
# endif
#endif
+/*
+** System V Rel 5.x (a.k.a Unixware7 w/o BSD-Compatiblity Libs ie. native)
+**
+** Contributed by Paul Gampe <paulg@apnic.net>
+*/
+
+#ifdef __svr5__
+# include <sys/mkdev.h>
+# define __svr4__
+# define SYS5SIGNALS 1
+# define HASSETSID 1
+# define HASSETREUID 1
+# define HASWAITPID 1
+# define HASGETDTABLESIZE 1
+# define GIDSET_T gid_t
+# define SOCKADDR_LEN_T size_t
+# define SOCKOPT_LEN_T size_t
+# ifndef _PATH_UNIX
+# define _PATH_UNIX "/stand/unix"
+# endif
+# define SPT_PADCHAR '\0' /* pad process title with nulls */
+# define SYSLOG_BUFSIZE 1024 /* unsure */
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/etc/sendmail.cf"
+# endif
+# ifndef _PATH_SENDMAILPID
+# define _PATH_SENDMAILPID "/etc/sendmail.pid"
+# endif
+#endif
+
+/* ###################################################################### */
/*
** UnixWare 2.x
@@ -1516,7 +1591,9 @@ typedef int pid_t;
# define LA_TYPE LA_ZERO
# undef WIFEXITED
# undef WEXITSTATUS
-# define _PATH_UNIX "/unix"
+# ifndef _PATH_UNIX
+# define _PATH_UNIX "/unix"
+# endif
# ifndef _PATH_VENDOR_CF
# define _PATH_VENDOR_CF "/usr/ucblib/sendmail.cf"
# endif
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/err.c b/contrib/sendmail/src/err.c
index 0661395..1a875a2 100644
--- a/contrib/sendmail/src/err.c
+++ b/contrib/sendmail/src/err.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)err.c 8.74 (Berkeley) 6/4/98";
+static char sccsid[] = "@(#)err.c 8.74 (Berkeley) 6/4/1998";
#endif /* not lint */
# include "sendmail.h"
diff --git a/contrib/sendmail/src/headers.c b/contrib/sendmail/src/headers.c
index a04f59e..fcf1d9c 100644
--- a/contrib/sendmail/src/headers.c
+++ b/contrib/sendmail/src/headers.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)headers.c 8.127 (Berkeley) 6/4/98";
+static char sccsid[] = "@(#)headers.c 8.134 (Berkeley) 11/29/1998";
#endif /* not lint */
# include <errno.h>
@@ -521,8 +521,8 @@ eatheader(e, full)
#if 0
/*
- ** Change functionality so a fatal error on an
- ** address doesn't affect the entire envelope.
+ ** Change functionality so a fatal error on an
+ ** address doesn't affect the entire envelope.
*/
/* delete fatal errors generated by this address */
@@ -1198,6 +1198,59 @@ putheader(mci, hdr, e)
xputs(p);
}
+#if _FFR_MAX_MIME_HEADER_LENGTH
+ /* heuristic shortening of MIME fields to avoid MUA overflows */
+ if (MaxMimeFieldLength > 0 &&
+ wordinclass(h->h_field,
+ macid("{checkMIMEFieldHeaders}", NULL)))
+ {
+ extern bool fix_mime_header __P((char *));
+
+ if (fix_mime_header(h->h_value))
+ {
+ sm_syslog(LOG_ALERT, e->e_id,
+ "Truncated MIME %s header due to field size (possible attack)",
+ h->h_field);
+ if (tTd(34, 11))
+ printf(" truncated MIME %s header due to field size (possible attack)\n",
+ h->h_field);
+ }
+ }
+
+ if (MaxMimeHeaderLength > 0 &&
+ wordinclass(h->h_field,
+ macid("{checkMIMETextHeaders}", NULL)))
+ {
+ if (strlen(h->h_value) > MaxMimeHeaderLength)
+ {
+ h->h_value[MaxMimeHeaderLength - 1] = '\0';
+ sm_syslog(LOG_ALERT, e->e_id,
+ "Truncated long MIME %s header (possible attack)",
+ h->h_field);
+ if (tTd(34, 11))
+ printf(" truncated long MIME %s header (possible attack)\n",
+ h->h_field);
+ }
+ }
+
+ if (MaxMimeHeaderLength > 0 &&
+ wordinclass(h->h_field,
+ macid("{checkMIMEHeaders}", NULL)))
+ {
+ extern bool shorten_rfc822_string __P((char *, int));
+
+ if (shorten_rfc822_string(h->h_value, MaxMimeHeaderLength))
+ {
+ sm_syslog(LOG_ALERT, e->e_id,
+ "Truncated long MIME %s header (possible attack)",
+ h->h_field);
+ if (tTd(34, 11))
+ printf(" truncated long MIME %s header (possible attack)\n",
+ h->h_field);
+ }
+ }
+#endif
+
/* suppress Content-Transfer-Encoding: if we are MIMEing */
if (bitset(H_CTE, h->h_flags) &&
bitset(MCIF_CVT8TO7|MCIF_CVT7TO8|MCIF_INMIME, mci->mci_flags))
@@ -1568,3 +1621,69 @@ copyheader(header)
return ret;
}
+ /*
+** FIX_MIME_HEADER -- possibly truncate/rebalance parameters in a MIME header
+**
+** Run through all of the parameters of a MIME header and
+** possibly truncate and rebalance the parameter according
+** to MaxMimeFieldLength.
+**
+** Parameters:
+** string -- the full header
+**
+** Returns:
+** TRUE if the header was modified, FALSE otherwise
+**
+** Side Effects:
+** string modified in place
+*/
+
+bool
+fix_mime_header(string)
+ char *string;
+{
+ bool modified = FALSE;
+ char *begin = string;
+ char *end;
+ extern char *find_character __P((char *, char));
+ extern bool shorten_rfc822_string __P((char *, int));
+
+ if (string == NULL || *string == '\0')
+ return FALSE;
+
+ /* Split on each ';' */
+ while ((end = find_character(begin, ';')) != NULL)
+ {
+ char save = *end;
+ char *bp;
+
+ *end = '\0';
+
+ /* Shorten individual parameter */
+ if (shorten_rfc822_string(begin, MaxMimeFieldLength))
+ modified = TRUE;
+
+ /* Collapse the possibly shortened string with rest */
+ bp = begin + strlen(begin);
+ if (bp != end)
+ {
+ char *ep = end;
+
+ *end = save;
+ end = bp;
+
+ /* copy character by character due to overlap */
+ while (*ep != '\0')
+ *bp++ = *ep++;
+ *bp = '\0';
+ }
+ else
+ *end = save;
+ if (*end == '\0')
+ break;
+
+ /* Move past ';' */
+ begin = end + 1;
+ }
+ return modified;
+}
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/mailq.1 b/contrib/sendmail/src/mailq.1
index fa1d0d5..8b6e63a 100644
--- a/contrib/sendmail/src/mailq.1
+++ b/contrib/sendmail/src/mailq.1
@@ -8,7 +8,7 @@
.\" the sendmail distribution.
.\"
.\"
-.\" @(#)mailq.1 8.10 (Berkeley) 5/19/98
+.\" @(#)mailq.1 8.10 (Berkeley) 5/19/1998
.\"
.Dd May 19, 1998
.Dt MAILQ 1
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/mci.c b/contrib/sendmail/src/mci.c
index efb8cba..41649a2 100644
--- a/contrib/sendmail/src/mci.c
+++ b/contrib/sendmail/src/mci.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)mci.c 8.82 (Berkeley) 6/15/98";
+static char sccsid[] = "@(#)mci.c 8.83 (Berkeley) 10/13/1998";
#endif /* not lint */
#include "sendmail.h"
@@ -503,7 +503,7 @@ mci_dump_all(logit)
mci_dump(MciCache[i], logit);
}
/*
-** MCI_LOCK_HOST -- Lock host while sending.
+** MCI_LOCK_HOST -- Lock host while sending.
**
** If we are contacting a host, we'll need to
** update the status information in the host status
@@ -643,7 +643,7 @@ mci_unlock_host(mci)
errno = saveErrno;
}
/*
-** MCI_LOAD_PERSISTENT -- load persistent host info
+** MCI_LOAD_PERSISTENT -- load persistent host info
**
** Load information about host that is kept
** in common for all running sendmails.
@@ -1016,8 +1016,8 @@ mci_traverse_persistent(action, pathname)
*hostptr = '\0';
/*
- ** Do something with the file containing the persistent
- ** information.
+ ** Do something with the file containing the persistent
+ ** information.
*/
ret = (*action)(pathname, host);
}
@@ -1167,7 +1167,7 @@ mci_purge_persistent(pathname, hostname)
return 0;
}
/*
-** MCI_GENERATE_PERSISTENT_PATH -- generate path from hostname
+** MCI_GENERATE_PERSISTENT_PATH -- generate path from hostname
**
** Given `host', convert from a.b.c to $QueueDir/.hoststat/c./b./a,
** putting the result into `path'. if `createflag' is set, intervening
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/savemail.c b/contrib/sendmail/src/savemail.c
index 4fbfd67..f15c8de 100644
--- a/contrib/sendmail/src/savemail.c
+++ b/contrib/sendmail/src/savemail.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)savemail.c 8.138 (Berkeley) 6/17/98";
+static char sccsid[] = "@(#)savemail.c 8.139 (Berkeley) 8/5/1998";
#endif /* not lint */
# include "sendmail.h"
@@ -91,8 +91,7 @@ savemail(e, sendbody)
RF_COPYPARSE|RF_SENDERADDR, '\0', NULL, e) == NULL)
{
syserr("553 Cannot parse Postmaster!");
- ExitStat = EX_SOFTWARE;
- finis();
+ finis(TRUE, EX_SOFTWARE);
}
}
e->e_to = NULL;
diff --git a/contrib/sendmail/src/sendmail.8 b/contrib/sendmail/src/sendmail.8
index 5105e83..093b6e6 100644
--- a/contrib/sendmail/src/sendmail.8
+++ b/contrib/sendmail/src/sendmail.8
@@ -8,9 +8,9 @@
.\" the sendmail distribution.
.\"
.\"
-.\" @(#)sendmail.8 8.19 (Berkeley) 5/19/98
+.\" @(#)sendmail.8 8.20 (Berkeley) 8/2/1998
.\"
-.Dd May 19, 1998
+.Dd August 2, 1998
.Dt SENDMAIL 8
.Os BSD 4
.Sh NAME
@@ -277,6 +277,9 @@ Log all traffic in and out of mailers in the indicated log file.
This should only be used as a last resort
for debugging mailer bugs.
It will log a lot of data very quickly.
+.It Fl -
+Stop processing command flags and use the rest of the arguments
+as addresses.
.El
.Ss Options
There are also a number of processing options that may be set.
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