summaryrefslogtreecommitdiff
path: root/usr.sbin/sendmail/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/sendmail/src')
-rw-r--r--usr.sbin/sendmail/src/Makefile12
-rw-r--r--usr.sbin/sendmail/src/READ_ME177
-rw-r--r--usr.sbin/sendmail/src/alias.c11
-rw-r--r--usr.sbin/sendmail/src/cdefs.h2
-rw-r--r--usr.sbin/sendmail/src/collect.c9
-rw-r--r--usr.sbin/sendmail/src/conf.c337
-rw-r--r--usr.sbin/sendmail/src/conf.h250
-rw-r--r--usr.sbin/sendmail/src/daemon.c83
-rw-r--r--usr.sbin/sendmail/src/deliver.c183
-rw-r--r--usr.sbin/sendmail/src/domain.c54
-rw-r--r--usr.sbin/sendmail/src/envelope.c16
-rw-r--r--usr.sbin/sendmail/src/err.c54
-rw-r--r--usr.sbin/sendmail/src/headers.c85
-rw-r--r--usr.sbin/sendmail/src/macro.c12
-rw-r--r--usr.sbin/sendmail/src/main.c20
-rw-r--r--usr.sbin/sendmail/src/map.c24
-rw-r--r--usr.sbin/sendmail/src/mci.c20
-rw-r--r--usr.sbin/sendmail/src/newaliases.123
-rw-r--r--usr.sbin/sendmail/src/parseaddr.c4
-rw-r--r--usr.sbin/sendmail/src/queue.c29
-rw-r--r--usr.sbin/sendmail/src/readcf.c26
-rw-r--r--usr.sbin/sendmail/src/recipient.c68
-rw-r--r--usr.sbin/sendmail/src/savemail.c120
-rw-r--r--usr.sbin/sendmail/src/sendmail.h98
-rw-r--r--usr.sbin/sendmail/src/srvrsmtp.c84
-rw-r--r--usr.sbin/sendmail/src/trace.c6
-rw-r--r--usr.sbin/sendmail/src/udb.c7
-rw-r--r--usr.sbin/sendmail/src/usersmtp.c13
-rw-r--r--usr.sbin/sendmail/src/util.c62
-rw-r--r--usr.sbin/sendmail/src/version.c4
30 files changed, 1386 insertions, 507 deletions
diff --git a/usr.sbin/sendmail/src/Makefile b/usr.sbin/sendmail/src/Makefile
index 3345fcead41..18795746010 100644
--- a/usr.sbin/sendmail/src/Makefile
+++ b/usr.sbin/sendmail/src/Makefile
@@ -1,8 +1,9 @@
#
# NetBSD Makefile
#
-# $Id: Makefile,v 1.19 1994/02/02 07:22:49 glass Exp $
-# @(#)Makefile 8.2 (Berkeley) 8/15/93
+# @(#)Makefile.NetBSD 8.1 (Berkeley) 2/26/94
+# @Id: Makefile.NetBSD,v 1.3 1994/02/01 05:33:44 glass Exp $
+#
PROG= sendmail
@@ -16,19 +17,16 @@ PROG= sendmail
# spiral snail, but it will work.
DBMDEF= -DNEWDB -DNIS
-#nasty warning about gcc 2.4.x caused bugs
-CFLAGS=-I${.CURDIR} ${DBMDEF} -DNETISO
-#CFLAGS+=-I${.CURDIR} ${DBMDEF} -DNETISO
+CFLAGS+=-I${.CURDIR} ${DBMDEF} -DNETISO
SRCS= alias.c arpadate.c clock.c collect.c conf.c convtime.c daemon.c \
deliver.c domain.c envelope.c err.c headers.c macro.c main.c map.c \
mci.c parseaddr.c queue.c readcf.c recipient.c savemail.c srvrsmtp.c \
stab.c stats.c sysexits.c trace.c udb.c usersmtp.c \
util.c version.c
-MAN1= newaliases.0
+MAN1= mailq.0 newaliases.0
MAN5= aliases.0
MAN8= sendmail.0
-MLINKS= sendmail.8 mailq.8
LINKS= /usr/sbin/sendmail /usr/bin/newaliases \
/usr/sbin/sendmail /usr/bin/mailq
BINDIR= /usr/sbin
diff --git a/usr.sbin/sendmail/src/READ_ME b/usr.sbin/sendmail/src/READ_ME
index a2e7ad793bf..50f75fba991 100644
--- a/usr.sbin/sendmail/src/READ_ME
+++ b/usr.sbin/sendmail/src/READ_ME
@@ -30,7 +30,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# @(#)READ_ME 8.47 (Berkeley) 1/12/94
+# @(#)READ_ME 8.58 (Berkeley) 3/13/94
#
This directory contains the source files for sendmail.
@@ -138,6 +138,12 @@ use the version from the Net2 distribution! However, if you are on
BSD/386 or 386BSD-based systems, use the one that already exists
on your system. You may need to define OLD_NEWDB to do this.]
+[NOTE WELL: it is CRITICAL that you remove ndbm.o from libdb.a and
+ndbm.h from the appropriate include directories if you want to get
+ndbm support. These files OVERRIDE calls to ndbm routines -- in
+particular, if you leave ndbm.h in, you can find yourself using
+the new db package even if you don't define NEWDB.]
+
If NEWDB and NDBM are defined (but not NIS), then sendmail will read
NDBM format alias files, but the next time a newaliases is run the
format will be converted to NEWDB; that format will be used forever
@@ -179,6 +185,7 @@ NeXT Define this if you are on a NeXT box. (This one may
have to make -- see below.
_AIX3 Define this if you are IBM AIX 3.x.
RISCOS Define this if you are running RISC/os from MIPS.
+IRIX Define this if you are running IRIX from SGI.
_SCO_unix_ Define this if you are on SCO UNIX.
_SCO_unix_4_2 Define this if you are on SCO Open Server 3.2v4.
@@ -204,12 +211,6 @@ HASUNAME Set if you have the "uname" system call. Implied by
SYSTEM5.
HASUNSETENV Define this if your system library has the "unsetenv"
subroutine.
-HASSTATFS Define this if you have the statfs(2) system call. It's
- not a disaster to get this wrong -- but you do lose the
- queue free space code.
-HASUSTAT Define this if you have the ustat(2) system call. It's
- not a disaster to get this wrong -- but you do lose the
- queue free space code.
HASSETSID Define this if you have the setsid(2) system call. This
is implied if your system appears to be POSIX compliant.
HASINITGROUPS Define this if you have the initgroups(3) routine.
@@ -270,19 +271,36 @@ ARBPTR_T The type of an arbitrary pointer -- defaults to "void *".
If you are an very old compiler you may need to define
this to be "char *".
LA_TYPE The type of load average your kernel supports. These
- can be LA_SUBR (4) if you have the getloadavg(3) routine,
+ can be one of:
+ LA_ZERO (1) -- it always returns the load average as
+ "zero" (and does so on all architectures).
+ LA_SUBR (4) if you have the getloadavg(3) routine,
LA_MACH (5) to use MACH-style load averages (calls
- processor_set_info()), LA_FLOAT (3) if you read kmem and
- interpret the value as a floating point number, LA_INT (2)
- to interpret as a long integer, or LA_SHORT (6) to
- interpret as a short integer. These last three have
- several other parameters that they try to divine: the
- name of your kernel, the name of the variable in the
- kernel to examine, the number of bits of precision in
- a fixed point load average, and so forth. In desparation,
- use LA_ZERO (1) -- it always returns the load average as
- "zero" (and does so on all architectures). The actual
- code is in conf.c -- it can be tweaked if you are brave.
+ processor_set_info()),
+ LA_PROCSTR (7) to read /proc/loadavg and interpret it
+ as a string representing a floating-point
+ number (Linux-style),
+ LA_FLOAT (3) if you read kmem and interpret the value
+ as a floating point number,
+ LA_INT (2) to interpret as a long integer,
+ LA_SHORT (6) to interpret as a short integer.
+ These last three have several other parameters that they
+ try to divine: the name of your kernel, the name of the
+ variable in the kernel to examine, the number of bits of
+ precision in a fixed point load average, and so forth.
+ In desperation, use LA_ZERO. The actual code is in
+ conf.c -- it can be tweaked if you are brave.
+SFS_TYPE Encodes how your kernel can locate the amount of free
+ space on a disk partition. This can be set to SFS_NONE
+ (0) if you have no way of getting this information,
+ SFS_USTAT (1) if you have the ustat(2) system call,
+ SFS_4ARGS (2) if you have a four-argument statfs(2)
+ system call (and the include file is <sys/statfs.h>),
+ and SFS_VFS (3), SFS_MOUNT (4), or SFS_STATFS (5) if
+ you have the two-argument statfs(2) system call, with
+ includes in <sys/vfs.h>, <sys/mount.h>, or <sys/statfs.h>
+ respectively. The default if nothing is defined is
+ SFS_NONE.
ERRLIST_PREDEFINED
If set, assumes that some header file defines sys_errlist.
This may be needed if you get type conflicts on this
@@ -301,6 +319,12 @@ SYSLOG_BUFSIZE You can define this to be the size of the buffer that
e-mail message will log many more messages, since it
will log each piece of information as a separate line
in syslog.
+BROKEN_RES_SEARCH
+ On Ultrix (and maybe other systems?) if you use the
+ res_search routine with an unknown host name, it returns
+ -1 but sets h_errno to 0 instead of HOST_NOT_FOUND. If
+ you set this, sendmail considers 0 to be the same as
+ HOST_NOT_FOUND.
+-----------------------+
@@ -371,7 +395,7 @@ help to link with "-l44bsd" to solve this problem.
the header files you used -- some people have used the 4.9 headers
and linked with BIND 4.8 or vice versa, and it doesn't work.
Unfortunately, it doesn't fail in an obvious way -- things just
-subtlely don't work.
+subtly don't work.
+-------------------------------------+
@@ -440,6 +464,10 @@ SunOS 4.x (Solaris 1.x)
Solaris 2.x (SunOS 5.x)
To compile for Solaris, be sure you use -DSOLARIS.
+ To the best of my knowledge, Solaris does not have the
+ gethostbyname problem described above. However, it does
+ have another one:
+
From a correspondent:
For solaris 2.2, I have
@@ -450,17 +478,41 @@ Solaris 2.x (SunOS 5.x)
qualified host name. I think "files" has to be before "dns"
in /etc/nsswitch.conf during bootup.
- To the best of my knowledge, Solaris does not have the
- gethostbyname problem described above.
+ From another correspondent:
+
+ When running sendmail under Solaris, the gethostbyname()
+ hack in conf.c which should perform proper canonicalization
+ of host names could fail. Result: the host name is not
+ canonicalized despite the hack, and you'll have to define $j
+ and $m in sendmail.cf somewhere.
+
+ The reason could be that /etc/nsswitch.conf is improperly
+ configured (at least from sendmail's point of view). For
+ example, the line
+
+ hosts: files nisplus dns
+
+ will make gethostbyname() look in /etc/hosts first, then ask
+ nisplus, then dns. However, if /etc/hosts does not contain
+ the full canonicalized hostname, then no amount of
+ gethostbyname()s will work.
+
+ Solution (or rather, a workaround): Ask nisplus first, then
+ dns, then local files:
+
+ hosts: nisplus dns [NOTFOUND=return] files
The Solaris "syslog" function is apparently limited to something
about 90 characters because of a kernel limitation. If you have
- source code, you can probably up this number. The syslogd patch
- is included in kernel jumbo patch for Solaris 2.2 as of revision
- -39 or so. At least one person is running with patch 100999-45
- and their long lost sendmail logging is finally showing up. At
- least one other person is running with patch 101318 installed
- under Solaris 2.3 with success.
+ source code, you can probably up this number. You can get patches
+ that fix this problem: the patch ids are:
+
+ Solaris 2.1 100834
+ Solaris 2.2 100999
+ Solaris 2.3 101318
+
+ Be sure you have the appropriate patch installed or you won't
+ see system logging.
OSF/1
If you are compiling on OSF/1 (DEC Alpha), you must use
@@ -471,6 +523,17 @@ OSF/1
Also, the enclosed makefile removed /usr/sbin/smtpd; if you need
it, just create the link to the sendmail binary.
+IRIX
+ The header files on SGI IRIX are completely prototyped, and as
+ a result you can sometimes get some warning messages during
+ compilation. These can be ignored. There are two errors in
+ deliver only if you are using gcc, both of the form ``warning:
+ passing arg N of `execve' from incompatible pointer type''.
+ Also, if you compile with -DNIS, you will get a complaint
+ about a declaration of struct dom_binding in a prototype
+ when compiling map.c; this is not important because the
+ function being prototyped is not used in that file.
+
NeXT
If you are compiling on NeXT, you will have to create an empty
file "unistd.h" and create a file "dirent.h" containing:
@@ -560,6 +623,50 @@ DG/UX
DG/UX -- the person who has this working, Douglas Anderson
<dlander@afterlife.ncsc.mil>, used procmail instead.
+Apollo DomainOS
+ If you are compiling on Apollo, you will have to create an empty
+ file "unistd.h" and create a file "dirent.h" containing:
+
+ #include <sys/dir.h>
+ #define dirent direct
+
+ (The Makefile.DomainOS will attempt to do both of these for you.)
+
+HP-UX 8.00
+ Date: Mon, 24 Jan 1994 13:25:45 +0200
+ From: Kimmo Suominen <Kimmo.Suominen@lut.fi>
+ Subject: 8.6.5 w/ HP-UX 8.00 on s300
+
+ Just compiled and fought with sendmail 8.6.5 on a HP9000/360 (ie. a
+ series 300 machine) running HP-UX 8.00.
+
+ I was getting segmentation fault when delivering to a local user.
+ With debugging I saw it was faulting when doing _free@libc... *sigh*
+ It seems the new implementation of malloc on s300 is buggy as of 8.0,
+ so I tried out the one in -lmalloc (malloc(3X)). With that it seems
+ to work just dandy.
+
+ When linking, you will get the following error:
+
+ ld: multiply defined symbol _freespace in file /usr/lib/libmalloc.a
+
+ but you can just ignore it. You might want to add this info to the
+ README file for the future...
+
+Linux
+ Something broke between versions 0.99.13 and 0.99.14 of Linux:
+ the flock() system call gives errors. If you are running .14,
+ you must not use flock. You can do this with -DHASFLOCK=0.
+
+AIX
+ This version of sendmail does not support MB, MG, and MR resource
+ records, which are supported by AIX sendmail.
+
+RISC/os
+ RISC/os from MIPS is a merged AT&T/Berkeley system. When you
+ compile on that platform you will get duplicate definitions
+ on many files. You can ignore these.
+
System V Release 4 Based Systems
There is a single Makefile that is intended for all SVR4-based
systems (called Makefile.SVR4). It defines __svr4__, which is
@@ -642,6 +749,18 @@ GNU getopt
I'm told that GNU getopt has a problem in that it gets confused
by the double call. Use the version in conf.c instead.
+BIND 4.9.2 and Ultrix
+ If you are running on Ultrix, be sure you read the conf/Info.Ultrix
+ carefully -- there is information in there that you need to know
+ in order to avoid errors of the form:
+
+ /lib/libc.a(gethostent.o): sethostent: multiply defined
+ /lib/libc.a(gethostent.o): endhostent: multiply defined
+ /lib/libc.a(gethostent.o): gethostbyname: multiply defined
+ /lib/libc.a(gethostent.o): gethostbyaddr: multiply defined
+
+ during the link stage.
+
+--------------+
| MANUAL PAGES |
@@ -742,4 +861,4 @@ version.c The version number and information about this
Eric Allman
-(Version 8.47, last update 1/12/94 05:59:56)
+(Version 8.58, last update 3/13/94 09:38:06)
diff --git a/usr.sbin/sendmail/src/alias.c b/usr.sbin/sendmail/src/alias.c
index 66d81d77bf6..20a316200ca 100644
--- a/usr.sbin/sendmail/src/alias.c
+++ b/usr.sbin/sendmail/src/alias.c
@@ -36,7 +36,7 @@
# include <pwd.h>
#ifndef lint
-static char sccsid[] = "@(#)alias.c 8.21 (Berkeley) 12/11/93";
+static char sccsid[] = "@(#)alias.c 8.24 (Berkeley) 2/28/94";
#endif /* not lint */
@@ -114,7 +114,9 @@ alias(a, sendq, e)
message("aliased to %s", p);
#ifdef LOG
if (LogLevel > 9)
- syslog(LOG_INFO, "%s: alias %s => %s", e->e_id, a->q_paddr, p);
+ syslog(LOG_INFO, "%s: alias %s => %s",
+ e->e_id == NULL ? "NOQUEUE" : e->e_id,
+ a->q_paddr, p);
#endif
a->q_flags &= ~QSELFREF;
AliasLevel++;
@@ -417,7 +419,7 @@ rebuildaliases(map, automatic)
/* try to lock the source file */
if ((af = fopen(map->map_file, "r+")) == NULL)
{
- if (errno != EACCES || automatic ||
+ if ((errno != EACCES && errno != EROFS) || automatic ||
(af = fopen(map->map_file, "r")) == NULL)
{
int saveerr = errno;
@@ -748,7 +750,8 @@ forward(user, sendq, e)
#ifdef LOG
if (LogLevel > 2)
syslog(LOG_ERR, "%s: forward %s: transient error: %s",
- e->e_id, buf, errstring(err));
+ e->e_id == NULL ? "NOQUEUE" : e->e_id,
+ buf, errstring(err));
#endif
message("%s: %s: message queued", buf, errstring(err));
user->q_flags |= QQUEUEUP;
diff --git a/usr.sbin/sendmail/src/cdefs.h b/usr.sbin/sendmail/src/cdefs.h
index afc1a68ef19..c104b9e964d 100644
--- a/usr.sbin/sendmail/src/cdefs.h
+++ b/usr.sbin/sendmail/src/cdefs.h
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)cdefs.h 8.5 (Berkeley) 1/4/94
+ * @(#)cdefs.h 8.7 (Berkeley) 1/21/94
*/
#ifndef _CDEFS_H_
diff --git a/usr.sbin/sendmail/src/collect.c b/usr.sbin/sendmail/src/collect.c
index e0eb672358b..b434d4900eb 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.8 (Berkeley) 1/8/94";
+static char sccsid[] = "@(#)collect.c 8.9 (Berkeley) 1/31/94";
#endif /* not lint */
# include <errno.h>
@@ -317,8 +317,11 @@ readerr:
"collect: %s on connection from %s, sender=%s: %m\n",
problem, host, e->e_from.q_paddr);
# endif
- (feof(InChannel) ? usrerr : syserr)
- ("451 collect: %s on connection from %s, from=%s",
+ if (feof(InChannel))
+ usrerr("451 collect: %s on connection from %s, from=%s",
+ problem, host, e->e_from.q_paddr);
+ else
+ syserr("451 collect: %s on connection from %s, from=%s",
problem, host, e->e_from.q_paddr);
/* don't return an error indication */
diff --git a/usr.sbin/sendmail/src/conf.c b/usr.sbin/sendmail/src/conf.c
index cc6605a66c1..1c859282e8f 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.62 (Berkeley) 1/9/94";
+static char sccsid[] = "@(#)conf.c 8.82 (Berkeley) 3/6/94";
#endif /* not lint */
# include "sendmail.h"
@@ -628,6 +628,7 @@ init_md(argc, argv)
#define LA_SUBR 4 /* call getloadavg */
#define LA_MACH 5 /* MACH load averages (as on NeXT boxes) */
#define LA_SHORT 6 /* read kmem for avenrun; interpret as short */
+#define LA_PROCSTR 7 /* read string ("1.17") from /proc/loadavg */
/* do guesses based on general OS type */
#ifndef LA_TYPE
@@ -827,6 +828,52 @@ getla()
#else
+#if LA_TYPE == LA_PROCSTR
+
+/*
+** Read /proc/loadavg for the load average. This is assumed to be
+** in a format like "0.15 0.12 0.06".
+**
+** Initially intended for Linux. This has been in the kernel
+** since at least 0.99.15.
+*/
+
+# ifndef _PATH_LOADAVG
+# define _PATH_LOADAVG "/proc/loadavg"
+# endif
+
+int
+getla()
+{
+ double avenrun;
+ register int result;
+ FILE *fp;
+
+ fp = fopen(_PATH_LOADAVG, "r");
+ if (fp == NULL)
+ {
+ if (tTd(3, 1))
+ printf("getla: fopen(%s): %s\n",
+ _PATH_LOADAVG, errstring(errno));
+ return -1;
+ }
+ result = fscanf(fp, "%lf", &avenrun);
+ fclose(fp);
+ if (result != 1)
+ {
+ if (tTd(3, 1))
+ printf("getla: fscanf() = %d: %s\n",
+ result, errstring(errno));
+ return -1;
+ }
+
+ if (tTd(3, 1))
+ printf("getla(): %.2f\n", avenrun);
+
+ return ((int) (avenrun + 0.5));
+}
+
+#else
getla()
{
@@ -838,6 +885,54 @@ getla()
#endif
#endif
#endif
+#endif
+
+
+/*
+ * Copyright 1989 Massachusetts Institute of Technology
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of M.I.T. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. M.I.T. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Many and varied...
+ */
+
+/* Non Apollo stuff removed by Don Lewis 11/15/93 */
+#ifndef lint
+static char rcsid[] = "@(#)$Id: conf.c,v 1.7 1994/03/16 02:13:13 glass Exp $";
+#endif /* !lint */
+
+#ifdef apollo
+# undef volatile
+# include <apollo/base.h>
+
+/* ARGSUSED */
+int getloadavg( call_data )
+ caddr_t call_data; /* pointer to (double) return value */
+{
+ double *avenrun = (double *) call_data;
+ int i;
+ status_$t st;
+ long loadav[3];
+ proc1_$get_loadav(loadav, &st);
+ *avenrun = loadav[0] / (double) (1 << 16);
+ return(0);
+}
+# endif /* apollo */
/*
** SHOULDQUEUE -- should this message be queued or sent?
**
@@ -909,6 +1004,9 @@ refuseconnections()
*/
#ifdef SETPROCTITLE
+# ifdef HASSETPROCTITLE
+ *** ERROR *** Cannot have both SETPROCTITLE and HASSETPROCTITLE defined
+# endif
# ifdef __hpux
# include <sys/pstat.h>
# endif
@@ -932,6 +1030,8 @@ refuseconnections()
# define PROCTITLEPAD ' '
#endif
+#ifndef HASSETPROCTITLE
+
/*VARARGS1*/
#ifdef __STDC__
setproctitle(char *fmt, ...)
@@ -986,6 +1086,8 @@ setproctitle(fmt, va_alist)
# endif
# endif /* SETPROCTITLE */
}
+
+#endif
/*
** REAPCHILD -- pick up the body of my child, lest it become a zombie
**
@@ -1407,6 +1509,8 @@ char *DefaultUserShells[] =
#endif
+#define WILDCARD_SHELL "/SENDMAIL/ANY/SHELL/"
+
bool
usershellok(shell)
char *shell;
@@ -1417,7 +1521,7 @@ usershellok(shell)
setusershell();
while ((p = getusershell()) != NULL)
- if (strcmp(p, shell) == 0 || strcmp(p, "*") == 0)
+ if (strcmp(p, shell) == 0 || strcmp(p, WILDCARD_SHELL) == 0)
break;
endusershell();
return p != NULL;
@@ -1452,7 +1556,7 @@ usershellok(shell)
while (*p != '\0' && *p != '#' && !isspace(*p))
p++;
*p = '\0';
- if (strcmp(shell, q) == 0 || strcmp("*", q) == 0)
+ if (strcmp(shell, q) == 0 || strcmp(WILDCARD_SHELL, q) == 0)
{
fclose(shellf);
return TRUE;
@@ -1480,24 +1584,29 @@ usershellok(shell)
** Puts the filesystem block size into bsize.
*/
-#ifdef HASSTATFS
-# undef HASUSTAT
+/* statfs types */
+#define SFS_NONE 0 /* no statfs implementation */
+#define SFS_USTAT 1 /* use ustat */
+#define SFS_4ARGS 2 /* use four-argument statfs call */
+#define SFS_VFS 3 /* use <sys/vfs.h> implementation */
+#define SFS_MOUNT 4 /* use <sys/mount.h> implementation */
+#define SFS_STATFS 5 /* use <sys/statfs.h> implementation */
+
+#ifndef SFS_TYPE
+# define SFS_TYPE SFS_NONE
#endif
-#if defined(HASUSTAT)
+#if SFS_TYPE == SFS_USTAT
# include <ustat.h>
#endif
-
-#ifdef HASSTATFS
-# if defined(IRIX) || defined(apollo) || defined(_SCO_unix_) || defined(UMAXV) || defined(DGUX) || defined(_AIX3)
-# include <sys/statfs.h>
-# else
-# if (defined(sun) && !defined(BSD)) || defined(__hpux) || defined(_CONVEX_SOURCE) || defined(NeXT) || defined(_AUX_SOURCE) || defined(MACH386)
-# include <sys/vfs.h>
-# else
-# include <sys/mount.h>
-# endif
-# endif
+#if SFS_TYPE == SFS_4ARGS || SFS_TYPE == SFS_STATFS
+# include <sys/statfs.h>
+#endif
+#if SFS_TYPE == SFS_VFS
+# include <sys/vfs.h>
+#endif
+#if SFS_TYPE == SFS_MOUNT
+# include <sys/mount.h>
#endif
long
@@ -1505,8 +1614,8 @@ freespace(dir, bsize)
char *dir;
long *bsize;
{
-#if defined(HASSTATFS) || defined(HASUSTAT)
-# if defined(HASUSTAT)
+#if SFS_TYPE != SFS_NONE
+# if SFS_TYPE == SFS_USTAT
struct ustat fs;
struct stat statbuf;
# define FSBLOCKSIZE DEV_BSIZE
@@ -1519,17 +1628,17 @@ freespace(dir, bsize)
# else
struct statfs fs;
# define FSBLOCKSIZE fs.f_bsize
-# if defined(_SCO_unix_) || defined(IRIX)
+# if defined(_SCO_unix_) || defined(IRIX) || defined(apollo)
# define f_bavail f_bfree
# endif
# endif
# endif
extern int errno;
-# if defined(HASUSTAT)
+# if SFS_TYPE == SFS_USTAT
if (stat(dir, &statbuf) == 0 && ustat(statbuf.st_dev, &fs) == 0)
# else
-# if defined(IRIX) || defined(apollo) || defined(UMAXV) || defined(DGUX)
+# if SFS_TYPE == SFS_4ARGS
if (statfs(dir, &fs, sizeof fs, 0) == 0)
# else
# if defined(ultrix)
@@ -1694,6 +1803,9 @@ transienterror(err)
#ifdef EADDRNOTAVAIL
case EADDRNOTAVAIL: /* Can't assign requested address */
#endif
+#ifdef ETXTBSY
+ case ETXTBSY: /* (Apollo) file locked */
+#endif
#if defined(ENOSR) && (!defined(ENOBUFS) || (ENOBUFS != ENOSR))
case ENOSR: /* Out of streams resources */
#endif
@@ -1726,7 +1838,7 @@ lockfile(fd, filename, ext, type)
char *ext;
int type;
{
-# ifndef HASFLOCK
+# if !HASFLOCK
int action;
struct flock lfd;
@@ -1823,6 +1935,65 @@ lockfile(fd, filename, ext, type)
return FALSE;
}
/*
+** CHOWNSAFE -- tell if chown is "safe" (executable only by root)
+**
+** Parameters:
+** fd -- the file descriptor to check.
+**
+** Returns:
+** TRUE -- if only root can chown the file to an arbitrary
+** user.
+** FALSE -- if an arbitrary user can give away a file.
+*/
+
+bool
+chownsafe(fd)
+ int fd;
+{
+#ifdef __hpux
+ char *s;
+ int tfd;
+ uid_t o_uid, o_euid;
+ gid_t o_gid, o_egid;
+ bool rval;
+ struct stat stbuf;
+
+ o_uid = getuid();
+ o_euid = geteuid();
+ o_gid = getgid();
+ o_egid = getegid();
+ fstat(fd, &stbuf);
+ setresuid(stbuf.st_uid, stbuf.st_uid, -1);
+ setresgid(stbuf.st_gid, stbuf.st_gid, -1);
+ s = tmpnam(NULL);
+ tfd = open(s, O_RDONLY|O_CREAT, 0600);
+ rval = fchown(tfd, DefUid, DefGid) != 0;
+ close(tfd);
+ unlink(s);
+ setreuid(o_uid, o_euid);
+ setresgid(o_gid, o_egid, -1);
+ return rval;
+#else
+# ifdef _POSIX_CHOWN_RESTRICTED
+# if _POSIX_CHOWN_RESTRICTED == -1
+ return FALSE;
+# else
+ return TRUE;
+# endif
+# else
+# ifdef _PC_CHOWN_RESTRICTED
+ return fpathconf(fd, _PC_CHOWN_RESTRICTED) > 0;
+# else
+# ifdef BSD
+ return TRUE;
+# else
+ return FALSE;
+# endif
+# endif
+# endif
+#endif
+}
+ /*
** GETCFNAME -- return the name of the .cf file.
**
** Some systems (e.g., NeXT) determine this dynamically.
@@ -1877,46 +2048,104 @@ setvendor(vendor)
** STRTOL -- convert string to long integer
**
** For systems that don't have it in the C library.
+**
+** This is taken verbatim from the 4.4-Lite C library.
*/
#ifdef NEEDSTRTOL
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strtol.c 8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+
+#include <limits.h>
+
+/*
+ * Convert a string to a long integer.
+ *
+ * Ignores `locale' stuff. Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+
long
-strtol(p, ep, b)
- char *p;
- char **ep;
- int b;
+strtol(nptr, endptr, base)
+ const char *nptr;
+ char **endptr;
+ register int base;
{
- long l = 0;
- char c;
- char maxd;
- int neg = 1;
-
- maxd = (b > 10) ? '9' : b + '0';
+ register const char *s = nptr;
+ register unsigned long acc;
+ register int c;
+ register unsigned long cutoff;
+ register int neg = 0, any, cutlim;
- if (p && *p == '-') {
- neg = -1;
- p++;
+ /*
+ * Skip white space and pick up leading +/- sign if any.
+ * If base is 0, allow 0x for hex and 0 for octal, else
+ * assume decimal; if base is already 16, allow 0x.
+ */
+ do {
+ c = *s++;
+ } while (isspace(c));
+ if (c == '-') {
+ neg = 1;
+ c = *s++;
+ } else if (c == '+')
+ c = *s++;
+ if ((base == 0 || base == 16) &&
+ c == '0' && (*s == 'x' || *s == 'X')) {
+ c = s[1];
+ s += 2;
+ base = 16;
}
- while (p && (c = *p)) {
- if (c >= '0' && c <= maxd) {
- l = l*b + *p++ - '0';
- continue;
- }
- if (c >= 'A' && c <= 'Z')
- c -= 'A' + 'a';
- c = c - 'a' + 10;
- if (b > c) {
- l = l*b + c;
- p++;
- continue;
+ if (base == 0)
+ base = c == '0' ? 8 : 10;
+
+ /*
+ * Compute the cutoff value between legal numbers and illegal
+ * numbers. That is the largest legal value, divided by the
+ * base. An input number that is greater than this value, if
+ * followed by a legal input character, is too big. One that
+ * is equal to this value may be valid or not; the limit
+ * between valid and invalid numbers is then based on the last
+ * digit. For instance, if the range for longs is
+ * [-2147483648..2147483647] and the input base is 10,
+ * cutoff will be set to 214748364 and cutlim to either
+ * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
+ * a value > 214748364, or equal but the next digit is > 7 (or 8),
+ * the number is too big, and we will return a range error.
+ *
+ * Set any if any `digits' consumed; make it negative to indicate
+ * overflow.
+ */
+ cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
+ cutlim = cutoff % (unsigned long)base;
+ cutoff /= (unsigned long)base;
+ for (acc = 0, any = 0;; c = *s++) {
+ if (isdigit(c))
+ c -= '0';
+ else if (isalpha(c))
+ c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+ any = -1;
+ else {
+ any = 1;
+ acc *= base;
+ acc += c;
}
- break;
}
- l *= neg;
- if (ep)
- *ep = p;
- return l;
+ if (any < 0) {
+ acc = neg ? LONG_MIN : LONG_MAX;
+ errno = ERANGE;
+ } else if (neg)
+ acc = -acc;
+ if (endptr != 0)
+ *endptr = (char *)(any ? s - 1 : nptr);
+ return (acc);
}
#endif
@@ -1998,7 +2227,7 @@ ni_propval(directory, propname)
char *directory;
char *propname;
{
- char *propval;
+ char *propval = NULL;
int i;
void *ni = NULL;
void *lastni = NULL;
diff --git a/usr.sbin/sendmail/src/conf.h b/usr.sbin/sendmail/src/conf.h
index a06738c0fb8..8341de5cb2d 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.75 (Berkeley) 1/8/94
+ * @(#)conf.h 8.96 (Berkeley) 3/11/94
*/
/*
@@ -80,14 +80,22 @@
# define NETUNIX 1 /* include unix domain support */
# define NETINET 1 /* include internet support */
# define SETPROCTITLE 1 /* munge argv to display current status */
-# define NAMED_BIND 1 /* use Berkeley Internet Domain Server */
# define MATCHGECOS 1 /* match user names from gecos field */
# define XDEBUG 1 /* enable extended debugging */
-
# ifdef NEWDB
# define USERDB 1 /* look in user database (requires NEWDB) */
# endif
+/**********************************************************************
+** 0/1 Compilation options.
+** #define these to 1 if they are available;
+** #define them to 0 otherwise.
+**********************************************************************/
+
+# ifndef NAMED_BIND
+# define NAMED_BIND 1 /* use Berkeley Internet Domain Server */
+# endif
+
/*
** Most systems have symbolic links today, so default them on. You
** can turn them off by #undef'ing this below.
@@ -131,10 +139,10 @@
# undef m_flags
# define SYSTEM5 1 /* include all the System V defines */
# define HASINITGROUPS 1 /* has initgroups(3) call */
-# define HASSTATFS 1 /* has the statfs(2) syscall */
# define HASSETREUID 1 /* has setreuid(2) call */
-# define setreuid(r, e) setresuid(r, e, -1)
+# define setreuid(r, e) setresuid(r, e, -1)
# define LA_TYPE LA_FLOAT
+# define SFS_TYPE SFS_VFS /* use <sys/vfs.h> statfs() implementation */
# define GIDSET_T gid_t
# define _PATH_UNIX "/hp-ux"
# ifndef _PATH_SENDMAILCF
@@ -159,11 +167,11 @@ extern int syslog(int, char *, ...);
# ifdef _AIX3
# define HASINITGROUPS 1 /* has initgroups(3) call */
-# define HASSTATFS 1 /* has the statfs(2) syscall */
# define HASUNAME 1 /* use System V uname(2) system call */
# define HASGETUSERSHELL 0 /* does not have getusershell(3) call */
# define FORK fork /* no vfork primitive available */
# undef SETPROCTITLE /* setproctitle confuses AIX */
+# define SFS_TYPE SFS_STATFS /* use <sys/statfs.h> statfs() impl */
# endif
@@ -177,12 +185,12 @@ extern int syslog(int, char *, ...);
# include <sys/sysmacros.h>
# define HASSETREUID 1 /* has setreuid(2) call */
# define HASINITGROUPS 1 /* has initgroups(3) call */
-# define HASSTATFS 1 /* has the statfs(2) syscall */
# define HASGETUSERSHELL 0 /* does not have getusershell(3) call */
# define FORK fork /* no vfork primitive available */
# define WAITUNION 1 /* use "union wait" as wait argument type */
# define setpgid BSDsetpgrp
# define GIDSET_T gid_t
+# define SFS_TYPE SFS_4ARGS /* four argument statfs() call */
# endif
@@ -195,10 +203,10 @@ extern int syslog(int, char *, ...);
#if defined(sun) && !defined(BSD)
-# define LA_TYPE LA_INT
# define HASINITGROUPS 1 /* has initgroups(3) call */
# define HASUNAME 1 /* use System V uname(2) system call */
# define HASGETUSERSHELL 1 /* DOES have getusershell(3) call in libc */
+# define LA_TYPE LA_INT
# ifdef SOLARIS_2_3
# define SOLARIS
@@ -222,12 +230,17 @@ extern int syslog(int, char *, ...);
# ifndef _PATH_SENDMAILPID
# define _PATH_SENDMAILPID "/etc/mail/sendmail.pid"
# endif
+# ifndef SYSLOG_BUFSIZE
+# define SYSLOG_BUFSIZE 1024 /* allow full size syslog buffer */
+# endif
# else
/* SunOS 4.0.3 or 4.1.x */
# define HASSETREUID 1 /* has setreuid(2) call */
-# define HASSTATFS 1 /* has the statfs(2) syscall */
-# define HASFLOCK 1 /* has flock(2) call */
+# ifndef HASFLOCK
+# define HASFLOCK 1 /* has flock(2) call */
+# endif
+# define SFS_TYPE SFS_VFS /* use <sys/vfs.h> statfs() implementation */
# include <vfork.h>
# ifdef SUNOS403
@@ -255,15 +268,16 @@ extern char *getenv();
#ifdef DGUX
# define SYSTEM5 1
# define LA_TYPE LA_SUBR
-# define HASSTATFS 1 /* has the statfs(2) syscall */
# define HASSETREUID 1 /* has setreuid(2) call */
# define HASUNAME 1 /* use System V uname(2) system call */
# define HASSETSID 1 /* has Posix setsid(2) call */
# define HASINITGROUPS 1 /* has initgroups(3) call */
+# define HASGETUSERSHELL 0 /* does not have getusershell(3) */
# ifndef IDENTPROTO
# define IDENTPROTO 0 /* TCP/IP implementation is broken */
# endif
# undef SETPROCTITLE
+# define SFS_TYPE SFS_4ARGS /* four argument statfs() call */
/* these include files must be included early on DG/UX */
# include <netinet/in.h>
@@ -283,18 +297,22 @@ extern long dgux_inet_addr();
*/
#ifdef ultrix
-# define HASSTATFS 1 /* has the statfs(2) syscall */
# define HASSETREUID 1 /* has setreuid(2) call */
# define HASUNSETENV 1 /* has unsetenv(3) call */
# define HASINITGROUPS 1 /* has initgroups(3) call */
-# define HASFLOCK 1 /* has flock(2) call */
+# define HASUNAME 1 /* use System V uname(2) system call */
+# ifndef HASFLOCK
+# define HASFLOCK 1 /* has flock(2) call */
+# endif
# define HASGETUSERSHELL 0 /* does not have getusershell(3) call */
+# define BROKEN_RES_SEARCH 1 /* res_search(unknown) returns h_errno=0 */
# ifdef vax
# define LA_TYPE LA_FLOAT
# else
# define LA_TYPE LA_INT
# define LA_AVENRUN "avenrun"
# endif
+# define SFS_TYPE SFS_MOUNT /* use <sys/mount.h> statfs() impl */
# ifndef IDENTPROTO
# define IDENTPROTO 0 /* TCP/IP implementation is broken */
# endif
@@ -306,12 +324,14 @@ extern long dgux_inet_addr();
*/
#ifdef __osf__
-# define HASSTATFS 1 /* has the statfs(2) syscall */
# define HASUNSETENV 1 /* has unsetenv(3) call */
# define HASSETREUID 1 /* has setreuid(2) call */
# define HASINITGROUPS 1 /* has initgroups(3) call */
-# define HASFLOCK 1 /* has flock(2) call */
+# ifndef HASFLOCK
+# define HASFLOCK 1 /* has flock(2) call */
+# endif
# define LA_TYPE LA_INT
+# define SFS_TYPE SFS_MOUNT /* use <sys/mount.h> statfs() impl */
# ifndef _PATH_SENDMAILPID
# define _PATH_SENDMAILPID "/var/run/sendmail.pid"
# endif
@@ -324,15 +344,17 @@ extern long dgux_inet_addr();
#ifdef NeXT
# define HASINITGROUPS 1 /* has initgroups(3) call */
-# define HASFLOCK 1 /* has flock(2) call */
+# ifndef HASFLOCK
+# define HASFLOCK 1 /* has flock(2) call */
+# endif
# define NEEDGETOPT 1 /* need a replacement for getopt(3) */
-# define HASSTATFS 1 /* has the statfs(2) syscall */
# define WAITUNION 1 /* use "union wait" as wait argument type */
# define sleep sleepX
# define setpgid setpgrp
# ifndef LA_TYPE
# define LA_TYPE LA_MACH
# endif
+# define SFS_TYPE SFS_VFS /* use <sys/vfs.h> statfs() implementation */
# ifndef _POSIX_SOURCE
typedef int pid_t;
# undef WEXITSTATUS
@@ -355,7 +377,29 @@ typedef int pid_t;
#ifdef BSD4_4
# define HASUNSETENV 1 /* has unsetenv(3) call */
-# define HASSTATFS 1 /* has the statfs(2) syscall */
+# include <sys/cdefs.h>
+# define ERRLIST_PREDEFINED /* don't declare sys_errlist */
+# ifndef LA_TYPE
+# define LA_TYPE LA_SUBR
+# endif
+# define SFS_TYPE SFS_MOUNT /* use <sys/mount.h> statfs() impl */
+#endif
+
+
+/*
+** BSD/386 (all versions)
+** From Tony Sanders, BSDI
+*/
+
+#ifdef __bsdi__
+# define HASUNSETENV 1 /* has the unsetenv(3) call */
+# define HASSETSID 1 /* has the setsid(2) POSIX syscall */
+# define SFS_TYPE SFS_MOUNT /* use <sys/mount.h> statfs() impl */
+# if defined(_BSDI_VERSION) && _BSDI_VERSION >= 199312
+# define HASSETPROCTITLE 1 /* setproctitle is in libc */
+# else
+# define SETPROCTITLE 1
+# endif
# include <sys/cdefs.h>
# define ERRLIST_PREDEFINED /* don't declare sys_errlist */
# ifndef LA_TYPE
@@ -364,6 +408,7 @@ typedef int pid_t;
#endif
+
/*
** 386BSD / FreeBSD 1.0E / NetBSD (all architectures, all versions)
**
@@ -375,12 +420,12 @@ typedef int pid_t;
#if defined(__386BSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
# define HASUNSETENV 1 /* has unsetenv(3) call */
# define HASSETSID 1 /* has the setsid(2) POSIX syscall */
-# define HASSTATFS 1 /* has the statfs(2) syscall */
# include <sys/cdefs.h>
# define ERRLIST_PREDEFINED /* don't declare sys_errlist */
# ifndef LA_TYPE
# define LA_TYPE LA_SUBR
# endif
+# define SFS_TYPE SFS_MOUNT /* use <sys/mount.h> statfs() impl */
#endif
@@ -394,14 +439,16 @@ typedef int pid_t;
# define MACH386 1
# define HASUNSETENV 1 /* has unsetenv(3) call */
# define HASINITGROUPS 1 /* has initgroups(3) call */
-# define HASFLOCK 1 /* has flock(2) call */
-# define HASSTATFS 1 /* has the statfs(2) syscall */
+# ifndef HASFLOCK
+# define HASFLOCK 1 /* has flock(2) call */
+# endif
# define NEEDGETOPT 1 /* need a replacement for getopt(3) */
# define NEEDSTRTOL 1 /* need the strtol() function */
# define setpgid setpgrp
# ifndef LA_TYPE
# define LA_TYPE LA_FLOAT
# endif
+# define SFS_TYPE SFS_VFS /* use <sys/vfs.h> statfs() implementation */
# undef HASSETVBUF /* don't actually have setvbuf(3) */
# undef WEXITSTATUS
# undef WIFEXITED
@@ -417,11 +464,13 @@ typedef int pid_t;
/*
** 4.3 BSD -- this is for very old systems
**
+** Should work for mt Xinu MORE/BSD and Mips UMIPS-BSD 2.1.
+**
** You'll also have to install a new resolver library.
** I don't guarantee that support for this environment is complete.
*/
-#ifdef oldBSD43
+#if defined(oldBSD43) || defined(MORE_BSD) || defined(umipsbsd)
# define NEEDVPRINTF 1 /* need a replacement for vprintf(3) */
# define NEEDGETOPT 1 /* need a replacement for getopt(3) */
# define ARBPTR_T char *
@@ -465,26 +514,40 @@ extern int errno;
#ifdef _SCO_unix_
# define SYSTEM5 1 /* include all the System V defines */
# define SYS5SIGNALS 1 /* SysV signal semantics -- reset on each sig */
-# define HASSTATFS 1 /* has the statfs(2) syscall */
# define HASGETUSERSHELL 0 /* does not have getusershell(3) call */
# define FORK fork
# define MAXPATHLEN PATHSIZE
# define LA_TYPE LA_SHORT
+# define SFS_TYPE SFS_STATFS /* use <sys/statfs.h> statfs() impl */
# undef NETUNIX /* no unix domain socket support */
#endif
/*
** ConvexOS 11.0 and later
+**
+** "Todd C. Miller" <millert@mroe.cs.colorado.edu> claims this
+** works on 9.1 as well.
*/
#ifdef _CONVEX_SOURCE
# define BSD 1 /* include all the BSD defines */
# define HASUNAME 1 /* use System V uname(2) system call */
-# define HASSTATFS 1 /* has the statfs(2) syscall */
# define HASSETSID 1 /* has POSIX setsid(2) call */
# define NEEDGETOPT 1 /* need replacement for getopt(3) */
# define LA_TYPE LA_FLOAT
+# define SFS_TYPE SFS_VFS /* use <sys/vfs.h> statfs() implementation */
+# ifndef _PATH_SENDMAILCF
+# define _PATH_SENDMAILCF "/usr/lib/sendmail.cf"
+# endif
+# ifndef S_IREAD
+# define S_IREAD _S_IREAD
+# define S_IWRITE _S_IWRITE
+# define S_IEXEC _S_IEXEC
+# define S_IFMT _S_IFMT
+# define S_IFCHR _S_IFCHR
+# define S_IFBLK _S_IFBLK
+# endif
# ifndef IDENTPROTO
# define IDENTPROTO 0 /* TCP/IP implementation is broken */
# endif
@@ -500,7 +563,9 @@ extern int errno;
#ifdef RISCOS
# define HASUNSETENV 1 /* has unsetenv(3) call */
-# define HASFLOCK 1 /* has flock(2) call */
+# ifndef HASFLOCK
+# define HASFLOCK 1 /* has flock(2) call */
+# endif
# define WAITUNION 1 /* use "union wait" as wait argument type */
# define NEEDGETOPT 1 /* need a replacement for getopt(3) */
# define LA_TYPE LA_INT
@@ -522,19 +587,32 @@ extern void *malloc();
/*
** Linux 0.99pl10 and above...
-** From Karl London <karl@borg.demon.co.uk>.
+**
+** Thanks to, in reverse order of contact:
+**
+** John Kennedy <warlock@csuchico.edu>
+** Florian La Roche <rzsfl@rz.uni-sb.de>
+** Karl London <karl@borg.demon.co.uk>
+**
+** Last compiled against: [03/02/94 @ 05:34 PM (Wednesday)]
+** sendmail 8.6.6.b9 named 4.9.2-931205-p1 db-1.73
+** gcc 2.5.8 libc.so.4.5.19
+** slackware 1.1.2 linux 0.99.15
*/
#ifdef __linux__
-# define BSD 1 /* pretend to be BSD based today */
-# undef NEEDVPRINTF 1 /* need a replacement for vprintf(3) */
+# define BSD 1 /* include BSD defines */
# define NEEDGETOPT 1 /* need a replacement for getopt(3) */
+# define HASUNAME 1 /* use System V uname(2) system call */
# define HASUNSETENV 1 /* has unsetenv(3) call */
+# define ERRLIST_PREDEFINED /* don't declare sys_errlist */
+# define GIDSET_T gid_t /* from <linux/types.h> */
# ifndef LA_TYPE
-# define LA_TYPE LA_FLOAT
+# define LA_TYPE LA_PROCSTR
# endif
+# define SFS_TYPE SFS_VFS /* use <sys/vfs.h> statfs() impl */
# include <sys/sysmacros.h>
-# define GIDSET_T gid_t
+# undef atol /* wounded in <stdlib.h> */
#endif
@@ -563,9 +641,7 @@ extern void *malloc();
#ifdef _AUX_SOURCE
# include <sys/sysmacros.h>
# define BSD /* has BSD routines */
-# define HASSTATFS 1 /* has the statfs(2) syscall */
# define HASUNAME 1 /* use System V uname(2) system call */
-# define HASUSTAT 1 /* use System V ustat(2) syscall */
# define HASSETVBUF 1 /* we have setvbuf(3) in libc */
# define SIGFUNC_DEFINED /* sigfunc_t already defined */
# ifndef IDENTPROTO
@@ -578,6 +654,7 @@ extern void *malloc();
# ifndef LA_TYPE
# define LA_TYPE LA_ZERO
# endif
+# define SFS_TYPE SFS_VFS /* use <sys/vfs.h> statfs() implementation */
# undef WIFEXITED
# undef WEXITSTATUS
#endif
@@ -592,13 +669,13 @@ extern void *malloc();
#ifdef UMAXV
# include <limits.h>
# define HASUNAME 1 /* use System V uname(2) system call */
-# define HASSTATFS 1 /* has the statfs(2) syscall */
# define HASSETVBUF 1 /* we have setvbuf(3) in libc */
# define HASINITGROUPS 1 /* has initgroups(3) call */
# define HASGETUSERSHELL 0 /* does not have getusershell(3) call */
# define SYS5SIGNALS 1 /* SysV signal semantics -- reset on each sig */
# define SYS5SETPGRP 1 /* use System V setpgrp(2) syscall */
# define FORK fork /* no vfork(2) primitive available */
+# define SFS_TYPE SFS_4ARGS /* four argument statfs() call */
# define MAXPATHLEN PATH_MAX
extern struct passwd *getpwent(), *getpwnam(), *getpwuid();
extern struct group *getgrent(), *getgrnam(), *getgrgid();
@@ -632,6 +709,7 @@ typedef int pid_t;
*/
#ifdef sequent
+
# define BSD 1
# define HASUNSETENV 1
# define BSD4_3 1 /* to get signal() in conf.c */
@@ -651,6 +729,10 @@ typedef int pid_t;
typedef int pid_t;
# define isgraph(c) (isprint(c) && (c != ' '))
+# ifndef IDENTPROTO
+# define IDENTPROTO 0 /* TCP/IP implementation is broken */
+# endif
+
# ifndef _PATH_UNIX
# define _PATH_UNIX "/dynix"
# endif
@@ -661,6 +743,81 @@ typedef int pid_t;
#endif
+/*
+** Sequent DYNIX/ptx v2.0 (and higher)
+**
+** For DYNIX/ptx v1.x, undefine HASSETREUID.
+**
+** From Tim Wright <timw@sequent.com>.
+*/
+
+#ifdef _SEQUENT_
+# define SYSTEM5 1 /* include all the System V defines */
+# define HASSETSID 1 /* has POSIX setsid(2) call */
+# define HASINITGROUPS 1 /* has initgroups(3) call */
+# define HASSETREUID 1 /* has setreuid(2) call */
+# define HASGETUSERSHELL 0 /* does not have getusershell(3) call */
+# define GIDSET_T gid_t
+# define LA_TYPE LA_INT
+# define SFS_TYPE SFS_STATFS /* use <sys/statfs.h> statfs() impl */
+# undef SETPROCTITLE
+# ifndef IDENTPROTO
+# define IDENTPROTO 0 /* TCP/IP implementation is broken */
+# endif
+# ifndef _PATH_SENDMAILCF
+# define _PATH_SENDMAILCF "/usr/lib/sendmail.cf"
+# endif
+# ifndef _PATH_SENDMAILPID
+# define _PATH_SENDMAILPID "/etc/sendmail.pid"
+# endif
+#endif
+
+
+/*
+** Cray Unicos
+**
+** Ported by David L. Kensiski, Sterling Sofware <kensiski@nas.nasa.gov>
+*/
+
+#ifdef UNICOS
+# define SYSTEM5 1 /* include all the System V defines */
+# define SYS5SIGNALS 1 /* SysV signal semantics -- reset on each sig */
+# define MAXPATHLEN PATHSIZE
+# define LA_TYPE LA_ZERO
+# define SFS_TYPE SFS_4ARGS /* four argument statfs() call */
+#endif
+
+
+/*
+** Apollo DomainOS
+**
+** From Todd Martin <tmartint@tus.ssi1.com> & Don Lewis <gdonl@gv.ssi1.com>
+**
+** 15 Jan 1994
+**
+*/
+
+#ifdef apollo
+# define HASSETREUID 1 /* has setreuid(2) call */
+# define HASINITGROUPS 1 /* has initgroups(2) call */
+# undef SETPROCTITLE
+# define LA_TYPE LA_SUBR /* use getloadavg.c */
+# define SFS_TYPE SFS_4ARGS /* four argument statfs() call */
+# ifndef _PATH_SENDMAILCF
+# define _PATH_SENDMAILCF "/usr/lib/sendmail.cf"
+# endif
+# ifndef _PATH_SENDMAILPID
+# define _PATH_SENDMAILPID "/etc/sendmail.pid"
+# endif
+# undef S_IFSOCK /* S_IFSOCK and S_IFIFO are the same */
+# undef S_IFIFO
+# define S_IFIFO 0010000
+# ifndef IDENTPROTO
+# define IDENTPROTO 0 /* TCP/IP implementation is broken */
+# endif
+#endif
+
+
/**********************************************************************
@@ -676,7 +833,9 @@ typedef int pid_t;
# define HASGETDTABLESIZE 1 /* has getdtablesize(2) call */
# define HASSETREUID 1 /* has setreuid(2) call */
# define HASINITGROUPS 1 /* has initgroups(2) call */
-# define HASFLOCK 1 /* has flock(2) call */
+# ifndef HASFLOCK
+# define HASFLOCK 1 /* has flock(2) call */
+# endif
#endif
/* general System V Release 4 defines */
@@ -703,19 +862,21 @@ typedef int pid_t;
#endif
/* general System V defines */
-# ifdef SYSTEM5
+#ifdef SYSTEM5
# include <sys/sysmacros.h>
# define HASUNAME 1 /* use System V uname(2) system call */
-# define HASUSTAT 1 /* use System V ustat(2) syscall */
# define SYS5SETPGRP 1 /* use System V setpgrp(2) syscall */
# define HASSETVBUF 1 /* we have setvbuf(3) in libc */
# ifndef LA_TYPE
-# define LA_TYPE LA_INT
+# define LA_TYPE LA_INT /* assume integer load average */
+# endif
+# ifndef SFS_TYPE
+# define SFS_TYPE SFS_USTAT /* use System V ustat(2) syscall */
# endif
# define bcopy(s, d, l) (memmove((d), (s), (l)))
# define bzero(d, l) (memset((d), '\0', (l)))
# define bcmp(s, d, l) (memcmp((s), (d), (l)))
-# endif
+#endif
/* general POSIX defines */
#ifdef _POSIX_VERSION
@@ -742,6 +903,7 @@ typedef int pid_t;
# undef HASINITGROUPS /* doesn't have initgroups(3) call */
#endif
+
/*
** Due to a "feature" in some operating systems such as Ultrix 4.3 and
** HPUX 8.0, if you receive a "No route to host" message (ICMP message
@@ -761,6 +923,10 @@ typedef int pid_t;
# define HASGETUSERSHELL 1 /* libc has getusershell(3) call */
#endif
+#ifndef HASFLOCK
+# define HASFLOCK 0 /* assume no flock(2) support */
+#endif
+
/**********************************************************************
** Remaining definitions should never have to be changed. They are
@@ -935,3 +1101,11 @@ typedef void (*sigfunc_t) __P((int));
# ifndef FORK
# define FORK vfork /* function to call to fork mailer */
# endif
+
+/*
+** If we are going to link scanf anyway, use it in readcf
+*/
+
+#if !defined(HASUNAME) && !defined(SCANF)
+# define SCANF 1
+#endif
diff --git a/usr.sbin/sendmail/src/daemon.c b/usr.sbin/sendmail/src/daemon.c
index 8e5f55540f9..f7876825161 100644
--- a/usr.sbin/sendmail/src/daemon.c
+++ b/usr.sbin/sendmail/src/daemon.c
@@ -37,19 +37,18 @@
#ifndef lint
#ifdef DAEMON
-static char sccsid[] = "@(#)daemon.c 8.30 (Berkeley) 1/8/94 (with daemon mode)";
+static char sccsid[] = "@(#)daemon.c 8.39 (Berkeley) 3/13/94 (with daemon mode)";
#else
-static char sccsid[] = "@(#)daemon.c 8.30 (Berkeley) 1/8/94 (without daemon mode)";
+static char sccsid[] = "@(#)daemon.c 8.39 (Berkeley) 3/13/94 (without daemon mode)";
#endif
#endif /* not lint */
#ifdef DAEMON
# include <netdb.h>
-# include <sys/time.h>
# include <arpa/inet.h>
-#ifdef NAMED_BIND
+#if NAMED_BIND
# include <arpa/nameser.h>
# include <resolv.h>
#endif
@@ -302,10 +301,15 @@ getrequests()
*/
(void) setsignal(SIGCHLD, SIG_DFL);
+ DisConnected = FALSE;
+
+ setproctitle("startup with %s",
+ anynet_ntoa(&RealHostAddr));
/* determine host name */
p = hostnamebyanyaddr(&RealHostAddr);
RealHostName = newstr(p);
+ setproctitle("startup with %s", p);
#ifdef LOG
if (LogLevel > 11)
@@ -545,7 +549,7 @@ makeconnection(host, port, mci, usesecureport)
SOCKADDR addr;
int sav_errno;
int addrlen;
-#ifdef NAMED_BIND
+#if NAMED_BIND
extern int h_errno;
#endif
@@ -554,7 +558,7 @@ makeconnection(host, port, mci, usesecureport)
** Accept "[a.b.c.d]" syntax for host name.
*/
-#ifdef NAMED_BIND
+#if NAMED_BIND
h_errno = 0;
#endif
errno = 0;
@@ -577,6 +581,12 @@ makeconnection(host, port, mci, usesecureport)
{
/* try it as a host name (avoid MX lookup) */
hp = gethostbyname(&host[1]);
+ if (hp == NULL && p[-1] == '.')
+ {
+ p[-1] = '\0';
+ hp = gethostbyname(&host[1]);
+ p[-1] = '.';
+ }
*p = ']';
goto gothostent;
}
@@ -594,11 +604,19 @@ makeconnection(host, port, mci, usesecureport)
}
else
{
+ register char *p = &host[strlen(host) - 1];
+
hp = gethostbyname(host);
+ if (hp == NULL && *p == '.')
+ {
+ *p = '\0';
+ hp = gethostbyname(host);
+ *p = '.';
+ }
gothostent:
if (hp == NULL)
{
-#ifdef NAMED_BIND
+#if NAMED_BIND
if (errno == ETIMEDOUT || h_errno == TRY_AGAIN)
return (EX_TEMPFAIL);
@@ -844,9 +862,6 @@ myhostname(hostbuf, size)
**
** Returns:
** The user@host information associated with this descriptor.
-**
-** Side Effects:
-** Sets RealHostName to the name of the host at the other end.
*/
#if IDENTPROTO
@@ -884,18 +899,16 @@ getauthinfo(fd)
if (getpeername(fd, &fa.sa, &falen) < 0 || falen <= 0 ||
fa.sa.sa_family == 0)
{
- RealHostName = "localhost";
(void) sprintf(hbuf, "%s@localhost", RealUserName);
if (tTd(9, 1))
printf("getauthinfo: %s\n", hbuf);
return hbuf;
}
- p = hostnamebyanyaddr(&fa);
- RealHostName = newstr(p);
- RealHostAddr = fa;
-
#if IDENTPROTO
+ if (TimeOuts.to_ident == 0)
+ goto noident;
+
lalen = sizeof la;
if (fa.sa.sa_family != AF_INET ||
getsockname(fd, &la.sa, &lalen) < 0 || lalen <= 0 ||
@@ -940,10 +953,7 @@ getauthinfo(fd)
if (bind(s, &la.sa, sizeof la.sin) < 0 ||
connect(s, &fa.sa, sizeof fa.sin) < 0)
{
-closeident:
- (void) close(s);
- clrevent(ev);
- goto noident;
+ goto closeident;
}
if (tTd(9, 10))
@@ -1002,16 +1012,27 @@ closeident:
continue;
/* p now points to the authenticated name */
- (void) sprintf(hbuf, "%s@%s", p, RealHostName);
+ (void) sprintf(hbuf, "%s@%s",
+ p, RealHostName == NULL ? "localhost" : RealHostName);
goto finish;
+closeident:
+ (void) close(s);
+ clrevent(ev);
+
#endif /* IDENTPROTO */
noident:
+ if (RealHostName == NULL)
+ {
+ if (tTd(9, 1))
+ printf("getauthinfo: NULL\n");
+ return NULL;
+ }
(void) strcpy(hbuf, RealHostName);
finish:
- if (RealHostName[0] != '[')
+ if (RealHostName != NULL && RealHostName[0] != '[')
{
p = &hbuf[strlen(hbuf)];
(void) sprintf(p, " [%s]", anynet_ntoa(&RealHostAddr));
@@ -1055,7 +1076,9 @@ host_map_lookup(map, name, av, statp)
register STAB *s;
char hbuf[MAXNAME];
extern struct hostent *gethostbyaddr();
+#if NAMED_BIND
extern int h_errno;
+#endif
/*
** See if we have already looked up this name. If so, just
@@ -1069,7 +1092,9 @@ host_map_lookup(map, name, av, statp)
printf("host_map_lookup(%s) => CACHE %s\n",
name, s->s_namecanon.nc_cname);
errno = s->s_namecanon.nc_errno;
+#if NAMED_BIND
h_errno = s->s_namecanon.nc_herrno;
+#endif
*statp = s->s_namecanon.nc_stat;
if (CurEnv->e_message == NULL && *statp == EX_TEMPFAIL)
{
@@ -1107,10 +1132,11 @@ host_map_lookup(map, name, av, statp)
{
register struct hostent *hp;
- if (tTd(9, 1))
- printf("FAIL (%d)\n", h_errno);
s->s_namecanon.nc_errno = errno;
+#if NAMED_BIND
s->s_namecanon.nc_herrno = h_errno;
+ if (tTd(9, 1))
+ printf("FAIL (%d)\n", h_errno);
switch (h_errno)
{
case TRY_AGAIN:
@@ -1137,6 +1163,11 @@ host_map_lookup(map, name, av, statp)
*statp = EX_UNAVAILABLE;
break;
}
+#else
+ if (tTd(9, 1))
+ printf("FAIL\n");
+ *statp = EX_NOHOST;
+#endif
s->s_namecanon.nc_stat = *statp;
if (*statp != EX_TEMPFAIL || UseNameServer)
return NULL;
@@ -1167,7 +1198,9 @@ host_map_lookup(map, name, av, statp)
/* nope -- ask the name server */
hp = gethostbyaddr((char *)&in_addr, sizeof(struct in_addr), AF_INET);
s->s_namecanon.nc_errno = errno;
+#if NAMED_BIND
s->s_namecanon.nc_herrno = h_errno;
+#endif
s->s_namecanon.nc_flags |= NCF_VALID; /* will be soon */
if (hp == NULL)
{
@@ -1261,7 +1294,7 @@ hostnamebyanyaddr(sap)
register struct hostent *hp;
int saveretry;
-#ifdef NAMED_BIND
+#if NAMED_BIND
/* shorten name server timeout to avoid higher level timeouts */
saveretry = _res.retry;
_res.retry = 3;
@@ -1298,7 +1331,7 @@ hostnamebyanyaddr(sap)
break;
}
-#ifdef NAMED_BIND
+#if NAMED_BIND
_res.retry = saveretry;
#endif /* NAMED_BIND */
diff --git a/usr.sbin/sendmail/src/deliver.c b/usr.sbin/sendmail/src/deliver.c
index d627395bee9..692dffe932a 100644
--- a/usr.sbin/sendmail/src/deliver.c
+++ b/usr.sbin/sendmail/src/deliver.c
@@ -33,13 +33,13 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)deliver.c 8.62 (Berkeley) 1/12/94";
+static char sccsid[] = "@(#)deliver.c 8.78 (Berkeley) 3/11/94";
#endif /* not lint */
#include "sendmail.h"
#include <netdb.h>
#include <errno.h>
-#ifdef NAMED_BIND
+#if NAMED_BIND
#include <arpa/nameser.h>
#include <resolv.h>
@@ -124,9 +124,11 @@ sendall(e, mode)
if (e->e_hopcount > MaxHopCount)
{
errno = 0;
+ e->e_flags |= EF_FATALERRS|EF_PM_NOTIFY|EF_CLRQUEUE;
syserr("554 too many hops %d (%d max): from %s via %s, to %s",
e->e_hopcount, MaxHopCount, e->e_from.q_paddr,
- RealHostName, e->e_sendqueue->q_paddr);
+ RealHostName == NULL ? "localhost" : RealHostName,
+ e->e_sendqueue->q_paddr);
return;
}
@@ -247,10 +249,16 @@ sendall(e, mode)
for (q = e->e_sendqueue; q != NULL; q = q->q_next)
if (q->q_owner == owner)
+ {
q->q_flags |= QDONTSEND;
+ q->q_flags &= ~QQUEUEUP;
+ }
for (q = ee->e_sendqueue; q != NULL; q = q->q_next)
if (q->q_owner != owner)
+ {
q->q_flags |= QDONTSEND;
+ q->q_flags &= ~QQUEUEUP;
+ }
if (e->e_df != NULL && mode != SM_VERIFY)
{
@@ -263,13 +271,10 @@ sendall(e, mode)
e->e_df, ee->e_df);
}
}
-
- if (mode != SM_VERIFY)
- openxscript(ee);
#ifdef LOG
if (LogLevel > 4)
- syslog(LOG_INFO, "%s: clone %s",
- ee->e_id, e->e_id);
+ syslog(LOG_INFO, "%s: clone %s, owner=%s",
+ ee->e_id, e->e_id, owner);
#endif
}
}
@@ -309,15 +314,15 @@ sendall(e, mode)
for (ee = splitenv; ee != NULL; ee = ee->e_sibling)
{
CurEnv = ee;
+ if (mode != SM_VERIFY)
+ openxscript(ee);
sendenvelope(ee, mode);
+ dropenvelope(ee);
}
CurEnv = e;
}
sendenvelope(e, mode);
-
- for (; splitenv != NULL; splitenv = splitenv->e_sibling)
- dropenvelope(splitenv);
}
sendenvelope(e, mode)
@@ -360,7 +365,7 @@ sendenvelope(e, mode)
if (e->e_xfp != NULL)
(void) fflush(e->e_xfp);
-# ifndef HASFLOCK
+# if !HASFLOCK
/*
** Since fcntl locking has the interesting semantic that
** the lock is owned by a process, not by an open file
@@ -401,16 +406,27 @@ sendenvelope(e, mode)
(void) xfclose(e->e_dfp, "sendenvelope", e->e_df);
e->e_dfp = NULL;
e->e_id = e->e_df = NULL;
+
+ /* catch intermediate zombie */
+ (void) waitfor(pid);
return;
}
/* double fork to avoid zombies */
- if (fork() > 0)
+ pid = fork();
+ if (pid > 0)
exit(EX_OK);
/* be sure we are immune from the terminal */
disconnect(1, e);
+ /* prevent parent from waiting if there was an error */
+ if (pid < 0)
+ {
+ e->e_flags |= EF_INQUEUE|EF_KEEPQUEUE;
+ finis();
+ }
+
/*
** Close any cached connections.
**
@@ -604,7 +620,7 @@ deliver(e, firstto)
if (bitset(QDONTSEND|QBADADDR|QQUEUEUP, to->q_flags))
return (0);
-#ifdef NAMED_BIND
+#if NAMED_BIND
/* unless interactive, try twice, over a minute */
if (OpMode == MD_DAEMON || OpMode == MD_SMTP)
{
@@ -620,8 +636,8 @@ deliver(e, firstto)
SmtpError[0] = '\0';
if (tTd(10, 1))
- printf("\n--deliver, mailer=%d, host=`%s', first user=`%s'\n",
- m->m_mno, host, to->q_user);
+ printf("\n--deliver, id=%s, mailer=%s, host=`%s', first user=`%s'\n",
+ e->e_id, m->m_name, host, to->q_user);
if (tTd(10, 100))
printopenfds(FALSE);
@@ -916,10 +932,11 @@ deliver(e, firstto)
*/
/*XXX this seems a bit wierd */
- if (ctladdr == NULL && bitset(QGOODUID, e->e_from.q_flags))
+ if (ctladdr == NULL && m != ProgMailer &&
+ bitset(QGOODUID, e->e_from.q_flags))
ctladdr = &e->e_from;
-#ifdef NAMED_BIND
+#if NAMED_BIND
if (ConfigLevel < 2)
_res.options &= ~(RES_DEFNAMES | RES_DNSRCH); /* XXX */
#endif
@@ -1047,7 +1064,7 @@ tryhost:
bitnset(M_SECURE_PORT, m->m_flags));
mci->mci_exitstat = i;
mci->mci_errno = errno;
-#ifdef NAMED_BIND
+#if NAMED_BIND
mci->mci_herrno = h_errno;
#endif
if (i == EX_OK)
@@ -1223,7 +1240,8 @@ tryhost:
}
(void) close(rpvect[1]);
}
- else if (OpMode == MD_SMTP || OpMode == MD_DAEMON || HoldErrs)
+ else if (OpMode == MD_SMTP || OpMode == MD_DAEMON ||
+ HoldErrs || DisConnected)
{
/* put mailer output in transcript */
if (dup2(fileno(e->e_xfp), STDOUT_FILENO) < 0)
@@ -1260,12 +1278,20 @@ tryhost:
(void) fcntl(i, F_SETFD, j | 1);
}
- /* set up the mailer environment */
+ /*
+ ** Set up the mailer environment
+ ** TZ is timezone information.
+ ** SYSTYPE is Apollo software sys type (required).
+ ** ISP is Apollo hardware system type (required).
+ */
+
i = 0;
env[i++] = "AGENT=sendmail";
for (ep = environ; *ep != NULL; ep++)
{
- if (strncmp(*ep, "TZ=", 3) == 0)
+ if (strncmp(*ep, "TZ=", 3) == 0 ||
+ strncmp(*ep, "ISP=", 4) == 0 ||
+ strncmp(*ep, "SYSTYPE=", 8) == 0)
env[i++] = *ep;
}
env[i++] = NULL;
@@ -1344,7 +1370,7 @@ tryhost:
/* couldn't open the mailer */
rcode = mci->mci_exitstat;
errno = mci->mci_errno;
-#ifdef NAMED_BIND
+#if NAMED_BIND
h_errno = mci->mci_herrno;
#endif
if (rcode == EX_OK)
@@ -1366,10 +1392,10 @@ tryhost:
** Format and send message.
*/
- putfromline(mci->mci_out, m, e);
- (*e->e_puthdr)(mci->mci_out, m, e);
- putline("\n", mci->mci_out, m);
- (*e->e_putbody)(mci->mci_out, m, e, NULL);
+ putfromline(mci, e);
+ (*e->e_puthdr)(mci, e);
+ putline("\n", mci);
+ (*e->e_putbody)(mci, e, NULL);
/* get the exit status */
rcode = endmailer(mci, e, pv);
@@ -1437,7 +1463,7 @@ tryhost:
goto give_up;
}
#endif /* SMTP */
-#ifdef NAMED_BIND
+#if NAMED_BIND
if (ConfigLevel < 2)
_res.options |= RES_DEFNAMES | RES_DNSRCH; /* XXX */
#endif
@@ -1667,7 +1693,7 @@ giveresponse(stat, m, mci, ctladdr, e)
else if (stat == EX_TEMPFAIL)
{
(void) strcpy(buf, SysExMsg[i] + 1);
-#ifdef NAMED_BIND
+#if NAMED_BIND
if (h_errno == TRY_AGAIN)
statmsg = errstring(h_errno+E_DNSBASE);
else
@@ -1691,7 +1717,7 @@ giveresponse(stat, m, mci, ctladdr, e)
}
statmsg = buf;
}
-#ifdef NAMED_BIND
+#if NAMED_BIND
else if (stat == EX_NOHOST && h_errno != 0)
{
statmsg = errstring(h_errno + E_DNSBASE);
@@ -1717,7 +1743,7 @@ giveresponse(stat, m, mci, ctladdr, e)
{
extern char MsgBuf[];
- message(&statmsg[4], errstring(errno));
+ message("%s", &statmsg[4]);
if (stat == EX_TEMPFAIL && e->e_xfp != NULL)
fprintf(e->e_xfp, "%s\n", &MsgBuf[4]);
}
@@ -1737,6 +1763,10 @@ giveresponse(stat, m, mci, ctladdr, e)
if (LogLevel > ((stat == EX_TEMPFAIL) ? 8 : (stat == EX_OK) ? 7 : 6))
logdelivery(m, mci, &statmsg[4], ctladdr, e);
+ if (tTd(11, 2))
+ printf("giveresponse: stat=%d, e->e_message=%s\n",
+ stat, e->e_message);
+
if (stat != EX_TEMPFAIL)
setstat(stat);
if (stat != EX_OK && (stat != EX_TEMPFAIL || e->e_message == NULL))
@@ -1746,7 +1776,7 @@ giveresponse(stat, m, mci, ctladdr, e)
e->e_message = newstr(&statmsg[4]);
}
errno = 0;
-#ifdef NAMED_BIND
+#if NAMED_BIND
h_errno = 0;
#endif
}
@@ -1820,9 +1850,9 @@ logdelivery(m, mci, stat, ctladdr, e)
(void) strcat(bp, mci->mci_host);
# ifdef DAEMON
- (void) strcat(bp, " (");
+ (void) strcat(bp, " [");
(void) strcat(bp, anynet_ntoa(&CurHostAddr));
- (void) strcat(bp, ")");
+ (void) strcat(bp, "]");
# endif
}
else
@@ -1876,7 +1906,7 @@ logdelivery(m, mci, stat, ctladdr, e)
# else /* we have a very short log buffer size */
- l = SYSLOG_BUFSIZE - 80;
+ l = SYSLOG_BUFSIZE - 85;
p = e->e_to;
while (strlen(p) >= l)
{
@@ -1914,19 +1944,21 @@ logdelivery(m, mci, stat, ctladdr, e)
sprintf(bp, ", mailer=%s", m->m_name);
bp += strlen(bp);
}
+ syslog(LOG_INFO, "%s: %s", e->e_id, buf);
+ buf[0] = '\0';
if (mci != NULL && mci->mci_host != NULL)
{
# ifdef DAEMON
extern SOCKADDR CurHostAddr;
# endif
- sprintf(bp, ", relay=%s", mci->mci_host);
+ sprintf(buf, "relay=%s", mci->mci_host);
# ifdef DAEMON
- (void) strcat(bp, " (");
- (void) strcat(bp, anynet_ntoa(&CurHostAddr));
- (void) strcat(bp, ")");
+ (void) strcat(buf, " [");
+ (void) strcat(buf, anynet_ntoa(&CurHostAddr));
+ (void) strcat(buf, "]");
# endif
}
else
@@ -1934,9 +1966,10 @@ logdelivery(m, mci, stat, ctladdr, e)
char *p = macvalue('h', e);
if (p != NULL && p[0] != '\0')
- sprintf(bp, ", relay=%s", p);
+ sprintf(buf, "relay=%s", p);
}
- syslog(LOG_INFO, "%s: %s", e->e_id, buf);
+ if (buf[0] != '\0')
+ syslog(LOG_INFO, "%s: %s", e->e_id, buf);
syslog(LOG_INFO, "%s: stat=%s", e->e_id, shortenstring(stat, 63));
# endif /* short log buffer */
@@ -1953,8 +1986,8 @@ logdelivery(m, mci, stat, ctladdr, e)
** this kind of antique garbage????
**
** Parameters:
-** fp -- the file to output to.
-** m -- the mailer describing this entry.
+** mci -- the connection information.
+** e -- the envelope.
**
** Returns:
** none
@@ -1963,19 +1996,18 @@ logdelivery(m, mci, stat, ctladdr, e)
** outputs some text to fp.
*/
-putfromline(fp, m, e)
- register FILE *fp;
- register MAILER *m;
+putfromline(mci, e)
+ register MCI *mci;
ENVELOPE *e;
{
char *template = "\201l\n";
char buf[MAXLINE];
- if (bitnset(M_NHDR, m->m_flags))
+ if (bitnset(M_NHDR, mci->mci_mailer->m_flags))
return;
# ifdef UGLYUUCP
- if (bitnset(M_UGLYUUCP, m->m_flags))
+ if (bitnset(M_UGLYUUCP, mci->mci_mailer->m_flags))
{
char *bang;
char xbuf[MAXLINE];
@@ -1996,14 +2028,13 @@ putfromline(fp, m, e)
}
# endif /* UGLYUUCP */
expand(template, buf, &buf[sizeof buf - 1], e);
- putline(buf, fp, m);
+ putline(buf, mci);
}
/*
** PUTBODY -- put the body of a message.
**
** Parameters:
-** fp -- file to output onto.
-** m -- a mailer descriptor to control output format.
+** mci -- the connection information.
** e -- the envelope to put out.
** separator -- if non-NULL, a message separator that must
** not be permitted in the resulting message.
@@ -2015,9 +2046,8 @@ putfromline(fp, m, e)
** The message is written onto fp.
*/
-putbody(fp, m, e, separator)
- FILE *fp;
- MAILER *m;
+putbody(mci, e, separator)
+ register MCI *mci;
register ENVELOPE *e;
char *separator;
{
@@ -2037,25 +2067,26 @@ putbody(fp, m, e, separator)
e->e_df, e->e_to, e->e_from.q_paddr);
}
else
- putline("<<< No Message Collected >>>", fp, m);
+ putline("<<< No Message Collected >>>", mci);
}
if (e->e_dfp != NULL)
{
rewind(e->e_dfp);
- while (!ferror(fp) && fgets(buf, sizeof buf, e->e_dfp) != NULL)
+ while (!ferror(mci->mci_out) && fgets(buf, sizeof buf, e->e_dfp) != NULL)
{
- if (buf[0] == 'F' && bitnset(M_ESCFROM, m->m_flags) &&
+ if (buf[0] == 'F' &&
+ bitnset(M_ESCFROM, mci->mci_mailer->m_flags) &&
strncmp(buf, "From ", 5) == 0)
- (void) putc('>', fp);
+ (void) putc('>', mci->mci_out);
if (buf[0] == '-' && buf[1] == '-' && separator != NULL)
{
/* possible separator */
int sl = strlen(separator);
if (strncmp(&buf[2], separator, sl) == 0)
- (void) putc(' ', fp);
+ (void) putc(' ', mci->mci_out);
}
- putline(buf, fp, m);
+ putline(buf, mci);
}
if (ferror(e->e_dfp))
@@ -2066,11 +2097,12 @@ putbody(fp, m, e, separator)
}
/* some mailers want extra blank line at end of message */
- if (bitnset(M_BLANKEND, m->m_flags) && buf[0] != '\0' && buf[0] != '\n')
- putline("", fp, m);
+ if (bitnset(M_BLANKEND, mci->mci_mailer->m_flags) &&
+ buf[0] != '\0' && buf[0] != '\n')
+ putline("", mci);
- (void) fflush(fp);
- if (ferror(fp) && errno != EPIPE)
+ (void) fflush(mci->mci_out);
+ if (ferror(mci->mci_out) && errno != EPIPE)
{
syserr("putbody: write error");
ExitStat = EX_IOERR;
@@ -2135,6 +2167,7 @@ mailfile(filename, ctladdr, e)
{
/* child -- actually write to file */
struct stat stb;
+ MCI mcibuf;
(void) setsignal(SIGINT, SIG_DFL);
(void) setsignal(SIGHUP, SIG_DFL);
@@ -2197,11 +2230,17 @@ mailfile(filename, ctladdr, e)
exit(EX_CANTCREAT);
}
- putfromline(f, FileMailer, e);
- (*e->e_puthdr)(f, FileMailer, e);
- putline("\n", f, FileMailer);
- (*e->e_putbody)(f, FileMailer, e, NULL);
- putline("\n", f, FileMailer);
+ bzero(&mcibuf, sizeof mcibuf);
+ mcibuf.mci_mailer = FileMailer;
+ mcibuf.mci_out = f;
+ if (bitnset(M_7BITS, FileMailer->m_flags))
+ mcibuf.mci_flags |= MCIF_7BIT;
+
+ putfromline(&mcibuf, e);
+ (*e->e_puthdr)(&mcibuf, e);
+ putline("\n", &mcibuf);
+ (*e->e_putbody)(&mcibuf, e, NULL);
+ putline("\n", &mcibuf);
if (ferror(f))
{
message("451 I/O error: %s", errstring(errno));
@@ -2260,7 +2299,7 @@ hostsignature(m, host, e)
register STAB *s;
int i;
int len;
-#ifdef NAMED_BIND
+#if NAMED_BIND
int nmx;
auto int rcode;
char *hp;
@@ -2292,7 +2331,7 @@ hostsignature(m, host, e)
** Not already there -- create a signature.
*/
-#ifdef NAMED_BIND
+#if NAMED_BIND
if (ConfigLevel < 2)
{
oldoptions = _res.options;
@@ -2315,7 +2354,7 @@ hostsignature(m, host, e)
mci = mci_get(hp, m);
mci->mci_exitstat = rcode;
mci->mci_errno = errno;
-#ifdef NAMED_BIND
+#if NAMED_BIND
mci->mci_herrno = h_errno;
#endif
diff --git a/usr.sbin/sendmail/src/domain.c b/usr.sbin/sendmail/src/domain.c
index ab2f7ff5c4d..48109fef977 100644
--- a/usr.sbin/sendmail/src/domain.c
+++ b/usr.sbin/sendmail/src/domain.c
@@ -35,14 +35,14 @@
#include "sendmail.h"
#ifndef lint
-#ifdef NAMED_BIND
-static char sccsid[] = "@(#)domain.c 8.10 (Berkeley) 12/21/93 (with name server)";
+#if NAMED_BIND
+static char sccsid[] = "@(#)domain.c 8.19 (Berkeley) 3/11/94 (with name server)";
#else
-static char sccsid[] = "@(#)domain.c 8.10 (Berkeley) 12/21/93 (without name server)";
+static char sccsid[] = "@(#)domain.c 8.19 (Berkeley) 3/11/94 (without name server)";
#endif
#endif /* not lint */
-#ifdef NAMED_BIND
+#if NAMED_BIND
#include <errno.h>
#include <arpa/nameser.h>
@@ -69,6 +69,10 @@ static char MXHostBuf[MAXMXHOSTS*PACKETSZ];
# define NO_DATA NO_ADDRESS
#endif
+#ifndef HEADERSZ
+# define HEADERSZ sizeof(HEADER)
+#endif
+
/* don't use sizeof because sizeof(long) is different on 64-bit machines */
#define SHORTSIZE 2 /* size of a short (really, must be 2) */
#define LONGSIZE 4 /* size of a long (really, must be 4) */
@@ -116,6 +120,9 @@ getmxrr(host, mxhosts, droplocalhost, rcode)
int weight[MAXMXHOSTS];
extern bool getcanonname();
+ if (tTd(8, 2))
+ printf("getmxrr(%s, droplocalhost=%d)\n", host, droplocalhost);
+
if (fallbackMX != NULL)
{
if (firsttime && res_query(FallBackMX, C_IN, T_A,
@@ -156,6 +163,10 @@ getmxrr(host, mxhosts, droplocalhost, rcode)
goto punt;
case HOST_NOT_FOUND:
+#ifdef BROKEN_RES_SEARCH
+ /* Ultrix resolver returns failure w/ h_errno=0 */
+ case 0:
+#endif
/* the host just doesn't exist */
*rcode = EX_NOHOST;
@@ -174,6 +185,12 @@ getmxrr(host, mxhosts, droplocalhost, rcode)
/* it might come up later; better queue it up */
*rcode = EX_TEMPFAIL;
break;
+
+ default:
+ syserr("getmxrr: res_search (%s) failed with impossible h_errno (%d)\n",
+ host, h_errno);
+ *rcode = EX_OSERR;
+ break;
}
/* irreconcilable differences */
@@ -182,7 +199,7 @@ getmxrr(host, mxhosts, droplocalhost, rcode)
/* find first satisfactory answer */
hp = (HEADER *)&answer;
- cp = (u_char *)&answer + sizeof(HEADER);
+ cp = (u_char *)&answer + HEADERSZ;
eom = (u_char *)&answer + n;
for (qdcount = ntohs(hp->qdcount); qdcount--; cp += n + QFIXEDSZ)
if ((n = dn_skipname(cp, eom)) < 0)
@@ -216,6 +233,9 @@ getmxrr(host, mxhosts, droplocalhost, rcode)
(st = stab(bp, ST_CLASS, ST_FIND)) != NULL &&
bitnset('w', st->s_class))
{
+ if (tTd(8, 3))
+ printf("found localhost (%s) in MX list, pref=%d\n",
+ bp, pref);
if (!seenlocal || pref < localpref)
localpref = pref;
seenlocal = TRUE;
@@ -283,6 +303,8 @@ punt:
*/
*rcode = EX_CONFIG;
+ syserr("MX list for %s points back to %s",
+ host, MyHostName);
return -1;
}
strcpy(MXHostBuf, host);
@@ -365,7 +387,7 @@ mxrand(host)
if (isascii(c) && isupper(c))
c = tolower(c);
- hfunc = ((hfunc << 1) + c) % 2003;
+ hfunc = ((hfunc << 1) ^ c) % 2003;
}
hfunc &= 0xff;
@@ -478,6 +500,10 @@ cnameloop:
{
*dp++ = _res.defdname;
}
+ else if (*cp == '.')
+ {
+ *cp = '\0';
+ }
*dp = NULL;
/*
@@ -546,7 +572,7 @@ cnameloop:
*/
hp = (HEADER *) &answer;
- ap = (u_char *) &answer + sizeof(HEADER);
+ ap = (u_char *) &answer + HEADERSZ;
eom = (u_char *) &answer + ret;
/* skip question part of response -- we know what we asked */
@@ -597,9 +623,19 @@ cnameloop:
case T_CNAME:
if (loopcnt++ > MAXCNAMEDEPTH)
{
- syserr("DNS failure: CNAME loop for %s",
+ /*XXX should notify postmaster XXX*/
+ message("DNS failure: CNAME loop for %s",
host);
- continue;
+ if (CurEnv->e_message == NULL)
+ {
+ char ebuf[MAXLINE];
+
+ sprintf(ebuf, "Deferred: DNS failure: CNAME loop for %s",
+ host);
+ CurEnv->e_message = newstr(ebuf);
+ }
+ h_errno = NO_RECOVERY;
+ return FALSE;
}
/* value points at name */
diff --git a/usr.sbin/sendmail/src/envelope.c b/usr.sbin/sendmail/src/envelope.c
index 3048ac3dc3a..14656f0d7ee 100644
--- a/usr.sbin/sendmail/src/envelope.c
+++ b/usr.sbin/sendmail/src/envelope.c
@@ -33,11 +33,10 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)envelope.c 8.28 (Berkeley) 1/9/94";
+static char sccsid[] = "@(#)envelope.c 8.33 (Berkeley) 2/10/94";
#endif /* not lint */
#include "sendmail.h"
-#include <sys/time.h>
#include <pwd.h>
/*
@@ -585,7 +584,7 @@ setsender(from, e, delimptr, internal)
*/
if (bitset(EF_QUEUERUN, e->e_flags) || OpMode == MD_SMTP ||
- OpMode == MD_DAEMON)
+ OpMode == MD_ARPAFTP || OpMode == MD_DAEMON)
realname = from;
if (realname == NULL || realname[0] == '\0')
realname = username();
@@ -694,9 +693,11 @@ setsender(from, e, delimptr, internal)
** Process passwd file entry.
*/
-
/* extract home directory */
- e->e_from.q_home = newstr(pw->pw_dir);
+ if (strcmp(pw->pw_dir, "/") == 0)
+ e->e_from.q_home = newstr("");
+ else
+ e->e_from.q_home = newstr(pw->pw_dir);
define('z', e->e_from.q_home, e);
/* extract user and group id */
@@ -720,7 +721,12 @@ setsender(from, e, delimptr, internal)
else if (!internal && OpMode != MD_DAEMON)
{
if (e->e_from.q_home == NULL)
+ {
e->e_from.q_home = getenv("HOME");
+ if (e->e_from.q_home != NULL &&
+ strcmp(e->e_from.q_home, "/") == 0)
+ e->e_from.q_home++;
+ }
e->e_from.q_uid = RealUid;
e->e_from.q_gid = RealGid;
e->e_from.q_flags |= QGOODUID;
diff --git a/usr.sbin/sendmail/src/err.c b/usr.sbin/sendmail/src/err.c
index 60e78e3b7c5..fee36c4b42a 100644
--- a/usr.sbin/sendmail/src/err.c
+++ b/usr.sbin/sendmail/src/err.c
@@ -33,12 +33,13 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)err.c 8.19 (Berkeley) 1/8/94";
+static char sccsid[] = "@(#)err.c 8.26 (Berkeley) 3/11/94";
#endif /* not lint */
# include "sendmail.h"
# include <errno.h>
# include <netdb.h>
+# include <pwd.h>
/*
** SYSERR -- Print error message.
@@ -68,7 +69,7 @@ char MsgBuf[BUFSIZ*2]; /* text of most recent message */
static void fmtmsg();
-#if defined(NAMED_BIND) && !defined(NO_DATA)
+#if NAMED_BIND && !defined(NO_DATA)
# define NO_DATA NO_ADDRESS
#endif
@@ -85,6 +86,11 @@ syserr(fmt, va_alist)
register char *p;
int olderrno = errno;
bool panic;
+#ifdef LOG
+ char *uname;
+ struct passwd *pw;
+ char ubuf[80];
+#endif
VA_LOCAL_DECL
panic = *fmt == '!';
@@ -108,13 +114,24 @@ syserr(fmt, va_alist)
ExitStat = EX_SOFTWARE;
else
ExitStat = EX_OSERR;
+ if (tTd(54, 1))
+ printf("syserr: ExitStat = %d\n", ExitStat);
}
# ifdef LOG
+ pw = getpwuid(getuid());
+ if (pw != NULL)
+ uname = pw->pw_name;
+ else
+ {
+ uname = ubuf;
+ sprintf(ubuf, "UID%d", getuid());
+ }
+
if (LogLevel > 0)
- syslog(panic ? LOG_ALERT : LOG_CRIT, "%s: SYSERR: %s",
+ syslog(panic ? LOG_ALERT : LOG_CRIT, "%s: SYSERR(%s): %s",
CurEnv->e_id == NULL ? "NOQUEUE" : CurEnv->e_id,
- &MsgBuf[4]);
+ uname, &MsgBuf[4]);
# endif /* LOG */
if (olderrno == EMFILE)
{
@@ -285,7 +302,10 @@ putoutmsg(msg, holdmsg)
msg[0] = '5';
(void) fflush(stdout);
- if (OpMode == MD_SMTP || OpMode == MD_DAEMON)
+
+ /* if DisConnected, OutChannel now points to the transcript */
+ if (!DisConnected &&
+ (OpMode == MD_SMTP || OpMode == MD_DAEMON || OpMode == MD_ARPAFTP))
fprintf(OutChannel, "%s\r\n", msg);
else
fprintf(OutChannel, "%s\n", &msg[4]);
@@ -294,7 +314,7 @@ putoutmsg(msg, holdmsg)
(OpMode == MD_SMTP || OpMode == MD_DAEMON) ? msg : &msg[4]);
if (msg[3] == ' ')
(void) fflush(OutChannel);
- if (!ferror(OutChannel))
+ if (!ferror(OutChannel) || DisConnected)
return;
/*
@@ -404,7 +424,7 @@ fmtmsg(eb, to, num, eno, fmt, ap)
/* output the "to" person */
if (to != NULL && to[0] != '\0')
{
- (void) sprintf(eb, "%s... ", to);
+ (void) sprintf(eb, "%s... ", shortenstring(to, 203));
while (*eb != '\0')
*eb++ &= 0177;
}
@@ -434,18 +454,18 @@ fmtmsg(eb, to, num, eno, fmt, ap)
** ERRSTRING -- return string description of error code
**
** Parameters:
-** errno -- the error number to translate
+** errnum -- the error number to translate
**
** Returns:
-** A string description of errno.
+** A string description of errnum.
**
** Side Effects:
** none.
*/
const char *
-errstring(errno)
- int errno;
+errstring(errnum)
+ int errnum;
{
char *dnsmsg;
static char buf[MAXLINE];
@@ -464,12 +484,12 @@ errstring(errno)
*/
dnsmsg = NULL;
- switch (errno)
+ switch (errnum)
{
# if defined(DAEMON) && defined(ETIMEDOUT)
case ETIMEDOUT:
case ECONNRESET:
- (void) strcpy(buf, sys_errlist[errno]);
+ (void) strcpy(buf, sys_errlist[errnum]);
if (SmtpPhase != NULL)
{
(void) strcat(buf, " during ");
@@ -498,7 +518,7 @@ errstring(errno)
case EOPENTIMEOUT:
return "Timeout on file open";
-# ifdef NAMED_BIND
+# if NAMED_BIND
case HOST_NOT_FOUND + E_DNSBASE:
dnsmsg = "host not found";
break;
@@ -533,9 +553,9 @@ errstring(errno)
return buf;
}
- if (errno > 0 && errno < sys_nerr)
- return (sys_errlist[errno]);
+ if (errnum > 0 && errnum < sys_nerr)
+ return (sys_errlist[errnum]);
- (void) sprintf(buf, "Error %d", errno);
+ (void) sprintf(buf, "Error %d", errnum);
return (buf);
}
diff --git a/usr.sbin/sendmail/src/headers.c b/usr.sbin/sendmail/src/headers.c
index b05876bf20e..0d80b884b10 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.22 (Berkeley) 1/13/94";
+static char sccsid[] = "@(#)headers.c 8.30 (Berkeley) 2/25/94";
#endif /* not lint */
# include <errno.h>
@@ -163,6 +163,7 @@ chompheader(line, def, e)
{
auto ADDRESS a;
char *fancy;
+ bool oldSuprErrs = SuprErrs;
extern char *crackaddr();
extern char *udbsender();
@@ -170,8 +171,16 @@ chompheader(line, def, e)
** Try doing USERDB rewriting even on fully commented
** names; this saves the "comment" information (such
** as full name) and rewrites the electronic part.
+ **
+ ** XXX This code doesn't belong here -- parsing should
+ ** XXX not be done during collect() phase because
+ ** XXX error messages can confuse the SMTP phase.
+ ** XXX Setting SuprErrs is a crude hack around this
+ ** XXX problem.
*/
+ if (OpMode == MD_SMTP || OpMode == MD_ARPAFTP)
+ SuprErrs = TRUE;
fancy = crackaddr(fvalue);
if (parseaddr(fvalue, &a, RF_COPYNONE, '\0', NULL, e) != NULL &&
a.q_mailer == LocalMailer &&
@@ -184,6 +193,7 @@ chompheader(line, def, e)
define('g', oldg, e);
fvalue = buf;
}
+ SuprErrs = oldSuprErrs;
}
#endif
#endif
@@ -470,6 +480,32 @@ eatheader(e, full)
define('a', p, e);
/*
+ ** From person in antiquated ARPANET mode
+ ** required by UK Grey Book e-mail gateways (sigh)
+ */
+
+ if (OpMode == MD_ARPAFTP)
+ {
+ register struct hdrinfo *hi;
+
+ for (hi = HdrInfo; hi->hi_field != NULL; hi++)
+ {
+ if (bitset(H_FROM, hi->hi_flags) &&
+ (!bitset(H_RESENT, hi->hi_flags) ||
+ bitset(EF_RESENT, e->e_flags)) &&
+ (p = hvalue(hi->hi_field, e)) != NULL)
+ break;
+ }
+ if (hi->hi_field != NULL)
+ {
+ if (tTd(32, 2))
+ printf("eatheader: setsender(*%s == %s)\n",
+ hi->hi_field, p);
+ setsender(p, e, NULL, TRUE);
+ }
+ }
+
+ /*
** Log collection information.
*/
@@ -504,6 +540,8 @@ logsender(e, msgid)
name = "[RESPONSE]";
else if ((name = macvalue('_', e)) != NULL)
;
+ else if (RealHostName == NULL)
+ name = "localhost";
else if (RealHostName[0] == '[')
name = RealHostName;
else
@@ -860,8 +898,7 @@ crackaddr(addr)
** PUTHEADER -- put the header part of a message from the in-core copy
**
** Parameters:
-** fp -- file to put it on.
-** m -- mailer to use.
+** mci -- the connection information.
** e -- envelope to use.
**
** Returns:
@@ -878,9 +915,8 @@ crackaddr(addr)
# define MAX(a,b) (((a)>(b))?(a):(b))
#endif
-putheader(fp, m, e)
- register FILE *fp;
- register MAILER *m;
+putheader(mci, e)
+ register MCI *mci;
register ENVELOPE *e;
{
char buf[MAX(MAXLINE,BUFSIZ)];
@@ -888,7 +924,8 @@ putheader(fp, m, e)
char obuf[MAXLINE];
if (tTd(34, 1))
- printf("--- putheader, mailer = %s ---\n", m->m_name);
+ printf("--- putheader, mailer = %s ---\n",
+ mci->mci_mailer->m_name);
for (h = e->e_header; h != NULL; h = h->h_link)
{
@@ -902,7 +939,7 @@ putheader(fp, m, e)
}
if (bitset(H_CHECK|H_ACHECK, h->h_flags) &&
- !bitintersect(h->h_mflags, m->m_flags))
+ !bitintersect(h->h_mflags, mci->mci_mailer->m_flags))
{
if (tTd(34, 11))
printf(" (skipped)\n");
@@ -941,7 +978,7 @@ putheader(fp, m, e)
if (bitset(H_FROM, h->h_flags))
oldstyle = FALSE;
- commaize(h, p, fp, oldstyle, m, e);
+ commaize(h, p, oldstyle, mci, e);
}
else
{
@@ -954,12 +991,12 @@ putheader(fp, m, e)
*nlp = '\0';
(void) strcat(obuf, p);
*nlp = '\n';
- putline(obuf, fp, m);
+ putline(obuf, mci);
p = ++nlp;
obuf[0] = '\0';
}
(void) strcat(obuf, p);
- putline(obuf, fp, m);
+ putline(obuf, mci);
}
}
}
@@ -969,10 +1006,8 @@ putheader(fp, m, e)
** Parameters:
** h -- the header field to output.
** p -- the value to put in it.
-** fp -- file to put it to.
** oldstyle -- TRUE if this is an old style header.
-** m -- a pointer to the mailer descriptor. If NULL,
-** don't transform the name at all.
+** mci -- the connection information.
** e -- the envelope containing the message.
**
** Returns:
@@ -982,16 +1017,17 @@ putheader(fp, m, e)
** outputs "p" to file "fp".
*/
-commaize(h, p, fp, oldstyle, m, e)
+void
+commaize(h, p, oldstyle, mci, e)
register HDR *h;
register char *p;
- FILE *fp;
bool oldstyle;
- register MAILER *m;
+ register MCI *mci;
register ENVELOPE *e;
{
register char *obp;
int opos;
+ int omax;
bool firstone = TRUE;
char obuf[MAXLINE + 3];
@@ -1007,6 +1043,9 @@ commaize(h, p, fp, oldstyle, m, e)
(void) sprintf(obp, "%s: ", h->h_field);
opos = strlen(h->h_field) + 2;
obp += opos;
+ omax = mci->mci_mailer->m_linelimit - 2;
+ if (omax < 0 || omax > 78)
+ omax = 78;
/*
** Run through the list of values.
@@ -1070,7 +1109,7 @@ commaize(h, p, fp, oldstyle, m, e)
if (bitset(H_FROM, h->h_flags))
flags |= RF_SENDERADDR;
stat = EX_OK;
- name = remotename(name, m, flags, &stat, e);
+ name = remotename(name, mci->mci_mailer, flags, &stat, e);
if (*name == '\0')
{
*p = savechar;
@@ -1081,19 +1120,19 @@ commaize(h, p, fp, oldstyle, m, e)
opos += strlen(name);
if (!firstone)
opos += 2;
- if (opos > 78 && !firstone)
+ if (opos > omax && !firstone)
{
(void) strcpy(obp, ",\n");
- putline(obuf, fp, m);
+ putline(obuf, mci);
obp = obuf;
- (void) sprintf(obp, " ");
+ (void) strcpy(obp, " ");
opos = strlen(obp);
obp += opos;
opos += strlen(name);
}
else if (!firstone)
{
- (void) sprintf(obp, ", ");
+ (void) strcpy(obp, ", ");
obp += 2;
}
@@ -1103,7 +1142,7 @@ commaize(h, p, fp, oldstyle, m, e)
*p = savechar;
}
(void) strcpy(obp, "\n");
- putline(obuf, fp, m);
+ putline(obuf, mci);
}
/*
** COPYHEADER -- copy header list
diff --git a/usr.sbin/sendmail/src/macro.c b/usr.sbin/sendmail/src/macro.c
index 8beb5a7e375..8a8a90b4f0f 100644
--- a/usr.sbin/sendmail/src/macro.c
+++ b/usr.sbin/sendmail/src/macro.c
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)macro.c 8.2 (Berkeley) 7/29/93";
+static char sccsid[] = "@(#)macro.c 8.3 (Berkeley) 2/7/94";
#endif /* not lint */
# include "sendmail.h"
@@ -115,8 +115,14 @@ expand(s, buf, buflim, e)
continue;
case MACROEXPAND: /* macro interpolation */
- c = *++s;
- q = macvalue(c & 0177, e);
+ c = *++s & 0177;
+ if (c != '\0')
+ q = macvalue(c, e);
+ else
+ {
+ s--;
+ q = NULL;
+ }
if (q == NULL)
continue;
break;
diff --git a/usr.sbin/sendmail/src/main.c b/usr.sbin/sendmail/src/main.c
index d05f13da46c..cdd97c34a9a 100644
--- a/usr.sbin/sendmail/src/main.c
+++ b/usr.sbin/sendmail/src/main.c
@@ -39,14 +39,13 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)main.c 8.46 (Berkeley) 1/9/94";
+static char sccsid[] = "@(#)main.c 8.52 (Berkeley) 3/11/94";
#endif /* not lint */
#define _DEFINE
#include "sendmail.h"
-#include <sgtty.h>
-#ifdef NAMED_BIND
+#if NAMED_BIND
#include <arpa/nameser.h>
#include <resolv.h>
#endif
@@ -321,7 +320,7 @@ main(argc, argv, envp)
OpMode = MD_DELIVER;
FullName = getenv("NAME");
-#ifdef NAMED_BIND
+#if NAMED_BIND
if (tTd(8, 8))
_res.options |= RES_DEBUG;
#endif
@@ -443,6 +442,9 @@ main(argc, argv, envp)
case MD_TEST:
case MD_INITALIAS:
case MD_PRINT:
+#ifdef MAYBE_NEXT_RELEASE
+ case MD_ARPAFTP:
+#endif
OpMode = j;
break;
@@ -708,13 +710,6 @@ main(argc, argv, envp)
/* remove things that don't make sense in daemon mode */
FullName = NULL;
break;
-
- case MD_SMTP:
- if (RealUid != 0)
- auth_warning(CurEnv,
- "%s owned process doing -bs",
- RealUserName);
- break;
}
/* do heuristic mode adjustment */
@@ -1297,6 +1292,7 @@ disconnect(droplev, e)
HoldErrs = TRUE;
CurEnv->e_errormode = EM_MAIL;
Verbose = FALSE;
+ DisConnected = TRUE;
/* all input from /dev/null */
if (InChannel != stdin)
@@ -1360,7 +1356,7 @@ obsolete(argv)
/* skip over options that do have a value */
op = strchr(OPTIONS, ap[1]);
if (op != NULL && *++op == ':' && ap[2] == '\0' &&
- argv[1] != NULL && argv[1][0] != '-')
+ ap[1] != 'd' && argv[1] != NULL && argv[1][0] != '-')
{
argv++;
continue;
diff --git a/usr.sbin/sendmail/src/map.c b/usr.sbin/sendmail/src/map.c
index 7a3bdc0c002..7444cdab737 100644
--- a/usr.sbin/sendmail/src/map.c
+++ b/usr.sbin/sendmail/src/map.c
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)map.c 8.20 (Berkeley) 12/11/93";
+static char sccsid[] = "@(#)map.c 8.22 (Berkeley) 2/18/94";
#endif /* not lint */
#include "sendmail.h"
@@ -638,7 +638,7 @@ bt_map_open(map, mode)
if (omode == O_RDWR)
{
omode |= O_CREAT|O_TRUNC;
-#if defined(O_EXLOCK) && defined(HASFLOCK)
+#if defined(O_EXLOCK) && HASFLOCK
omode |= O_EXLOCK;
# if !defined(OLD_NEWDB)
}
@@ -664,7 +664,7 @@ bt_map_open(map, mode)
syserr("Cannot open BTREE database %s", map->map_file);
return FALSE;
}
-#if !defined(OLD_NEWDB) && defined(HASFLOCK)
+#if !defined(OLD_NEWDB) && HASFLOCK
fd = db->fd(db);
# if !defined(O_EXLOCK)
if (mode == O_RDWR && fd >= 0)
@@ -722,7 +722,7 @@ hash_map_open(map, mode)
if (omode == O_RDWR)
{
omode |= O_CREAT|O_TRUNC;
-#if defined(O_EXLOCK) && defined(HASFLOCK)
+#if defined(O_EXLOCK) && HASFLOCK
omode |= O_EXLOCK;
# if !defined(OLD_NEWDB)
}
@@ -748,7 +748,7 @@ hash_map_open(map, mode)
syserr("Cannot open HASH database %s", map->map_file);
return FALSE;
}
-#if !defined(OLD_NEWDB) && defined(HASFLOCK)
+#if !defined(OLD_NEWDB) && HASFLOCK
fd = db->fd(db);
# if !defined(O_EXLOCK)
if (mode == O_RDWR && fd >= 0)
@@ -965,12 +965,20 @@ nis_map_open(map, mode)
map->map_domain = p;
}
- if (map->map_domain == NULL)
- yp_get_default_domain(&map->map_domain);
-
if (*map->map_file == '\0')
map->map_file = "mail.aliases";
+ if (map->map_domain == NULL)
+ {
+ yperr = yp_get_default_domain(&map->map_domain);
+ if (yperr != 0)
+ {
+ syserr("NIS map %s specified, but NIS not running\n",
+ map->map_file);
+ return FALSE;
+ }
+ }
+
/* check to see if this map actually exists */
yperr = yp_match(map->map_domain, map->map_file, "@", 1,
&vp, &vsize);
diff --git a/usr.sbin/sendmail/src/mci.c b/usr.sbin/sendmail/src/mci.c
index 68a98dd3a67..978b8c3cdbc 100644
--- a/usr.sbin/sendmail/src/mci.c
+++ b/usr.sbin/sendmail/src/mci.c
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)mci.c 8.9 (Berkeley) 12/1/93";
+static char sccsid[] = "@(#)mci.c 8.12 (Berkeley) 2/9/94";
#endif /* not lint */
#include "sendmail.h"
@@ -275,6 +275,9 @@ mci_get(host, m)
bzero(&CurHostAddr, sizeof CurHostAddr);
#endif
+ /* clear out any expired connections */
+ mci_scan(NULL);
+
if (m->m_mno < 0)
syserr("negative mno %d (%s)", m->m_mno, m->m_name);
s = stab(host, ST_MCI + m->m_mno, ST_ENTER);
@@ -300,6 +303,21 @@ mci_get(host, m)
mci->mci_exitstat = EX_OK;
mci->mci_state = MCIS_CLOSED;
}
+ else
+ {
+ /* get peer host address for logging reasons only */
+ /* (this should really be in the mci struct) */
+ int socksize = sizeof CurHostAddr;
+
+ (void) getpeername(fileno(mci->mci_in),
+ (struct sockaddr *) &CurHostAddr, &socksize);
+ }
+ }
+ if (mci->mci_state == MCIS_CLOSED)
+ {
+ /* copy out any mailer flags needed in connection state */
+ if (bitnset(M_7BITS, m->m_flags))
+ mci->mci_flags |= MCIF_7BIT;
}
return mci;
diff --git a/usr.sbin/sendmail/src/newaliases.1 b/usr.sbin/sendmail/src/newaliases.1
index 65cfc5f38e3..c611b78b62b 100644
--- a/usr.sbin/sendmail/src/newaliases.1
+++ b/usr.sbin/sendmail/src/newaliases.1
@@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)newaliases.1 8.1 (Berkeley) 6/7/93
+.\" @(#)newaliases.1 8.4 (Berkeley) 2/22/94
.\"
-.Dd June 7, 1993
+.Dd February 22, 1994
.Dt NEWALIASES 1
.Os BSD 4
.Sh NAME
@@ -43,12 +43,23 @@
.Nm Newaliases
rebuilds the random access data base for the mail aliases file
.Pa /etc/aliases .
-It must be run each time
-.Pa /etc/aliases
-is changed in order
+It must be run each time this file is changed in order
for the change to take effect.
+.Pp
+.Nm Newaliases
+is identical to
+.Dq Li "sendmail -bi" .
+.Pp
+The
+.Nm newaliases
+utility exits 0 on success, and >0 if an error occurs.
+.Sh FILES
+.Bl -tag -width /etc/aliases -compact
+.It Pa /etc/aliases
+The mail aliases file
+.El
.Sh SEE ALSO
-.\" .Xr aliases 5 ,
+.Xr aliases 5 ,
.Xr sendmail 8
.Sh HISTORY
The
diff --git a/usr.sbin/sendmail/src/parseaddr.c b/usr.sbin/sendmail/src/parseaddr.c
index 13274dab7c6..800a1372cdc 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.29 (Berkeley) 1/5/94";
+static char sccsid[] = "@(#)parseaddr.c 8.30 (Berkeley) 2/9/94";
#endif /* not lint */
# include "sendmail.h"
@@ -1331,7 +1331,7 @@ badaddr:
}
else
{
- usrerr("%s", buf);
+ usrerr("553 %s", buf);
}
goto badaddr;
}
diff --git a/usr.sbin/sendmail/src/queue.c b/usr.sbin/sendmail/src/queue.c
index e2cad4cf51d..99e851efad7 100644
--- a/usr.sbin/sendmail/src/queue.c
+++ b/usr.sbin/sendmail/src/queue.c
@@ -36,9 +36,9 @@
#ifndef lint
#ifdef QUEUE
-static char sccsid[] = "@(#)queue.c 8.36 (Berkeley) 1/9/94 (with queueing)";
+static char sccsid[] = "@(#)queue.c 8.40 (Berkeley) 3/6/94 (with queueing)";
#else
-static char sccsid[] = "@(#)queue.c 8.36 (Berkeley) 1/9/94 (without queueing)";
+static char sccsid[] = "@(#)queue.c 8.40 (Berkeley) 3/6/94 (without queueing)";
#endif
#endif /* not lint */
@@ -94,6 +94,7 @@ queueup(e, queueall, announce)
bool newid;
register char *p;
MAILER nullmailer;
+ MCI mcibuf;
char buf[MAXLINE], tf[MAXLINE];
/*
@@ -182,7 +183,10 @@ queueup(e, queueall, announce)
if (fd < 0 || (dfp = fdopen(fd, "w")) == NULL)
syserr("!queueup: cannot create data temp file %s, uid=%d",
e->e_df, geteuid());
- (*e->e_putbody)(dfp, FileMailer, e, NULL);
+ bzero(&mcibuf, sizeof mcibuf);
+ mcibuf.mci_out = dfp;
+ mcibuf.mci_mailer = FileMailer;
+ (*e->e_putbody)(&mcibuf, e, NULL);
(void) xfclose(dfp, "queueup dfp", e->e_id);
e->e_putbody = putbody;
}
@@ -278,6 +282,9 @@ queueup(e, queueall, announce)
nullmailer.m_re_rwset = nullmailer.m_rh_rwset =
nullmailer.m_se_rwset = nullmailer.m_sh_rwset = -1;
nullmailer.m_eol = "\n";
+ bzero(&mcibuf, sizeof mcibuf);
+ mcibuf.mci_mailer = &nullmailer;
+ mcibuf.mci_out = tfp;
define('g', "\201f", e);
for (h = e->e_header; h != NULL; h = h->h_link)
@@ -330,8 +337,7 @@ queueup(e, queueall, announce)
if (bitset(H_FROM, h->h_flags))
oldstyle = FALSE;
- commaize(h, h->h_value, tfp, oldstyle,
- &nullmailer, e);
+ commaize(h, h->h_value, oldstyle, &mcibuf, e);
TrafficLogFile = savetrace;
}
@@ -565,7 +571,8 @@ runqueue(forkflag)
pid = dowork(w->w_name + 2, ForkQueueRuns, FALSE, e);
errno = 0;
- (void) waitfor(pid);
+ if (pid != 0)
+ (void) waitfor(pid);
}
free(w->w_name);
free((char *) w);
@@ -891,6 +898,7 @@ dowork(id, forkflag, requeueflag, e)
e->e_errormode = EM_MAIL;
e->e_id = id;
GrabTo = UseErrorsTo = FALSE;
+ ExitStat = EX_OK;
if (forkflag)
{
disconnect(1, e);
@@ -913,7 +921,7 @@ dowork(id, forkflag, requeueflag, e)
if (forkflag)
exit(EX_OK);
else
- return;
+ return 0;
}
e->e_flags |= EF_INQUEUE;
@@ -1135,7 +1143,7 @@ readqf(e)
break;
default:
- syserr("readqf: %s: line %s: bad line \"%s\"",
+ syserr("readqf: %s: line %d: bad line \"%s\"",
qf, LineNumber, bp);
fclose(qfp);
rename(qf, queuename(e, 'Q'));
@@ -1539,7 +1547,10 @@ setctluser(user)
*p++ = '\0';
if (*user != '\0' && (pw = getpwnam(user)) != NULL)
{
- a->q_home = newstr(pw->pw_dir);
+ if (strcmp(pw->pw_dir, "/") == 0)
+ a->q_home = "";
+ else
+ a->q_home = newstr(pw->pw_dir);
a->q_uid = pw->pw_uid;
a->q_gid = pw->pw_gid;
a->q_user = newstr(user);
diff --git a/usr.sbin/sendmail/src/readcf.c b/usr.sbin/sendmail/src/readcf.c
index 0d8d6fddf3a..4c6be01b090 100644
--- a/usr.sbin/sendmail/src/readcf.c
+++ b/usr.sbin/sendmail/src/readcf.c
@@ -33,13 +33,13 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)readcf.c 8.18 (Berkeley) 1/9/94";
+static char sccsid[] = "@(#)readcf.c 8.22 (Berkeley) 3/11/94";
#endif /* not lint */
# include "sendmail.h"
# include <pwd.h>
# include <grp.h>
-#ifdef NAMED_BIND
+#if NAMED_BIND
# include <arpa/nameser.h>
# include <resolv.h>
#endif
@@ -221,7 +221,7 @@ readcf(cfname, safe, e)
if (*p == '\0')
{
- syserr("invalid rewrite line \"%s\"", bp);
+ syserr("invalid rewrite line \"%s\" (tab expected)", bp);
break;
}
@@ -542,7 +542,7 @@ readcf(cfname, safe, e)
{
/* user didn't initialize: set up host map */
strcpy(buf, "host host");
-#ifdef NAMED_BIND
+#if NAMED_BIND
if (ConfigLevel >= 2)
strcat(buf, " -a.");
#endif
@@ -600,8 +600,19 @@ fileclass(class, filename, fmt, safe, optional)
struct stat stbuf;
char buf[MAXLINE];
+ if (tTd(37, 2))
+ printf("fileclass(%s, fmt=%s)\n", filename, fmt);
+
+ if (filename[0] == '|')
+ {
+ syserr("fileclass: pipes (F%c%s) not supported due to security problems",
+ class, filename);
+ return;
+ }
if (stat(filename, &stbuf) < 0)
{
+ if (tTd(37, 2))
+ printf(" cannot stat (%s)\n", errstring(errno));
if (!optional)
syserr("fileclass: cannot stat %s", filename);
return;
@@ -659,8 +670,7 @@ fileclass(class, filename, fmt, safe, optional)
*p++ = '\0';
/* enter the word in the symbol table */
- s = stab(q, ST_CLASS, ST_ENTER);
- setbitn(class, s->s_class);
+ setclass(class, q);
}
}
@@ -1007,7 +1017,7 @@ printrules()
static BITMAP StickyOpt; /* set if option is stuck */
-#ifdef NAMED_BIND
+#if NAMED_BIND
struct resolverflags
{
@@ -1216,7 +1226,7 @@ setoption(opt, val, safe, sticky, e)
break;
case 'I': /* use internet domain name server */
-#ifdef NAMED_BIND
+#if NAMED_BIND
UseNameServer = TRUE;
for (p = val; *p != 0; )
{
diff --git a/usr.sbin/sendmail/src/recipient.c b/usr.sbin/sendmail/src/recipient.c
index 706fddc82c4..c6c15c4b6c6 100644
--- a/usr.sbin/sendmail/src/recipient.c
+++ b/usr.sbin/sendmail/src/recipient.c
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)recipient.c 8.39 (Berkeley) 1/10/94";
+static char sccsid[] = "@(#)recipient.c 8.44 (Berkeley) 2/28/94";
#endif /* not lint */
# include "sendmail.h"
@@ -307,8 +307,9 @@ recipient(a, sendq, e)
{
#ifdef LOG
if (LogLevel > 2)
- syslog(LOG_ERR, "%s: include %s: transient error: %e",
- e->e_id, a->q_user, errstring(ret));
+ syslog(LOG_ERR, "%s: include %s: transient error: %s",
+ e->e_id == NULL ? "NOQUEUE" : e->e_id,
+ a->q_user, errstring(ret));
#endif
a->q_flags |= QQUEUEUP;
a->q_flags &= ~QDONTSEND;
@@ -376,7 +377,8 @@ recipient(a, sendq, e)
# ifdef LOG
if (LogLevel > 8)
syslog(LOG_INFO, "%s: deferred: udbexpand: %s",
- e->e_id, errstring(errno));
+ e->e_id == NULL ? "NOQUEUE" : e->e_id,
+ errstring(errno));
# endif
message("queued (user database error): %s",
errstring(errno));
@@ -447,7 +449,10 @@ recipient(a, sendq, e)
(void) strcpy(buf, pw->pw_name);
goto trylocaluser;
}
- a->q_home = newstr(pw->pw_dir);
+ if (strcmp(pw->pw_dir, "/") == 0)
+ a->q_home = "";
+ else
+ a->q_home = newstr(pw->pw_dir);
a->q_uid = pw->pw_uid;
a->q_gid = pw->pw_gid;
a->q_ruser = newstr(pw->pw_name);
@@ -719,6 +724,19 @@ writable(filename, ctladdr, flags)
** Side Effects:
** reads the :include: file and sends to everyone
** listed in that file.
+**
+** Security Note:
+** If you have restricted chown (that is, you can't
+** give a file away), it is reasonable to allow programs
+** and files called from this :include: file to be to be
+** run as the owner of the :include: file. This is bogus
+** if there is any chance of someone giving away a file.
+** We assume that pre-POSIX systems can give away files.
+**
+** There is an additional restriction that if you
+** forward to a :include: file, it will not take on
+** the ownership of the :include: file. This may not
+** be necessary, but shouldn't hurt.
*/
static jmp_buf CtxIncludeTimeout;
@@ -750,6 +768,24 @@ include(fname, forwarding, ctladdr, sendq, e)
int sfflags = forwarding ? SFF_MUSTOWN : SFF_ANYFILE;
struct stat st;
char buf[MAXLINE];
+#ifdef _POSIX_CHOWN_RESTRICTED
+# if _POSIX_CHOWN_RESTRICTED == -1
+# define safechown FALSE
+# else
+# define safechown TRUE
+# endif
+#else
+# ifdef _PC_CHOWN_RESTRICTED
+ bool safechown;
+# else
+# ifdef BSD
+# define safechown TRUE
+# else
+# define safechown FALSE
+# endif
+# endif
+#endif
+ extern bool chownsafe();
if (tTd(27, 2))
printf("include(%s)\n", fname);
@@ -858,7 +894,10 @@ resetuid:
return rval;
}
- if (ca == NULL)
+#ifndef safechown
+ safechown = chownsafe(fileno(fp));
+#endif
+ if (ca == NULL && safechown)
{
ctladdr->q_uid = st.st_uid;
ctladdr->q_gid = st.st_gid;
@@ -872,13 +911,25 @@ resetuid:
}
else
{
+ char *sh;
register struct passwd *pw;
+ sh = "/SENDMAIL/ANY/SHELL/";
pw = getpwuid(st.st_uid);
- if (pw == NULL || !usershellok(pw->pw_shell))
+ if (pw != NULL)
{
ctladdr->q_ruser = newstr(pw->pw_name);
+ if (safechown)
+ sh = pw->pw_shell;
+ }
+ if (pw == NULL)
ctladdr->q_flags |= QBOGUSSHELL;
+ else if(!usershellok(sh))
+ {
+ if (safechown)
+ ctladdr->q_flags |= QBOGUSSHELL;
+ else
+ ctladdr->q_flags |= QUNSAFEADDR;
}
}
@@ -924,7 +975,8 @@ resetuid:
#ifdef LOG
if (forwarding && LogLevel > 9)
syslog(LOG_INFO, "%s: forward %s => %s",
- e->e_id, oldto, buf);
+ e->e_id == NULL ? "NOQUEUE" : e->e_id,
+ oldto, buf);
#endif
AliasLevel++;
diff --git a/usr.sbin/sendmail/src/savemail.c b/usr.sbin/sendmail/src/savemail.c
index 2d09594b3c7..6467defcfdb 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.24 (Berkeley) 12/18/93";
+static char sccsid[] = "@(#)savemail.c 8.28 (Berkeley) 3/11/94";
#endif /* not lint */
# include "sendmail.h"
@@ -81,17 +81,19 @@ savemail(e)
register FILE *fp;
int state;
auto ADDRESS *q = NULL;
+ register char *p;
+ MCI mcibuf;
char buf[MAXLINE+1];
extern struct passwd *getpwnam();
- register char *p;
extern char *ttypath();
typedef int (*fnptr)();
extern bool writable();
if (tTd(6, 1))
{
- printf("\nsavemail, errormode = %c, id = %s\n e_from=",
- e->e_errormode, e->e_id == NULL ? "NONE" : e->e_id);
+ printf("\nsavemail, errormode = %c, id = %s, ExitStat = %d\n e_from=",
+ e->e_errormode, e->e_id == NULL ? "NONE" : e->e_id,
+ ExitStat);
printaddr(&e->e_from, FALSE);
}
@@ -282,8 +284,8 @@ savemail(e)
state = ESM_POSTMASTER;
break;
}
- if (returntosender(e->e_message,
- q, (e->e_class >= 0), e) == 0)
+ if (returntosender(e->e_message, e->e_errorqueue,
+ (e->e_class >= 0), e) == 0)
{
state = ESM_DONE;
break;
@@ -393,11 +395,17 @@ savemail(e)
break;
}
- putfromline(fp, FileMailer, e);
- (*e->e_puthdr)(fp, FileMailer, e);
- putline("\n", fp, FileMailer);
- (*e->e_putbody)(fp, FileMailer, e, NULL);
- putline("\n", fp, FileMailer);
+ bzero(&mcibuf, sizeof mcibuf);
+ mcibuf.mci_out = fp;
+ mcibuf.mci_mailer = FileMailer;
+ if (bitnset(M_7BITS, FileMailer->m_flags))
+ mcibuf.mci_flags |= MCIF_7BIT;
+
+ putfromline(&mcibuf, e);
+ (*e->e_puthdr)(&mcibuf, e);
+ putline("\n", &mcibuf);
+ (*e->e_putbody)(&mcibuf, e, NULL);
+ putline("\n", &mcibuf);
(void) fflush(fp);
state = ferror(fp) ? ESM_PANIC : ESM_DONE;
(void) xfclose(fp, "savemail", "/usr/tmp/dead.letter");
@@ -564,8 +572,7 @@ returntosender(msg, returnq, sendbody, e)
** original offending message.
**
** Parameters:
-** fp -- the output file.
-** m -- the mailer to output to.
+** mci -- the mailer connection information.
** e -- the envelope we are working in.
**
** Returns:
@@ -575,9 +582,8 @@ returntosender(msg, returnq, sendbody, e)
** Outputs the body of an error message.
*/
-errbody(fp, m, e)
- register FILE *fp;
- register struct mailer *m;
+errbody(mci, e)
+ register MCI *mci;
register ENVELOPE *e;
{
register FILE *xfile;
@@ -589,7 +595,7 @@ errbody(fp, m, e)
if (e->e_parent == NULL)
{
syserr("errbody: null parent");
- putline(" ----- Original message lost -----\n", fp, m);
+ putline(" ----- Original message lost -----\n", mci);
return;
}
@@ -599,11 +605,11 @@ errbody(fp, m, e)
if (e->e_msgboundary != NULL)
{
- putline("This is a MIME-encapsulated message", fp, m);
- putline("", fp, m);
+ putline("This is a MIME-encapsulated message", mci);
+ putline("", mci);
(void) sprintf(buf, "--%s", e->e_msgboundary);
- putline(buf, fp, m);
- putline("", fp, m);
+ putline(buf, mci);
+ putline("", mci);
}
/*
@@ -617,21 +623,21 @@ errbody(fp, m, e)
!bitset(EF_FATALERRS|EF_SENDRECEIPT, e->e_parent->e_flags))
{
putline(" **********************************************",
- fp, m);
+ mci);
putline(" ** THIS IS A WARNING MESSAGE ONLY **",
- fp, m);
+ mci);
putline(" ** YOU DO NOT NEED TO RESEND YOUR MESSAGE **",
- fp, m);
+ mci);
putline(" **********************************************",
- fp, m);
- putline("", fp, m);
+ mci);
+ putline("", mci);
}
sprintf(buf, "The original message was received at %s",
arpadate(ctime(&e->e_parent->e_ctime)));
- putline(buf, fp, m);
+ putline(buf, mci);
expand("from \201_", buf, &buf[sizeof buf - 1], e->e_parent);
- putline(buf, fp, m);
- putline("", fp, m);
+ putline(buf, mci);
+ putline("", mci);
/*
** Output error message header (if specified and available).
@@ -647,17 +653,17 @@ errbody(fp, m, e)
while (fgets(buf, sizeof buf, xfile) != NULL)
{
expand(buf, buf, &buf[sizeof buf - 1], e);
- putline(buf, fp, m);
+ putline(buf, mci);
}
(void) fclose(xfile);
- putline("\n", fp, m);
+ putline("\n", mci);
}
}
else
{
expand(ErrMsgFile, buf, &buf[sizeof buf - 1], e);
- putline(buf, fp, m);
- putline("", fp, m);
+ putline(buf, mci);
+ putline("", mci);
}
}
@@ -673,7 +679,7 @@ errbody(fp, m, e)
if (printheader)
{
putline(" ----- The following addresses had delivery problems -----",
- fp, m);
+ mci);
printheader = FALSE;
}
strcpy(buf, q->q_paddr);
@@ -681,18 +687,18 @@ errbody(fp, m, e)
strcat(buf, " (unrecoverable error)");
else
strcat(buf, " (transient failure)");
- putline(buf, fp, m);
+ putline(buf, mci);
if (q->q_alias != NULL)
{
strcpy(buf, " (expanded from: ");
strcat(buf, q->q_alias->q_paddr);
strcat(buf, ")");
- putline(buf, fp, m);
+ putline(buf, mci);
}
}
}
if (!printheader)
- putline("\n", fp, m);
+ putline("\n", mci);
/*
** Output transcript of errors
@@ -703,15 +709,15 @@ errbody(fp, m, e)
if ((xfile = fopen(p, "r")) == NULL)
{
syserr("Cannot open %s", p);
- putline(" ----- Transcript of session is unavailable -----\n", fp, m);
+ putline(" ----- Transcript of session is unavailable -----\n", mci);
}
else
{
- putline(" ----- Transcript of session follows -----\n", fp, m);
+ putline(" ----- Transcript of session follows -----\n", mci);
if (e->e_xfp != NULL)
(void) fflush(e->e_xfp);
while (fgets(buf, sizeof buf, xfile) != NULL)
- putline(buf, fp, m);
+ putline(buf, mci);
(void) xfclose(xfile, "errbody xscript", p);
}
errno = 0;
@@ -722,42 +728,42 @@ errbody(fp, m, e)
if (NoReturn)
SendBody = FALSE;
- putline("", fp, m);
+ putline("", mci);
if (e->e_parent->e_df != NULL)
{
if (SendBody)
- putline(" ----- Original message follows -----\n", fp, m);
+ putline(" ----- Original message follows -----\n", mci);
else
- putline(" ----- Message header follows -----\n", fp, m);
- (void) fflush(fp);
+ putline(" ----- Message header follows -----\n", mci);
+ (void) fflush(mci->mci_out);
if (e->e_msgboundary != NULL)
{
- putline("", fp, m);
+ putline("", mci);
(void) sprintf(buf, "--%s", e->e_msgboundary);
- putline(buf, fp, m);
- putline("Content-Type: message/rfc822", fp, m);
- putline("", fp, m);
+ putline(buf, mci);
+ putline("Content-Type: message/rfc822", mci);
+ putline("", mci);
}
- putheader(fp, m, e->e_parent);
- putline("", fp, m);
+ putheader(mci, e->e_parent);
+ putline("", mci);
if (SendBody)
- putbody(fp, m, e->e_parent, e->e_msgboundary);
+ putbody(mci, e->e_parent, e->e_msgboundary);
else
- putline(" ----- Message body suppressed -----", fp, m);
+ putline(" ----- Message body suppressed -----", mci);
}
else
{
- putline(" ----- No message was collected -----\n", fp, m);
+ putline(" ----- No message was collected -----\n", mci);
}
if (e->e_msgboundary != NULL)
{
- putline("", fp, m);
+ putline("", mci);
(void) sprintf(buf, "--%s--", e->e_msgboundary);
- putline(buf, fp, m);
+ putline(buf, mci);
}
- putline("", fp, m);
+ putline("", mci);
/*
** Cleanup and exit
@@ -786,7 +792,7 @@ errbody(fp, m, e)
pruneroute(addr)
char *addr;
{
-#ifdef NAMED_BIND
+#if NAMED_BIND
char *start, *at, *comma;
char c;
int rcode;
diff --git a/usr.sbin/sendmail/src/sendmail.h b/usr.sbin/sendmail/src/sendmail.h
index e68ffe09889..ca6af5fef14 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.38 (Berkeley) 1/5/94
+ * @(#)sendmail.h 8.41 (Berkeley) 2/6/94
*/
/*
@@ -41,7 +41,7 @@
# ifdef _DEFINE
# define EXTERN
# ifndef lint
-static char SmailSccsId[] = "@(#)sendmail.h 8.38 1/5/94";
+static char SmailSccsId[] = "@(#)sendmail.h 8.41 2/6/94";
# endif
# else /* _DEFINE */
# define EXTERN extern
@@ -268,6 +268,50 @@ extern struct hdrinfo HdrInfo[];
# define H_RECEIPTTO 02000 /* this field has return receipt info */
# define H_ERRORSTO 04000 /* this field has error address info */
/*
+** Information about currently open connections to mailers, or to
+** hosts that we have looked up recently.
+*/
+
+# define MCI struct mailer_con_info
+
+MCI
+{
+ short mci_flags; /* flag bits, see below */
+ short mci_errno; /* error number on last connection */
+ short mci_herrno; /* h_errno from last DNS lookup */
+ short mci_exitstat; /* exit status from last connection */
+ short mci_state; /* SMTP state */
+ long mci_maxsize; /* max size this server will accept */
+ FILE *mci_in; /* input side of connection */
+ FILE *mci_out; /* output side of connection */
+ int mci_pid; /* process id of subordinate proc */
+ char *mci_phase; /* SMTP phase string */
+ struct mailer *mci_mailer; /* ptr to the mailer for this conn */
+ char *mci_host; /* host name */
+ time_t mci_lastuse; /* last usage time */
+};
+
+
+/* flag bits */
+#define MCIF_VALID 000001 /* this entry is valid */
+#define MCIF_TEMP 000002 /* don't cache this connection */
+#define MCIF_CACHED 000004 /* currently in open cache */
+#define MCIF_ESMTP 000010 /* this host speaks ESMTP */
+#define MCIF_EXPN 000020 /* EXPN command supported */
+#define MCIF_SIZE 000040 /* SIZE option supported */
+#define MCIF_8BITMIME 000100 /* BODY=8BITMIME supported */
+#define MCIF_7BIT 000200 /* strip this message to 7 bits */
+#define MCIF_MULTSTAT 000400 /* MAIL11V3: handles MULT status */
+
+/* states */
+#define MCIS_CLOSED 0 /* no traffic on this connection */
+#define MCIS_OPENING 1 /* sending initial protocol */
+#define MCIS_OPEN 2 /* open, initial protocol sent */
+#define MCIS_ACTIVE 3 /* message being sent */
+#define MCIS_QUITING 4 /* running quit protocol */
+#define MCIS_SSD 5 /* service shutting down */
+#define MCIS_ERROR 6 /* I/O error on connection */
+ /*
** Envelope structure.
** This structure defines the message itself. There is usually
** only one of these -- for the message that we originally read
@@ -298,9 +342,9 @@ ENVELOPE
short e_nsent; /* number of sends since checkpoint */
short e_sendmode; /* message send mode */
short e_errormode; /* error return mode */
- int (*e_puthdr)__P((FILE *, MAILER *, ENVELOPE *));
+ int (*e_puthdr)__P((MCI *, ENVELOPE *));
/* function to put header of message */
- int (*e_putbody)__P((FILE *, MAILER *, ENVELOPE *, char *));
+ int (*e_putbody)__P((MCI *, ENVELOPE *, char *));
/* function to put body of message */
struct envelope *e_parent; /* the message this one encloses */
struct envelope *e_sibling; /* the next envelope of interest */
@@ -429,49 +473,6 @@ struct metamac
u_char metaval; /* internal code (as above) */
};
/*
-** Information about currently open connections to mailers, or to
-** hosts that we have looked up recently.
-*/
-
-# define MCI struct mailer_con_info
-
-MCI
-{
- short mci_flags; /* flag bits, see below */
- short mci_errno; /* error number on last connection */
- short mci_herrno; /* h_errno from last DNS lookup */
- short mci_exitstat; /* exit status from last connection */
- short mci_state; /* SMTP state */
- long mci_maxsize; /* max size this server will accept */
- FILE *mci_in; /* input side of connection */
- FILE *mci_out; /* output side of connection */
- int mci_pid; /* process id of subordinate proc */
- char *mci_phase; /* SMTP phase string */
- struct mailer *mci_mailer; /* ptr to the mailer for this conn */
- char *mci_host; /* host name */
- time_t mci_lastuse; /* last usage time */
-};
-
-
-/* flag bits */
-#define MCIF_VALID 000001 /* this entry is valid */
-#define MCIF_TEMP 000002 /* don't cache this connection */
-#define MCIF_CACHED 000004 /* currently in open cache */
-#define MCIF_ESMTP 000010 /* this host speaks ESMTP */
-#define MCIF_EXPN 000020 /* EXPN command supported */
-#define MCIF_SIZE 000040 /* SIZE option supported */
-#define MCIF_8BITMIME 000100 /* BODY=8BITMIME supported */
-#define MCIF_MULTSTAT 000200 /* MAIL11V3: handles MULT status */
-
-/* states */
-#define MCIS_CLOSED 0 /* no traffic on this connection */
-#define MCIS_OPENING 1 /* sending initial protocol */
-#define MCIS_OPEN 2 /* open, initial protocol sent */
-#define MCIS_ACTIVE 3 /* message being sent */
-#define MCIS_QUITING 4 /* running quit protocol */
-#define MCIS_SSD 5 /* service shutting down */
-#define MCIS_ERROR 6 /* I/O error on connection */
- /*
** Name canonification short circuit.
**
** If the name server for a host is down, the process of trying to
@@ -660,6 +661,7 @@ EXTERN char OpMode; /* operation mode, see below */
#define MD_DELIVER 'm' /* be a mail sender */
#define MD_SMTP 's' /* run SMTP on standard input */
+#define MD_ARPAFTP 'a' /* obsolete ARPANET mode (Grey Book) */
#define MD_DAEMON 'd' /* run as a daemon */
#define MD_VERIFY 'v' /* verify: don't collect or deliver */
#define MD_TEST 't' /* test mode: resolve addrs only */
@@ -824,6 +826,7 @@ EXTERN bool UseErrorsTo; /* use Errors-To: header (back compat) */
EXTERN bool TryNullMXList; /* if we are the best MX, try host directly */
extern bool CheckLoopBack; /* check for loopback on HELO packet */
EXTERN bool InChild; /* true if running in an SMTP subprocess */
+EXTERN bool DisConnected; /* running with OutChannel redirected to xf */
EXTERN char SpaceSub; /* substitution for <lwsp> */
EXTERN int PrivacyFlags; /* privacy flags */
EXTERN char *ConfFile; /* location of configuration file [conf.c] */
@@ -950,6 +953,7 @@ extern void closexscript __P((ENVELOPE *));
extern sigfunc_t setsignal __P((int, sigfunc_t));
extern char *shortenstring __P((char *, int));
extern bool usershellok __P((char *));
+extern void commaize __P((HDR *, char *, int, MCI *, ENVELOPE *));
/* ellipsis is a different case though */
#ifdef __STDC__
diff --git a/usr.sbin/sendmail/src/srvrsmtp.c b/usr.sbin/sendmail/src/srvrsmtp.c
index 2966f80af6e..e049de3ff17 100644
--- a/usr.sbin/sendmail/src/srvrsmtp.c
+++ b/usr.sbin/sendmail/src/srvrsmtp.c
@@ -36,9 +36,9 @@
#ifndef lint
#ifdef SMTP
-static char sccsid[] = "@(#)srvrsmtp.c 8.23 (Berkeley) 12/21/93 (with SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 8.32 (Berkeley) 3/8/94 (with SMTP)";
#else
-static char sccsid[] = "@(#)srvrsmtp.c 8.23 (Berkeley) 12/21/93 (without SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 8.32 (Berkeley) 3/8/94 (without SMTP)";
#endif
#endif /* not lint */
@@ -117,6 +117,10 @@ bool OneXact = FALSE; /* one xaction only this run */
char *CurSmtpClient; /* who's at the other end of channel */
static char *skipword();
+extern char RealUserName[];
+
+
+#define MAXBADCOMMANDS 25 /* maximum number of bad commands */
smtp(e)
register ENVELOPE *e;
@@ -132,10 +136,12 @@ smtp(e)
char *protocol; /* sending protocol */
char *sendinghost; /* sending hostname */
long msize; /* approximate maximum message size */
+ char *peerhostname; /* name of SMTP peer or "localhost" */
auto char *delimptr;
char *id;
int nrcpts; /* number of RCPT commands */
bool doublequeue;
+ int badcommands = 0; /* count of bad commands */
char inp[MAXLINE];
char cmdbuf[MAXLINE];
extern char Version[];
@@ -147,10 +153,13 @@ smtp(e)
(void) dup2(fileno(OutChannel), fileno(stdout));
}
settime(e);
- CurHostName = RealHostName;
+ peerhostname = RealHostName;
+ if (peerhostname == NULL)
+ peerhostname = "localhost";
+ CurHostName = peerhostname;
CurSmtpClient = macvalue('_', e);
if (CurSmtpClient == NULL)
- CurSmtpClient = RealHostName;
+ CurSmtpClient = CurHostName;
setproctitle("server %s startup", CurSmtpClient);
expand("\201e", inp, &inp[sizeof inp], e);
@@ -170,11 +179,15 @@ smtp(e)
for (;;)
{
/* arrange for backout */
- if (setjmp(TopFrame) > 0 && InChild)
+ if (setjmp(TopFrame) > 0)
{
- QuickAbort = FALSE;
- SuprErrs = TRUE;
- finis();
+ /* if() nesting is necessary for Cray UNICOS */
+ if (InChild)
+ {
+ QuickAbort = FALSE;
+ SuprErrs = TRUE;
+ finis();
+ }
}
QuickAbort = FALSE;
HoldErrs = FALSE;
@@ -196,6 +209,7 @@ smtp(e)
if (p == NULL)
{
/* end of file, just die */
+ disconnect(1, e);
message("421 %s Lost input channel from %s",
MyHostName, CurSmtpClient);
#ifdef LOG
@@ -260,14 +274,6 @@ smtp(e)
SmtpPhase = "server HELO";
}
sendinghost = newstr(p);
- if (strcasecmp(p, RealHostName) != 0 &&
- (strcasecmp(RealHostName, "localhost") != 0 ||
- strcasecmp(p, MyHostName) != 0))
- {
- auth_warning(e, "Host %s claimed to be %s",
- RealHostName, p);
- }
-
gothello = TRUE;
if (c->cmdcode != CMDEHLO)
{
@@ -297,7 +303,7 @@ smtp(e)
{
/* set sending host to our known value */
if (sendinghost == NULL)
- sendinghost = RealHostName;
+ sendinghost = peerhostname;
if (bitset(PRIV_NEEDMAILHELO, PrivacyFlags))
{
@@ -326,8 +332,18 @@ smtp(e)
{
auth_warning(e,
"Host %s didn't use HELO protocol",
- RealHostName);
+ peerhostname);
}
+#ifdef PICKY_HELO_CHECK
+ if (strcasecmp(sendinghost, peerhostname) != 0 &&
+ (strcasecmp(peerhostname, "localhost") != 0 ||
+ strcasecmp(sendinghost, MyHostName) != 0))
+ {
+ auth_warning(e, "Host %s claimed to be %s",
+ peerhostname, sendinghost);
+ }
+#endif
+
if (protocol == NULL)
protocol = "SMTP";
define('r', protocol, e);
@@ -362,12 +378,21 @@ smtp(e)
if (p != NULL && *p != '\0')
*p++ = '\0';
+ /* check for possible spoofing */
+ if (RealUid != 0 && OpMode == MD_SMTP &&
+ (e->e_from.q_mailer != LocalMailer &&
+ strcmp(e->e_from.q_user, RealUserName) != 0))
+ {
+ auth_warning(e, "%s owned process doing -bs",
+ RealUserName);
+ }
+
/* now parse ESMTP arguments */
msize = 0;
for (; p != NULL && *p != '\0'; p++)
{
char *kp;
- char *vp;
+ char *vp = NULL;
/* locate the beginning of the keyword */
while (isascii(*p) && isspace(*p))
@@ -700,8 +725,9 @@ smtp(e)
case CMDQUIT: /* quit -- leave mail */
message("221 %s closing connection", MyHostName);
+doquit:
/* avoid future 050 messages */
- Verbose = FALSE;
+ disconnect(1, e);
if (InChild)
ExitStat = EX_QUIT;
@@ -745,12 +771,19 @@ smtp(e)
if (LogLevel > 0)
syslog(LOG_CRIT,
"\"%s\" command from %s (%s)",
- c->cmdname, RealHostName,
+ c->cmdname, peerhostname,
anynet_ntoa(&RealHostAddr));
# endif
/* FALL THROUGH */
case CMDERROR: /* unknown command */
+ if (++badcommands > MAXBADCOMMANDS)
+ {
+ message("421 %s Too many bad commands; closing connection",
+ MyHostName);
+ goto doquit;
+ }
+
message("500 Command unrecognized");
break;
@@ -782,6 +815,7 @@ skipword(p, w)
char *w;
{
register char *q;
+ char *firstp = p;
/* find beginning of word */
while (isascii(*p) && isspace(*p))
@@ -796,7 +830,8 @@ skipword(p, w)
if (*p != ':')
{
syntax:
- message("501 Syntax error in parameters");
+ message("501 Syntax error in parameters scanning \"%s\"",
+ firstp);
Errors++;
return (NULL);
}
@@ -955,8 +990,11 @@ runinchild(label, e)
label, st & 0177);
/* if we exited on a QUIT command, complete the process */
- if (st == (EX_QUIT << 8))
+ if (WEXITSTATUS(st) == EX_QUIT)
+ {
+ disconnect(1, e);
finis();
+ }
return (1);
}
diff --git a/usr.sbin/sendmail/src/trace.c b/usr.sbin/sendmail/src/trace.c
index f27d70b318e..29421eee3c6 100644
--- a/usr.sbin/sendmail/src/trace.c
+++ b/usr.sbin/sendmail/src/trace.c
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)trace.c 8.1 (Berkeley) 6/7/93";
+static char sccsid[] = "@(#)trace.c 8.2 (Berkeley) 3/14/94";
#endif /* not lint */
# include "sendmail.h"
@@ -82,8 +82,8 @@ tTsetup(vect, size, defflags)
tTflag(s)
register char *s;
{
- int first, last;
- register int i;
+ unsigned int first, last;
+ register unsigned int i;
if (*s == '\0')
s = DefFlags;
diff --git a/usr.sbin/sendmail/src/udb.c b/usr.sbin/sendmail/src/udb.c
index 46b9d658453..dbd1d046c19 100644
--- a/usr.sbin/sendmail/src/udb.c
+++ b/usr.sbin/sendmail/src/udb.c
@@ -36,15 +36,14 @@
#ifndef lint
#ifdef USERDB
-static char sccsid [] = "@(#)udb.c 8.4 (Berkeley) 11/25/93 (with USERDB)";
+static char sccsid [] = "@(#)udb.c 8.6 (Berkeley) 3/11/94 (with USERDB)";
#else
-static char sccsid [] = "@(#)udb.c 8.4 (Berkeley) 11/25/93 (without USERDB)";
+static char sccsid [] = "@(#)udb.c 8.6 (Berkeley) 3/11/94 (without USERDB)";
#endif
#endif
#ifdef USERDB
-#include <sys/time.h>
#include <errno.h>
#include <netdb.h>
#include <db.h>
@@ -571,7 +570,7 @@ _udbx_init()
case '*': /* search remote database (expand MX) */
if (*spec == '*')
{
-#ifdef NAMED_BIND
+#if NAMED_BIND
nmx = getmxrr(spec + 1, mxhosts, FALSE, &rcode);
#else
mxhosts[0] = spec + 1;
diff --git a/usr.sbin/sendmail/src/usersmtp.c b/usr.sbin/sendmail/src/usersmtp.c
index 14b2f7fda72..06acd3f2fc8 100644
--- a/usr.sbin/sendmail/src/usersmtp.c
+++ b/usr.sbin/sendmail/src/usersmtp.c
@@ -36,9 +36,9 @@
#ifndef lint
#ifdef SMTP
-static char sccsid[] = "@(#)usersmtp.c 8.17 (Berkeley) 1/5/94 (with SMTP)";
+static char sccsid[] = "@(#)usersmtp.c 8.18 (Berkeley) 1/24/94 (with SMTP)";
#else
-static char sccsid[] = "@(#)usersmtp.c 8.17 (Berkeley) 1/5/94 (without SMTP)";
+static char sccsid[] = "@(#)usersmtp.c 8.18 (Berkeley) 1/24/94 (without SMTP)";
#endif
#endif /* not lint */
@@ -303,7 +303,10 @@ helo_options(line, m, mci, e)
mci->mci_maxsize = atol(p);
}
else if (strcasecmp(line, "8bitmime") == 0)
+ {
mci->mci_flags |= MCIF_8BITMIME;
+ mci->mci_flags &= ~MCIF_7BIT;
+ }
else if (strcasecmp(line, "expn") == 0)
mci->mci_flags |= MCIF_EXPN;
}
@@ -536,9 +539,9 @@ smtpdata(m, mci, e)
ev = setevent(timeout, datatimeout, 0);
/* now output the actual message */
- (*e->e_puthdr)(mci->mci_out, m, e);
- putline("\n", mci->mci_out, m);
- (*e->e_putbody)(mci->mci_out, m, e, NULL);
+ (*e->e_puthdr)(mci, e);
+ putline("\n", mci);
+ (*e->e_putbody)(mci, e, NULL);
clrevent(ev);
diff --git a/usr.sbin/sendmail/src/util.c b/usr.sbin/sendmail/src/util.c
index 85e0f04dd34..ca7612d7673 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.28 (Berkeley) 1/4/94";
+static char sccsid[] = "@(#)util.c 8.34 (Berkeley) 3/11/94";
#endif /* not lint */
# include "sendmail.h"
@@ -644,8 +644,16 @@ dfopen(filename, omode, cmode)
fd = open(filename, omode, cmode);
if (fd >= 0)
break;
- if (errno != ENFILE && errno != EINTR)
- break;
+ switch (errno)
+ {
+ case ENFILE: /* system file table full */
+ case EINTR: /* interrupted syscall */
+#ifdef ETXTBSY
+ case ETXTBSY: /* Apollo: net file locked */
+#endif
+ continue;
+ }
+ break;
}
if (fd >= 0 && fstat(fd, &st) >= 0 && S_ISREG(st.st_mode))
{
@@ -672,8 +680,7 @@ dfopen(filename, omode, cmode)
**
** Parameters:
** l -- line to put.
-** fp -- file to put it onto.
-** m -- the mailer used to control output.
+** mci -- the mailer connection information.
**
** Returns:
** none
@@ -682,16 +689,16 @@ dfopen(filename, omode, cmode)
** output of l to fp.
*/
-putline(l, fp, m)
+putline(l, mci)
register char *l;
- FILE *fp;
- MAILER *m;
+ register MCI *mci;
{
register char *p;
register char svchar;
+ int slop = 0;
/* strip out 0200 bits -- these can look like TELNET protocol */
- if (bitnset(M_7BITS, m->m_flags))
+ if (bitset(MCIF_7BIT, mci->mci_flags))
{
for (p = l; (svchar = *p) != '\0'; ++p)
if (bitset(0200, svchar))
@@ -709,40 +716,45 @@ putline(l, fp, m)
fprintf(TrafficLogFile, "%05d >>> ", getpid());
/* check for line overflow */
- while (m->m_linelimit > 0 && (p - l) > m->m_linelimit)
+ while (mci->mci_mailer->m_linelimit > 0 &&
+ (p - l + slop) > mci->mci_mailer->m_linelimit)
{
- register char *q = &l[m->m_linelimit - 1];
+ register char *q = &l[mci->mci_mailer->m_linelimit - slop - 1];
svchar = *q;
*q = '\0';
- if (l[0] == '.' && bitnset(M_XDOT, m->m_flags))
+ if (l[0] == '.' && slop == 0 &&
+ bitnset(M_XDOT, mci->mci_mailer->m_flags))
{
- (void) putc('.', fp);
+ (void) putc('.', mci->mci_out);
if (TrafficLogFile != NULL)
(void) putc('.', TrafficLogFile);
}
- fputs(l, fp);
- (void) putc('!', fp);
- fputs(m->m_eol, fp);
+ fputs(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)
- fprintf(TrafficLogFile, "%s!\n%05d >>> ",
+ fprintf(TrafficLogFile, "%s!\n%05d >>> ",
l, getpid());
*q = svchar;
l = q;
+ slop = 1;
}
/* output last part */
- if (l[0] == '.' && bitnset(M_XDOT, m->m_flags))
+ if (l[0] == '.' && slop == 0 &&
+ bitnset(M_XDOT, mci->mci_mailer->m_flags))
{
- (void) putc('.', fp);
+ (void) putc('.', mci->mci_out);
if (TrafficLogFile != NULL)
(void) putc('.', TrafficLogFile);
}
if (TrafficLogFile != NULL)
fprintf(TrafficLogFile, "%.*s\n", p - l, l);
for ( ; l < p; ++l)
- (void) putc(*l, fp);
- fputs(m->m_eol, fp);
+ (void) putc(*l, mci->mci_out);
+ fputs(mci->mci_mailer->m_eol, mci->mci_out);
if (*l == '\n')
++l;
} while (l[0] != '\0');
@@ -836,6 +848,12 @@ sfgets(buf, siz, fp, timeout, during)
register EVENT *ev = NULL;
register char *p;
+ if (fp == NULL)
+ {
+ buf[0] = '\0';
+ return NULL;
+ }
+
/* set the timeout */
if (timeout != 0)
{
@@ -1309,7 +1327,7 @@ dumpfd(fd, printclosed, logit)
p += strlen(p);
goto defprint;
-#ifdef S_IFIFO
+#if defined(S_IFIFO) && (!defined(S_IFSOCK) || S_IFIFO != S_IFSOCK)
case S_IFIFO:
sprintf(p, "FIFO: ");
p += strlen(p);
diff --git a/usr.sbin/sendmail/src/version.c b/usr.sbin/sendmail/src/version.c
index 3169f6ac937..881c30a2c5d 100644
--- a/usr.sbin/sendmail/src/version.c
+++ b/usr.sbin/sendmail/src/version.c
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)version.c 8.6.1.5 (Berkeley) 1/13/94";
+static char sccsid[] = "@(#)version.c 8.6.7.1 (Berkeley) 3/14/94";
#endif /* not lint */
-char Version[] = "8.6.5";
+char Version[] = "8.6.7";