diff options
| author | Peter Wemm <peter@FreeBSD.org> | 1997-11-10 01:58:17 +0000 | 
|---|---|---|
| committer | Peter Wemm <peter@FreeBSD.org> | 1997-11-10 01:58:17 +0000 | 
| commit | ff37c899d76b8a843614fb348674c7e94e4f53ce (patch) | |
| tree | ec1e00a87146aa91a3fe520fcbd0e82387524022 /usr.sbin/sendmail/src | |
| parent | e54babdf0c067b521dc066286e05db2ab1add3df (diff) | |
Notes
Diffstat (limited to 'usr.sbin/sendmail/src')
| -rw-r--r-- | usr.sbin/sendmail/src/READ_ME | 49 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/collect.c | 4 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/conf.c | 22 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/conf.h | 21 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/daemon.c | 39 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/deliver.c | 89 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/err.c | 6 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/headers.c | 20 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/main.c | 50 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/map.c | 156 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/parseaddr.c | 15 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/queue.c | 13 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/readcf.c | 12 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/recipient.c | 9 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/savemail.c | 64 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/sendmail.h | 7 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/srvrsmtp.c | 30 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/usersmtp.c | 5 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/util.c | 10 | ||||
| -rw-r--r-- | usr.sbin/sendmail/src/version.c | 4 | 
20 files changed, 390 insertions, 235 deletions
| diff --git a/usr.sbin/sendmail/src/READ_ME b/usr.sbin/sendmail/src/READ_ME index 154916a0a6e6..7eea26746515 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.148 (Berkeley) 8/1/97 +#	@(#)READ_ME	8.156 (Berkeley) 10/23/97  #  This directory contains the source files for sendmail. @@ -148,9 +148,10 @@ The options are:  NEWDB		The new Berkeley DB package.  Some systems (e.g., BSD/OS and  		Digital UNIX 4.0) have this package pre-installed.  If your -		system does not have NEWDB installed, get the latest version +		system does not have NEWDB installed, get version 1.85  		from http://www.sleepycat.com/packages/db.1.85.tar.gz. -		DO NOT use the version from the Net2 distribution.  If you are +		DO NOT use Berkeley DB version 2.X with sendmail.  DO NOT +		use the version from the Net2 distribution.  If you are  		still running BSD/386 1.x, you will also need to define  		OLD_NEWDB.  NDBM		The older NDBM implementation -- the very old V7 DBM @@ -731,7 +732,13 @@ SunOS 4.1.3, 4.1.3_U1  	101790-01 (SunOS 4.1.3_U1: TCP socket and reset problems).  Solaris 2.x (SunOS 5.x) -	To compile for Solaris, be sure you use -DSOLARIS. +	To compile for Solaris, the Makefile chosen by makesendmail must +	include a SOLARIS definition which reflects the Solaris version +	(i.e. -DSOLARIS=20400 for 2.4 or -DSOLARIS=20501 for 2.5.1). +	If you are using gcc, make sure -I/usr/include is not used (or +	it might complain about TopFrame).  If you are using Sun's cc, +	make sure /opt/SUNWspro/bin/cc is used instead of /usr/ucb/cc +	(or it might complain about tm_zone).  	To the best of my knowledge, Solaris does not have the  	gethostbyname problem described above.  However, it does @@ -828,22 +835,25 @@ Solaris 2.6 (SunOS 5.6)  	incompatible snprintf(3s) calls.  This problem is fixed in sendmail  	8.8.5. -Solaris 2.5.1 (SunOS 5.5.1) -	Apparently patch 103663-01 installs a new /usr/include/resolv.h -	file that defines the __P macro without checking to see if it is -	already defined.  This causes compile warnings such as: +Solaris 2.5.1 (SunOS 5.5.1) and 2.6 (SunOS 5.6) +	Apparently Solaris 2.5.1 patch 103663-01 installs a new +	/usr/include/resolv.h file that defines the __P macro without +	checking to see if it is already defined.  This new resolv.h is also +	included in the Solaris 2.6 distribution. This causes compile +	warnings such as:  	   In file included from daemon.c:51:  	   /usr/include/resolv.h:208: warning: `__P' redefined  	   cdefs.h:58: warning: this is the location of the previous definition -	If you are running with this patch, create a resolv.h file in the -	obj.SunOS.5.5.1.* directory that reads: +	These warnings can be safely ignored or you can create a resolv.h +	file in the obj.SunOS.5.5.1.* or obj.SunOS.5.6.* directory that reads:  	   #undef __P  	   #include "/usr/include/resolv.h" -	... And then file a bug report with Sun. +	Sun is aware of the problem (Sun bug ID 4081053) and it will be fixed +	in a to-be-released patch.  Ultrix  	By default, the IDENT protocol is turned off on Ultrix.  If you @@ -852,7 +862,7 @@ Ultrix  	IDENT on in the configuration file by setting the "ident" timeout  	to 30 seconds. -OSF/1 +Digital UNIX (formerly DEC OSF/1)  	If you are compiling on OSF/1 (DEC Alpha), you must use  	-L/usr/shlib (otherwise it core dumps on startup).  You may also  	need -mld to get the nlist() function, although some versions @@ -865,6 +875,19 @@ OSF/1  	properly due to a bug in the getpw* routines.  If you want to use  	this, use -DDEC_OSF_BROKEN_GETPWENT=1.  The problem is fixed in 3.2C. +	On Digital UNIX 4.0 and later, Berkeley DB is included with the +	operating system and already has the ndbm.o module removed.  However, +	Digital has modified the original Berkeley DB db.h include file. +	This results in the following warning while compiling map.c and udb.c: + +	cc: Warning: /usr/include/db.h, line 74: The redefinition of the macro +	 "__signed" conflicts with a current definition because the replacement +	 lists differ.  The redefinition is now in effect. +	#define __signed        signed +	------------------------^ + +	This warning can be ignored. +  IRIX  	The header files on SGI IRIX are completely prototyped, and as  	a result you can sometimes get some warning messages during @@ -1439,4 +1462,4 @@ version.c	The version number and information about this  Eric Allman -(Version 8.148, last update 8/1/97 16:41:54) +(Version 8.156, last update 10/23/97 12:53:12) diff --git a/usr.sbin/sendmail/src/collect.c b/usr.sbin/sendmail/src/collect.c index de4ee064879f..58f0dc75142a 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.71 (Berkeley) 6/30/97"; +static char sccsid[] = "@(#)collect.c	8.72 (Berkeley) 10/6/97";  #endif /* not lint */  # include <errno.h> @@ -567,7 +567,7 @@ readerr:  	/* check for message too large */  	if (MaxMessageSize > 0 && e->e_msgsize > MaxMessageSize)  	{ -		e->e_flags |= EF_NO_BODY_RETN; +		e->e_flags |= EF_NO_BODY_RETN|EF_CLRQUEUE;  		e->e_status = "5.2.3";  		usrerr("552 Message exceeds maximum fixed size (%ld)",  			MaxMessageSize); diff --git a/usr.sbin/sendmail/src/conf.c b/usr.sbin/sendmail/src/conf.c index 1c394628412d..cd51efcacfe0 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.374 (Berkeley) 8/2/97"; +static char sccsid[] = "@(#)conf.c	8.379 (Berkeley) 10/20/97";  #endif /* not lint */  # include "sendmail.h" @@ -2066,7 +2066,6 @@ refuseconnections(port)  	static time_t lastconn = (time_t) 0;  	static int conncnt = 0;  	extern bool enoughdiskspace(); -	extern void setproctitle __P((const char *, ...));  #ifdef XLA  	if (!xla_smtp_ok()) @@ -2225,7 +2224,7 @@ initsetproctitle(argc, argv, envp)  	char **argv;  	char **envp;  { -	register int i; +	register int i, envpsize = 0;  	extern char **environ;  	/* @@ -2234,7 +2233,7 @@ initsetproctitle(argc, argv, envp)  	*/  	for (i = 0; envp[i] != NULL; i++) -		continue; +		envpsize += strlen(envp[i]) + 1;  	environ = (char **) xalloc(sizeof (char *) * (i + 1));  	for (i = 0; envp[i] != NULL; i++)  		environ[i] = newstr(envp[i]); @@ -2245,6 +2244,16 @@ initsetproctitle(argc, argv, envp)  	*/  	Argv = argv; + +	/* +	**  Find the last environment variable within sendmail's +	**  process memory area. +	*/ +	while (i > 0 && (envp[i - 1] < argv[0] || +			 envp[i - 1] > (argv[argc - 1] + +					strlen(argv[argc - 1]) + 1 + envpsize))) +		i--; +  	if (i > 0)  		LastArgv = envp[i - 1] + strlen(envp[i - 1]);  	else @@ -2820,6 +2829,7 @@ char	*optarg = NULL;		/* argument associated with option */  #define tell(s)	if (opterr) {fputs(*nargv,stderr);fputs(s,stderr); \  		fputc(optopt,stderr);fputc('\n',stderr);return(BADCH);} +int  getopt(nargc,nargv,ostr)  	int		nargc;  	char *const	*nargv; @@ -2827,7 +2837,7 @@ getopt(nargc,nargv,ostr)  {  	static char	*place = EMSG;	/* option letter processing */  	static char	atend = 0; -	register char	*oli;		/* option letter list index */ +	register char	*oli = NULL;	/* option letter list index */  	if (atend) {  		atend = 0; @@ -3844,7 +3854,7 @@ chownsafe(fd, safedir)  	bool safedir;  {  #if (!defined(_POSIX_CHOWN_RESTRICTED) || _POSIX_CHOWN_RESTRICTED != -1) && \ -    defined(_PC_CHOWN_RESTRICTED) +    (defined(_PC_CHOWN_RESTRICTED) || defined(_GNU_TYPES_H))  	int rval;  	/* give the system administrator a chance to override */ diff --git a/usr.sbin/sendmail/src/conf.h b/usr.sbin/sendmail/src/conf.h index 7414904429d7..de37c145b782 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.328 (Berkeley) 8/3/97 + *	@(#)conf.h	8.335 (Berkeley) 10/24/97   */  /* @@ -294,7 +294,9 @@ typedef int		pid_t;    define BSD_REMAP_SIGNAL_TO_SIGVEC      RTisms needed above */  /* make this sendmail in a completely different place */ -# define _PATH_VENDORCF		"/usr/local/newmail/sendmail.cf" +# ifndef _PATH_VENDOR_CF +#  define _PATH_VENDOR_CF	"/usr/local/newmail/sendmail.cf" +# endif  # ifndef _PATH_SENDMAILPID  #  define _PATH_SENDMAILPID	"/usr/local/newmail/sendmail.pid"  # endif @@ -348,6 +350,7 @@ typedef int		pid_t;  # ifdef IRIX6  #  define LA_TYPE	LA_IRIX6	/* figure out at run time */  #  define SAFENFSPATHCONF 0	/* pathconf(2) lies on NFS filesystems */ +#  define SYSLOG_BUFSIZE 512  # else  #  define LA_TYPE	LA_INT @@ -382,7 +385,6 @@ typedef int		pid_t;  # include <sys/time.h>  # 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 HASFCHMOD	1	/* has fchmod(2) syscall */  # define IP_SRCROUTE	1	/* can check IP source routing */  # define SAFENFSPATHCONF 1	/* pathconf(2) pessimizes on NFS filesystems */ @@ -438,6 +440,7 @@ typedef int		pid_t;  # else  			/* SunOS 4.0.3 or 4.1.x */ +#  define HASGETUSERSHELL 1	/* DOES have getusershell(3) call in libc */  #  define HASSETREUID	1	/* has setreuid(2) call */  #  ifndef HASFLOCK  #   define HASFLOCK	1	/* has flock(2) call */ @@ -903,6 +906,7 @@ extern int		errno;  #if _SCO_DS >= 1  # include <paths.h>  # define _SCO_unix_4_2 +# define SIOCGIFNUM_IS_BROKEN 1	/* SIOCGIFNUM returns bogus value */  # define HASSNPRINTF	1	/* has snprintf(3) call */  # define HASFCHMOD	1	/* has fchmod(2) call */  # define HASSETRLIMIT	1	/* has setrlimit(2) call */ @@ -1188,6 +1192,7 @@ extern void		*malloc();  #  define LA_TYPE	LA_PROCSTR  # endif  # define SFS_TYPE	SFS_VFS		/* use <sys/vfs.h> statfs() impl */ +# define SPT_PADCHAR	'\0'		/* pad process title with nulls */  # ifndef _PATH_SENDMAILPID  #  define _PATH_SENDMAILPID	"/var/run/sendmail.pid"  # endif @@ -1224,6 +1229,7 @@ extern void		*malloc();  # define BSD			/* has BSD routines */  # define HASSETRLIMIT	0	/* ... but not setrlimit(2) */  # define BROKEN_RES_SEARCH 1	/* res_search(unknown) returns h_errno=0 */ +# define BOGUS_O_EXCL	1	/* exclusive open follows symlinks */  # define HASUNAME	1	/* use System V uname(2) system call */  # define HASFCHMOD	1	/* has fchmod(2) syscall */  # define HASINITGROUPS	1	/* has initgroups(3) call */ @@ -1836,6 +1842,15 @@ typedef struct msgb		mblk_t;  # undef offsetof	/* avoid stddefs.h and sys/sysmacros.h conflict */  #endif +/* +**  Siemens Nixdorf Informationssysteme AG SINIX  +** +**	Contributed by Gerald Rinske <Gerald.Rinske@mch.sni.de> +**	of Siemens Business Services VAS. +*/ +#ifdef _sinix_ +# define SYSLOG_BUFSIZE		1024 +#endif  /**********************************************************************  **  End of Per-Operating System defines diff --git a/usr.sbin/sendmail/src/daemon.c b/usr.sbin/sendmail/src/daemon.c index bc8fd6f1e906..e62aaf147d5f 100644 --- a/usr.sbin/sendmail/src/daemon.c +++ b/usr.sbin/sendmail/src/daemon.c @@ -37,9 +37,9 @@  #ifndef lint  #ifdef DAEMON -static char sccsid[] = "@(#)daemon.c	8.186 (Berkeley) 8/2/97 (with daemon mode)"; +static char sccsid[] = "@(#)daemon.c	8.195 (Berkeley) 10/23/97 (with daemon mode)";  #else -static char sccsid[] = "@(#)daemon.c	8.186 (Berkeley) 8/2/97 (without daemon mode)"; +static char sccsid[] = "@(#)daemon.c	8.195 (Berkeley) 10/23/97 (without daemon mode)";  #endif  #endif /* not lint */ @@ -103,9 +103,7 @@ static char sccsid[] = "@(#)daemon.c	8.186 (Berkeley) 8/2/97 (without daemon mod  **		e -- the current envelope.  **  **	Returns: -**		TRUE -- if a "null server" should be used -- that is, one -**			that rejects all commands. -**		FALSE -- to use a normal server. +**		none.  **  **	Side Effects:  **		Waits until some interesting activity occurs.  When @@ -122,7 +120,7 @@ int		ListenQueueSize = 10;		/* size of listen queue */  int		TcpRcvBufferSize = 0;		/* size of TCP receive buffer */  int		TcpSndBufferSize = 0;		/* size of TCP send buffer */ -bool +void  getrequests(e)  	ENVELOPE *e;  { @@ -188,7 +186,7 @@ getrequests(e)  	*/  	if (tTd(15, 1)) -		printf("getrequests: port 0x%x\n", DaemonAddr.sin.sin_port); +		printf("getrequests: port 0x%x\n", port);  	/* get a socket for the SMTP connection */  	socksize = opendaemonsocket(TRUE); @@ -238,7 +236,7 @@ getrequests(e)  		/* see if we are rejecting connections */  		(void) blocksignal(SIGALRM); -		if (refuseconnections(ntohs(DaemonAddr.sin.sin_port))) +		if (refuseconnections(ntohs(port)))  		{  			if (DaemonSocket >= 0)  			{ @@ -284,7 +282,7 @@ getrequests(e)  		/* wait for a connection */  		setproctitle("accepting connections on port %d", -			     ntohs(DaemonAddr.sin.sin_port)); +			     ntohs(port));  #if 0  		/*  		**  Andrew Sun <asun@ieps-sun.ml.com> claims that this will @@ -372,7 +370,6 @@ getrequests(e)  			char *p;  			extern SIGFUNC_DECL intsig __P((int));  			FILE *inchannel, *outchannel; -			bool nullconn;  			/*  			**  CHILD -- return to caller. @@ -437,13 +434,6 @@ getrequests(e)  			/* open maps for check_relay ruleset */  			initmaps(FALSE, e); -			/* validate the connection */ -			HoldErrs = TRUE; -			nullconn = !validate_connection(&RealHostAddr, RealHostName, e); -			HoldErrs = FALSE; -			if (nullconn) -				break; -  #ifdef XLA  			if (!xla_host_ok(RealHostName))  			{ @@ -452,9 +442,7 @@ getrequests(e)  			}  #endif -			if (tTd(15, 2)) -				printf("getreq: returning (normal server)\n"); -			return FALSE; +			break;  		}  		/* parent -- keep track of children */ @@ -473,8 +461,8 @@ getrequests(e)  			(void) close(pipefd[1]);  	}  	if (tTd(15, 2)) -		printf("getreq: returning (null server)\n"); -	return TRUE; +		printf("getreq: returning\n"); +	return;  }  /*  **  OPENDAEMONSOCKET -- open the SMTP socket @@ -1265,7 +1253,7 @@ getauthinfo(fd)  	int nleft;  	struct hostent *hp;  	char **ha; -	bool may_be_forged; +	volatile bool may_be_forged;  	char ibuf[MAXNAME + 1];  	static char hbuf[MAXNAME * 2 + 2]; @@ -1750,6 +1738,7 @@ host_map_lookup(map, name, av, statp)  	}  	/* found a match -- copy out */ +	hp->h_name = denlstring((char *) hp->h_name, TRUE, TRUE);  	s->s_namecanon.nc_stat = *statp = EX_OK;  	s->s_namecanon.nc_cname = newstr(hp->h_name);  	if (bitset(MF_MATCHONLY, map->map_mflags)) @@ -2027,7 +2016,9 @@ hostnamebyanyaddr(sap)  #endif /* NAMED_BIND */  	if (hp != NULL && hp->h_name[0] != '[') -		return (char *) hp->h_name; +		return denlstring((char *) hp->h_name, TRUE, TRUE); +	else if (sap->sa.sa_family == AF_UNIX && sap->sunix.sun_path[0] == '\0') +		return "localhost";  	else  	{  		/* produce a dotted quad */ diff --git a/usr.sbin/sendmail/src/deliver.c b/usr.sbin/sendmail/src/deliver.c index 741af15de1dd..957551590fcd 100644 --- a/usr.sbin/sendmail/src/deliver.c +++ b/usr.sbin/sendmail/src/deliver.c @@ -33,7 +33,7 @@   */  #ifndef lint -static char sccsid[] = "@(#)deliver.c	8.285 (Berkeley) 8/2/97"; +static char sccsid[] = "@(#)deliver.c	8.296 (Berkeley) 10/22/97";  #endif /* not lint */  #include "sendmail.h" @@ -44,6 +44,10 @@ static char sccsid[] = "@(#)deliver.c	8.285 (Berkeley) 8/2/97";  extern int	h_errno;  #endif +#if HASSETUSERCONTEXT +# include <login_cap.h> +#endif +  #if SMTP  extern char	SmtpError[];  #endif @@ -77,7 +81,7 @@ sendall(e, mode)  	register ENVELOPE *ee;  	ENVELOPE *splitenv = NULL;  	int oldverbose = Verbose; -	bool somedeliveries = FALSE; +	bool somedeliveries = FALSE, expensive = FALSE;  	pid_t pid;  	extern void sendenvelope(); @@ -281,6 +285,7 @@ sendall(e, mode)  				if (tTd(13, 30))  					printf("    ... expensive\n");  				q->q_flags |= QQUEUEUP; +				expensive = TRUE;  			}  			else  			{ @@ -393,11 +398,13 @@ sendall(e, mode)  		/* treat this as a delivery in terms of counting tries */  		e->e_dtime = curtime(); -		e->e_ntries++; +		if (!expensive) +			e->e_ntries++;  		for (ee = splitenv; ee != NULL; ee = ee->e_sibling)  		{  			ee->e_dtime = curtime(); -			ee->e_ntries++; +			if (!expensive) +				ee->e_ntries++;  		}  	} @@ -466,34 +473,13 @@ sendall(e, mode)  		/*  		**  Since fcntl locking has the interesting semantic that  		**  the lock is owned by a process, not by an open file -		**  descriptor, we have to flush this to the queue, and +		**  descriptor, we have to unlock this envelope, and  		**  then restart from scratch in the child.  		*/ -		{ -			/* save id for future use */ -			char *qid = e->e_id; - -			/* now drop the envelope in the parent */ -			e->e_flags |= EF_INQUEUE; -			dropenvelope(e, FALSE); - -			/* arrange to reacquire lock after fork */ -			e->e_id = qid; -		} - +		unlockqueue(e);  		for (ee = splitenv; ee != NULL; ee = ee->e_sibling) -		{ -			/* save id for future use */ -			char *qid = ee->e_id; - -			/* drop envelope in parent */ -			ee->e_flags |= EF_INQUEUE; -			dropenvelope(ee, FALSE); - -			/* and save qid for reacquisition */ -			ee->e_id = qid; -		} +			unlockqueue(ee);  # endif /* !HASFLOCK */ @@ -1368,7 +1354,7 @@ tryhost:  					hostbuf, m->m_name);  			else  				message("Connecting to %s port %d via %s...", -					hostbuf, port, m->m_name); +					hostbuf, ntohs(port), m->m_name);  			i = makeconnection(hostbuf, port, mci, e);  			mci->mci_lastuse = curtime();  			mci->mci_exitstat = i; @@ -1577,7 +1563,7 @@ tryhost:  					pwd = sm_getpwnam(contextaddr->q_user);  				if (pwd != NULL)  					(void) setusercontext(NULL, -						pwd, pwd->m_uid, +						pwd, pwd->pw_uid,  						LOGIN_SETRESOURCES|LOGIN_SETPRIORITY);  			}  #endif @@ -1901,7 +1887,7 @@ tryhost:  			for (to = tochain; to != NULL; to = to->q_tchain)  			{  				e->e_to = to->q_paddr; -				if (strlen(to->q_paddr) + (t - tobuf) + 2 >= sizeof tobuf) +				if (strlen(to->q_paddr) + (t - tobuf) + 2 > sizeof tobuf)  				{  					/* not enough room */  					continue; @@ -2244,6 +2230,8 @@ endmailer(mci, e, pv)  {  	int st; +	mci_unlock_host(mci); +  	/* close any connections */  	if (mci->mci_in != NULL)  		(void) xfclose(mci->mci_in, mci->mci_mailer->m_name, "mci_in"); @@ -2331,6 +2319,9 @@ giveresponse(stat, m, mci, ctladdr, xstart, e)  	extern int N_SysEx;  	char buf[MAXLINE]; +	if (e == NULL) +		syserr("giveresponse: null envelope"); +  	/*  	**  Compute status message from code.  	*/ @@ -2428,7 +2419,8 @@ giveresponse(stat, m, mci, ctladdr, xstart, e)  	**	that.  	*/ -	if (LogLevel > ((stat == EX_TEMPFAIL) ? 8 : (stat == EX_OK) ? 7 : 6)) +	if (OpMode != MD_VERIFY && !bitset(EF_VRFYONLY, e->e_flags) && +	    LogLevel > ((stat == EX_TEMPFAIL) ? 8 : (stat == EX_OK) ? 7 : 6))  		logdelivery(m, mci, &statmsg[4], ctladdr, xstart, e);  	if (tTd(11, 2)) @@ -2741,7 +2733,7 @@ putfromline(mci, e)  		}  	}  	expand(template, buf, sizeof buf, e); -	putxline(buf, strlen(buf), mci, PXLF_NOTHINGSPECIAL); +	putxline(buf, strlen(buf), mci, PXLF_HEADER);  }  /*  **  PUTBODY -- put the body of a message. @@ -3096,17 +3088,21 @@ endofmessage:  **		none.  */ +static jmp_buf	CtxMailfileTimeout; +static void	mailfiletimeout(); +  int  mailfile(filename, ctladdr, sfflags, e) -	char *filename; +	char *volatile filename;  	ADDRESS *ctladdr; -	int sfflags; +	volatile int sfflags;  	register ENVELOPE *e;  {  	register FILE *f;  	register pid_t pid = -1; -	int mode = ST_MODE_NOFILE; +	volatile int mode = ST_MODE_NOFILE;  	bool suidwarn = geteuid() == 0; +	EVENT *ev;  	if (tTd(11, 1))  	{ @@ -3140,7 +3136,7 @@ mailfile(filename, ctladdr, sfflags, e)  		/* child -- actually write to file */  		struct stat stb;  		MCI mcibuf; -		int oflags = O_WRONLY|O_APPEND; +		volatile int oflags = O_WRONLY|O_APPEND;  		if (e->e_lockfp != NULL)  			(void) close(fileno(e->e_lockfp)); @@ -3152,6 +3148,16 @@ mailfile(filename, ctladdr, sfflags, e)  		e->e_to = filename;  		ExitStat = EX_OK; +		if (setjmp(CtxMailfileTimeout) != 0) +		{ +			exit(EX_TEMPFAIL); +		} + +		if (TimeOuts.to_fileopen > 0) +			ev = setevent(TimeOuts.to_fileopen, mailfiletimeout, 0); +		else +			ev = NULL; +  #ifdef HASLSTAT  		if (lstat(filename, &stb) < 0)  #else @@ -3287,6 +3293,9 @@ mailfile(filename, ctladdr, sfflags, e)  			exit(EX_CANTCREAT);  		} +		if (ev != NULL) +			clrevent(ev); +  		bzero(&mcibuf, sizeof mcibuf);  		mcibuf.mci_mailer = FileMailer;  		mcibuf.mci_out = f; @@ -3332,6 +3341,12 @@ mailfile(filename, ctladdr, sfflags, e)  	}  	return EX_UNAVAILABLE;	/* avoid compiler warning on IRIX */  } + +static void +mailfiletimeout() +{ +	longjmp(CtxMailfileTimeout, 1); +}  /*  **  HOSTSIGNATURE -- return the "signature" for a host.  ** diff --git a/usr.sbin/sendmail/src/err.c b/usr.sbin/sendmail/src/err.c index f4f95e6cd0f2..f08d9609d8eb 100644 --- a/usr.sbin/sendmail/src/err.c +++ b/usr.sbin/sendmail/src/err.c @@ -33,7 +33,7 @@   */  #ifndef lint -static char sccsid[] = "@(#)err.c	8.64 (Berkeley) 7/25/97"; +static char sccsid[] = "@(#)err.c	8.65 (Berkeley) 10/18/97";  #endif /* not lint */  # include "sendmail.h" @@ -556,7 +556,9 @@ fmtmsg(eb, to, num, eno, fmt, ap)  	}  	/* output the "to" person */ -	if (to != NULL && to[0] != '\0') +	if (to != NULL && to[0] != '\0' && +	    strncmp(num, "551", 3) != 0 && +	    strncmp(num, "251", 3) != 0)  	{  		(void) snprintf(eb, spaceleft, "%s... ",  			shortenstring(to, 203)); diff --git a/usr.sbin/sendmail/src/headers.c b/usr.sbin/sendmail/src/headers.c index 5bfd40003310..857e9c32da10 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.111 (Berkeley) 7/9/97"; +static char sccsid[] = "@(#)headers.c	8.115 (Berkeley) 10/22/97";  #endif /* not lint */  # include <errno.h> @@ -522,9 +522,16 @@ eatheader(e, full)  			(void) sendtolist(h->h_value, NULLADDR,  					  &e->e_sendqueue, 0, e); +#if 0 +			/* +			** Change functionality so a fatal error on an +			** address doesn't affect the entire envelope. +			*/ +			   			/* delete fatal errors generated by this address */ -			if (!GrabTo && !bitset(EF_FATALERRS, saveflags)) +			if (!bitset(EF_FATALERRS, saveflags))  				e->e_flags &= ~EF_FATALERRS; +#endif  		}  		/* save the message-id for logging */ @@ -1330,7 +1337,7 @@ put_vanilla_header(h, v, mci)  	int putflags;  	char obuf[MAXLINE]; -	putflags = 0; +	putflags = PXLF_HEADER;  #if _FFR_7BITHDRS  	if (bitnset(M_7BITHDRS, mci->mci_mailer->m_flags))  		putflags |= PXLF_STRIP8BIT; @@ -1342,8 +1349,8 @@ put_vanilla_header(h, v, mci)  		int l;  		l = nlp - v; -		if (sizeof obuf - (obp - obuf) < l) -			l = sizeof obuf - (obp - obuf); +		if (SPACELEFT(obuf, obp) - 1 < l) +			l = SPACELEFT(obuf, obp) - 1;  		snprintf(obp, SPACELEFT(obuf, obp), "%.*s", l, v);  		putxline(obuf, strlen(obuf), mci, putflags); @@ -1385,7 +1392,7 @@ commaize(h, p, oldstyle, mci, e)  	int opos;  	int omax;  	bool firstone = TRUE; -	int putflags = 0; +	int putflags = PXLF_HEADER;  	char obuf[MAXLINE + 3];  	/* @@ -1491,6 +1498,7 @@ commaize(h, p, oldstyle, mci, e)  			*p = savechar;  			continue;  		} +		name = denlstring(name, FALSE, TRUE);  		/* output the name with nice formatting */  		opos += strlen(name); diff --git a/usr.sbin/sendmail/src/main.c b/usr.sbin/sendmail/src/main.c index 5a303822edc2..c496adb78eed 100644 --- a/usr.sbin/sendmail/src/main.c +++ b/usr.sbin/sendmail/src/main.c @@ -39,7 +39,7 @@ static char copyright[] =  #endif /* not lint */  #ifndef lint -static char sccsid[] = "@(#)main.c	8.249 (Berkeley) 7/25/97"; +static char sccsid[] = "@(#)main.c	8.258 (Berkeley) 10/20/97";  #endif /* not lint */  #define	_DEFINE @@ -50,10 +50,6 @@ static char sccsid[] = "@(#)main.c	8.249 (Berkeley) 7/25/97";  #include <resolv.h>  #endif -# ifdef lint -char	edata, end; -# endif /* lint */ -  /*  **  SENDMAIL -- Post mail to a set of destinations.  ** @@ -122,7 +118,6 @@ main(argc, argv, envp)  	char **av;  	extern char Version[];  	char *ep, *from; -	typedef int (*fnptr)();  	STAB *st;  	register int i;  	int j; @@ -133,7 +128,6 @@ main(argc, argv, envp)  	bool run_in_foreground = FALSE;	/* -bD mode */  	static bool reenter = FALSE;  	struct passwd *pw; -	struct stat stb;  	struct hostent *hp;  	bool nullserver = FALSE;  	char jbuf[MAXHOSTNAMELEN];	/* holds MyHostName */ @@ -436,6 +430,8 @@ main(argc, argv, envp)  		res_init();  	if (tTd(8, 8))  		_res.options |= RES_DEBUG; +	else +		_res.options &= ~RES_DEBUG;  # ifdef RES_NOALIASES  	_res.options |= RES_NOALIASES;  # endif @@ -832,6 +828,15 @@ main(argc, argv, envp)  	ConfigFileRead = TRUE;  	vendor_post_defaults(CurEnv); +	/* Enforce use of local time (null string overrides this) */ +	if (TimeZoneSpec == NULL) +		unsetenv("TZ"); +	else if (TimeZoneSpec[0] != '\0') +		setuserenv("TZ", TimeZoneSpec); +	else +		setuserenv("TZ", NULL); +	tzset(); +  	/* avoid denial-of-service attacks */  	resetlimits(); @@ -903,15 +908,6 @@ main(argc, argv, envp)  	if (DefaultNotify == 0)  		DefaultNotify = QPINGONFAILURE|QPINGONDELAY; -	/* Enforce use of local time (null string overrides this) */ -	if (TimeZoneSpec == NULL) -		unsetenv("TZ"); -	else if (TimeZoneSpec[0] != '\0') -		setuserenv("TZ", TimeZoneSpec); -	else -		setuserenv("TZ", NULL); -	tzset(); -  	/* be sure we don't pick up bogus HOSTALIASES environment variable */  	if (queuemode && RealUid != 0)  		(void) unsetenv("HOSTALIASES"); @@ -1321,7 +1317,7 @@ main(argc, argv, envp)  	if (OpMode == MD_DAEMON || QueueIntvl != 0)  	{  		char dtype[200]; -		extern bool getrequests __P((ENVELOPE *)); +		extern void getrequests __P((ENVELOPE *));  		if (!run_in_foreground && !tTd(99, 100))  		{ @@ -1371,7 +1367,7 @@ main(argc, argv, envp)  		dropenvelope(CurEnv, TRUE);  #if DAEMON -		nullserver = getrequests(CurEnv); +		getrequests(CurEnv);  		/* drop privileges */  		(void) drop_privileges(FALSE); @@ -1385,6 +1381,11 @@ main(argc, argv, envp)  		p = getauthinfo(fileno(InChannel));  		define('_', p, &BlankEnvelope); + +		/* validate the connection */ +		HoldErrs = TRUE; +		nullserver = !validate_connection(&RealHostAddr, RealHostName, CurEnv); +		HoldErrs = FALSE;  #endif /* DAEMON */  	} @@ -1476,10 +1477,9 @@ main(argc, argv, envp)  		CurEnv->e_flags &= ~EF_FATALERRS;  		collect(InChannel, FALSE, NULL, CurEnv); -		/* bail out if there were fatal errors in collect */ -		if (OpMode != MD_VERIFY && bitset(EF_FATALERRS, CurEnv->e_flags)) +		/* bail out if message too large */ +		if (bitset(EF_CLRQUEUE, CurEnv->e_flags))  		{ -			CurEnv->e_flags |= EF_CLRQUEUE;  			finis();  			/*NOTREACHED*/  			return -1; @@ -2047,7 +2047,7 @@ sighup(sig)  				RunAsUid, RunAsGid);  		exit(EX_OSERR);  	} -	execv(SaveArgv[0], (ARGV_T) SaveArgv); +	execve(SaveArgv[0], (ARGV_T) SaveArgv, (ARGV_T) ExternalEnviron);  	if (LogLevel > 0)  		sm_syslog(LOG_ALERT, NOQID, "could not exec %s: %m", SaveArgv[0]);  	exit(EX_OSFILE); @@ -2089,14 +2089,14 @@ drop_privileges(to_real_uid)  #ifdef NGROUPS_MAX  	/* reset group permissions; these can be set later */ -	emptygidset[0] = RunAsGid == 0 ? getegid() : RunAsGid; +	emptygidset[0] = (to_real_uid || RunAsGid != 0) ? RunAsGid : getegid();  	(void) setgroups(1, emptygidset);  #endif  	/* reset primary group and user id */ -	if (RunAsGid != 0 && setgid(RunAsGid) < 0) +	if ((to_real_uid || RunAsGid != 0) && setgid(RunAsGid) < 0)  		rval = EX_OSERR; -	if (RunAsUid != 0 && setuid(RunAsUid) < 0) +	if ((to_real_uid || RunAsUid != 0) && setuid(RunAsUid) < 0)  		rval = EX_OSERR;  	return rval;  } diff --git a/usr.sbin/sendmail/src/map.c b/usr.sbin/sendmail/src/map.c index 88e82b19f98a..e88973660957 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.181 (Berkeley) 7/9/97"; +static char sccsid[] = "@(#)map.c	8.186 (Berkeley) 10/21/97";  #endif /* not lint */  #include "sendmail.h" @@ -402,8 +402,8 @@ map_rewrite(map, s, slen, av)  **  **	Side Effects:  **		initializes aliases: -**		if NDBM:  opens the database. -**		if ~NDBM: reads the aliases into the symbol table. +**		if alias database:  opens the database. +**		if no database available: reads aliases into the symbol table.  */  void @@ -417,25 +417,20 @@ initmaps(rebuild, e)  	checkfd012("entering initmaps");  #endif  	CurEnv = e; -	if (rebuild) -	{ -		stabapply(map_init, 1); -		stabapply(map_init, 2); -	} -	else -	{ -		stabapply(map_init, 0); -	} + +	stabapply(map_init, 0); +	stabapply(map_init, rebuild ? 2 : 1);  #if XDEBUG  	checkfd012("exiting initmaps");  #endif  }  void -map_init(s, rebuild) +map_init(s, pass)  	register STAB *s; -	int rebuild; +	int pass;  { +	bool rebuildable;  	register MAP *map;  	/* has to be a map */ @@ -452,13 +447,23 @@ map_init(s, rebuild)  				map->map_class->map_cname,  			map->map_mname == NULL ? "NULL" : map->map_mname,  			map->map_file == NULL ? "NULL" : map->map_file, -			rebuild); +			pass); + +	/* +	** Pass 0 opens all non-rebuildable maps. +	** Pass 1 opens all rebuildable maps for read. +	** Pass 2 rebuilds all rebuildable maps. +	*/ + +	rebuildable = (bitset(MF_ALIAS, map->map_mflags) && +		       bitset(MCF_REBUILDABLE, map->map_class->map_cflags)); -	if (rebuild == (bitset(MF_ALIAS, map->map_mflags) && -		    bitset(MCF_REBUILDABLE, map->map_class->map_cflags) ? 1 : 2)) +	if ((pass == 0 && rebuildable) || +	    ((pass == 1 || pass == 2) && !rebuildable))  	{  		if (tTd(38, 3)) -			printf("\twrong pass\n"); +			printf("\twrong pass (pass = %d, rebuildable = %d)\n", +			       pass, rebuildable);  		return;  	} @@ -468,43 +473,42 @@ map_init(s, rebuild)  		map->map_class->map_close(map);  		map->map_mflags &= ~(MF_OPEN|MF_WRITABLE);  	} - -	if (rebuild == 2) +		 +	if (pass == 2)  	{  		rebuildaliases(map, FALSE); +		return; +	} + +	if (map->map_class->map_open(map, O_RDONLY)) +	{ +		if (tTd(38, 4)) +			printf("\t%s:%s %s: valid\n", +				map->map_class->map_cname == NULL ? "NULL" : +					map->map_class->map_cname, +				map->map_mname == NULL ? "NULL" : +					map->map_mname, +				map->map_file == NULL ? "NULL" : +					map->map_file); +		map->map_mflags |= MF_OPEN;  	}  	else  	{ -		if (map->map_class->map_open(map, O_RDONLY)) -		{ -			if (tTd(38, 4)) -				printf("\t%s:%s %s: valid\n", -					map->map_class->map_cname == NULL ? "NULL" : -						map->map_class->map_cname, -					map->map_mname == NULL ? "NULL" : -						map->map_mname, -					map->map_file == NULL ? "NULL" : -						map->map_file); -			map->map_mflags |= MF_OPEN; -		} -		else +		if (tTd(38, 4)) +			printf("\t%s:%s %s: invalid: %s\n", +				map->map_class->map_cname == NULL ? "NULL" : +					map->map_class->map_cname, +				map->map_mname == NULL ? "NULL" : +					map->map_mname, +				map->map_file == NULL ? "NULL" : +					map->map_file, +				errstring(errno)); +		if (!bitset(MF_OPTIONAL, map->map_mflags))  		{ -			if (tTd(38, 4)) -				printf("\t%s:%s %s: invalid: %s\n", -					map->map_class->map_cname == NULL ? "NULL" : -						map->map_class->map_cname, -					map->map_mname == NULL ? "NULL" : -						map->map_mname, -					map->map_file == NULL ? "NULL" : -						map->map_file, -					errstring(errno)); -			if (!bitset(MF_OPTIONAL, map->map_mflags)) -			{ -				extern MAPCLASS BogusMapClass; +			extern MAPCLASS BogusMapClass; -				map->map_class = &BogusMapClass; -				map->map_mflags |= MF_OPEN; -			} +			map->map_class = &BogusMapClass; +			map->map_mflags |= MF_OPEN;  		}  	}  } @@ -781,14 +785,6 @@ ndbm_map_open(map, mode)  	if (std.st_mode == ST_MODE_NOFILE)  		mode |= O_CREAT|O_EXCL; -	/* heuristic: if files are linked, this is actually gdbm */ -	if (std.st_dev == stp.st_dev && std.st_ino == stp.st_ino) -	{ -		syserr("dbm map \"%s\": cannot support GDBM", -			map->map_mname); -		return FALSE; -	} -  #if LOCK_ON_OPEN  	if (mode == O_RDONLY)  		mode |= O_SHLOCK; @@ -891,6 +887,20 @@ ndbm_map_open(map, mode)  	}  	dfd = dbm_dirfno(dbm);  	pfd = dbm_pagfno(dbm); +	if (dfd == pfd) +	{ +		/* heuristic: if files are linked, this is actually gdbm */ +		dbm_close(dbm); +#if !LOCK_ON_OPEN && !NOFTRUNCATE +		if (map->map_lockfd >= 0) +			close(map->map_lockfd); +#endif +		errno = 0; +		syserr("dbm map \"%s\": cannot support GDBM", +			map->map_mname); +		return FALSE; +	} +  	if (filechanged(dirfile, dfd, &std, sff) ||  	    filechanged(pagfile, pfd, &stp, sff))  	{ @@ -944,6 +954,7 @@ ndbm_map_lookup(map, name, av, statp)  	datum key, val;  	int fd;  	char keybuf[MAXNAME + 1]; +	struct stat stbuf;  	if (tTd(38, 20))  		printf("ndbm_map_lookup(%s, %s)\n", @@ -960,9 +971,40 @@ ndbm_map_lookup(map, name, av, statp)  		makelower(keybuf);  		key.dptr = keybuf;  	} +lockdbm:  	fd = dbm_dirfno((DBM *) map->map_db1);  	if (fd >= 0 && !bitset(MF_LOCKED, map->map_mflags))  		(void) lockfile(fd, map->map_file, ".dir", LOCK_SH); +	if (fd < 0 || fstat(fd, &stbuf) < 0 || stbuf.st_mtime > map->map_mtime)  +	{ +		/* Reopen the database to sync the cache */ +		int omode = bitset(map->map_mflags, MF_WRITABLE) ? O_RDWR +								 : O_RDONLY; + +		map->map_class->map_close(map); +		map->map_mflags &= ~(MF_OPEN|MF_WRITABLE); +		if (map->map_class->map_open(map, omode))  +		{ +			map->map_mflags |= MF_OPEN; +			if ((omode && O_ACCMODE) == O_RDWR) +				map->map_mflags |= MF_WRITABLE; +			goto lockdbm; +		} +		else +		{ +			if (!bitset(MF_OPTIONAL, map->map_mflags))  +			{ +				extern MAPCLASS BogusMapClass; + +				*statp = EX_TEMPFAIL; +				map->map_class = &BogusMapClass; +				map->map_mflags |= MF_OPEN; +				syserr("Cannot reopen NDBM database %s", +					map->map_file); +			} +			return NULL; +		} +	}  	val.dptr = NULL;  	if (bitset(MF_TRY0NULL, map->map_mflags))  	{ @@ -2489,7 +2531,7 @@ ldap_map_lookup(map, name, av, statp)  					filter, map->map_mname);  			}  			result = NULL; -			*statp = EX_UNAVAILABLE; +			*statp = EX_TEMPFAIL;  			goto quick_exit;  		}  	} diff --git a/usr.sbin/sendmail/src/parseaddr.c b/usr.sbin/sendmail/src/parseaddr.c index 75b90898f218..783183470436 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.130 (Berkeley) 8/2/97"; +static char sccsid[] = "@(#)parseaddr.c	8.132 (Berkeley) 10/20/97";  #endif /* not lint */  # include "sendmail.h" @@ -1859,6 +1859,7 @@ struct qflags	AddressFlags[] =  	{ "QDELIVERED",		QDELIVERED	},  	{ "QDELAYED",		QDELAYED	},  	{ "QTHISPASS",		QTHISPASS	}, +	{ "QRCPTOK",		QRCPTOK		},  	{ NULL }  }; @@ -2136,7 +2137,11 @@ maplocaluser(a, sendq, aliaslevel, e)  	}  	pvp = prescan(a->q_user, '\0', pvpbuf, sizeof pvpbuf, &delimptr, NULL);  	if (pvp == NULL) +	{ +		if (tTd(29, 9)) +			printf("maplocaluser: cannot prescan %s\n", a->q_user);  		return; +	}  	define('h', a->q_host, e);  	define('u', a->q_user, e); @@ -2144,17 +2149,25 @@ maplocaluser(a, sendq, aliaslevel, e)  	if (rewrite(pvp, 5, 0, e) == EX_TEMPFAIL)  	{ +		if (tTd(29, 9)) +			printf("maplocaluser: rewrite tempfail\n");  		a->q_flags |= QQUEUEUP;  		a->q_status = "4.4.3";  		return;  	}  	if (pvp[0] == NULL || (pvp[0][0] & 0377) != CANONNET) +	{ +		if (tTd(29, 9)) +			printf("maplocaluser: doesn't resolve\n");  		return; +	}  	/* if non-null, mailer destination specified -- has it changed? */  	a1 = buildaddr(pvp, NULL, 0, e);  	if (a1 == NULL || sameaddr(a, a1))  	{ +		if (tTd(29, 9)) +			printf("maplocaluser: address unchanged\n");  		if (a1 != NULL)  			free(a1);  		return; diff --git a/usr.sbin/sendmail/src/queue.c b/usr.sbin/sendmail/src/queue.c index 1d812b8f50d6..d48efb1179b7 100644 --- a/usr.sbin/sendmail/src/queue.c +++ b/usr.sbin/sendmail/src/queue.c @@ -36,9 +36,9 @@  #ifndef lint  #if QUEUE -static char sccsid[] = "@(#)queue.c	8.174 (Berkeley) 7/23/97 (with queueing)"; +static char sccsid[] = "@(#)queue.c	8.175 (Berkeley) 10/4/97 (with queueing)";  #else -static char sccsid[] = "@(#)queue.c	8.174 (Berkeley) 7/23/97 (without queueing)"; +static char sccsid[] = "@(#)queue.c	8.175 (Berkeley) 10/4/97 (without queueing)";  #endif  #endif /* not lint */ @@ -474,7 +474,6 @@ printctladdr(a, tfp)  	FILE *tfp;  {  	char *uname; -	char *paddr;  	register ADDRESS *q;  	uid_t uid;  	gid_t gid; @@ -514,12 +513,12 @@ printctladdr(a, tfp)  	lastuid = uid;  	lastctladdr = a; -	paddr = denlstring(a->q_paddr, TRUE, FALSE);  	if (uid == 0 || uname == NULL || uname[0] == '\0') -		fprintf(tfp, "C:%s\n", paddr); +		fprintf(tfp, "C");  	else -		fprintf(tfp, "C%s:%ld:%ld:%s\n", -			uname, (long) uid, (long) gid, paddr); +		fprintf(tfp, "C%s:%ld:%ld", +			denlstring(uname, TRUE, FALSE), (long) uid, (long) gid); +	fprintf(tfp, ":%s\n", denlstring(a->q_paddr, TRUE, FALSE));  }  /*  **  RUNQUEUE -- run the jobs in the queue. diff --git a/usr.sbin/sendmail/src/readcf.c b/usr.sbin/sendmail/src/readcf.c index a1e42387fa89..681c3d3a1d7c 100644 --- a/usr.sbin/sendmail/src/readcf.c +++ b/usr.sbin/sendmail/src/readcf.c @@ -33,7 +33,7 @@   */  #ifndef lint -static char sccsid[] = "@(#)readcf.c	8.200 (Berkeley) 8/2/97"; +static char sccsid[] = "@(#)readcf.c	8.201 (Berkeley) 10/1/97";  #endif /* not lint */  # include "sendmail.h" @@ -1521,6 +1521,10 @@ struct optioninfo  #define O_DONTLOCK	0xa5  	{ "DontLockFilesForRead",	O_DONTLOCK,	FALSE	},  #endif +#if _FFR_MAXALIASRECURSION_OPTION +#define O_MAXALIASRCSN	0xa6 +	{ "MaxAliasRecursion",		O_MAXALIASRCSN,	FALSE	}, +#endif  	{ NULL,				'\0',		FALSE	}  }; @@ -2355,6 +2359,12 @@ setoption(opt, val, safe, sticky, e)  		break;  #endif +#if _FFR_MAXALIASRECURSION_OPTION +	  case O_MAXALIASRCSN: +		MaxAliasRecursion = atoi(val); +		break; +#endif +  	  default:  		if (tTd(37, 1))  		{ diff --git a/usr.sbin/sendmail/src/recipient.c b/usr.sbin/sendmail/src/recipient.c index 2076884f0903..adcce7acf835 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.130 (Berkeley) 5/29/97"; +static char sccsid[] = "@(#)recipient.c	8.133 (Berkeley) 10/19/97";  #endif /* not lint */  # include "sendmail.h" @@ -263,6 +263,7 @@ recipient(a, sendq, aliaslevel, e)  	/* break aliasing loops */  	if (aliaslevel > MaxAliasRecursion)  	{ +		a->q_flags |= QBADADDR;  		a->q_status = "5.4.6";  		usrerr("554 aliasing/forwarding loop broken (%d aliases deep; %d max)",  			aliaslevel, MaxAliasRecursion); @@ -327,7 +328,7 @@ recipient(a, sendq, aliaslevel, e)  	for (pq = sendq; (q = *pq) != NULL; pq = &q->q_next)  	{ -		if (sameaddr(q, a)) +		if (sameaddr(q, a) && bitset(QRCPTOK, q->q_flags))  		{  			if (tTd(26, 1))  			{ @@ -641,7 +642,7 @@ recipient(a, sendq, aliaslevel, e)  					a->q_paddr);  		}  	} - +	a->q_flags |= QRCPTOK;  	return (a);  }  /* @@ -922,7 +923,7 @@ include(fname, forwarding, ctladdr, sendq, aliaslevel, e)  	volatile int sfflags = SFF_REGONLY;  	register char *p;  	bool safechown = FALSE; -	bool safedir = FALSE; +	volatile bool safedir = FALSE;  	struct stat st;  	char buf[MAXLINE];  	extern bool chownsafe(); diff --git a/usr.sbin/sendmail/src/savemail.c b/usr.sbin/sendmail/src/savemail.c index 1d39df8c7678..76209dcc40e5 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.114 (Berkeley) 8/2/97"; +static char sccsid[] = "@(#)savemail.c	8.121 (Berkeley) 10/22/97";  #endif /* not lint */  # include "sendmail.h" @@ -85,7 +85,6 @@ savemail(e, sendbody)  	int flags;  	char buf[MAXLINE+1];  	extern char *ttypath(); -	typedef int (*fnptr)();  	extern bool writable();  	if (tTd(6, 1)) @@ -254,8 +253,29 @@ savemail(e, sendbody)  			}  			if (!emptyaddr(&e->e_from))  			{ -				(void) sendtolist(e->e_from.q_paddr, -					  NULLADDR, &e->e_errorqueue, 0, e); +				char from[TOBUFSIZE]; +				extern bool pruneroute __P((char *)); + +				if (strlen(e->e_from.q_paddr) + 1 > sizeof from) +				{ +					state = ESM_POSTMASTER; +					break; +				} +				strcpy(from, e->e_from.q_paddr); + +				if (!DontPruneRoutes && pruneroute(from)) +				{ +					ADDRESS *a; + +					for (a = e->e_errorqueue; a != NULL; +					     a = a->q_next) +					{ +						if (sameaddr(a, &e->e_from)) +							a->q_flags |= QDONTSEND; +					} +				} +				(void) sendtolist(from, NULLADDR, +						  &e->e_errorqueue, 0, e);  			}  			/* @@ -379,7 +399,7 @@ savemail(e, sendbody)  				break;  			} -			flags = SFF_NOLINK|SFF_CREAT|SFF_REGONLY|SFF_OPENASROOT|SFF_MUSTOWN; +			flags = SFF_NOLINK|SFF_CREAT|SFF_REGONLY|SFF_ROOTOK|SFF_OPENASROOT|SFF_MUSTOWN;  			if (!writable(DeadLetterDrop, NULL, flags) ||  			    (fp = safefopen(DeadLetterDrop, O_WRONLY|O_APPEND,  					    FileMode, flags)) == NULL) @@ -519,26 +539,12 @@ returntosender(msg, returnq, flags, e)  	initsys(ee);  	for (q = returnq; q != NULL; q = q->q_next)  	{ -		extern bool pruneroute __P((char *)); -  		if (bitset(QBADADDR, q->q_flags))  			continue;  		q->q_flags &= ~(QHASNOTIFY|Q_PINGFLAGS);  		q->q_flags |= QPINGONFAILURE; -		if (!DontPruneRoutes && pruneroute(q->q_paddr)) -		{ -			register ADDRESS *p; - -			parseaddr(q->q_paddr, q, RF_COPYPARSE, '\0', NULL, e); -			for (p = returnq; p != NULL; p = p->q_next) -			{ -				if (p != q && sameaddr(p, q)) -					q->q_flags |= QDONTSEND; -			} -		} -  		if (!bitset(QDONTSEND, q->q_flags))  			ee->e_nrcpts++; @@ -650,7 +656,7 @@ returntosender(msg, returnq, flags, e)  		return 0;  	for (q = ee->e_sendqueue; q != NULL; q = q->q_next)  	{ -		if (bitset(QSENT, q->q_flags)) +		if (bitset(QQUEUEUP|QSENT, q->q_flags))  			return 0;  	}  	return -1; @@ -681,7 +687,7 @@ errbody(mci, e, separator)  {  	register FILE *xfile;  	char *p; -	register ADDRESS *q; +	register ADDRESS *q = NULL;  	bool printheader;  	bool sendbody;  	bool pm_notify; @@ -1001,17 +1007,23 @@ errbody(mci, e, separator)  				p = "rfc822";  			for (r = q; r->q_alias != NULL; r = r->q_alias)  				continue; -			if (strchr(r->q_user, '@') == NULL) +			if (strchr(r->q_user, '@') != NULL)  			{  				(void) snprintf(buf, sizeof buf, -					"Final-Recipient: %s; %.700s@%.100s", -					p, r->q_user, MyHostName); +					"Final-Recipient: %s; %.800s", +					p, r->q_user);  			} -			else +			else if (strchr(r->q_paddr, '@') != NULL)  			{  				(void) snprintf(buf, sizeof buf,  					"Final-Recipient: %s; %.800s", -					p, r->q_user); +					p, r->q_paddr); +			} +			else +			{ +				(void) snprintf(buf, sizeof buf, +					"Final-Recipient: %s; %.700s@%.100s", +					p, r->q_user, MyHostName);  			}  			putline(buf, mci); diff --git a/usr.sbin/sendmail/src/sendmail.h b/usr.sbin/sendmail/src/sendmail.h index 00559ea1dffd..fc3bf4942ca0 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.242 (Berkeley) 8/2/97 + *	@(#)sendmail.h	8.245 (Berkeley) 10/22/97   */  /* @@ -41,7 +41,7 @@  # ifdef _DEFINE  # define EXTERN  # ifndef lint -static char SmailSccsId[] =	"@(#)sendmail.h	8.242		8/2/97"; +static char SmailSccsId[] =	"@(#)sendmail.h	8.245		10/22/97";  # endif  # else /*  _DEFINE */  # define EXTERN extern @@ -206,6 +206,7 @@ typedef struct address ADDRESS;  # define QDELIVERED	0x00040000	/* DSN: successful final delivery */  # define QDELAYED	0x00080000	/* DSN: message delayed */  # define QTHISPASS	0x40000000	/* temp: address set this pass */ +# define QRCPTOK	0x80000000	/* recipient() processed address */  # define Q_PINGFLAGS	(QPINGONSUCCESS|QPINGONFAILURE|QPINGONDELAY) @@ -928,6 +929,7 @@ EXTERN int		NoRecipientAction;  #define PXLF_NOTHINGSPECIAL	0	/* no special mapping */  #define PXLF_MAPFROM		0x0001	/* map From_ to >From_ */  #define PXLF_STRIP8BIT		0x0002	/* strip 8th bit */ +#define PXLF_HEADER		0x0004	/* map newlines in headers */  /*  **  Additional definitions  */ @@ -1231,7 +1233,6 @@ EXTERN int	MaxRuleRecursion;	/* maximum depth of ruleset recursion */  EXTERN char	*MustQuoteChars;	/* quote these characters in phrases */  EXTERN char	*ServiceSwitchFile;	/* backup service switch */  EXTERN char	*DefaultCharSet;	/* default character set for MIME */ -EXTERN int	DeliveryNiceness;	/* how nice to be during delivery */  EXTERN char	*PostMasterCopy;	/* address to get errs cc's */  EXTERN int	CheckpointInterval;	/* queue file checkpoint interval */  EXTERN bool	DontPruneRoutes;	/* don't prune source routes */ diff --git a/usr.sbin/sendmail/src/srvrsmtp.c b/usr.sbin/sendmail/src/srvrsmtp.c index 3255e83eeb80..cd47d5de9169 100644 --- a/usr.sbin/sendmail/src/srvrsmtp.c +++ b/usr.sbin/sendmail/src/srvrsmtp.c @@ -36,9 +36,9 @@  #ifndef lint  #if SMTP -static char sccsid[] = "@(#)srvrsmtp.c	8.154 (Berkeley) 8/2/97 (with SMTP)"; +static char sccsid[] = "@(#)srvrsmtp.c	8.159 (Berkeley) 10/19/97 (with SMTP)";  #else -static char sccsid[] = "@(#)srvrsmtp.c	8.154 (Berkeley) 8/2/97 (without SMTP)"; +static char sccsid[] = "@(#)srvrsmtp.c	8.159 (Berkeley) 10/19/97 (without SMTP)";  #endif  #endif /* not lint */ @@ -153,7 +153,7 @@ smtp(nullserver, e)  	volatile int n_noop = 0;	/* count of NOOP/VERB/ONEX etc cmds */  	volatile int n_helo = 0;	/* count of HELO/EHLO commands */  	bool ok; -	int lognullconnection = TRUE; +	volatile int lognullconnection = TRUE;  	register char *q;  	char inp[MAXLINE];  	char cmdbuf[MAXLINE]; @@ -252,6 +252,18 @@ smtp(nullserver, e)  				sm_syslog(LOG_NOTICE, e->e_id,  					"lost input channel from %.100s",  					CurSmtpClient); +			if (lognullconnection && LogLevel > 5) +				sm_syslog(LOG_INFO, NULL, +				"Null connection from %.100s", +				CurSmtpClient); + +			/* +			** If have not accepted mail (DATA), do not bounce +			** bad addresses back to sender. +			*/ +			if (bitset(EF_CLRQUEUE, e->e_flags)) +				e->e_sendqueue = NULL; +  			if (InChild)  				ExitStat = EX_QUIT;  			finis(); @@ -872,6 +884,7 @@ smtp(nullserver, e)  					shortenstring(inp, 203));  			if (setjmp(TopFrame) > 0)  				goto undo_subproc; +			QuickAbort = TRUE;  			vrfyqueue = NULL;  			if (vrfy)  				e->e_flags |= EF_VRFYONLY; @@ -917,16 +930,17 @@ smtp(nullserver, e)  			/* crude way to avoid denial-of-service attacks */  			checksmtpattack(&n_etrn, MAXETRNCOMMANDS, "ETRN", e); +			if (LogLevel > 5) +				sm_syslog(LOG_INFO, e->e_id, +					"%.100s: ETRN %s", +					CurSmtpClient, +					shortenstring(p, 203)); +  			id = p;  			if (*id == '@')  				id++;  			else  				*--id = '@'; -			if (LogLevel > 5) -				sm_syslog(LOG_INFO, e->e_id, -					"%.100s: ETRN %s", -					CurSmtpClient, -					shortenstring(id, 203));  			QueueLimitRecipient = id;  			ok = runqueue(TRUE, TRUE);  			QueueLimitRecipient = NULL; diff --git a/usr.sbin/sendmail/src/usersmtp.c b/usr.sbin/sendmail/src/usersmtp.c index 475a0dc2aa25..b088d6089438 100644 --- a/usr.sbin/sendmail/src/usersmtp.c +++ b/usr.sbin/sendmail/src/usersmtp.c @@ -36,9 +36,9 @@  #ifndef lint  #if SMTP -static char sccsid[] = "@(#)usersmtp.c	8.87 (Berkeley) 6/3/97 (with SMTP)"; +static char sccsid[] = "@(#)usersmtp.c	8.88 (Berkeley) 10/20/97 (with SMTP)";  #else -static char sccsid[] = "@(#)usersmtp.c	8.87 (Berkeley) 6/3/97 (without SMTP)"; +static char sccsid[] = "@(#)usersmtp.c	8.88 (Berkeley) 10/20/97 (without SMTP)";  #endif  #endif /* not lint */ @@ -60,7 +60,6 @@ static char sccsid[] = "@(#)usersmtp.c	8.87 (Berkeley) 6/3/97 (without SMTP)";  char	SmtpMsgBuffer[MAXLINE];		/* buffer for commands */  char	SmtpReplyBuffer[MAXLINE];	/* buffer for replies */  char	SmtpError[MAXLINE] = "";	/* save failure error messages */ -int	SmtpPid;			/* pid of mailer */  bool	SmtpNeedIntro;			/* need "while talking" in transcript */  extern void	smtpmessage __P((char *f, MAILER *m, MCI *mci, ...)); diff --git a/usr.sbin/sendmail/src/util.c b/usr.sbin/sendmail/src/util.c index 36592a007a8b..2e5aebe6e6c0 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.133 (Berkeley) 8/1/97"; +static char sccsid[] = "@(#)util.c	8.137 (Berkeley) 10/22/97";  #endif /* not lint */  # include "sendmail.h" @@ -520,6 +520,7 @@ putline(l, mci)  **		pxflags -- flag bits:  **		    PXLF_MAPFROM -- map From_ to >From_.  **		    PXLF_STRIP8BIT -- strip 8th bit. +**		    PXLF_HEADER -- map bare newline in header to newline space.  **  **	Returns:  **		none @@ -626,7 +627,8 @@ putxline(l, len, mci, pxflags)  		fputs(mci->mci_mailer->m_eol, mci->mci_out);  		if (l < end && *l == '\n')  		{ -			if (*++l != ' ' && *l != '\t' && *l != '\0') +			if (*++l != ' ' && *l != '\t' && *l != '\0' && +			    bitset(PXLF_HEADER, pxflags))  			{  				(void) putc(' ', mci->mci_out);  				if (TrafficLogFile != NULL) @@ -1058,7 +1060,6 @@ checkfd012(where)  {  #if XDEBUG  	register int i; -	struct stat stbuf;  	for (i = 0; i < 3; i++)  		fill_fd(i, where); @@ -1199,7 +1200,6 @@ dumpfd(fd, printclosed, logit)  	int i;  	struct stat st;  	char buf[200]; -	extern char *hostnamebyanyaddr();  	p = buf;  	snprintf(p, SPACELEFT(buf, p), "%3d: ", fd); @@ -1311,7 +1311,7 @@ defprint:  printit:  	if (logit) -		sm_syslog(LOG_DEBUG, CurEnv->e_id, +		sm_syslog(LOG_DEBUG, CurEnv ? CurEnv->e_id : NULL,  			"%.800s", buf);  	else  		printf("%s\n", buf); diff --git a/usr.sbin/sendmail/src/version.c b/usr.sbin/sendmail/src/version.c index c531c5bdf075..dc041baa38ac 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.8.7.3 (Berkeley) 8/3/97"; +static char sccsid[] = "@(#)version.c	8.8.8.1 (Berkeley) 10/24/97";  #endif /* not lint */ -char	Version[] = "8.8.7"; +char	Version[] = "8.8.8"; | 
