summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail
diff options
context:
space:
mode:
authorgshapiro <gshapiro@FreeBSD.org>2006-03-22 16:45:56 +0000
committergshapiro <gshapiro@FreeBSD.org>2006-03-22 16:45:56 +0000
commita393d787927121cf30504364496d75df64982b05 (patch)
tree0975b5f8e840cd5028a5c1969d0ef38c559335ad /contrib/sendmail
parent7ec7c93b1895442f91f42eb78a2c77ca31b7b8d8 (diff)
downloadFreeBSD-src-a393d787927121cf30504364496d75df64982b05.zip
FreeBSD-src-a393d787927121cf30504364496d75df64982b05.tar.gz
Resolve conflicts from sendmail 8.13.6 import
Diffstat (limited to 'contrib/sendmail')
-rw-r--r--contrib/sendmail/src/conf.c140
-rw-r--r--contrib/sendmail/src/conf.h56
-rw-r--r--contrib/sendmail/src/headers.c69
-rw-r--r--contrib/sendmail/src/mci.c13
-rw-r--r--contrib/sendmail/src/savemail.c263
5 files changed, 365 insertions, 176 deletions
diff --git a/contrib/sendmail/src/conf.c b/contrib/sendmail/src/conf.c
index 381ca0a..573cd1d 100644
--- a/contrib/sendmail/src/conf.c
+++ b/contrib/sendmail/src/conf.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993
@@ -14,13 +14,21 @@
#include <sendmail.h>
-SM_RCSID("@(#)$Id: conf.c,v 8.1061 2005/03/07 17:18:44 ca Exp $")
+SM_RCSID("@(#)$Id: conf.c,v 8.1081 2006/02/24 02:21:53 ca Exp $")
#include <sendmail/pathnames.h>
#if NEWDB
# include "sm/bdb.h"
#endif /* NEWDB */
+#ifdef DEC
+# if NETINET6
+/* for the IPv6 device lookup */
+# define _SOCKADDR_LEN
+# include <macros.h>
+# endif /* NETINET6 */
+#endif /* DEC */
+
# include <sys/ioctl.h>
# include <sys/param.h>
@@ -345,6 +353,7 @@ setdefaults(e)
MaxMimeFieldLength = MaxMimeHeaderLength / 2;
MaxForwardEntries = 0;
FastSplit = 1;
+ MaxNOOPCommands = MAXNOOPCOMMANDS;
#if SASL
AuthMechanisms = newstr(AUTH_MECHANISMS);
AuthRealm = NULL;
@@ -2175,10 +2184,25 @@ shouldqueue(pri, ct)
time_t ct;
{
bool rval;
+#if _FFR_MEMSTAT
+ long memfree;
+#endif /* _FFR_MEMSTAT */
if (tTd(3, 30))
sm_dprintf("shouldqueue: CurrentLA=%d, pri=%ld: ",
CurrentLA, pri);
+
+#if _FFR_MEMSTAT
+ if (QueueLowMem > 0 &&
+ sm_memstat_get(MemoryResource, &memfree) >= 0 &&
+ memfree < QueueLowMem)
+ {
+ if (tTd(3, 30))
+ sm_dprintf("true (memfree=%ld < QueueLowMem)\n",
+ memfree, QueueLowMem);
+ return true;
+ }
+#endif /* _FFR_MEMSTAT */
if (CurrentLA < QueueLA)
{
if (tTd(3, 30))
@@ -2227,6 +2251,9 @@ refuseconnections(name, e, d, active)
static int conncnt[MAXDAEMONS];
static time_t firstrejtime[MAXDAEMONS];
static time_t nextlogtime[MAXDAEMONS];
+#if _FFR_MEMSTAT
+ long memfree;
+#endif /* _FFR_MEMSTAT */
#if XLA
if (!xla_smtp_ok())
@@ -2263,6 +2290,19 @@ refuseconnections(name, e, d, active)
conncnt[d] = 0;
}
+
+#if _FFR_MEMSTAT
+ if (RefuseLowMem > 0 &&
+ sm_memstat_get(MemoryResource, &memfree) >= 0 &&
+ memfree < RefuseLowMem)
+ {
+# define R_MSG_LM "rejecting connections on daemon %s: free memory: %ld"
+ sm_setproctitle(true, e, R_MSG_LM, name, memfree);
+ if (LogLevel > 8)
+ sm_syslog(LOG_NOTICE, NOQID, R_MSG_LM, name, memfree);
+ return true;
+ }
+#endif /* _FFR_MEMSTAT */
sm_getla();
if (RefuseLA > 0 && CurrentLA >= RefuseLA)
{
@@ -3732,7 +3772,7 @@ chownsafe(fd, safedir)
#if HASSETRLIMIT
# ifdef RLIMIT_NEEDS_SYS_TIME_H
-# include <sys/time.h>
+# include <sm/time.h>
# endif /* RLIMIT_NEEDS_SYS_TIME_H */
# include <sys/resource.h>
#endif /* HASSETRLIMIT */
@@ -3794,6 +3834,13 @@ setvendor(vendor)
return true;
}
#endif /* SUN_EXTENSIONS */
+#ifdef DEC
+ if (sm_strcasecmp(vendor, "Digital") == 0)
+ {
+ VendorCode = VENDOR_DEC;
+ return true;
+ }
+#endif /* DEC */
#if defined(VENDOR_NAME) && defined(VENDOR_CODE)
if (sm_strcasecmp(vendor, VENDOR_NAME) == 0)
@@ -3885,8 +3932,8 @@ vendor_pre_defaults(e)
** /etc/mail/sendmail.cf without this
*/
- setuserenv("ISP", NULL);
- setuserenv("SYSTYPE", NULL);
+ sm_setuserenv("ISP", NULL);
+ sm_setuserenv("SYSTYPE", NULL);
#endif /* apollo */
}
@@ -3900,7 +3947,7 @@ vendor_post_defaults(e)
/* Makes sure the SOCK environment variable remains */
if (p = getextenv("SOCK"))
- setuserenv("SOCK", p);
+ sm_setuserenv("SOCK", p);
#endif /* __QNX__ */
#if defined(SUN_EXTENSIONS) && defined(SUN_DEFAULT_VALUES)
sun_post_defaults(e);
@@ -4676,7 +4723,7 @@ add_hostnames(sa)
struct rtentry;
struct mbuf;
# ifndef SUNOS403
-# include <sys/time.h>
+# include <sm/time.h>
# endif /* ! SUNOS403 */
# if (_AIX4 >= 40300) && !defined(_NET_IF_H)
# undef __P
@@ -4817,7 +4864,13 @@ load_if_names()
i += sizeof ifr->lifr_name + sa->sa.sa_len;
else
# endif /* BSD4_4_SOCKADDR */
+# ifdef DEC
+ /* fix for IPv6 size differences */
+ i += sizeof ifr->ifr_name +
+ max(sizeof(ifr->ifr_addr), ifr->ifr_addr.sa_len);
+# else /* DEC */
i += sizeof *ifr;
+# endif /* DEC */
if (tTd(0, 20))
sm_dprintf("%s\n", anynet_ntoa(sa));
@@ -5310,8 +5363,8 @@ sm_syslog(level, id, fmt, va_alist)
va_dcl
#endif /* __STDC__ */
{
- static char *buf = NULL;
- static size_t bufsize;
+ char *buf;
+ size_t bufsize;
char *begin, *end;
int save_errno;
int seq = 1;
@@ -5335,11 +5388,8 @@ sm_syslog(level, id, fmt, va_alist)
else
idlen = strlen(id) + SyslogPrefixLen;
- if (buf == NULL)
- {
- buf = buf0;
- bufsize = sizeof buf0;
- }
+ buf = buf0;
+ bufsize = sizeof buf0;
for (;;)
{
@@ -5381,8 +5431,8 @@ sm_syslog(level, id, fmt, va_alist)
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: %s\n", id, newstring);
#endif /* LOG */
- if (buf == buf0)
- buf = NULL;
+ if (buf != buf0)
+ sm_free(buf);
errno = save_errno;
return;
}
@@ -5446,8 +5496,8 @@ sm_syslog(level, id, fmt, va_alist)
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s[%d]: %s\n", id, seq, begin);
#endif /* LOG */
- if (buf == buf0)
- buf = NULL;
+ if (buf != buf0)
+ sm_free(buf);
errno = save_errno;
}
/*
@@ -5657,6 +5707,9 @@ char *CompileOptions[] =
#if LDAPMAP
"LDAPMAP",
#endif /* LDAPMAP */
+#if LDAP_REFERRALS
+ "LDAP_REFERRALS",
+#endif /* LDAP_REFERRALS */
#if LOG
"LOG",
#endif /* LOG */
@@ -6047,6 +6100,10 @@ char *FFRCompileOptions[] =
/* What it says :-) */
"_FFR_DEPRECATE_MAILER_FLAG_I",
#endif /* _FFR_DEPRECATE_MAILER_FLAG_I */
+#if _FFR_DM_ONE
+ /* deliver first TA in background, then queue */
+ "_FFR_DM_ONE",
+#endif /* _FFR_DM_ONE */
#if _FFR_DIGUNIX_SAFECHOWN
/* Properly set SAFECHOWN (include/sm/conf.h) for Digital UNIX */
/* Problem noted by Anne Bennett of Concordia University */
@@ -6110,6 +6167,10 @@ char *FFRCompileOptions[] =
/* Generate a ORCPT DSN arg if not already provided */
"_FFR_GEN_ORCPT",
#endif /* _FFR_GEN_ORCPT */
+#if _FFR_LOG_GREET_PAUSE
+ /* log time for greet_pause delay; from Nik Clayton */
+ "_FFR_LOG_GREET_PAUSE",
+#endif /* _FFR_LOG_GREET_PAUSE */
#if _FFR_GROUPREADABLEAUTHINFOFILE
/* Allow group readable DefaultAuthInfo file. */
"_FFR_GROUPREADABLEAUTHINFOFILE",
@@ -6159,10 +6220,22 @@ char *FFRCompileOptions[] =
/* Randall S. Winchester of the University of Maryland */
"_FFR_MAX_FORWARD_ENTRIES",
#endif /* _FFR_MAX_FORWARD_ENTRIES */
+#if _FFR_MAXKEY
+ /* increase key size for LDAP lookups, see conf.h */
+ "_FFR_MAXKEY",
+#endif /* _FFR_MAXKEY */
+#if _FFR_MAXNOOPCOMMANDS
+ /* runtime option for "MaxNOOPCommands" */
+ "_FFR_MAXNOOPCOMMANDS",
+#endif /* _FFR_MAXNOOPCOMMANDS */
#if _FFR_MAX_SLEEP_TIME
/* Limit sleep(2) time in libsm/clock.c */
"_FFR_MAX_SLEEP_TIME",
#endif /* _FFR_MAX_SLEEP_TIME */
+#if _FFR_MEMSTAT
+ /* Check free memory */
+ "_FFR_MEMSTAT",
+#endif /* _FFR_MEMSTAT */
#if _FFR_MILTER_NAGLE
/* milter: turn off Nagle ("cork" on Linux) */
/* John Gardiner Myers of Proofpoint */
@@ -6177,6 +6250,10 @@ char *FFRCompileOptions[] =
/* Old mime7to8 code, the new is broken for at least one example. */
"_FFR_MIME7TO8_OLD",
#endif /* _FFR_MAX_SLEEP_TIME */
+#if _FFR_MSG_ACCEPT
+ /* allow to override "Message accepted for delivery" */
+ "_FFR_MSG_ACCEPT",
+#endif /* _FFR_MSG_ACCEPT */
#if _FFR_NODELAYDSN_ON_HOLD
/* Do not issue a DELAY DSN for mailers that use the hold flag. */
/* Steven Pitzl */
@@ -6192,9 +6269,9 @@ char *FFRCompileOptions[] =
#endif /* _FFR_LOG_NTRIES */
#if _FFR_PRIV_NOACTUALRECIPIENT
/*
- ** PrivacyOptions=noactualrecipient stops sendmail from putting
- ** X-Actual-Recipient lines in DSNs revealing the actual
- ** account that addresses map to. Patch from Dan Harkless.
+ ** PrivacyOptions=noactualrecipient stops sendmail from putting
+ ** X-Actual-Recipient lines in DSNs revealing the actual
+ ** account that addresses map to. Patch from Dan Harkless.
*/
"_FFR_PRIV_NOACTUALRECIPIENT",
@@ -6213,7 +6290,7 @@ char *FFRCompileOptions[] =
"_FFR_QUEUE_MACRO",
#endif /* _FFR_QUEUE_MACRO */
#if _FFR_QUEUE_RUN_PARANOIA
- /* Additional checks when doing queue runs. */
+ /* Additional checks when doing queue runs; interval of checks */
"_FFR_QUEUE_RUN_PARANOIA",
#endif /* _FFR_QUEUE_RUN_PARANOIA */
#if _FFR_QUEUE_SCHED_DBG
@@ -6245,6 +6322,25 @@ char *FFRCompileOptions[] =
/* Donated code (unused). */
"_FFR_SHM_STATUS",
#endif /* _FFR_SHM_STATUS */
+#if _FFR_LDAP_SINGLEDN
+ /*
+ ** The LDAP database map code in Sendmail 8.12.10, when
+ ** given the -1 switch, would match only a single DN,
+ ** but was able to return multiple attributes for that
+ ** DN. In Sendmail 8.13 this "bug" was corrected to
+ ** only return if exactly one attribute matched.
+ **
+ ** Unfortunately, our configuration uses the former
+ ** behaviour. Attached is a relatively simple patch
+ ** to 8.13.4 which adds a -2 switch (for lack of a
+ ** better option) which returns the single dn/multiple
+ ** attributes.
+ **
+ ** Jeffrey T. Eaton, Carnegie-Mellon University
+ */
+
+ "_FFR_LDAP_SINGLEDN",
+#endif /* _FFR_LDAP_SINGLEDN */
#if _FFR_SKIP_DOMAINS
/* process every N'th domain instead of every N'th message */
"_FFR_SKIP_DOMAINS",
diff --git a/contrib/sendmail/src/conf.h b/contrib/sendmail/src/conf.h
index 77577c4..ab23bca 100644
--- a/contrib/sendmail/src/conf.h
+++ b/contrib/sendmail/src/conf.h
@@ -10,7 +10,10 @@
* the sendmail distribution.
*
*
- * $Id: conf.h,v 8.567 2004/07/23 20:45:01 gshapiro Exp $
+ * $Id: conf.h,v 8.570 2005/12/09 18:37:27 ca Exp $
+ *
+ * $FreeBSD$
+ *
*/
/*
@@ -59,31 +62,40 @@ struct rusage; /* forward declaration to get gcc to shut up in wait.h */
** If you do, be careful, none should be set anywhere near INT_MAX
**********************************************************************/
-#define MAXLINE 2048 /* max line length */
-#define MAXNAME 256 /* max length of a name */
+#define MAXLINE 2048 /* max line length */
+#define MAXNAME 256 /* max length of a name */
#ifndef MAXAUTHINFO
-# define MAXAUTHINFO 100 /* max length of authinfo token */
+# define MAXAUTHINFO 100 /* max length of authinfo token */
#endif /* ! MAXAUTHINFO */
-#define MAXPV 256 /* max # of parms to mailers */
-#define MAXATOM 1000 /* max atoms per address */
-#define MAXRWSETS 200 /* max # of sets of rewriting rules */
-#define MAXPRIORITIES 25 /* max values for Precedence: field */
-#define MAXMXHOSTS 100 /* max # of MX records for one host */
-#define SMTPLINELIM 990 /* maximum SMTP line length */
-#define MAXKEY 128 /* maximum size of a database key */
-#define MEMCHUNKSIZE 1024 /* chunk size for memory allocation */
-#define MAXUSERENVIRON 100 /* max envars saved, must be >= 3 */
-#define MAXMAPSTACK 12 /* max # of stacked or sequenced maps */
+#define MAXPV 256 /* max # of parms to mailers */
+#define MAXATOM 1000 /* max atoms per address */
+#define MAXRWSETS 200 /* max # of sets of rewriting rules */
+#define MAXPRIORITIES 25 /* max values for Precedence: field */
+#define MAXMXHOSTS 100 /* max # of MX records for one host */
+#define SMTPLINELIM 990 /* max SMTP line length */
+#define MAXUDBKEY 128 /* max size of a database key (udb only) */
+#if _FFR_MAXKEY
+# define MAXKEY 1024 /* max size of a database key */
+#else /* _FFR_MAXKEY */
+# define MAXKEY (MAXNAME + 1) /* max size of a database key */
+#endif /* _FFR_MAXKEY */
+#define MEMCHUNKSIZE 1024 /* chunk size for memory allocation */
+#define MAXUSERENVIRON 100 /* max envars saved, must be >= 3 */
+#define MAXMAPSTACK 12 /* max # of stacked or sequenced maps */
#if MILTER
-# define MAXFILTERS 25 /* max # of milter filters */
-# define MAXFILTERMACROS 50 /* max # of macros per milter cmd */
+# define MAXFILTERS 25 /* max # of milter filters */
+# define MAXFILTERMACROS 50 /* max # of macros per milter cmd */
#endif /* MILTER */
-#define MAXSMTPARGS 20 /* max # of ESMTP args for MAIL/RCPT */
-#define MAXTOCLASS 8 /* max # of message timeout classes */
-#define MAXRESTOTYPES 3 /* max # of resolver timeout types */
-#define MAXMIMEARGS 20 /* max args in Content-Type: */
-#define MAXMIMENESTING 20 /* max MIME multipart nesting */
-#define QUEUESEGSIZE 1000 /* increment for queue size */
+#define MAXSMTPARGS 20 /* max # of ESMTP args for MAIL/RCPT */
+#define MAXTOCLASS 8 /* max # of message timeout classes */
+#define MAXRESTOTYPES 3 /* max # of resolver timeout types */
+#define MAXMIMEARGS 20 /* max args in Content-Type: */
+#define MAXMIMENESTING 20 /* max MIME multipart nesting */
+#define QUEUESEGSIZE 1000 /* increment for queue size */
+
+#ifndef MAXNOOPCOMMANDS
+# define MAXNOOPCOMMANDS 20 /* max "noise" commands before slowdown */
+#endif /* ! MAXNOOPCOMMANDS */
/*
** MAXQFNAME == 2 (size of "qf", "df" prefix)
diff --git a/contrib/sendmail/src/headers.c b/contrib/sendmail/src/headers.c
index ec0d376..0bd0c49 100644
--- a/contrib/sendmail/src/headers.c
+++ b/contrib/sendmail/src/headers.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1998-2004, 2006 Sendmail, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993
@@ -14,12 +14,12 @@
#include <sendmail.h>
-SM_RCSID("@(#)$Id: headers.c,v 8.287 2004/12/03 18:29:51 ca Exp $")
+SM_RCSID("@(#)$Id: headers.c,v 8.290 2006/02/25 02:16:52 ca Exp $")
static HDR *allocheader __P((char *, char *, int, SM_RPOOL_T *));
static size_t fix_mime_header __P((HDR *, ENVELOPE *));
static int priencode __P((char *));
-static void put_vanilla_header __P((HDR *, char *, MCI *));
+static bool put_vanilla_header __P((HDR *, char *, MCI *));
/*
** SETUPHEADERS -- initialize headers in symbol table
@@ -994,7 +994,6 @@ logsender(e, msgid)
char *name;
register char *sbp;
register char *p;
- int l;
char hbuf[MAXNAME + 1];
char sbuf[MAXLINE + 1];
char mbuf[MAXNAME + 1];
@@ -1003,6 +1002,8 @@ logsender(e, msgid)
/* XXX do we still need this? sm_syslog() replaces control chars */
if (msgid != NULL)
{
+ size_t l;
+
l = strlen(msgid);
if (l > sizeof mbuf - 1)
l = sizeof mbuf - 1;
@@ -1542,13 +1543,13 @@ crackaddr(addr, e)
** flags -- MIME conversion flags.
**
** Returns:
-** none.
+** success
**
** Side Effects:
** none.
*/
-void
+bool
putheader(mci, hdr, e, flags)
register MCI *mci;
HDR *hdr;
@@ -1683,7 +1684,8 @@ putheader(mci, hdr, e, flags)
{
if (tTd(34, 11))
sm_dprintf("\n");
- put_vanilla_header(h, p, mci);
+ if (!put_vanilla_header(h, p, mci))
+ goto writeerr;
continue;
}
@@ -1742,7 +1744,8 @@ putheader(mci, hdr, e, flags)
/* no other recipient headers: truncate value */
(void) sm_strlcpyn(obuf, sizeof obuf, 2,
h->h_field, ":");
- putline(obuf, mci);
+ if (!putline(obuf, mci))
+ goto writeerr;
}
continue;
}
@@ -1761,7 +1764,8 @@ putheader(mci, hdr, e, flags)
}
else
{
- put_vanilla_header(h, p, mci);
+ if (!put_vanilla_header(h, p, mci))
+ goto writeerr;
}
}
@@ -1778,18 +1782,25 @@ putheader(mci, hdr, e, flags)
!bitset(MCIF_CVT8TO7|MCIF_CVT7TO8|MCIF_INMIME, mci->mci_flags) &&
hvalue("MIME-Version", e->e_header) == NULL)
{
- putline("MIME-Version: 1.0", mci);
+ if (!putline("MIME-Version: 1.0", mci))
+ goto writeerr;
if (hvalue("Content-Type", e->e_header) == NULL)
{
(void) sm_snprintf(obuf, sizeof obuf,
"Content-Type: text/plain; charset=%s",
defcharset(e));
- putline(obuf, mci);
+ if (!putline(obuf, mci))
+ goto writeerr;
}
- if (hvalue("Content-Transfer-Encoding", e->e_header) == NULL)
- putline("Content-Transfer-Encoding: 8bit", mci);
+ if (hvalue("Content-Transfer-Encoding", e->e_header) == NULL
+ && !putline("Content-Transfer-Encoding: 8bit", mci))
+ goto writeerr;
}
#endif /* MIME8TO7 */
+ return true;
+
+ writeerr:
+ return false;
}
/*
** PUT_VANILLA_HEADER -- output a fairly ordinary header
@@ -1800,10 +1811,10 @@ putheader(mci, hdr, e, flags)
** mci -- the connection info for output
**
** Returns:
-** none.
+** success
*/
-static void
+static bool
put_vanilla_header(h, v, mci)
HDR *h;
char *v;
@@ -1834,7 +1845,8 @@ put_vanilla_header(h, v, mci)
l = SPACELEFT(obuf, obp) - 1;
(void) sm_snprintf(obp, SPACELEFT(obuf, obp), "%.*s", l, v);
- putxline(obuf, strlen(obuf), mci, putflags);
+ if (!putxline(obuf, strlen(obuf), mci, putflags))
+ goto writeerr;
v += l + 1;
obp = obuf;
if (*v != ' ' && *v != '\t')
@@ -1844,7 +1856,10 @@ put_vanilla_header(h, v, mci)
/* XXX This is broken for SPACELEFT()==0 */
(void) sm_snprintf(obp, SPACELEFT(obuf, obp), "%.*s",
(int) (SPACELEFT(obuf, obp) - 1), v);
- putxline(obuf, strlen(obuf), mci, putflags);
+ return putxline(obuf, strlen(obuf), mci, putflags);
+
+ writeerr:
+ return false;
}
/*
** COMMAIZE -- output a header field, making a comma-translated list.
@@ -1857,13 +1872,13 @@ put_vanilla_header(h, v, mci)
** e -- the envelope containing the message.
**
** Returns:
-** none.
+** success
**
** Side Effects:
** outputs "p" to file "fp".
*/
-void
+bool
commaize(h, p, oldstyle, mci, e)
register HDR *h;
register char *p;
@@ -2002,13 +2017,6 @@ commaize(h, p, oldstyle, mci, e)
}
name = denlstring(name, false, true);
- /*
- ** record data progress so DNS timeouts
- ** don't cause DATA timeouts
- */
-
- DataProgress = true;
-
/* output the name with nice formatting */
opos += strlen(name);
if (!firstone)
@@ -2016,7 +2024,8 @@ commaize(h, p, oldstyle, mci, e)
if (opos > omax && !firstone)
{
(void) sm_strlcpy(obp, ",\n", SPACELEFT(obuf, obp));
- putxline(obuf, strlen(obuf), mci, putflags);
+ if (!putxline(obuf, strlen(obuf), mci, putflags))
+ goto writeerr;
obp = obuf;
(void) sm_strlcpy(obp, " ", sizeof obuf);
opos = strlen(obp);
@@ -2038,8 +2047,12 @@ commaize(h, p, oldstyle, mci, e)
*obp = '\0';
else
obuf[sizeof obuf - 1] = '\0';
- putxline(obuf, strlen(obuf), mci, putflags);
+ return putxline(obuf, strlen(obuf), mci, putflags);
+
+ writeerr:
+ return false;
}
+
/*
** COPYHEADER -- copy header list
**
diff --git a/contrib/sendmail/src/mci.c b/contrib/sendmail/src/mci.c
index d3cbce6..dd07449 100644
--- a/contrib/sendmail/src/mci.c
+++ b/contrib/sendmail/src/mci.c
@@ -14,7 +14,7 @@
#include <sendmail.h>
-SM_RCSID("@(#)$Id: mci.c,v 8.214 2005/02/04 22:01:45 ca Exp $")
+SM_RCSID("@(#)$Id: mci.c,v 8.216 2005/07/12 22:27:44 ca Exp $")
#if NETINET || NETINET6
# include <arpa/inet.h>
@@ -48,11 +48,9 @@ static int mci_read_persistent __P((SM_FILE_T *, MCI *));
** MciCacheTimeout is the time (in seconds) that a connection
** is permitted to survive without activity.
**
-** We actually try any cached connections by sending a NOOP
-** before we use them; if the NOOP fails we close down the
-** connection and reopen it. Note that this means that a
-** server SMTP that doesn't support NOOP will hose the
-** algorithm -- but that doesn't seem too likely.
+** We actually try any cached connections by sending a RSET
+** before we use them; if the RSET fails we close down the
+** connection and reopen it (see smtpprobe()).
**
** The persistent MCI code is donated by Mark Lovell and Paul
** Vixie. It is based on the long term host status code in KJS
@@ -1127,6 +1125,9 @@ mci_traverse_persistent(action, pathname)
char *newptr;
struct dirent *e;
char newpath[MAXPATHLEN];
+#if MAXPATHLEN <= MAXNAMLEN - 3
+ ERROR "MAXPATHLEN <= MAXNAMLEN - 3"
+#endif /* MAXPATHLEN <= MAXNAMLEN - 3 */
if ((d = opendir(pathname)) == NULL)
{
diff --git a/contrib/sendmail/src/savemail.c b/contrib/sendmail/src/savemail.c
index 857d81f..66141df 100644
--- a/contrib/sendmail/src/savemail.c
+++ b/contrib/sendmail/src/savemail.c
@@ -9,13 +9,15 @@
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
+ * $FreeBSD$
+ *
*/
#include <sendmail.h>
-SM_RCSID("@(#)$Id: savemail.c,v 8.304 2004/10/06 21:36:06 ca Exp $")
+SM_RCSID("@(#)$Id: savemail.c,v 8.306 2006/02/25 02:16:53 ca Exp $")
-static void errbody __P((MCI *, ENVELOPE *, char *));
+static bool errbody __P((MCI *, ENVELOPE *, char *));
static bool pruneroute __P((char *));
/*
@@ -432,12 +434,13 @@ savemail(e, sendbody)
p = macvalue('g', e);
macdefine(&e->e_macro, A_PERM, 'g', e->e_sender);
- putfromline(&mcibuf, e);
- (*e->e_puthdr)(&mcibuf, e->e_header, e, M87F_OUTER);
- (*e->e_putbody)(&mcibuf, e, NULL);
- putline("\n", &mcibuf); /* XXX EOL from FileMailer? */
- (void) sm_io_flush(fp, SM_TIME_DEFAULT);
- if (sm_io_error(fp) ||
+ if (!putfromline(&mcibuf, e) ||
+ !(*e->e_puthdr)(&mcibuf, e->e_header, e,
+ M87F_OUTER) ||
+ !(*e->e_putbody)(&mcibuf, e, NULL) ||
+ !putline("\n", &mcibuf) ||
+ sm_io_flush(fp, SM_TIME_DEFAULT) == SM_IO_EOF ||
+ sm_io_error(fp) ||
sm_io_close(fp, SM_TIME_DEFAULT) < 0)
state = ESM_PANIC;
else
@@ -732,14 +735,14 @@ returntosender(msg, returnq, flags, e)
** separator -- any possible MIME separator (unused).
**
** Returns:
-** none
+** success
**
** Side Effects:
** Outputs the body of an error message.
*/
/* ARGSUSED2 */
-static void
+static bool
errbody(mci, e, separator)
register MCI *mci;
register ENVELOPE *e;
@@ -757,14 +760,16 @@ errbody(mci, e, separator)
if (bitset(MCIF_INHEADER, mci->mci_flags))
{
- putline("", mci);
+ if (!putline("", mci))
+ goto writeerr;
mci->mci_flags &= ~MCIF_INHEADER;
}
if (e->e_parent == NULL)
{
syserr("errbody: null parent");
- putline(" ----- Original message lost -----\n", mci);
- return;
+ if (!putline(" ----- Original message lost -----\n", mci))
+ goto writeerr;
+ return true;
}
/*
@@ -773,11 +778,12 @@ errbody(mci, e, separator)
if (e->e_msgboundary != NULL)
{
- putline("This is a MIME-encapsulated message", mci);
- putline("", mci);
(void) sm_strlcpyn(buf, sizeof buf, 2, "--", e->e_msgboundary);
- putline(buf, mci);
- putline("", mci);
+ if (!putline("This is a MIME-encapsulated message", mci) ||
+ !putline("", mci) ||
+ !putline(buf, mci) ||
+ !putline("", mci))
+ goto writeerr;
}
/*
@@ -799,31 +805,36 @@ errbody(mci, e, separator)
if (!pm_notify && q == NULL &&
!bitset(EF_FATALERRS|EF_SENDRECEIPT, e->e_parent->e_flags))
{
- putline(" **********************************************",
- mci);
- putline(" ** THIS IS A WARNING MESSAGE ONLY **",
- mci);
- putline(" ** YOU DO NOT NEED TO RESEND YOUR MESSAGE **",
- mci);
- putline(" **********************************************",
- mci);
- putline("", mci);
+ if (!putline(" **********************************************",
+ mci) ||
+ !putline(" ** THIS IS A WARNING MESSAGE ONLY **",
+ mci) ||
+ !putline(" ** YOU DO NOT NEED TO RESEND YOUR MESSAGE **",
+ mci) ||
+ !putline(" **********************************************",
+ mci) ||
+ !putline("", mci))
+ goto writeerr;
}
(void) sm_snprintf(buf, sizeof buf,
"The original message was received at %s",
arpadate(ctime(&e->e_parent->e_ctime)));
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
expand("from \201_", buf, sizeof buf, e->e_parent);
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
/* include id in postmaster copies */
if (pm_notify && e->e_parent->e_id != NULL)
{
(void) sm_strlcpyn(buf, sizeof buf, 2, "with id ",
e->e_parent->e_id);
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
- putline("", mci);
+ if (!putline("", mci))
+ goto writeerr;
/*
** Output error message header (if specified and available).
@@ -849,17 +860,19 @@ errbody(mci, e, separator)
{
translate_dollars(buf);
expand(buf, buf, sizeof buf, e);
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
(void) sm_io_close(xfile, SM_TIME_DEFAULT);
- putline("\n", mci);
+ if (!putline("\n", mci))
+ goto writeerr;
}
}
else
{
expand(ErrMsgFile, buf, sizeof buf, e);
- putline(buf, mci);
- putline("", mci);
+ if (!putline(buf, mci) || !putline("", mci))
+ goto writeerr;
}
}
@@ -877,21 +890,24 @@ errbody(mci, e, separator)
if (printheader)
{
- putline(" ----- The following addresses had permanent fatal errors -----",
- mci);
+ if (!putline(" ----- The following addresses had permanent fatal errors -----",
+ mci))
+ goto writeerr;
printheader = false;
}
(void) sm_strlcpy(buf, shortenstring(q->q_paddr, MAXSHORTSTR),
sizeof buf);
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
if (q->q_rstatus != NULL)
{
(void) sm_snprintf(buf, sizeof buf,
" (reason: %s)",
shortenstring(exitstat(q->q_rstatus),
MAXSHORTSTR));
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
if (q->q_alias != NULL)
{
@@ -899,11 +915,12 @@ errbody(mci, e, separator)
" (expanded from: %s)",
shortenstring(q->q_alias->q_paddr,
MAXSHORTSTR));
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
}
- if (!printheader)
- putline("", mci);
+ if (!printheader && !putline("", mci))
+ goto writeerr;
/* transient non-fatal errors */
printheader = true;
@@ -917,25 +934,28 @@ errbody(mci, e, separator)
if (printheader)
{
- putline(" ----- The following addresses had transient non-fatal errors -----",
- mci);
+ if (!putline(" ----- The following addresses had transient non-fatal errors -----",
+ mci))
+ goto writeerr;
printheader = false;
}
(void) sm_strlcpy(buf, shortenstring(q->q_paddr, MAXSHORTSTR),
sizeof buf);
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
if (q->q_alias != NULL)
{
(void) sm_snprintf(buf, sizeof buf,
" (expanded from: %s)",
shortenstring(q->q_alias->q_paddr,
MAXSHORTSTR));
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
}
- if (!printheader)
- putline("", mci);
+ if (!printheader && !putline("", mci))
+ goto writeerr;
/* successful delivery notifications */
printheader = true;
@@ -968,25 +988,28 @@ errbody(mci, e, separator)
if (printheader)
{
- putline(" ----- The following addresses had successful delivery notifications -----",
- mci);
+ if (!putline(" ----- The following addresses had successful delivery notifications -----",
+ mci))
+ goto writeerr;
printheader = false;
}
(void) sm_snprintf(buf, sizeof buf, "%s (%s)",
shortenstring(q->q_paddr, MAXSHORTSTR), p);
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
if (q->q_alias != NULL)
{
(void) sm_snprintf(buf, sizeof buf,
" (expanded from: %s)",
shortenstring(q->q_alias->q_paddr,
MAXSHORTSTR));
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
}
- if (!printheader)
- putline("", mci);
+ if (!printheader && !putline("", mci))
+ goto writeerr;
/*
** Output transcript of errors
@@ -995,8 +1018,9 @@ errbody(mci, e, separator)
(void) sm_io_flush(smioout, SM_TIME_DEFAULT);
if (e->e_parent->e_xfp == NULL)
{
- putline(" ----- Transcript of session is unavailable -----\n",
- mci);
+ if (!putline(" ----- Transcript of session is unavailable -----\n",
+ mci))
+ goto writeerr;
}
else
{
@@ -1007,11 +1031,12 @@ errbody(mci, e, separator)
while (sm_io_fgets(e->e_parent->e_xfp, SM_TIME_DEFAULT, buf,
sizeof buf) != NULL)
{
- if (printheader)
- putline(" ----- Transcript of session follows -----\n",
- mci);
+ if (printheader && !putline(" ----- Transcript of session follows -----\n",
+ mci))
+ goto writeerr;
printheader = false;
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
}
errno = 0;
@@ -1023,11 +1048,12 @@ errbody(mci, e, separator)
if (e->e_msgboundary != NULL)
{
- putline("", mci);
(void) sm_strlcpyn(buf, sizeof buf, 2, "--", e->e_msgboundary);
- putline(buf, mci);
- putline("Content-Type: message/delivery-status", mci);
- putline("", mci);
+ if (!putline("", mci) ||
+ !putline(buf, mci) ||
+ !putline("Content-Type: message/delivery-status", mci) ||
+ !putline("", mci))
+ goto writeerr;
/*
** Output per-message information.
@@ -1039,13 +1065,15 @@ errbody(mci, e, separator)
(void) sm_snprintf(buf, sizeof buf,
"Original-Envelope-Id: %.800s",
xuntextify(e->e_parent->e_envid));
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
/* Reporting-MTA: is us (required) */
(void) sm_snprintf(buf, sizeof buf,
"Reporting-MTA: dns; %.800s", MyHostName);
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
/* DSN-Gateway: not relevant since we are not translating */
@@ -1059,13 +1087,15 @@ errbody(mci, e, separator)
(void) sm_snprintf(buf, sizeof buf,
"Received-From-MTA: %s; %.800s",
p, RealHostName);
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
/* Arrival-Date: -- when it arrived here */
(void) sm_strlcpyn(buf, sizeof buf, 2, "Arrival-Date: ",
arpadate(ctime(&e->e_parent->e_ctime)));
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
/* Deliver-By-Date: -- when it should have been delivered */
if (IS_DLVR_BY(e->e_parent))
@@ -1076,7 +1106,8 @@ errbody(mci, e, separator)
(void) sm_strlcpyn(buf, sizeof buf, 2,
"Deliver-By-Date: ",
arpadate(ctime(&dbyd)));
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
/*
@@ -1119,7 +1150,8 @@ errbody(mci, e, separator)
else
continue;
- putline("", mci);
+ if (!putline("", mci))
+ goto writeerr;
/* Original-Recipient: -- passed from on high */
if (q->q_orcpt != NULL)
@@ -1127,7 +1159,8 @@ errbody(mci, e, separator)
(void) sm_snprintf(buf, sizeof buf,
"Original-Recipient: %.800s",
q->q_orcpt);
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
/* Figure out actual recipient */
@@ -1176,7 +1209,8 @@ errbody(mci, e, separator)
(void) sm_snprintf(buf, sizeof buf,
"Final-Recipient: %s",
q->q_finalrcpt);
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
/* X-Actual-Recipient: -- the real problem address */
@@ -1190,13 +1224,15 @@ errbody(mci, e, separator)
(void) sm_snprintf(buf, sizeof buf,
"X-Actual-Recipient: %s",
actual);
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
/* Action: -- what happened? */
(void) sm_strlcpyn(buf, sizeof buf, 2, "Action: ",
action);
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
/* Status: -- what _really_ happened? */
if (q->q_status != NULL)
@@ -1208,7 +1244,8 @@ errbody(mci, e, separator)
else
p = "2.0.0";
(void) sm_strlcpyn(buf, sizeof buf, 2, "Status: ", p);
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
/* Remote-MTA: -- who was I talking to? */
if (q->q_statmta != NULL)
@@ -1222,7 +1259,8 @@ errbody(mci, e, separator)
p = &buf[strlen(buf) - 1];
if (*p == '.')
*p = '\0';
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
/* Diagnostic-Code: -- actual result from other end */
@@ -1234,7 +1272,8 @@ errbody(mci, e, separator)
(void) sm_snprintf(buf, sizeof buf,
"Diagnostic-Code: %s; %.800s",
p, q->q_rstatus);
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
/* Last-Attempt-Date: -- fine granularity */
@@ -1243,7 +1282,8 @@ errbody(mci, e, separator)
(void) sm_strlcpyn(buf, sizeof buf, 2,
"Last-Attempt-Date: ",
arpadate(ctime(&q->q_statdate)));
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
/* Will-Retry-Until: -- for delayed messages only */
if (QS_IS_QUEUEUP(q->q_state))
@@ -1255,7 +1295,8 @@ errbody(mci, e, separator)
(void) sm_strlcpyn(buf, sizeof buf, 2,
"Will-Retry-Until: ",
arpadate(ctime(&xdate)));
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
}
}
@@ -1265,7 +1306,8 @@ errbody(mci, e, separator)
** Output text of original message
*/
- putline("", mci);
+ if (!putline("", mci))
+ goto writeerr;
if (bitset(EF_HAS_DF, e->e_parent->e_flags))
{
sendbody = !bitset(EF_NO_BODY_RETN, e->e_parent->e_flags) &&
@@ -1273,21 +1315,27 @@ errbody(mci, e, separator)
if (e->e_msgboundary == NULL)
{
- if (sendbody)
- putline(" ----- Original message follows -----\n", mci);
- else
- putline(" ----- Message header follows -----\n", mci);
+ if (!putline(
+ sendbody
+ ? " ----- Original message follows -----\n"
+ : " ----- Message header follows -----\n",
+ mci))
+ {
+ goto writeerr;
+ }
}
else
{
(void) sm_strlcpyn(buf, sizeof buf, 2, "--",
e->e_msgboundary);
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
(void) sm_strlcpyn(buf, sizeof buf, 2, "Content-Type: ",
sendbody ? "message/rfc822"
: "text/rfc822-headers");
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
p = hvalue("Content-Transfer-Encoding",
e->e_parent->e_header);
@@ -1301,43 +1349,62 @@ errbody(mci, e, separator)
(void) sm_snprintf(buf, sizeof buf,
"Content-Transfer-Encoding: %s",
p);
- putline(buf, mci);
+ if (!putline(buf, mci))
+ goto writeerr;
}
}
- putline("", mci);
+ if (!putline("", mci))
+ goto writeerr;
save_errno = errno;
- putheader(mci, e->e_parent->e_header, e->e_parent, M87F_OUTER);
+ if (!putheader(mci, e->e_parent->e_header, e->e_parent,
+ M87F_OUTER))
+ goto writeerr;
errno = save_errno;
if (sendbody)
- putbody(mci, e->e_parent, e->e_msgboundary);
+ {
+ if (!putbody(mci, e->e_parent, e->e_msgboundary))
+ goto writeerr;
+ }
else if (e->e_msgboundary == NULL)
{
- putline("", mci);
- putline(" ----- Message body suppressed -----", mci);
+ if (!putline("", mci) ||
+ !putline(" ----- Message body suppressed -----",
+ mci))
+ {
+ goto writeerr;
+ }
}
}
else if (e->e_msgboundary == NULL)
{
- putline(" ----- No message was collected -----\n", mci);
+ if (!putline(" ----- No message was collected -----\n", mci))
+ goto writeerr;
}
if (e->e_msgboundary != NULL)
{
- putline("", mci);
(void) sm_strlcpyn(buf, sizeof buf, 3, "--", e->e_msgboundary,
"--");
- putline(buf, mci);
+ if (!putline("", mci) || !putline(buf, mci))
+ goto writeerr;
}
- putline("", mci);
- (void) sm_io_flush(mci->mci_out, SM_TIME_DEFAULT);
+ if (!putline("", mci) ||
+ sm_io_flush(mci->mci_out, SM_TIME_DEFAULT) == SM_IO_EOF)
+ goto writeerr;
/*
** Cleanup and exit
*/
if (errno != 0)
+ {
+ writeerr:
syserr("errbody: I/O error");
+ return false;
+ }
+ return true;
}
+
/*
** SMTPTODSN -- convert SMTP to DSN status code
**
@@ -1402,9 +1469,9 @@ smtptodsn(smtpstat)
return "5.0.0";
}
- if ((smtpstat / 100) == 2)
+ if (REPLYTYPE(smtpstat) == 2)
return "2.0.0";
- if ((smtpstat / 100) == 4)
+ if (REPLYTYPE(smtpstat) == 4)
return "4.0.0";
return "5.0.0";
}
OpenPOWER on IntegriCloud