Fix sendmail 8.12.10 import conflicts

This commit is contained in:
Gregory Neil Shapiro 2003-09-19 23:14:57 +00:00
parent 2baeb480ca
commit 7660b554bc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=120259
7 changed files with 158 additions and 68 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 1998-2002 Sendmail, Inc. and its suppliers.
# Copyright (c) 1998-2003 Sendmail, Inc. and its suppliers.
# All rights reserved.
# Copyright (c) 1983, 1995 Eric P. Allman. All rights reserved.
# Copyright (c) 1988, 1993
@ -307,4 +307,4 @@ define(`confMILTER_MACROS_ENVRCPT', ``{rcpt_mailer}, {rcpt_host}, {rcpt_addr}'')
divert(0)dnl
VERSIONID(`$Id: cfhead.m4,v 8.108.2.2 2003/03/11 21:24:20 ca Exp $')
VERSIONID(`$Id: cfhead.m4,v 8.108.2.3 2003/04/03 17:51:51 ca Exp $')

View File

@ -20,7 +20,7 @@ SM_IDSTR(copyright,
Copyright (c) 1990, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n")
SM_IDSTR(id, "@(#)$Id: mail.local.c,v 8.239.2.5 2003/03/15 23:43:20 gshapiro Exp $")
SM_IDSTR(id, "@(#)$Id: mail.local.c,v 8.239.2.11 2003/09/01 01:49:46 gshapiro Exp $")
#include <stdlib.h>
#include <sm/errstring.h>
@ -30,6 +30,7 @@ SM_IDSTR(id, "@(#)$Id: mail.local.c,v 8.239.2.5 2003/03/15 23:43:20 gshapiro Exp
# ifdef EX_OK
# undef EX_OK /* unistd.h may have another use for this */
# endif /* EX_OK */
# define LOCKFILE_PMODE 0
#include <sm/mbdb.h>
#include <sm/sysexits.h>
@ -65,10 +66,6 @@ SM_IDSTR(id, "@(#)$Id: mail.local.c,v 8.239.2.5 2003/03/15 23:43:20 gshapiro Exp
#include <sendmail/pathnames.h>
/* additional mode for open() */
# define EXTRA_MODE 0
#ifndef LOCKTO_RM
# define LOCKTO_RM 300 /* timeout for stale lockfile removal */
#endif /* ! LOCKTO_RM */
@ -867,7 +864,7 @@ deliver(fd, name)
int exitval;
char *p;
char *errcode;
off_t curoff;
off_t curoff, cursize;
#ifdef CONTENTLENGTH
off_t headerbytes;
int readamount;
@ -1010,7 +1007,7 @@ deliver(fd, name)
mode |= S_IRGRP|S_IWGRP;
#endif /* MAILGID */
mbfd = open(path, O_APPEND|O_CREAT|O_EXCL|O_WRONLY|EXTRA_MODE,
mbfd = open(path, O_APPEND|O_CREAT|O_EXCL|O_WRONLY,
mode);
save_errno = errno;
@ -1080,7 +1077,7 @@ deliver(fd, name)
#ifdef DEBUG
fprintf(stderr, "new euid = %d\n", (int) geteuid());
#endif /* DEBUG */
mbfd = open(path, O_APPEND|O_WRONLY|EXTRA_MODE, 0);
mbfd = open(path, O_APPEND|O_WRONLY, 0);
if (mbfd < 0)
{
mailerr("450 4.2.0", "%s: %s", path, sm_errstring(errno));
@ -1220,7 +1217,6 @@ deliver(fd, name)
{
mailerr("450 4.2.0", "%s: %s", path, sm_errstring(errno));
err3:
(void) setreuid(0, 0);
#ifdef DEBUG
fprintf(stderr, "reset euid = %d\n", (int) geteuid());
#endif /* DEBUG */
@ -1228,10 +1224,26 @@ deliver(fd, name)
(void) ftruncate(mbfd, curoff);
err1: if (mbfd >= 0)
(void) close(mbfd);
err0: unlockmbox();
err0: (void) setreuid(0, 0);
unlockmbox();
return;
}
/*
** Save the current size so if the close() fails below
** we can make sure no other process has changed the mailbox
** between the failed close and the re-open()/re-lock().
** If something else has changed the size, we shouldn't
** try to truncate it as we may do more harm then good
** (e.g., truncate a later message delivery).
*/
if (fstat(mbfd, &sb) < 0)
cursize = 0;
else
cursize = sb.st_size;
/* Close and check -- NFS doesn't write until the close. */
if (close(mbfd))
{
@ -1241,9 +1253,12 @@ err0: unlockmbox();
errcode = "552 5.2.2";
#endif /* EDQUOT */
mailerr(errcode, "%s: %s", path, sm_errstring(errno));
mbfd = open(path, O_WRONLY|EXTRA_MODE, 0);
if (mbfd < 0
|| fstat(mbfd, &sb) < 0 ||
mbfd = open(path, O_WRONLY, 0);
if (mbfd < 0 ||
cursize == 0
|| flock(mbfd, LOCK_EX) < 0 ||
fstat(mbfd, &sb) < 0 ||
sb.st_size != cursize ||
sb.st_nlink != 1 ||
!S_ISREG(sb.st_mode) ||
sb.st_dev != fsb.st_dev ||
@ -1361,7 +1376,7 @@ lockmbox(path)
errno = 0;
return EX_TEMPFAIL;
}
fd = open(LockName, O_WRONLY|O_EXCL|O_CREAT, 0);
fd = open(LockName, O_WRONLY|O_EXCL|O_CREAT, LOCKFILE_PMODE);
if (fd >= 0)
{
/* defeat lock checking programs which test pid */

View File

@ -9,9 +9,9 @@
.\" the sendmail distribution.
.\"
.\"
.\" $Id: smrsh.8,v 8.16 2002/04/25 13:33:40 ca Exp $
.\" $Id: smrsh.8,v 8.16.2.1 2003/07/08 01:33:03 gshapiro Exp $
.\"
.TH SMRSH 8 "$Date: 2001/01/24 00:40:47 $"
.TH SMRSH 8 "$Date: 2003/07/08 01:33:03 $"
.SH NAME
smrsh \- restricted shell for sendmail
.SH SYNOPSIS
@ -47,7 +47,7 @@ It also rejects any commands with the characters
or `\en' (newline)
on the command line to prevent ``end run'' attacks.
It allows ``||'' and ``&&'' to enable commands like:
``"|exec /usr/local/bin/procmail -f- /etc/procmailrcs/user || exit 75"''
``"|exec /usr/local/bin/filter || exit 75"''
.PP
Initial pathnames on programs are stripped,
so forwarding to ``/usr/bin/vacation'',
@ -59,9 +59,8 @@ all actually forward to
.PP
System administrators should be conservative about populating
the sm.bin directory.
Reasonable additions are
For example, a reasonable additions is
.IR vacation (1),
.IR procmail (1),
and the like.
No matter how brow-beaten you may be,
never include any shell or shell-like program
@ -73,6 +72,12 @@ directory.
Note that this does not restrict the use of shell or perl scripts
in the sm.bin directory (using the ``#!'' syntax);
it simply disallows execution of arbitrary programs.
Also, including mail filtering programs such as
.IR procmail (1)
is a very bad idea.
.IR procmail (1)
allows users to run arbitrary programs in their
.IR procmailrc (5).
.SH COMPILATION
Compilation should be trivial on most systems.
You may need to use \-DSMRSH_PATH=\e"\fIpath\fP\e"

View File

@ -9,13 +9,17 @@
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
* $FreeBSD$
*/
#include <sendmail.h>
SM_RCSID("@(#)$Id: conf.c,v 8.972.2.35 2003/03/28 05:46:09 ca Exp $")
SM_RCSID("@(#)$Id: conf.c,v 8.972.2.50 2003/09/03 21:37:03 ca Exp $")
#include <sendmail/pathnames.h>
#if NEWDB
# include "sm/bdb.h"
#endif /* NEWDB */
# include <sys/ioctl.h>
# include <sys/param.h>
@ -465,6 +469,19 @@ setupmaps()
register STAB *s;
#if NEWDB
# if DB_VERSION_MAJOR > 1
int major_v, minor_v, patch_v;
(void) db_version(&major_v, &minor_v, &patch_v);
if (major_v != DB_VERSION_MAJOR || minor_v != DB_VERSION_MINOR)
{
errno = 0;
syserr("Berkeley DB version mismatch: compiled against %d.%d.%d, run-time linked against %d.%d.%d",
DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
major_v, minor_v, patch_v);
}
# endif /* DB_VERSION_MAJOR > 1 */
MAPDEF("hash", ".db", MCF_ALIASOK|MCF_REBUILDABLE,
map_parseargs, hash_map_open, db_map_close,
db_map_lookup, db_map_store);
@ -2227,7 +2244,7 @@ refuseconnections(name, e, d, active)
sm_setproctitle(true, e, R_MSG_LA, name, CurrentLA);
if (LogLevel > 8)
sm_syslog(LOG_NOTICE, NOQID, R_MSG_LA, name, CurrentLA);
#if _FFR_REJECT_LOG
# if _FFR_REJECT_LOG
now = curtime();
if (firstrejtime[d] == 0)
{
@ -2240,13 +2257,13 @@ refuseconnections(name, e, d, active)
pintvl(now - firstrejtime[d], true));
nextlogtime[d] = now + RejectLogInterval;
}
#endif /* _FFR_REJECT_LOG */
# endif /* _FFR_REJECT_LOG */
return true;
}
#if _FFR_REJECT_LOG
# if _FFR_REJECT_LOG
else
firstrejtime[d] = 0;
#endif /* _FFR_REJECT_LOG */
# endif /* _FFR_REJECT_LOG */
if (DelayLA > 0 && CurrentLA >= DelayLA)
{
@ -2428,12 +2445,12 @@ initsetproctitle(argc, argv, envp)
*/
align = -1;
#if _FFR_SPT_ALIGN
# ifdef SPT_ALIGN_SIZE
# if _FFR_SPT_ALIGN
# ifdef SPT_ALIGN_SIZE
for (i = SPT_ALIGN_SIZE; i > 0; i >>= 1)
align++;
# endif /* SPT_ALIGN_SIZE */
#endif /* _FFR_SPT_ALIGN */
# endif /* SPT_ALIGN_SIZE */
# endif /* _FFR_SPT_ALIGN */
for (i = 0; i < argc; i++)
{
@ -2818,25 +2835,6 @@ uname(name)
return 0;
}
# if 0
/*
** Popen is known to have security holes.
*/
/* try uuname -l to return local name */
if ((file = popen("uuname -l", "r")) != NULL)
{
(void) sm_io_fgets(file, SM_TIME_DEFAULT, name,
NODE_LENGTH + 1);
(void) pclose(file);
n = strchr(name, '\n');
if (n != NULL)
*n = '\0';
if (name->nodename[0] != '\0')
return 0;
}
# endif /* 0 */
return -1;
}
#endif /* !HASUNAME */
@ -4733,7 +4731,7 @@ load_if_names()
# ifndef __hpux
lifc.lifc_family = AF_UNSPEC;
lifc.lifc_flags = 0;
# endif /* __hpux */
# endif /* ! __hpux */
if (ioctl(s, SIOCGLIFCONF, (char *)&lifc) < 0)
{
if (tTd(0, 4))
@ -5678,6 +5676,9 @@ char *OsCompileOptions[] =
#if ADDRCONFIG_IS_BROKEN
"ADDRCONFIG_IS_BROKEN",
#endif /* ADDRCONFIG_IS_BROKEN */
#if ALLOW_255
"ALLOW_255",
#endif /* ALLOW_255 */
#ifdef AUTO_NETINFO_HOSTS
"AUTO_NETINFO_HOSTS",
#endif /* AUTO_NETINFO_HOSTS */
@ -5929,6 +5930,10 @@ char *FFRCompileOptions[] =
/* Stricter checks about queue directory permissions. */
"_FFR_CHK_QUEUE",
#endif /* _FFR_CHK_QUEUE */
#if _FFR_CLIENT_SIZE
/* Don't try to send mail if its size exceeds SIZE= of server. */
"_FFR_CLIENT_SIZE",
#endif /* _FFR_CLIENT_SIZE */
#if _FFR_CONTROL_MSTAT
/* Extended daemon status. */
"_FFR_CONTROL_MSTAT",
@ -5989,6 +5994,10 @@ char *FFRCompileOptions[] =
"_FFR_DROP_TRUSTUSER_WARNING",
#endif /* _FFR_DROP_TRUSTUSER_WARNING */
#if _FFR_EXTRA_MAP_CHECK
/* perform extra checks on $( $) in R lines */
"_FFR_EXTRA_MAP_CHECK",
#endif /* _FFR_EXTRA_MAP_CHECK */
#if _FFR_FIX_DASHT
/*
** If using -t, force not sending to argv recipients, even
@ -6026,6 +6035,10 @@ char *FFRCompileOptions[] =
/* Use nsswitch on HP-UX */
"_FFR_HPUX_NSSWITCH",
#endif /* _FFR_HPUX_NSSWITCH */
#if _FFR_IGNORE_BOGUS_ADDR
/* Ignore addresses for which prescan() failed */
"_FFR_IGNORE_BOGUS_ADDR",
#endif /* _FFR_IGNORE_BOGUS_ADDR */
#if _FFR_IGNORE_EXT_ON_HELO
/* Ignore extensions offered in response to HELO */
"_FFR_IGNORE_EXT_ON_HELO",
@ -6049,12 +6062,16 @@ char *FFRCompileOptions[] =
/* Randall S. Winchester of the University of Maryland */
"_FFR_MAX_FORWARD_ENTRIES",
#endif /* _FFR_MAX_FORWARD_ENTRIES */
#if _FFR_MAX_SLEEP_TIME
/* Limit sleep(2) time in libsm/clock.c */
"_FFR_MAX_SLEEP_TIME",
#endif /* _FFR_MAX_SLEEP_TIME */
#if MILTER
# if _FFR_MILTER_421
/* If a filter returns 421, close the SMTP connection */
"_FFR_MILTER_421",
# endif /* _FFR_MILTER_421 */
# if _FFR_MILTER_PERDAEMON
# if _FFR_MILTER_PERDAEMON
/* Per DaemonPortOptions InputMailFilter lists */
"_FFR_MILTER_PERDAEMON",
# endif /* _FFR_MILTER_PERDAEMON */
@ -6144,6 +6161,10 @@ char *FFRCompileOptions[] =
/* Donated code (unused). */
"_FFR_SHM_STATUS",
#endif /* _FFR_SHM_STATUS */
#if _FFR_SLEEP_USE_SELECT
/* Use select(2) in libsm/clock.c to emulate sleep(2) */
"_FFR_SLEEP_USE_SELECT ",
#endif /* _FFR_SLEEP_USE_SELECT */
#if _FFR_SMFI_OPENSOCKET
/* libmilter: smfi_opensocket() to force the socket open early */
"_FFR_SMFI_OPENSOCKET",

View File

@ -9,11 +9,12 @@
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
* $FreeBSD$
*/
#include <sendmail.h>
SM_RCSID("@(#)$Id: headers.c,v 8.266.4.5 2003/03/12 22:42:52 gshapiro Exp $")
SM_RCSID("@(#)$Id: headers.c,v 8.266.4.7 2003/09/03 21:32:20 ca Exp $")
static size_t fix_mime_header __P((HDR *, ENVELOPE *));
static int priencode __P((char *));
@ -140,7 +141,10 @@ chompheader(line, pflag, hdrp, e)
mid = (unsigned char) macid(p);
if (bitset(0200, mid))
{
p += strlen(macname(mid)) + 2;
SM_ASSERT(p <= q);
}
else
p++;
@ -315,6 +319,7 @@ chompheader(line, pflag, hdrp, e)
qval[l++] = '"';
/* - 3 to avoid problems with " at the end */
/* should be sizeof(qval), not MAXNAME */
for (k = 0; fvalue[k] != '\0' && l < MAXNAME - 3; k++)
{
switch (fvalue[k])
@ -1175,7 +1180,7 @@ crackaddr(addr, e)
else if (c == ')')
{
/* syntax error: unmatched ) */
if (copylev > 0 && SM_HAVE_ROOM)
if (copylev > 0 && SM_HAVE_ROOM && bp > bufhead)
bp--;
}
@ -1349,7 +1354,7 @@ crackaddr(addr, e)
else if (SM_HAVE_ROOM)
{
/* syntax error: unmatched > */
if (copylev > 0)
if (copylev > 0 && bp > bufhead)
bp--;
quoteit = true;
continue;
@ -1693,6 +1698,12 @@ put_vanilla_header(h, v, mci)
int l;
l = nlp - v;
/*
** XXX This is broken for SPACELEFT()==0
** However, SPACELEFT() is always > 0 unless MAXLINE==1.
*/
if (SPACELEFT(obuf, obp) - 1 < (size_t) l)
l = SPACELEFT(obuf, obp) - 1;
@ -1703,6 +1714,8 @@ put_vanilla_header(h, v, mci)
if (*v != ' ' && *v != '\t')
*obp++ = ' ';
}
/* 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);
@ -1737,6 +1750,7 @@ commaize(h, p, oldstyle, mci, e)
int omax;
bool firstone = true;
int putflags = PXLF_HEADER;
char **res;
char obuf[MAXLINE + 3];
/*
@ -1753,6 +1767,8 @@ commaize(h, p, oldstyle, mci, e)
obp = obuf;
(void) sm_snprintf(obp, SPACELEFT(obuf, obp), "%.200s: ",
h->h_field);
/* opos = strlen(obp); */
opos = strlen(h->h_field) + 2;
if (opos > 202)
opos = 202;
@ -1785,14 +1801,23 @@ commaize(h, p, oldstyle, mci, e)
while ((isascii(*p) && isspace(*p)) || *p == ',')
p++;
name = p;
res = NULL;
for (;;)
{
auto char *oldp;
char pvpbuf[PSBUFSIZE];
(void) prescan(p, oldstyle ? ' ' : ',', pvpbuf,
sizeof pvpbuf, &oldp, NULL);
res = prescan(p, oldstyle ? ' ' : ',', pvpbuf,
sizeof pvpbuf, &oldp, NULL);
p = oldp;
#if _FFR_IGNORE_BOGUS_ADDR
/* ignore addresses that can't be parsed */
if (res == NULL)
{
name = p;
continue;
}
#endif /* _FFR_IGNORE_BOGUS_ADDR */
/* look to see if we have an at sign */
while (*p != '\0' && isascii(*p) && isspace(*p))
@ -1815,6 +1840,15 @@ commaize(h, p, oldstyle, mci, e)
p--;
if (++p == name)
continue;
/*
** if prescan() failed go a bit backwards; this is a hack,
** there should be some better error recovery.
*/
if (res == NULL && p > name &&
!((isascii(*p) && isspace(*p)) || *p == ',' || *p == '\0'))
--p;
savechar = *p;
*p = '\0';
@ -1858,7 +1892,7 @@ commaize(h, p, oldstyle, mci, e)
(void) sm_strlcpy(obp, ",\n", SPACELEFT(obuf, obp));
putxline(obuf, strlen(obuf), mci, putflags);
obp = obuf;
(void) sm_strlcpy(obp, " ", sizeof obp);
(void) sm_strlcpy(obp, " ", sizeof obuf);
opos = strlen(obp);
obp += opos;
opos += strlen(name);
@ -1874,7 +1908,10 @@ commaize(h, p, oldstyle, mci, e)
firstone = false;
*p = savechar;
}
*obp = '\0';
if (obp < &obuf[sizeof obuf])
*obp = '\0';
else
obuf[sizeof obuf - 1] = '\0';
putxline(obuf, strlen(obuf), mci, putflags);
}
/*
@ -1946,6 +1983,7 @@ fix_mime_header(h, e)
return 0;
/* Split on each ';' */
/* find_character() never returns NULL */
while ((end = find_character(begin, ';')) != NULL)
{
char save = *end;

View File

@ -9,11 +9,12 @@
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
* $FreeBSD$
*/
#include <sendmail.h>
SM_RCSID("@(#)$Id: mci.c,v 8.205.2.3 2003/01/07 03:56:19 ca Exp $")
SM_RCSID("@(#)$Id: mci.c,v 8.205.2.4 2003/03/31 17:35:27 ca Exp $")
#if NETINET || NETINET6
# include <arpa/inet.h>
@ -548,11 +549,21 @@ mci_dump(mci, logit)
}
(void) sm_snprintf(p, SPACELEFT(buf, p), "flags=%lx", mci->mci_flags);
p += strlen(p);
/*
** The following check is just for paranoia. It protects the
** assignment in the if() clause. If there's not some minimum
** amount of space we can stop right now. The check will not
** trigger as long as sizeof(buf)=4000.
*/
if (p >= buf + sizeof(buf) - 4)
goto printit;
if (mci->mci_flags != 0)
{
struct mcifbits *f;
*p++ = '<';
*p++ = '<'; /* protected above */
for (f = MciFlags; f->mcif_bit != 0; f++)
{
if (!bitset(f->mcif_bit, mci->mci_flags))
@ -1152,7 +1163,7 @@ mci_traverse_persistent(action, pathname)
if (hostptr != host)
*(hostptr++) = '.';
start = end;
while (*(start - 1) != '/')
while (start > pathname && *(start - 1) != '/')
start--;
if (*end == '.')
@ -1162,7 +1173,7 @@ mci_traverse_persistent(action, pathname)
*(hostptr++) = *scan;
end = start - 2;
} while (*end == '.');
} while (end > pathname && *end == '.');
*hostptr = '\0';
@ -1352,7 +1363,7 @@ mci_purge_persistent(pathname, hostname)
/*
** MCI_GENERATE_PERSISTENT_PATH -- generate path from hostname
**
** Given `host', convert from a.b.c to $QueueDir/.hoststat/c./b./a,
** Given `host', convert from a.b.c to $HostStatDir/c./b./a,
** putting the result into `path'. if `createflag' is set, intervening
** directories will be created as needed.
**

View File

@ -9,9 +9,9 @@
.\" the sendmail distribution.
.\"
.\"
.\" $Id: sendmail.8,v 8.51 2002/05/24 15:42:13 ca Exp $
.\" $Id: sendmail.8,v 8.51.2.1 2003/05/20 16:38:15 gshapiro Exp $
.\"
.TH SENDMAIL 8 "$Date: 2001/03/23 22:10:00 $"
.TH SENDMAIL 8 "$Date: 2003/05/20 16:38:15 $"
.SH NAME
sendmail
\- an electronic mail transport agent
@ -295,21 +295,21 @@ Process jobs in queue group called
.I name
only.
.TP
\fB\-q\fR[\fI!\fR]I substr
\fB\-q\fR[\fI!\fR]I\fIsubstr\fR
Limit processed jobs to those containing
.I substr
as a substring of the queue id or not when
.I !
is specified.
.TP
\fB\-q\fR[\fI!\fR]R substr
\fB\-q\fR[\fI!\fR]R\fIsubstr\fR
Limit processed jobs to those containing
.I substr
as a substring of one of the recipients or not when
.I !
is specified.
.TP
\fB\-q\fR[\fI!\fR]S substr
\fB\-q\fR[\fI!\fR]S\fIsubstr\fR
Limit processed jobs to those containing
.I substr
as a substring of the sender or not when