summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sendmail/src
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1997-08-04 05:06:42 +0000
committerpeter <peter@FreeBSD.org>1997-08-04 05:06:42 +0000
commit5a27937fcdd3e822dbb6634b110749d5db655fda (patch)
tree313ffb39dad3c04a6f3e05cff8aab358c802a22a /usr.sbin/sendmail/src
parent8f01114fd6a20cb3eb0bebf1407ee2c4d1a81164 (diff)
downloadFreeBSD-src-5a27937fcdd3e822dbb6634b110749d5db655fda.zip
FreeBSD-src-5a27937fcdd3e822dbb6634b110749d5db655fda.tar.gz
Merge sendmail 8.8.7 changes from vendor branch
Diffstat (limited to 'usr.sbin/sendmail/src')
-rw-r--r--usr.sbin/sendmail/src/collect.c7
-rw-r--r--usr.sbin/sendmail/src/conf.c55
-rw-r--r--usr.sbin/sendmail/src/conf.h169
-rw-r--r--usr.sbin/sendmail/src/daemon.c109
-rw-r--r--usr.sbin/sendmail/src/deliver.c20
-rw-r--r--usr.sbin/sendmail/src/domain.c9
-rw-r--r--usr.sbin/sendmail/src/headers.c5
-rw-r--r--usr.sbin/sendmail/src/main.c160
-rw-r--r--usr.sbin/sendmail/src/parseaddr.c38
-rw-r--r--usr.sbin/sendmail/src/readcf.c65
-rw-r--r--usr.sbin/sendmail/src/savemail.c31
-rw-r--r--usr.sbin/sendmail/src/sendmail.h31
-rw-r--r--usr.sbin/sendmail/src/srvrsmtp.c177
-rw-r--r--usr.sbin/sendmail/src/util.c42
14 files changed, 626 insertions, 292 deletions
diff --git a/usr.sbin/sendmail/src/collect.c b/usr.sbin/sendmail/src/collect.c
index 219a47f..de4ee06 100644
--- a/usr.sbin/sendmail/src/collect.c
+++ b/usr.sbin/sendmail/src/collect.c
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)collect.c 8.69 (Berkeley) 5/29/97";
+static char sccsid[] = "@(#)collect.c 8.71 (Berkeley) 6/30/97";
#endif /* not lint */
# include <errno.h>
@@ -427,7 +427,8 @@ readerr:
return;
if (tf != NULL &&
- (fflush(tf) != 0 || ferror(tf) || fsync(fileno(tf)) < 0 ||
+ (fflush(tf) != 0 || ferror(tf) ||
+ (SuperSafe && fsync(fileno(tf)) < 0) ||
fclose(tf) < 0))
{
tferror(tf, e);
@@ -541,7 +542,7 @@ readerr:
break;
case NRA_ADD_BCC:
- addheader("Bcc", "", &e->e_header);
+ addheader("Bcc", " ", &e->e_header);
break;
case NRA_ADD_TO_UNDISCLOSED:
diff --git a/usr.sbin/sendmail/src/conf.c b/usr.sbin/sendmail/src/conf.c
index 0d50508..60502b3 100644
--- a/usr.sbin/sendmail/src/conf.c
+++ b/usr.sbin/sendmail/src/conf.c
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)conf.c 8.362 (Berkeley) 6/14/97";
+static char sccsid[] = "@(#)conf.c 8.374 (Berkeley) 8/2/97";
#endif /* not lint */
# include "sendmail.h"
@@ -177,6 +177,10 @@ int DtableSize = 50; /* max open files; reset in 4.2bsd */
#define HOURS * 60 MINUTES
#define DAYS * 24 HOURS
+#ifndef _PATH_VARTMP
+# define _PATH_VARTMP "/usr/tmp/"
+#endif
+
#ifndef MAXRULERECURSION
# define MAXRULERECURSION 50 /* max ruleset recursion depth */
#endif
@@ -186,6 +190,7 @@ setdefaults(e)
register ENVELOPE *e;
{
int i;
+ char buf[MAXNAME];
extern void inittimeouts();
extern void setdefuser();
extern void setupmaps();
@@ -233,7 +238,12 @@ setdefaults(e)
MaxAliasRecursion = 10;
MaxMacroRecursion = 10;
ColonOkInAddr = TRUE;
+ DontLockReadFiles = TRUE;
DoubleBounceAddr = "postmaster";
+ snprintf(buf, sizeof buf, "%s%sdead.letter",
+ _PATH_VARTMP,
+ _PATH_VARTMP[sizeof _PATH_VARTMP - 2] == '/' ? "" : "/");
+ DeadLetterDrop = newstr(buf);
setdefuser();
setupmaps();
setupmailers();
@@ -412,6 +422,13 @@ setupmaps()
MAPDEF("null", NULL, MCF_ALIASOK|MCF_OPTFILE,
map_parseargs, null_map_open, null_map_close,
null_map_lookup, null_map_store);
+
+#if _FFR_SYSLOG_MAP
+ /* syslog map -- logs information to syslog */
+ MAPDEF("syslog", NULL, 0,
+ syslog_map_parseargs, null_map_open, null_map_close,
+ syslog_map_lookup, null_map_store);
+#endif
}
#undef MAPDEF
@@ -3822,8 +3839,8 @@ chownsafe(fd, safedir)
int fd;
bool safedir;
{
-#if !defined(_POSIX_CHOWN_RESTRICTED) || _POSIX_CHOWN_RESTRICTED != -1
-# if defined(_PC_CHOWN_RESTRICTED)
+#if (!defined(_POSIX_CHOWN_RESTRICTED) || _POSIX_CHOWN_RESTRICTED != -1) && \
+ defined(_PC_CHOWN_RESTRICTED)
int rval;
/* give the system administrator a chance to override */
@@ -3838,11 +3855,10 @@ chownsafe(fd, safedir)
errno = 0;
rval = fpathconf(fd, _PC_CHOWN_RESTRICTED);
-# if SAFENFSPATHCONF
+# if SAFENFSPATHCONF
return errno == 0 && rval IS_SAFE_CHOWN;
-# else
+# else
return safedir && errno == 0 && rval IS_SAFE_CHOWN;
-# endif
# endif
#else
return ChownAlwaysSafe;
@@ -3981,7 +3997,7 @@ vendor_pre_defaults(e)
/* OTHERUID is defined in shares.h, do not be alarmed */
DefShareUid = OTHERUID;
#endif
-#ifdef SUN_EXTENSIONS
+#if defined(SUN_EXTENSIONS) && defined(SUN_DEFAULT_VALUES)
sun_pre_defaults(e);
#endif
#ifdef apollo
@@ -3996,7 +4012,7 @@ void
vendor_post_defaults(e)
ENVELOPE *e;
{
-#ifdef SUN_EXTENSIONS
+#if defined(SUN_EXTENSIONS) && defined(SUN_DEFAULT_VALUES)
sun_post_defaults(e);
#endif
}
@@ -4076,12 +4092,22 @@ validate_connection(sap, hostname, e)
char *hostname;
ENVELOPE *e;
{
+ if (tTd(48, 3))
+ printf("validate_connection(%s, %s)\n",
+ hostname, anynet_ntoa(sap));
+
if (rscheck("check_relay", hostname, anynet_ntoa(sap), e) != EX_OK)
+ {
+ if (tTd(48, 4))
+ printf(" ... validate_connection: BAD (rscheck)\n");
return FALSE;
+ }
#if TCPWRAPPERS
if (!hosts_ctl("sendmail", hostname, anynet_ntoa(sap), STRING_UNKNOWN))
{
+ if (tTd(48, 4))
+ printf(" ... validate_connection: BAD (tcpwrappers)\n");
if (LogLevel >= 4)
sm_syslog(LOG_NOTICE, NOQID,
"tcpwrappers (%s, %s) rejection",
@@ -4089,6 +4115,8 @@ validate_connection(sap, hostname, e)
return FALSE;
}
#endif
+ if (tTd(48, 4))
+ printf(" ... validate_connection: OK\n");
return TRUE;
}
@@ -4462,7 +4490,7 @@ load_if_names()
return;
/* get the list of known IP address from the kernel */
-# ifdef SIOCGIFNUM
+# if defined(SIOCGIFNUM) && !SIOCGIFNUM_IS_BROKEN
if (ioctl(s, SIOCGIFNUM, (char *) &numifs) < 0)
{
/* can't get number of interfaces -- fall back */
@@ -4967,6 +4995,9 @@ char *OsCompileOptions[] =
#if HASSNPRINTF
"HASSNPRINTF",
#endif
+#if HAS_ST_GEN
+ "HAS_ST_GEN",
+#endif
#if HASSTRERROR
"HASSTRERROR",
#endif
@@ -4988,6 +5019,9 @@ char *OsCompileOptions[] =
#if IP_SRCROUTE
"IP_SRCROUTE",
#endif
+#if O_EXLOCK && HASFLOCK && !BOGUS_O_EXCL
+ "LOCK_ON_OPEN",
+#endif
#if NEEDFSYNC
"NEEDFSYNC",
#endif
@@ -5009,6 +5043,9 @@ char *OsCompileOptions[] =
#if SIOCGIFCONF_IS_BROKEN
"SIOCGIFCONF_IS_BROKEN",
#endif
+#if SIOCGIFNUM_IS_BROKEN
+ "SIOCGIFNUM_IS_BROKEN",
+#endif
#if SYS5SETPGRP
"SYS5SETPGRP",
#endif
diff --git a/usr.sbin/sendmail/src/conf.h b/usr.sbin/sendmail/src/conf.h
index 745b7a0..2da4506 100644
--- a/usr.sbin/sendmail/src/conf.h
+++ b/usr.sbin/sendmail/src/conf.h
@@ -31,7 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)conf.h 8.313 (Berkeley) 6/11/97
+ * @(#)conf.h 8.328 (Berkeley) 8/3/97
*/
/*
@@ -192,7 +192,9 @@ struct rusage; /* forward declaration to get gcc to shut up in wait.h */
# ifdef V4FS
/* HP-UX 10.x */
# define _PATH_UNIX "/stand/vmunix"
-# define _PATH_VENDOR_CF "/etc/mail/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/etc/mail/sendmail.cf"
+# endif
# ifndef _PATH_SENDMAILPID
# define _PATH_SENDMAILPID "/etc/mail/sendmail.pid"
# endif
@@ -203,13 +205,16 @@ struct rusage; /* forward declaration to get gcc to shut up in wait.h */
# else
/* HP-UX 9.x */
# define _PATH_UNIX "/hp-ux"
-# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# endif
# ifndef IDENTPROTO
# define IDENTPROTO 0 /* TCP/IP implementation is broken */
# endif
# ifdef __STDC__
extern void hard_syslog(int, char *, ...);
# endif
+# define FDSET_CAST (int *) /* cast for fd_set parameters to select */
# endif
#endif
@@ -220,10 +225,11 @@ extern void hard_syslog(int, char *, ...);
*/
#ifdef _AIX4
-# include <sys/select.h>
# define _AIX3 1 /* pull in AIX3 stuff */
# define USESETEUID 1 /* seteuid(2) works */
# define TZ_TYPE TZ_NAME /* use tzname[] vector */
+# define SOCKADDR_LEN_T size_t /* e.g., arg#3 to accept, getsockname */
+# define SOCKOPT_LEN_T size_t /* arg#5 to getsockopt */
# if _AIX4 >= 40200
# define HASSETREUID 1 /* setreuid(2) works as of AIX 4.2 */
# endif
@@ -237,6 +243,7 @@ extern void hard_syslog(int, char *, ...);
#ifdef _AIX3
# include <paths.h>
# include <sys/machine.h> /* to get byte order */
+# include <sys/select.h>
# define HASINITGROUPS 1 /* has initgroups(3) call */
# define HASUNAME 1 /* use System V uname(2) system call */
# define HASGETUSERSHELL 0 /* does not have getusershell(3) call */
@@ -398,7 +405,9 @@ typedef int pid_t;
# ifndef _PATH_UNIX
# define _PATH_UNIX "/dev/ksyms"
# endif
-# define _PATH_VENDOR_CF "/etc/mail/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/etc/mail/sendmail.cf"
+# endif
# ifndef _PATH_SENDMAILPID
# define _PATH_SENDMAILPID "/etc/mail/sendmail.pid"
# endif
@@ -435,6 +444,7 @@ typedef int pid_t;
# endif
# define SFS_TYPE SFS_VFS /* use <sys/vfs.h> statfs() implementation */
# define TZ_TYPE TZ_TM_ZONE /* use tm->tm_zone */
+# include <memory.h>
# include <vfork.h>
# ifdef SUNOS403
@@ -585,12 +595,15 @@ extern long dgux_inet_addr();
# define HASINITGROUPS 1 /* has initgroups(3) call */
# define HASFCHMOD 1 /* has fchmod(2) syscall */
# define IP_SRCROUTE 1 /* can check IP source routing */
+# define HAS_ST_GEN 1 /* has st_gen field in stat struct */
# ifndef HASFLOCK
# define HASFLOCK 1 /* has flock(2) call */
# endif
# define LA_TYPE LA_ALPHAOSF
# define SFS_TYPE SFS_MOUNT /* use <sys/mount.h> statfs() impl */
-# define _PATH_VENDOR_CF "/var/adm/sendmail/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/var/adm/sendmail/sendmail.cf"
+# endif
# ifndef _PATH_SENDMAILPID
# define _PATH_SENDMAILPID "/var/run/sendmail.pid"
# endif
@@ -625,10 +638,20 @@ typedef int pid_t;
# undef WEXITSTATUS
# undef WIFEXITED
# endif
-# define _PATH_VENDOR_CF "/etc/sendmail/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/etc/sendmail/sendmail.cf"
+# endif
# ifndef _PATH_SENDMAILPID
# define _PATH_SENDMAILPID "/etc/sendmail/sendmail.pid"
# endif
+
+# ifdef TCPWRAPPERS
+# ifndef HASUNSETENV
+# define HASUNSETENV 1
+# endif
+# undef NEEDPUTENV
+# endif
+
#endif
@@ -645,6 +668,7 @@ typedef int pid_t;
# define HASFCHMOD 1 /* has fchmod(2) syscall */
# define HASSNPRINTF 1 /* has snprintf(3) and vsnprintf(3) */
# define HASSTRERROR 1 /* has strerror(3) */
+# define HAS_ST_GEN 1 /* has st_gen field in stat struct */
# include <sys/cdefs.h>
# define ERRLIST_PREDEFINED /* don't declare sys_errlist */
# define BSD4_4_SOCKADDR /* has sa_len */
@@ -671,6 +695,7 @@ typedef int pid_t;
# define HASSNPRINTF 1 /* has snprintf(3) and vsnprintf(3) */
# define HASUNAME 1 /* has uname(2) syscall */
# define HASSTRERROR 1 /* has strerror(3) */
+# define HAS_ST_GEN 1 /* has st_gen field in stat struct */
# include <sys/cdefs.h>
# define ERRLIST_PREDEFINED /* don't declare sys_errlist */
# define BSD4_4_SOCKADDR /* has sa_len */
@@ -713,6 +738,7 @@ typedef int pid_t;
# define HASSNPRINTF 1 /* has snprintf(3) and vsnprintf(3) */
# define HASUNAME 1 /* has uname(2) syscall */
# define HASSTRERROR 1 /* has strerror(3) */
+# define HAS_ST_GEN 1 /* has st_gen field in stat struct */
# include <sys/cdefs.h>
# define ERRLIST_PREDEFINED /* don't declare sys_errlist */
# define BSD4_4_SOCKADDR /* has sa_len */
@@ -776,7 +802,9 @@ typedef int pid_t;
# undef HASSETVBUF /* don't actually have setvbuf(3) */
# undef WEXITSTATUS
# undef WIFEXITED
-# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# endif
# ifndef _PATH_SENDMAILPID
# define _PATH_SENDMAILPID "/etc/sendmail.pid"
# endif
@@ -844,7 +872,9 @@ typedef int pid_t;
# ifndef LA_TYPE
# define LA_TYPE LA_FLOAT
# endif
-# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# endif
# ifndef IDENTPROTO
# define IDENTPROTO 0 /* TCP/IP implementation is broken */
# endif
@@ -888,6 +918,8 @@ extern int errno;
# define LA_TYPE LA_DEVSHORT
# endif
# define _PATH_AVENRUN "/dev/table/avenrun"
+# define SOCKADDR_LEN_T size_t /* e.g., arg#3 to accept, getsockname */
+# define SOCKOPT_LEN_T size_t /* arg#5 to getsockopt */
#endif
/* SCO UNIX 3.2v4.2/Open Desktop 3.0 */
@@ -912,7 +944,9 @@ extern int errno;
# define GID_T gid_t
# define GIDSET_T gid_t
# define _PATH_UNIX "/unix"
-# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# endif
# ifndef _PATH_SENDMAILPID
# define _PATH_SENDMAILPID "/etc/sendmail.pid"
# endif
@@ -953,7 +987,9 @@ extern int errno;
# define SFS_TYPE SFS_STATFS /* use <sys/statfs.h> statfs() impl */
# define SFS_BAVAIL f_bfree /* alternate field name */
# define _PATH_UNIX "/unix"
-# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# endif
# ifndef _PATH_SENDMAILPID
# define _PATH_SENDMAILPID "/etc/sendmail.pid"
# endif
@@ -1032,7 +1068,9 @@ extern struct group *getgrnam();
# define IP_SRCROUTE 0 /* Something is broken with getsockopt() */
# define LA_TYPE LA_FLOAT
# define SFS_TYPE SFS_VFS /* use <sys/vfs.h> statfs() implementation */
-# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# endif
# ifndef S_IREAD
# define S_IREAD _S_IREAD
# define S_IWRITE _S_IWRITE
@@ -1088,13 +1126,22 @@ extern struct group *getgrnam();
extern int errno;
typedef int pid_t;
-#define SIGFUNC_DEFINED
-#define SIGFUNC_RETURN (0)
-#define SIGFUNC_DECL int
+# define SIGFUNC_DEFINED
+# define SIGFUNC_RETURN (0)
+# define SIGFUNC_DECL int
typedef int (*sigfunc_t)();
extern char *getenv();
extern void *malloc();
+/* added for RISC/os 4.01...which is dumber than 4.50 */
+# ifdef RISCOS_4_0
+# ifndef ARBPTR_T
+# define ARBPTR_T char *
+# endif
+# undef HASFLOCK
+# define HASFLOCK 0
+# endif /* RISCOS_4_0 */
+
# include <sys/time.h>
#endif
@@ -1203,7 +1250,9 @@ extern void *malloc();
# ifndef _PATH_UNIX
# define _PATH_UNIX "/unix" /* should be in <paths.h> */
# endif
-# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# endif
# undef WIFEXITED
# undef WEXITSTATUS
#endif
@@ -1283,8 +1332,9 @@ typedef int pid_t;
# ifndef _PATH_UNIX
# define _PATH_UNIX "/dynix"
# endif
-# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
-
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# endif
#endif
@@ -1312,7 +1362,9 @@ typedef int pid_t;
# ifndef IDENTPROTO
# define IDENTPROTO 0 /* TCP/IP implementation is broken */
# endif
-# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# endif
# ifndef _PATH_SENDMAILPID
# define _PATH_SENDMAILPID "/etc/sendmail.pid"
# endif
@@ -1353,7 +1405,9 @@ typedef int pid_t;
# define SFS_TYPE SFS_4ARGS /* four argument statfs() call */
# define SFS_BAVAIL f_bfree /* alternate field name */
# define TZ_TYPE TZ_TZNAME
-# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# endif
# ifndef _PATH_SENDMAILPID
# define _PATH_SENDMAILPID "/etc/sendmail.pid"
# endif
@@ -1377,6 +1431,7 @@ typedef int pid_t;
#ifdef UNIXWARE2
# define UNIXWARE 1
# define HASSNPRINTF 1 /* has snprintf(3) and vsnprintf(3) */
+# undef offsetof /* avoid stddefs.h, sys/sysmacros.h conflict */
#endif
@@ -1401,7 +1456,9 @@ typedef int pid_t;
# undef WIFEXITED
# undef WEXITSTATUS
# define _PATH_UNIX "/unix"
-# define _PATH_VENDOR_CF "/usr/ucblib/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/usr/ucblib/sendmail.cf"
+# endif
# ifndef _PATH_SENDMAILPID
# define _PATH_SENDMAILPID "/usr/ucblib/sendmail.pid"
# endif
@@ -1451,8 +1508,9 @@ typedef int pid_t;
#ifdef NCR_MP_RAS3
# define __svr4__
+# define SIOCGIFNUM_IS_BROKEN 1 /* SIOCGIFNUM has non-std interface */
# define SYSLOG_BUFSIZE 1024
-# define SPT_TYPE SPT_NONE
+# define SPT_TYPE SPT_NONE
#endif
@@ -1487,7 +1545,9 @@ typedef int pid_t;
# ifndef _PATH_UNIX
# define _PATH_UNIX "/HI-UX"
# endif
-# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# endif
# ifndef IDENTPROTO
# define IDENTPROTO 0 /* TCP/IP implementation is broken */
# endif
@@ -1528,7 +1588,9 @@ extern int syslog(int, char *, ...);
# define SFS_TYPE SFS_4ARGS /* use 4-arg statfs() */
# define SFS_BAVAIL f_bfree /* alternate field name */
# define _PATH_UNIX "/unix"
-# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# endif
#endif
/*
@@ -1598,7 +1660,9 @@ typedef int (*sigfunc_t)();
# define SYSLOG_BUFSIZE 1024
# endif
# define _PATH_UNIX "/stand/unix"
-# define _PATH_VENDOR_CF "/etc/mail/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/etc/mail/sendmail.cf"
+# endif
# ifndef _PATH_SENDMAILPID
# define _PATH_SENDMAILPID "/etc/mail/sendmail.pid"
# endif
@@ -1647,7 +1711,9 @@ typedef int (*sigfunc_t)();
# define SIGFUNC_DECL int
extern char *getenv();
extern int errno;
-# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/usr/lib/sendmail.cf"
+# endif
#endif
@@ -1696,7 +1762,9 @@ extern int errno;
# define HASSNPRINTF 1 /* has snprintf(3) and vsnprintf(3) */
# endif
# define _PATH_UNIX "/stand/unix"
-# define _PATH_VENDOR_CF "/usr/ucblib/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/usr/ucblib/sendmail.cf"
+# endif
# ifndef _PATH_SENDMAILPID
# define _PATH_SENDMAILPID "/usr/ucblib/sendmail.pid"
# endif
@@ -1759,7 +1827,9 @@ extern int errno;
# ifndef __svr4__
# define __svr4__
# endif
-# define _PATH_VENDOR_CF "/etc/mail/sendmail.cf"
+# ifndef _PATH_VENDOR_CF
+# define _PATH_VENDOR_CF "/etc/mail/sendmail.cf"
+# endif
# ifndef _PATH_SENDMAILPID
# define _PATH_SENDMAILPID "/etc/mail/sendmail.pid"
# endif
@@ -1954,6 +2024,10 @@ typedef struct msgb mblk_t;
# define USE_SIGLONGJMP 0 /* assume setjmp handles signals properly */
#endif
+#ifndef FDSET_CAST
+# define FDSET_CAST /* (empty) cast for fd_set arg to select */
+#endif
+
/*
** If no type for argument two of getgroups call is defined, assume
** it's an integer -- unfortunately, there seem to be several choices
@@ -1983,6 +2057,14 @@ typedef struct msgb mblk_t;
#ifndef ARGV_T
# define ARGV_T char **
#endif
+
+#ifndef SOCKADDR_LEN_T
+# define SOCKADDR_LEN_T int
+#endif
+
+#ifndef SOCKOPT_LEN_T
+# define SOCKOPT_LEN_T int
+#endif
/**********************************************************************
** Remaining definitions should never have to be changed. They are
** primarily to provide back compatibility for older systems -- for
@@ -2077,28 +2159,6 @@ extern int h_errno;
#endif
/*
-** The size of an IP address -- can't use sizeof because of problems
-** on Crays, where everything is 64 bits. This will break if/when
-** IP addresses are expanded to eight bytes.
-*/
-
-#ifndef INADDRSZ
-# define INADDRSZ 4
-#endif
-
-/*
-** The size of various known types -- for reading network protocols.
-** Again, we can't use sizeof because of compiler randomness.
-*/
-
-#ifndef INT16SZ
-# define INT16SZ 2
-#endif
-#ifndef INT32SZ
-# define INT32SZ 4
-#endif
-
-/*
** Do some required dependencies
*/
@@ -2256,12 +2316,17 @@ typedef void (*sigfunc_t) __P((int));
*/
#if USE_SIGLONGJMP
-/* Silly SCO /usr/include/setjmp.h file has #define setjmp(env) setjmp(env) */
+# ifdef jmp_buf
+# undef jmp_buf
+# endif
+# define jmp_buf sigjmp_buf
# ifdef setjmp
# undef setjmp
# endif
-# define jmp_buf sigjmp_buf
# define setjmp(env) sigsetjmp(env, 1)
+# ifdef longjmp
+# undef longjmp
+# endif
# define longjmp(env, val) siglongjmp(env, val)
#endif
diff --git a/usr.sbin/sendmail/src/daemon.c b/usr.sbin/sendmail/src/daemon.c
index 41f1a72..bc8fd6f 100644
--- a/usr.sbin/sendmail/src/daemon.c
+++ b/usr.sbin/sendmail/src/daemon.c
@@ -37,9 +37,9 @@
#ifndef lint
#ifdef DAEMON
-static char sccsid[] = "@(#)daemon.c 8.175 (Berkeley) 6/1/97 (with daemon mode)";
+static char sccsid[] = "@(#)daemon.c 8.186 (Berkeley) 8/2/97 (with daemon mode)";
#else
-static char sccsid[] = "@(#)daemon.c 8.175 (Berkeley) 6/1/97 (without daemon mode)";
+static char sccsid[] = "@(#)daemon.c 8.186 (Berkeley) 8/2/97 (without daemon mode)";
#endif
#endif /* not lint */
@@ -130,6 +130,7 @@ getrequests(e)
bool refusingconnections = TRUE;
FILE *pidf;
int socksize;
+ u_short port;
#if XDEBUG
bool j_has_dot;
#endif
@@ -140,11 +141,24 @@ getrequests(e)
** Set up the address for the mailer.
*/
- if (DaemonAddr.sin.sin_family == 0)
- DaemonAddr.sin.sin_family = AF_INET;
- if (DaemonAddr.sin.sin_addr.s_addr == 0)
- DaemonAddr.sin.sin_addr.s_addr = INADDR_ANY;
- if (DaemonAddr.sin.sin_port == 0)
+ switch (DaemonAddr.sa.sa_family)
+ {
+ case AF_UNSPEC:
+ DaemonAddr.sa.sa_family = AF_INET;
+ /* fall through ... */
+
+ case AF_INET:
+ if (DaemonAddr.sin.sin_addr.s_addr == 0)
+ DaemonAddr.sin.sin_addr.s_addr = INADDR_ANY;
+ port = DaemonAddr.sin.sin_port;
+ break;
+
+ default:
+ /* unknown protocol */
+ port = 0;
+ break;
+ }
+ if (port == 0)
{
register struct servent *sp;
@@ -152,10 +166,21 @@ getrequests(e)
if (sp == NULL)
{
syserr("554 service \"smtp\" unknown");
- DaemonAddr.sin.sin_port = htons(25);
+ port = htons(25);
}
else
- DaemonAddr.sin.sin_port = sp->s_port;
+ port = sp->s_port;
+ }
+
+ switch (DaemonAddr.sa.sa_family)
+ {
+ case AF_INET:
+ DaemonAddr.sin.sin_port = port;
+ break;
+
+ default:
+ /* unknown protocol */
+ break;
}
/*
@@ -171,7 +196,7 @@ getrequests(e)
(void) setsignal(SIGCHLD, reapchild);
/* write the pid to the log file for posterity */
- pidf = safefopen(PidFile, O_WRONLY|O_CREAT|O_TRUNC, 0644,
+ pidf = safefopen(PidFile, O_WRONLY|O_TRUNC, 0644,
SFF_NOLINK|SFF_ROOTOK|SFF_REGONLY|SFF_CREAT);
if (pidf == NULL)
{
@@ -206,7 +231,7 @@ getrequests(e)
for (;;)
{
register pid_t pid;
- auto int lotherend;
+ auto SOCKADDR_LEN_T lotherend;
int savederrno;
int pipefd[2];
extern bool refuseconnections();
@@ -281,7 +306,8 @@ getrequests(e)
timeout.tv_sec = 60;
timeout.tv_usec = 0;
- t = select(DaemonSocket + 1, &readfds, NULL, NULL, &timeout);
+ t = select(DaemonSocket + 1, FDSET_CAST &readfds,
+ NULL, NULL, &timeout);
if (DoQueueRun)
(void) runqueue(TRUE, FALSE);
if (t <= 0 || !FD_ISSET(DaemonSocket, &readfds))
@@ -972,7 +998,7 @@ gothostent:
}
else
{
- s = socket(AF_INET, SOCK_STREAM, 0);
+ s = socket(addr.sa.sa_family, SOCK_STREAM, 0);
}
if (s < 0)
{
@@ -1176,6 +1202,35 @@ myhostname(hostbuf, size)
return (hp);
}
/*
+** ADDRCMP -- compare two host addresses
+**
+** Parameters:
+** hp -- hostent structure for the first address
+** ha -- actual first address
+** sa -- second address
+**
+** Returns:
+** 0 -- if ha and sa match
+** else -- they don't match
+*/
+
+int
+addrcmp(hp, ha, sa)
+ struct hostent *hp;
+ char *ha;
+ SOCKADDR *sa;
+{
+ switch (sa->sa.sa_family)
+ {
+ case AF_INET:
+ if (hp->h_addrtype == AF_INET)
+ return bcmp(ha, (char *) &sa->sin.sin_addr, hp->h_length);
+ break;
+
+ }
+ return -1;
+}
+ /*
** GETAUTHINFO -- get the real host name asociated with a file descriptor
**
** Uses RFC1413 protocol to try to get info from the other end.
@@ -1199,10 +1254,10 @@ char *
getauthinfo(fd)
int fd;
{
- int falen;
+ SOCKADDR_LEN_T falen;
register char *volatile p = NULL;
SOCKADDR la;
- int lalen;
+ SOCKADDR_LEN_T lalen;
register struct servent *sp;
volatile int s;
int i;
@@ -1239,19 +1294,22 @@ getauthinfo(fd)
/* address is not a socket */
may_be_forged = FALSE;
}
+ else if (RealHostName[0] == '[')
+ {
+ /* have IP address with no forward lookup */
+ may_be_forged = FALSE;
+ }
else
{
/* try to match the reverse against the forward lookup */
- hp = gethostbyname(RealHostName);
+ hp = sm_gethostbyname(RealHostName);
if (hp == NULL)
may_be_forged = TRUE;
else
{
for (ha = hp->h_addr_list; *ha != NULL; ha++)
- if (bcmp(*ha,
- (char *) &RealHostAddr.sin.sin_addr,
- hp->h_length) == 0)
+ if (addrcmp(hp, *ha, &RealHostAddr) == 0)
break;
may_be_forged = *ha == NULL;
}
@@ -1412,7 +1470,8 @@ postident:
if (RealHostAddr.sa.sa_family == AF_INET)
{
- int ipoptlen, j;
+ SOCKOPT_LEN_T ipoptlen;
+ int j;
u_char *q;
u_char *o;
int l;
@@ -1573,6 +1632,14 @@ host_map_lookup(map, name, av, statp)
}
if (*statp != EX_OK)
return NULL;
+ if (s->s_namecanon.nc_cname == NULL)
+ {
+ syserr("host_map_lookup(%s): bogus NULL cache entry, errno = %d, h_errno = %d",
+ name,
+ s->s_namecanon.nc_errno,
+ s->s_namecanon.nc_herrno);
+ return NULL;
+ }
if (bitset(MF_MATCHONLY, map->map_mflags))
cp = map_rewrite(map, name, strlen(name), NULL);
else
@@ -1959,7 +2026,7 @@ hostnamebyanyaddr(sap)
_res.retry = saveretry;
#endif /* NAMED_BIND */
- if (hp != NULL)
+ if (hp != NULL && hp->h_name[0] != '[')
return (char *) hp->h_name;
else
{
diff --git a/usr.sbin/sendmail/src/deliver.c b/usr.sbin/sendmail/src/deliver.c
index b5d5413..8805ab9 100644
--- a/usr.sbin/sendmail/src/deliver.c
+++ b/usr.sbin/sendmail/src/deliver.c
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)deliver.c 8.282 (Berkeley) 6/11/97";
+static char sccsid[] = "@(#)deliver.c 8.285 (Berkeley) 8/2/97";
#endif /* not lint */
#include "sendmail.h"
@@ -543,7 +543,7 @@ sendall(e, mode)
}
/* be sure to give error messages in child */
- QuickAbort = OnlyOneError = FALSE;
+ QuickAbort = FALSE;
/*
** Close any cached connections.
@@ -3105,7 +3105,7 @@ mailfile(filename, ctladdr, sfflags, e)
{
register FILE *f;
register pid_t pid = -1;
- int mode;
+ int mode = ST_MODE_NOFILE;
bool suidwarn = geteuid() == 0;
if (tTd(11, 1))
@@ -3153,19 +3153,20 @@ mailfile(filename, ctladdr, sfflags, e)
ExitStat = EX_OK;
#ifdef HASLSTAT
- if ((SafeFileEnv != NULL ? lstat(filename, &stb)
- : stat(filename, &stb)) < 0)
+ if (lstat(filename, &stb) < 0)
#else
if (stat(filename, &stb) < 0)
#endif
{
- stb.st_mode = FileMode;
+ stb.st_mode = ST_MODE_NOFILE;
+ mode = FileMode;
oflags |= O_CREAT|O_EXCL;
}
else if (bitset(0111, stb.st_mode) || stb.st_nlink != 1 ||
(SafeFileEnv != NULL && !S_ISREG(stb.st_mode)))
exit(EX_CANTCREAT);
- mode = stb.st_mode;
+ if (mode == ST_MODE_NOFILE)
+ mode = stb.st_mode;
/* limit the errors to those actually caused in the child */
errno = 0;
@@ -3275,6 +3276,11 @@ mailfile(filename, ctladdr, sfflags, e)
message("554 cannot open: %s", errstring(errno));
exit(EX_CANTCREAT);
}
+ if (filechanged(filename, fileno(f), &stb, sfflags))
+ {
+ message("554 file changed after open");
+ exit(EX_CANTCREAT);
+ }
if (fstat(fileno(f), &stb) < 0)
{
message("554 cannot fstat %s", errstring(errno));
diff --git a/usr.sbin/sendmail/src/domain.c b/usr.sbin/sendmail/src/domain.c
index 741a7cd..a9bc023 100644
--- a/usr.sbin/sendmail/src/domain.c
+++ b/usr.sbin/sendmail/src/domain.c
@@ -36,9 +36,9 @@
#ifndef lint
#if NAMED_BIND
-static char sccsid[] = "@(#)domain.c 8.67 (Berkeley) 4/9/97 (with name server)";
+static char sccsid[] = "@(#)domain.c 8.68 (Berkeley) 8/2/97 (with name server)";
#else
-static char sccsid[] = "@(#)domain.c 8.67 (Berkeley) 4/9/97 (without name server)";
+static char sccsid[] = "@(#)domain.c 8.68 (Berkeley) 8/2/97 (without name server)";
#endif
#endif /* not lint */
@@ -854,12 +854,15 @@ gethostalias(host)
char *fname;
FILE *fp;
register char *p = NULL;
+ int sff = SFF_REGONLY;
char buf[MAXLINE];
static char hbuf[MAXDNAME];
+ if (DontLockReadFiles)
+ sff |= SFF_NOLOCK;
fname = getenv("HOSTALIASES");
if (fname == NULL ||
- (fp = safefopen(fname, O_RDONLY, 0, SFF_REGONLY)) == NULL)
+ (fp = safefopen(fname, O_RDONLY, 0, sff)) == NULL)
return NULL;
while (fgets(buf, sizeof buf, fp) != NULL)
{
diff --git a/usr.sbin/sendmail/src/headers.c b/usr.sbin/sendmail/src/headers.c
index 940faf7..ac67f2c 100644
--- a/usr.sbin/sendmail/src/headers.c
+++ b/usr.sbin/sendmail/src/headers.c
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)headers.c 8.110 (Berkeley) 6/14/97";
+static char sccsid[] = "@(#)headers.c 8.111 (Berkeley) 7/9/97";
#endif /* not lint */
# include <errno.h>
@@ -192,7 +192,8 @@ chompheader(line, def, hdrp, e)
printf("no header flags match\n");
else
printf("header match, flags=%x, ruleset=%s\n",
- hi->hi_flags, hi->hi_ruleset);
+ hi->hi_flags,
+ hi->hi_ruleset == NULL ? "<NULL>" : hi->hi_ruleset);
}
/* see if this is a resent message */
diff --git a/usr.sbin/sendmail/src/main.c b/usr.sbin/sendmail/src/main.c
index b9be725..61c54e7 100644
--- a/usr.sbin/sendmail/src/main.c
+++ b/usr.sbin/sendmail/src/main.c
@@ -39,7 +39,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)main.c 8.246 (Berkeley) 6/11/97";
+static char sccsid[] = "@(#)main.c 8.249 (Berkeley) 7/25/97";
#endif /* not lint */
#define _DEFINE
@@ -93,6 +93,7 @@ ADDRESS NullAddress = /* a null address */
char *CommandLineArgs; /* command line args for pid file */
bool Warn_Q_option = FALSE; /* warn about Q option use */
char **SaveArgv; /* argument vector for re-execing */
+int MissingFds = 0; /* bit map of fds missing on startup */
#ifdef NGROUPS_MAX
GIDSET_T InitialGidSet[NGROUPS_MAX];
@@ -164,7 +165,6 @@ main(argc, argv, envp)
extern void printqueue __P((void));
extern void sendtoargv __P((char **, ENVELOPE *));
extern void resetlimits __P((void));
- extern void drop_privileges __P((void));
/*
** Check to see if we reentered.
@@ -185,11 +185,6 @@ main(argc, argv, envp)
/* do machine-dependent initializations */
init_md(argc, argv);
-#ifdef SIGUSR1
- /* arrange to dump state on user-1 signal */
- setsignal(SIGUSR1, sigusr1);
-#endif
-
/* in 4.4BSD, the table can be huge; impose a reasonable limit */
DtableSize = getdtsize();
if (DtableSize > 256)
@@ -200,15 +195,9 @@ main(argc, argv, envp)
** But also be sure that 0, 1, & 2 are open.
*/
- i = open("/dev/null", O_RDWR, 0);
- if (fstat(STDIN_FILENO, &stb) < 0 && errno != EOPNOTSUPP)
- (void) dup2(i, STDIN_FILENO);
- if (fstat(STDOUT_FILENO, &stb) < 0 && errno != EOPNOTSUPP)
- (void) dup2(i, STDOUT_FILENO);
- if (fstat(STDERR_FILENO, &stb) < 0 && errno != EOPNOTSUPP)
- (void) dup2(i, STDERR_FILENO);
- if (i != STDIN_FILENO && i != STDOUT_FILENO && i != STDERR_FILENO)
- (void) close(i);
+ fill_fd(STDIN_FILENO, NULL);
+ fill_fd(STDOUT_FILENO, NULL);
+ fill_fd(STDERR_FILENO, NULL);
i = DtableSize;
while (--i > 0)
@@ -226,6 +215,28 @@ main(argc, argv, envp)
# endif
#endif
+ if (MissingFds != 0)
+ {
+ char mbuf[MAXLINE];
+
+ mbuf[0] = '\0';
+ if (bitset(1 << STDIN_FILENO, MissingFds))
+ strcat(mbuf, ", stdin");
+ if (bitset(1 << STDOUT_FILENO, MissingFds))
+ strcat(mbuf, ", stdout");
+ if (bitset(1 << STDERR_FILENO, MissingFds))
+ strcat(mbuf, ", stderr");
+ syserr("File descriptors missing on startup: %s", &mbuf[2]);
+ }
+
+ /* reset status from syserr() calls for missing file descriptors */
+ Errors = 0;
+ ExitStat = EX_OK;
+
+#if XDEBUG
+ checkfd012("after openlog");
+#endif
+
tTsetup(tTdvect, sizeof tTdvect, "0-99.1");
#ifdef NGROUPS_MAX
@@ -238,7 +249,12 @@ main(argc, argv, envp)
#endif
/* drop group id privileges (RunAsUser not yet set) */
- drop_privileges();
+ (void) drop_privileges(FALSE);
+
+#ifdef SIGUSR1
+ /* arrange to dump state on user-1 signal */
+ setsignal(SIGUSR1, sigusr1);
+#endif
/* Handle any non-getoptable constructions. */
obsolete(argv);
@@ -301,6 +317,17 @@ main(argc, argv, envp)
(void) snprintf(rnamebuf, sizeof rnamebuf, "Unknown UID %d", RealUid);
RealUserName = rnamebuf;
+ /* if running non-setuid binary, pretend we are the RunAsUid */
+ if (geteuid() == RealUid)
+ {
+ if (tTd(47, 1))
+ printf("Non-setuid binary: RunAsUid = RealUid = %d\n",
+ RealUid);
+ RunAsUid = RealUid;
+ }
+ if (getegid() == RealGid)
+ RunAsGid = RealGid;
+
/* save command line arguments */
i = 0;
for (av = argv; *av != NULL; )
@@ -572,9 +599,7 @@ main(argc, argv, envp)
if (RealUid != 0)
warn_C_flag = TRUE;
ConfFile = optarg;
- endpwent();
- (void) setgid(RealGid);
- (void) setuid(RealUid);
+ (void) drop_privileges(TRUE);
safecf = FALSE;
break;
@@ -726,9 +751,7 @@ main(argc, argv, envp)
break;
case 'X': /* traffic log file */
- endpwent();
- setgid(RealGid);
- setuid(RealUid);
+ (void) drop_privileges(TRUE);
TrafficLogFile = fopen(optarg, "a");
if (TrafficLogFile == NULL)
{
@@ -815,7 +838,7 @@ main(argc, argv, envp)
if (OpMode != MD_DAEMON && OpMode != MD_FGDAEMON)
{
/* drop privileges -- daemon mode done after socket/bind */
- drop_privileges();
+ (void) drop_privileges(FALSE);
}
/*
@@ -1351,7 +1374,7 @@ main(argc, argv, envp)
nullserver = getrequests(CurEnv);
/* drop privileges */
- drop_privileges();
+ (void) drop_privileges(FALSE);
/* at this point we are in a child: reset state */
(void) newenvelope(CurEnv, CurEnv);
@@ -2017,11 +2040,11 @@ sighup(sig)
sm_syslog(LOG_INFO, NOQID, "restarting %s on signal", SaveArgv[0]);
alarm(0);
releasesignal(SIGHUP);
- if (setgid(RealGid) < 0 || setuid(RealUid) < 0)
+ if (drop_privileges(TRUE) != EX_OK)
{
if (LogLevel > 0)
sm_syslog(LOG_ALERT, NOQID, "could not set[ug]id(%d, %d): %m",
- RealUid, RealGid);
+ RunAsUid, RunAsGid);
exit(EX_OSERR);
}
execv(SaveArgv[0], (ARGV_T) SaveArgv);
@@ -2033,26 +2056,91 @@ sighup(sig)
** DROP_PRIVILEGES -- reduce privileges to those of the RunAsUser option
**
** Parameters:
-** none.
+** to_real_uid -- if set, drop to the real uid instead
+** of the RunAsUser.
**
** Returns:
-** none.
+** EX_OSERR if the setuid failed.
+** EX_OK otherwise.
*/
-void
-drop_privileges()
+int
+drop_privileges(to_real_uid)
+ bool to_real_uid;
{
+ int rval = EX_OK;
#ifdef NGROUPS_MAX
- /* reset group permissions; these can be set later */
GIDSET_T emptygidset[NGROUPS_MAX];
+#endif
+
+ if (tTd(47, 1))
+ printf("drop_privileges(%d): Real[UG]id=%d:%d, RunAs[UG]id=%d:%d\n",
+ to_real_uid, RealUid, RealGid, RunAsUid, RunAsGid);
+
+ if (to_real_uid)
+ {
+ RunAsUserName = RealUserName;
+ RunAsUid = RealUid;
+ RunAsGid = RealGid;
+ }
+
+ /* make sure no one can grab open descriptors for secret files */
+ endpwent();
+#ifdef NGROUPS_MAX
+ /* reset group permissions; these can be set later */
emptygidset[0] = RunAsGid == 0 ? getegid() : RunAsGid;
(void) setgroups(1, emptygidset);
#endif
- if (RunAsGid != 0)
- (void) setgid(RunAsGid);
- if (RunAsUid != 0)
- (void) setuid(RunAsUid);
+
+ /* reset primary group and user id */
+ if (RunAsGid != 0 && setgid(RunAsGid) < 0)
+ rval = EX_OSERR;
+ if (RunAsUid != 0 && setuid(RunAsUid) < 0)
+ rval = EX_OSERR;
+ return rval;
+}
+ /*
+** FILL_FD -- make sure a file descriptor has been properly allocated
+**
+** Used to make sure that stdin/out/err are allocated on startup
+**
+** Parameters:
+** fd -- the file descriptor to be filled.
+** where -- a string used for logging. If NULL, this is
+** being called on startup, and logging should
+** not be done.
+**
+** Returns:
+** none
+*/
+
+void
+fill_fd(fd, where)
+ int fd;
+ char *where;
+{
+ int i;
+ struct stat stbuf;
+
+ if (fstat(fd, &stbuf) >= 0 || errno != EBADF)
+ return;
+
+ if (where != NULL)
+ syserr("fill_fd: %s: fd %d not open", where, fd);
+ else
+ MissingFds |= 1 << fd;
+ i = open("/dev/null", fd == 0 ? O_RDONLY : O_WRONLY, 0666);
+ if (i < 0)
+ {
+ syserr("!fill_fd: %s: cannot open /dev/null",
+ where == NULL ? "startup" : where);
+ }
+ if (fd != i)
+ {
+ (void) dup2(i, fd);
+ (void) close(i);
+ }
}
/*
** TESTMODELINE -- process a test mode input line
diff --git a/usr.sbin/sendmail/src/parseaddr.c b/usr.sbin/sendmail/src/parseaddr.c
index 258e0a9..75b9089 100644
--- a/usr.sbin/sendmail/src/parseaddr.c
+++ b/usr.sbin/sendmail/src/parseaddr.c
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)parseaddr.c 8.128 (Berkeley) 6/14/97";
+static char sccsid[] = "@(#)parseaddr.c 8.130 (Berkeley) 8/2/97";
#endif /* not lint */
# include "sendmail.h"
@@ -2349,7 +2349,6 @@ rscheck(rwset, p1, p2, e)
auto ADDRESS a1;
bool saveQuickAbort = QuickAbort;
bool saveSuprErrs = SuprErrs;
- bool saveOnlyOneError = OnlyOneError;
char buf0[MAXLINE];
char pvpbuf[PSBUFSIZE];
extern char MsgBuf[];
@@ -2387,7 +2386,7 @@ rscheck(rwset, p1, p2, e)
(void) snprintf(buf, bufsize, "%s", p1);
}
SuprErrs = TRUE;
- OnlyOneError = QuickAbort = FALSE;
+ QuickAbort = FALSE;
pvp = prescan(buf, '\0', pvpbuf, sizeof pvpbuf, NULL, NULL);
SuprErrs = saveSuprErrs;
if (pvp == NULL)
@@ -2413,25 +2412,38 @@ rscheck(rwset, p1, p2, e)
if (LogLevel >= 4)
{
- if (p2 == NULL)
- sm_syslog(LOG_NOTICE, e->e_id,
- "Ruleset %s (%s) rejection: %s",
- rwset, p1, MsgBuf);
- else
- sm_syslog(LOG_NOTICE, e->e_id,
- "Ruleset %s (%s, %s) rejection: %s",
- rwset, p1, p2, MsgBuf);
+ char *relay;
+ char *p;
+ char lbuf[MAXLINE];
+
+ p = lbuf;
+ if (p2 != NULL)
+ {
+ snprintf(p, SPACELEFT(lbuf, p),
+ ", arg2=%s",
+ p2);
+ p += strlen(p);
+ }
+ if ((relay = macvalue('_', e)) != NULL)
+ {
+ snprintf(p, SPACELEFT(lbuf, p),
+ ", relay=%s", relay);
+ p += strlen(p);
+ }
+ *p = '\0';
+ sm_syslog(LOG_NOTICE, e->e_id,
+ "ruleset=%s, arg1=%s%s, reject=%s",
+ rwset, p1, lbuf, MsgBuf);
}
finis:
/* clean up */
QuickAbort = saveQuickAbort;
- OnlyOneError = saveOnlyOneError;
setstat(rstat);
if (buf != buf0)
free(buf);
- if (rstat != EX_OK && (QuickAbort || (OnlyOneError && !HoldErrs)))
+ if (rstat != EX_OK && QuickAbort)
longjmp(TopFrame, 2);
return rstat;
}
diff --git a/usr.sbin/sendmail/src/readcf.c b/usr.sbin/sendmail/src/readcf.c
index f050fde..a8c82f7 100644
--- a/usr.sbin/sendmail/src/readcf.c
+++ b/usr.sbin/sendmail/src/readcf.c
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)readcf.c 8.196 (Berkeley) 5/29/97";
+static char sccsid[] = "@(#)readcf.c 8.200 (Berkeley) 8/2/97";
#endif /* not lint */
# include "sendmail.h"
@@ -105,13 +105,14 @@ readcf(cfname, safe, e)
char *file;
bool optional;
int mid;
- char buf[MAXLINE];
register char *p;
- extern char **copyplist();
+ int sff = SFF_OPENASROOT;
struct stat statb;
+ char buf[MAXLINE];
char exbuf[MAXLINE];
char pvpbuf[MAXLINE + MAXATOM];
static char *null_list[1] = { NULL };
+ extern char **copyplist __P((char **, bool));
extern char *munchstring __P((char *, char **, int));
extern void fileclass __P((int, char *, char *, bool, bool));
extern void toomany __P((int, int));
@@ -121,7 +122,9 @@ readcf(cfname, safe, e)
FileName = cfname;
LineNumber = 0;
- cf = safefopen(cfname, O_RDONLY, 0444, SFF_OPENASROOT|SFF_NOLOCK);
+ if (DontLockReadFiles)
+ sff |= SFF_NOLOCK;
+ cf = safefopen(cfname, O_RDONLY, 0444, sff);
if (cf == NULL)
{
syserr("cannot open");
@@ -438,11 +441,14 @@ readcf(cfname, safe, e)
break;
#endif
-#ifdef SUN_EXTENSIONS
+#if defined(SUN_EXTENSIONS) && defined(SUN_LOOKUP_MACRO)
case 'L': /* lookup macro */
case 'G': /* lookup class */
/* reserved for Sun -- NIS+ database lookup */
- goto badline;
+ if (VendorCode != VENDOR_SUN)
+ goto badline;
+ sun_lg_config_line(bp, e);
+ break;
#endif
case 'M': /* define mailer */
@@ -747,6 +753,8 @@ fileclass(class, filename, fmt, safe, optional)
sff = SFF_REGONLY|SFF_NOWLINK;
if (safe)
sff |= SFF_OPENASROOT;
+ if (DontLockReadFiles)
+ sff |= SFF_NOLOCK;
f = safefopen(filename, O_RDONLY, 0, sff);
}
if (f == NULL)
@@ -1505,6 +1513,14 @@ struct optioninfo
#define O_MAXRCPT 0xa3
{ "MaxRecipientPerMessage", O_MAXRCPT, FALSE },
#endif
+#if _FFR_DEADLETTERDROP_OPTION
+#define O_DEADLETTER 0xa4
+ { "DeadLetterDrop", O_DEADLETTER, FALSE },
+#endif
+#if _FFR_DONTLOCKFILESFORREAD_OPTION
+#define O_DONTLOCK 0xa5
+ { "DontLockFilesForRead", O_DONTLOCK, FALSE },
+#endif
{ NULL, '\0', FALSE }
};
@@ -1644,14 +1660,7 @@ setoption(opt, val, safe, sticky, e)
{
if (tTd(37, 1))
printf(" (unsafe)");
- if (RealUid != geteuid())
- {
- if (tTd(37, 1))
- printf("(Resetting uid)");
- endpwent();
- (void) setgid(RealGid);
- (void) setuid(RealUid);
- }
+ (void) drop_privileges(TRUE);
}
}
if (tTd(37, 1))
@@ -2256,7 +2265,10 @@ setoption(opt, val, safe, sticky, e)
}
}
if (isascii(*val) && isdigit(*val))
- RunAsUid = atoi(val);
+ {
+ if (RunAsUid == 0)
+ RunAsUid = atoi(val);
+ }
else
{
register struct passwd *pw;
@@ -2264,7 +2276,7 @@ setoption(opt, val, safe, sticky, e)
pw = sm_getpwnam(val);
if (pw == NULL)
syserr("readcf: option RunAsUser: unknown user %s", val);
- else
+ else if (RunAsUid == 0)
{
if (*p == '\0')
RunAsUserName = newstr(val);
@@ -2275,7 +2287,10 @@ setoption(opt, val, safe, sticky, e)
if (*p == '\0')
break;
if (isascii(*p) && isdigit(*p))
- RunAsGid = atoi(p);
+ {
+ if (RunAsGid == 0)
+ RunAsGid = atoi(p);
+ }
else
{
register struct group *gr;
@@ -2284,7 +2299,7 @@ setoption(opt, val, safe, sticky, e)
if (gr == NULL)
syserr("readcf: option RunAsUser: unknown group %s",
p);
- else
+ else if (RunAsGid == 0)
RunAsGid = gr->gr_gid;
}
break;
@@ -2326,6 +2341,20 @@ setoption(opt, val, safe, sticky, e)
break;
#endif
+#if _FFR_DEADLETTERDROP_OPTION
+ case O_DEADLETTER:
+ if (DeadLetterDrop != NULL)
+ free(DeadLetterDrop);
+ DeadLetterDrop = newstr(val);
+ break;
+#endif
+
+#if _FFR_DONTLOCKFILESFORREAD_OPTION
+ case O_DONTLOCK:
+ DontLockReadFiles = atobool(val);
+ break;
+#endif
+
default:
if (tTd(37, 1))
{
diff --git a/usr.sbin/sendmail/src/savemail.c b/usr.sbin/sendmail/src/savemail.c
index 894352c..40ad883 100644
--- a/usr.sbin/sendmail/src/savemail.c
+++ b/usr.sbin/sendmail/src/savemail.c
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)savemail.c 8.110 (Berkeley) 4/7/97";
+static char sccsid[] = "@(#)savemail.c 8.114 (Berkeley) 8/2/97";
#endif /* not lint */
# include "sendmail.h"
@@ -70,10 +70,6 @@ static char sccsid[] = "@(#)savemail.c 8.110 (Berkeley) 4/7/97";
# define ESM_PANIC 6 /* leave the locked queue/transcript files */
# define ESM_DONE 7 /* the message is successfully delivered */
-# ifndef _PATH_VARTMP
-# define _PATH_VARTMP "/usr/tmp/"
-# endif
-
void
savemail(e, sendbody)
@@ -301,7 +297,8 @@ savemail(e, sendbody)
*/
q = NULL;
- if (sendtolist(DoubleBounceAddr, NULL, &q, 0, e) <= 0)
+ if (sendtolist(DoubleBounceAddr,
+ NULLADDR, &q, 0, e) <= 0)
{
syserr("553 cannot parse %s!", DoubleBounceAddr);
ExitStat = EX_SOFTWARE;
@@ -375,17 +372,16 @@ savemail(e, sendbody)
break;
}
- if (SafeFileEnv != NULL && SafeFileEnv[0] != '\0')
+ if ((SafeFileEnv != NULL && SafeFileEnv[0] != '\0') ||
+ DeadLetterDrop == NULL || DeadLetterDrop[0] == '\0')
{
state = ESM_PANIC;
break;
}
- snprintf(buf, sizeof buf, "%sdead.letter", _PATH_VARTMP);
-
flags = SFF_NOLINK|SFF_CREAT|SFF_REGONLY|SFF_OPENASROOT|SFF_MUSTOWN;
- if (!writable(buf, NULL, flags) ||
- (fp = safefopen(buf, O_WRONLY|O_CREAT|O_APPEND,
+ if (!writable(DeadLetterDrop, NULL, flags) ||
+ (fp = safefopen(DeadLetterDrop, O_WRONLY|O_APPEND,
FileMode, flags)) == NULL)
{
state = ESM_PANIC;
@@ -410,15 +406,15 @@ savemail(e, sendbody)
int oldverb = Verbose;
Verbose = 1;
- message("Saved message in %s", buf);
+ message("Saved message in %s", DeadLetterDrop);
Verbose = oldverb;
if (LogLevel > 3)
sm_syslog(LOG_NOTICE, e->e_id,
"Saved message in %s",
- buf);
+ DeadLetterDrop);
state = ESM_DONE;
}
- (void) xfclose(fp, "savemail", buf);
+ (void) xfclose(fp, "savemail", DeadLetterDrop);
break;
default:
@@ -758,8 +754,11 @@ errbody(mci, e, separator)
{
if (*ErrMsgFile == '/')
{
- xfile = safefopen(ErrMsgFile, O_RDONLY, 0444,
- SFF_ROOTOK|SFF_REGONLY);
+ int sff = SFF_ROOTOK|SFF_REGONLY;
+
+ if (DontLockReadFiles)
+ sff |= SFF_NOLOCK;
+ xfile = safefopen(ErrMsgFile, O_RDONLY, 0444, sff);
if (xfile != NULL)
{
while (fgets(buf, sizeof buf, xfile) != NULL)
diff --git a/usr.sbin/sendmail/src/sendmail.h b/usr.sbin/sendmail/src/sendmail.h
index 2eb40c8..00559ea 100644
--- a/usr.sbin/sendmail/src/sendmail.h
+++ b/usr.sbin/sendmail/src/sendmail.h
@@ -31,7 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)sendmail.h 8.236 (Berkeley) 6/5/97
+ * @(#)sendmail.h 8.242 (Berkeley) 8/2/97
*/
/*
@@ -41,7 +41,7 @@
# ifdef _DEFINE
# define EXTERN
# ifndef lint
-static char SmailSccsId[] = "@(#)sendmail.h 8.236 6/5/97";
+static char SmailSccsId[] = "@(#)sendmail.h 8.242 8/2/97";
# endif
# else /* _DEFINE */
# define EXTERN extern
@@ -94,6 +94,25 @@ static char SmailSccsId[] = "@(#)sendmail.h 8.236 6/5/97";
# endif
#endif
+/*
+** Following are "sort of" configuration constants, but they should
+** be pretty solid on most architectures today. They have to be
+** defined after <arpa/nameser.h> because some versions of that
+** file also define them. In all cases, we can't use sizeof because
+** some systems (e.g., Crays) always treat everything as being at
+** least 64 bits.
+*/
+
+#ifndef INADDRSZ
+# define INADDRSZ 4 /* size of an IPv4 address in bytes */
+#endif
+#ifndef INT16SZ
+# define INT16SZ 2 /* size of a 16 bit integer in bytes */
+#endif
+#ifndef INT32SZ
+# define INT32SZ 4 /* size of a 32 bit integer in bytes */
+#endif
+
/* forward references for prototypes */
@@ -426,7 +445,7 @@ extern void addheader __P((char *, char *, HDR **));
extern char *hvalue __P((char *, HDR *));
extern void commaize __P((HDR *, char *, bool, MCI *, ENVELOPE *));
extern void put_vanilla_header __P((HDR *, char *, MCI *));
-extern void eatheader __P((ENVELOPE *e, bool));
+extern void eatheader __P((ENVELOPE *, bool));
extern int chompheader __P((char *, bool, HDR **, ENVELOPE *));
/*
** Envelope structure.
@@ -1197,12 +1216,14 @@ EXTERN bool DoQueueRun; /* non-interrupt time queue run needed */
#if _FFR_DSN_RRT_OPTION
EXTERN bool RrtImpliesDsn; /* turn Return-Receipt-To: into DSN */
#endif
+EXTERN char *DeadLetterDrop; /* path to dead letter office */
EXTERN bool DontProbeInterfaces; /* don't probe interfaces for names */
EXTERN bool ChownAlwaysSafe; /* treat chown(2) as safe */
EXTERN bool IgnoreHostStatus; /* ignore long term host status files */
EXTERN bool SingleThreadDelivery; /* single thread hosts on delivery */
EXTERN bool UnsafeGroupWrites; /* group-writable files are unsafe */
EXTERN bool SingleLineFromHeader; /* force From: header to be one line */
+EXTERN bool DontLockReadFiles; /* don't read lock support files */
EXTERN int ConnRateThrottle; /* throttle for SMTP connection rate */
EXTERN int MaxAliasRecursion; /* maximum depth of alias recursion */
EXTERN int MaxMacroRecursion; /* maximum depth of macro recursion */
@@ -1396,6 +1417,8 @@ extern int prog_open __P((char **, int *, ENVELOPE *));
extern bool getcanonname __P((char *, int, bool));
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 const char *errstring __P((int));
extern sigfunc_t setsignal __P((int, sigfunc_t));
@@ -1419,7 +1442,7 @@ extern void syserr(const char *, ...);
extern void usrerr(const char *, ...);
extern void message(const char *, ...);
extern void nmessage(const char *, ...);
-extern void setproctitle(const char *fmt, ...);
+extern void setproctitle(const char *, ...);
extern void sm_syslog(int, const char *, const char *, ...);
#else
extern void auth_warning();
diff --git a/usr.sbin/sendmail/src/srvrsmtp.c b/usr.sbin/sendmail/src/srvrsmtp.c
index fa39e68..3255e83 100644
--- a/usr.sbin/sendmail/src/srvrsmtp.c
+++ b/usr.sbin/sendmail/src/srvrsmtp.c
@@ -36,9 +36,9 @@
#ifndef lint
#if SMTP
-static char sccsid[] = "@(#)srvrsmtp.c 8.146 (Berkeley) 6/11/97 (with SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 8.154 (Berkeley) 8/2/97 (with SMTP)";
#else
-static char sccsid[] = "@(#)srvrsmtp.c 8.146 (Berkeley) 6/11/97 (without SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 8.154 (Berkeley) 8/2/97 (without SMTP)";
#endif
#endif /* not lint */
@@ -154,6 +154,7 @@ smtp(nullserver, e)
volatile int n_helo = 0; /* count of HELO/EHLO commands */
bool ok;
int lognullconnection = TRUE;
+ register char *q;
char inp[MAXLINE];
char cmdbuf[MAXLINE];
extern ENVELOPE BlankEnvelope;
@@ -221,16 +222,7 @@ smtp(nullserver, e)
for (;;)
{
/* arrange for backout */
- if (setjmp(TopFrame) > 0)
- {
- /* if() nesting is necessary for Cray UNICOS */
- if (InChild)
- {
- QuickAbort = FALSE;
- SuprErrs = TRUE;
- finis();
- }
- }
+ (void) setjmp(TopFrame);
QuickAbort = FALSE;
HoldErrs = FALSE;
SuprErrs = FALSE;
@@ -375,51 +367,50 @@ smtp(nullserver, e)
cmdbuf);
break;
}
- else
- {
- register char *q;
- for (q = p; *q != '\0'; q++)
- {
- if (!isascii(*q))
- break;
- if (isalnum(*q))
- continue;
- if (isspace(*q))
- {
- *q = '\0';
- break;
- }
- if (strchr("[].-_#", *q) == NULL)
- break;
- }
- if (*q != '\0')
+ for (q = p; *q != '\0'; q++)
+ {
+ if (!isascii(*q))
+ break;
+ if (isalnum(*q))
+ continue;
+ if (isspace(*q))
{
- if (!AllowBogusHELO)
- usrerr("501 Invalid domain name");
- else
- {
- message("250 %s Invalid domain name, accepting anyway",
- MyHostName);
- gothello = TRUE;
- }
+ *q = '\0';
break;
}
+ if (strchr("[].-_#", *q) == NULL)
+ break;
+ }
+ if (*q == '\0')
+ {
+ q = "pleased to meet you";
+ sendinghost = newstr(p);
+ }
+ else if (!AllowBogusHELO)
+ {
+ usrerr("501 Invalid domain name");
+ break;
+ }
+ else
+ {
+ q = "accepting invalid domain name";
}
- sendinghost = newstr(p);
gothello = TRUE;
+
+ /* print HELO response message */
if (c->cmdcode != CMDEHLO)
{
- /* print old message and be done with it */
- message("250 %s Hello %s, pleased to meet you",
- MyHostName, CurSmtpClient);
+ message("250 %s Hello %s, %s",
+ MyHostName, CurSmtpClient, q);
break;
}
- /* print extended message and brag */
- message("250-%s Hello %s, pleased to meet you",
- MyHostName, CurSmtpClient);
+ message("250-%s Hello %s, %s",
+ MyHostName, CurSmtpClient, q);
+
+ /* print EHLO features list */
if (!bitset(PRIV_NOEXPN, PrivacyFlags))
{
message("250-EXPN");
@@ -446,23 +437,14 @@ smtp(nullserver, e)
SmtpPhase = "server MAIL";
/* check for validity of this command */
- if (!gothello)
+ if (!gothello && bitset(PRIV_NEEDMAILHELO, PrivacyFlags))
{
- /* set sending host to our known value */
- if (sendinghost == NULL)
- sendinghost = peerhostname;
-
- if (bitset(PRIV_NEEDMAILHELO, PrivacyFlags))
- {
- usrerr("503 Polite people say HELO first");
- break;
- }
+ usrerr("503 Polite people say HELO first");
+ break;
}
if (gotmail)
{
usrerr("503 Sender already specified");
- if (InChild)
- finis();
break;
}
if (InChild)
@@ -472,6 +454,10 @@ smtp(nullserver, e)
finis();
}
+ /* make sure we know who the sending host is */
+ if (sendinghost == NULL)
+ sendinghost = peerhostname;
+
p = skipword(p, "from");
if (p == NULL)
break;
@@ -479,6 +465,8 @@ smtp(nullserver, e)
/* fork a subprocess to process this command */
if (runinchild("SMTP-MAIL", e) > 0)
break;
+ if (Errors > 0)
+ goto undo_subproc_no_pm;
if (!gothello)
{
auth_warning(e,
@@ -500,6 +488,8 @@ smtp(nullserver, e)
define('r', protocol, e);
define('s', sendinghost, e);
initsys(e);
+ if (Errors > 0)
+ goto undo_subproc_no_pm;
nrcpts = 0;
e->e_flags |= EF_LOGSENDER|EF_CLRQUEUE;
setproctitle("%s %s: %.80s", e->e_id, CurSmtpClient, inp);
@@ -508,6 +498,8 @@ smtp(nullserver, e)
if (setjmp(TopFrame) > 0)
{
/* this failed -- undo work */
+ undo_subproc_no_pm:
+ e->e_flags &= ~EF_PM_NOTIFY;
undo_subproc:
if (InChild)
{
@@ -525,10 +517,13 @@ smtp(nullserver, e)
setsender(p, e, &delimptr, ' ', FALSE);
if (delimptr != NULL && *delimptr != '\0')
*delimptr++ = '\0';
+ if (Errors > 0)
+ goto undo_subproc_no_pm;
/* do config file checking of the sender */
- if (rscheck("check_mail", p, NULL, e) != EX_OK)
- goto undo_subproc;
+ if (rscheck("check_mail", p, NULL, e) != EX_OK ||
+ Errors > 0)
+ goto undo_subproc_no_pm;
/* check for possible spoofing */
if (RealUid != 0 && OpMode == MD_SMTP &&
@@ -579,20 +574,26 @@ smtp(nullserver, e)
vp == NULL ? "<null>" : vp);
mail_esmtp_args(kp, vp, e);
+ if (Errors > 0)
+ goto undo_subproc_no_pm;
}
+ if (Errors > 0)
+ goto undo_subproc_no_pm;
if (MaxMessageSize > 0 && e->e_msgsize > MaxMessageSize)
{
usrerr("552 Message size exceeds fixed maximum message size (%ld)",
MaxMessageSize);
- /* NOTREACHED */
+ goto undo_subproc_no_pm;
}
if (!enoughdiskspace(e->e_msgsize))
{
usrerr("452 Insufficient disk space; try again later");
- break;
+ goto undo_subproc_no_pm;
}
+ if (Errors > 0)
+ goto undo_subproc_no_pm;
message("250 Sender ok");
gotmail = TRUE;
break;
@@ -615,7 +616,7 @@ smtp(nullserver, e)
/* limit flooding of our machine */
if (MaxRcptPerMsg > 0 && nrcpts >= MaxRcptPerMsg)
{
- usrerr("450 Too many recipients");
+ usrerr("452 Too many recipients");
break;
}
@@ -626,13 +627,14 @@ smtp(nullserver, e)
if (p == NULL)
break;
a = parseaddr(p, NULLADDR, RF_COPYALL, ' ', &delimptr, e);
- if (a == NULL)
+ if (a == NULL || Errors > 0)
break;
if (delimptr != NULL && *delimptr != '\0')
*delimptr++ = '\0';
/* do config file checking of the recipient */
- if (rscheck("check_rcpt", p, NULL, e) != EX_OK)
+ if (rscheck("check_rcpt", p, NULL, e) != EX_OK ||
+ Errors > 0)
break;
/* now parse ESMTP arguments */
@@ -673,12 +675,15 @@ smtp(nullserver, e)
vp == NULL ? "<null>" : vp);
rcpt_esmtp_args(a, kp, vp, e);
+ if (Errors > 0)
+ break;
}
+ if (Errors > 0)
+ break;
/* save in recipient list after ESMTP mods */
a = recipient(a, &e->e_sendqueue, 0, e);
-
- if (Errors != 0)
+ if (Errors > 0)
break;
/* no errors during parsing, but might be a duplicate */
@@ -732,9 +737,12 @@ smtp(nullserver, e)
SmtpPhase = "collect";
buffer_errors();
collect(InChannel, TRUE, NULL, e);
- flush_errors(TRUE);
- if (Errors != 0)
+ if (Errors > 0)
+ {
+ flush_errors(TRUE);
+ buffer_errors();
goto abortmessage;
+ }
/* make sure we actually do delivery */
e->e_flags &= ~EF_CLRQUEUE;
@@ -781,13 +789,19 @@ smtp(nullserver, e)
message("250 %s Message accepted for delivery", id);
/* if we just queued, poke it */
- if (doublequeue && e->e_sendmode != SM_QUEUE &&
+ if (doublequeue &&
+ e->e_sendmode != SM_QUEUE &&
e->e_sendmode != SM_DEFER)
{
- extern pid_t dowork();
+ CurrentLA = getla();
+
+ if (!shouldqueue(e->e_msgpriority, e->e_ctime))
+ {
+ extern pid_t dowork();
- unlockqueue(e);
- (void) dowork(id, TRUE, TRUE, e);
+ unlockqueue(e);
+ (void) dowork(id, TRUE, TRUE, e);
+ }
}
abortmessage:
@@ -849,11 +863,15 @@ smtp(nullserver, e)
}
if (runinchild(vrfy ? "SMTP-VRFY" : "SMTP-EXPN", e) > 0)
break;
+ if (Errors > 0)
+ goto undo_subproc;
if (LogLevel > 5)
sm_syslog(LOG_INFO, e->e_id,
"%.100s: %s",
CurSmtpClient,
shortenstring(inp, 203));
+ if (setjmp(TopFrame) > 0)
+ goto undo_subproc;
vrfyqueue = NULL;
if (vrfy)
e->e_flags |= EF_VRFYONLY;
@@ -867,12 +885,8 @@ smtp(nullserver, e)
{
(void) sendtolist(p, NULLADDR, &vrfyqueue, 0, e);
}
- if (Errors != 0)
- {
- if (InChild)
- finis();
- break;
- }
+ if (Errors > 0)
+ goto undo_subproc;
if (vrfyqueue == NULL)
{
usrerr("554 Nothing to %s", vrfy ? "VRFY" : "EXPN");
@@ -916,7 +930,7 @@ smtp(nullserver, e)
QueueLimitRecipient = id;
ok = runqueue(TRUE, TRUE);
QueueLimitRecipient = NULL;
- if (ok)
+ if (ok && Errors == 0)
message("250 Queuing for node %s started", p);
break;
@@ -1427,12 +1441,15 @@ help(topic)
register FILE *hf;
int len;
bool noinfo;
+ int sff = SFF_OPENASROOT|SFF_REGONLY;
char buf[MAXLINE];
extern char Version[];
+ if (DontLockReadFiles)
+ sff |= SFF_NOLOCK;
if (HelpFile == NULL ||
- (hf = safefopen(HelpFile, O_RDONLY, 0444, SFF_OPENASROOT|SFF_REGONLY|SFF_NOLOCK)) == NULL)
+ (hf = safefopen(HelpFile, O_RDONLY, 0444, sff)) == NULL)
{
/* no help */
errno = 0;
diff --git a/usr.sbin/sendmail/src/util.c b/usr.sbin/sendmail/src/util.c
index 5e5e7af..c655b62 100644
--- a/usr.sbin/sendmail/src/util.c
+++ b/usr.sbin/sendmail/src/util.c
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)util.c 8.129 (Berkeley) 6/11/97";
+static char sccsid[] = "@(#)util.c 8.133 (Berkeley) 8/1/97";
#endif /* not lint */
# include "sendmail.h"
@@ -536,13 +536,14 @@ putxline(l, len, mci, pxflags)
int pxflags;
{
register char *p, *end;
- register char svchar;
int slop = 0;
/* strip out 0200 bits -- these can look like TELNET protocol */
if (bitset(MCIF_7BIT, mci->mci_flags) ||
bitset(PXLF_STRIP8BIT, pxflags))
{
+ register char svchar;
+
for (p = l; (svchar = *p) != '\0'; ++p)
if (bitset(0200, svchar))
*p = svchar &~ 0200;
@@ -563,10 +564,9 @@ putxline(l, len, mci, pxflags)
while (mci->mci_mailer->m_linelimit > 0 &&
(p - l + slop) > mci->mci_mailer->m_linelimit)
{
+ char *l_base = l;
register char *q = &l[mci->mci_mailer->m_linelimit - slop - 1];
- svchar = *q;
- *q = '\0';
if (l[0] == '.' && slop == 0 &&
bitnset(M_XDOT, mci->mci_mailer->m_flags))
{
@@ -583,19 +583,18 @@ putxline(l, len, mci, pxflags)
if (TrafficLogFile != NULL)
(void) putc('>', TrafficLogFile);
}
- fputs(l, mci->mci_out);
+ while (l < q)
+ (void) putc(*l++, mci->mci_out);
(void) putc('!', mci->mci_out);
fputs(mci->mci_mailer->m_eol, mci->mci_out);
(void) putc(' ', mci->mci_out);
if (TrafficLogFile != NULL)
{
- for ( ; l < q; ++l)
+ for (l = l_base; l < q; l++)
(void) putc(*l, TrafficLogFile);
fprintf(TrafficLogFile, "!\n%05d >>> ",
(int) getpid());
}
- *q = svchar;
- l = q;
slop = 1;
}
@@ -625,7 +624,7 @@ putxline(l, len, mci, pxflags)
if (TrafficLogFile != NULL)
(void) putc('\n', TrafficLogFile);
fputs(mci->mci_mailer->m_eol, mci->mci_out);
- if (*l == '\n')
+ if (l < end && *l == '\n')
{
if (*++l != ' ' && *l != '\t' && *l != '\0')
{
@@ -1062,21 +1061,7 @@ checkfd012(where)
struct stat stbuf;
for (i = 0; i < 3; i++)
- {
- if (fstat(i, &stbuf) < 0 && errno == EBADF)
- {
- /* oops.... */
- int fd;
-
- syserr("%s: fd %d not open", where, i);
- fd = open("/dev/null", i == 0 ? O_RDONLY : O_WRONLY, 0666);
- if (fd != i)
- {
- (void) dup2(fd, i);
- (void) close(fd);
- }
- }
- }
+ fill_fd(i, where);
#endif /* XDEBUG */
}
/*
@@ -1210,7 +1195,8 @@ dumpfd(fd, printclosed, logit)
#ifdef S_IFSOCK
SOCKADDR sa;
#endif
- auto int slen;
+ auto SOCKADDR_LEN_T slen;
+ int i;
struct stat st;
char buf[200];
extern char *hostnamebyanyaddr();
@@ -1235,10 +1221,10 @@ dumpfd(fd, printclosed, logit)
return;
}
- slen = fcntl(fd, F_GETFL, NULL);
- if (slen != -1)
+ i = fcntl(fd, F_GETFL, NULL);
+ if (i != -1)
{
- snprintf(p, SPACELEFT(buf, p), "fl=0x%x, ", slen);
+ snprintf(p, SPACELEFT(buf, p), "fl=0x%x, ", i);
p += strlen(p);
}
OpenPOWER on IntegriCloud