diff options
| author | jbeck <none@none> | 2007-11-02 15:39:34 -0700 |
|---|---|---|
| committer | jbeck <none@none> | 2007-11-02 15:39:34 -0700 |
| commit | 7800901e60d340b6af88e94a2149805dcfcaaf56 (patch) | |
| tree | f5262ef9246bc6fb6ce10e12604839e39913e643 /usr/src/cmd/sendmail | |
| parent | ae43f94f532f9bb12ac36b64580b6fe707d1129f (diff) | |
| download | illumos-joyent-7800901e60d340b6af88e94a2149805dcfcaaf56.tar.gz | |
PSARC 2007/551 getldapaliasbyname clarification
6337505 Sendmail is unable to use LDAP mail aliases > 256 bytes
6547700 sendmail's ratecontrol limit is off by one
6625320 upgrade sendmail to 8.14.2
Diffstat (limited to 'usr/src/cmd/sendmail')
29 files changed, 549 insertions, 309 deletions
diff --git a/usr/src/cmd/sendmail/aux/editmap.c b/usr/src/cmd/sendmail/aux/editmap.c index 09ba089003..46d9fd10ba 100644 --- a/usr/src/cmd/sendmail/aux/editmap.c +++ b/usr/src/cmd/sendmail/aux/editmap.c @@ -24,7 +24,7 @@ SM_UNUSED(static char copyright[]) = #endif /* ! lint */ #ifndef lint -SM_UNUSED(static char id[]) = "@(#)$Id: editmap.c,v 1.24 2004/08/03 18:40:10 ca Exp $"; +SM_UNUSED(static char id[]) = "@(#)$Id: editmap.c,v 1.25 2007/05/11 18:50:35 ca Exp $"; #endif /* ! lint */ @@ -48,7 +48,7 @@ uid_t RealUid; gid_t RealGid; char *RealUserName; uid_t RunAsUid; -uid_t RunAsGid; +gid_t RunAsGid; char *RunAsUserName; int Verbose = 2; bool DontInitGroups = false; diff --git a/usr/src/cmd/sendmail/aux/makemap.c b/usr/src/cmd/sendmail/aux/makemap.c index 03a7375eb9..7ebd7353ef 100644 --- a/usr/src/cmd/sendmail/aux/makemap.c +++ b/usr/src/cmd/sendmail/aux/makemap.c @@ -22,7 +22,7 @@ SM_IDSTR(copyright, Copyright (c) 1992, 1993\n\ The Regents of the University of California. All rights reserved.\n") -SM_IDSTR(id, "@(#)$Id: makemap.c,v 8.177 2004/08/03 23:57:24 ca Exp $") +SM_IDSTR(id, "@(#)$Id: makemap.c,v 8.178 2007/05/11 18:45:39 ca Exp $") #include <sys/types.h> @@ -44,7 +44,7 @@ uid_t RealUid; gid_t RealGid; char *RealUserName; uid_t RunAsUid; -uid_t RunAsGid; +gid_t RunAsGid; char *RunAsUserName; int Verbose = 2; bool DontInitGroups = false; diff --git a/usr/src/cmd/sendmail/aux/praliases.c b/usr/src/cmd/sendmail/aux/praliases.c index b44be6721f..94c3a8a8d0 100644 --- a/usr/src/cmd/sendmail/aux/praliases.c +++ b/usr/src/cmd/sendmail/aux/praliases.c @@ -22,7 +22,7 @@ SM_IDSTR(copyright, Copyright (c) 1988, 1993\n\ The Regents of the University of California. All rights reserved.\n") -SM_IDSTR(id, "@(#)$Id: praliases.c,v 8.91 2001/03/29 21:15:53 rodney Exp $") +SM_IDSTR(id, "@(#)$Id: praliases.c,v 8.94 2007/05/11 18:50:36 ca Exp $") #include <sys/types.h> #include <ctype.h> @@ -47,7 +47,7 @@ uid_t RealUid; gid_t RealGid; char *RealUserName; uid_t RunAsUid; -uid_t RunAsGid; +gid_t RunAsGid; char *RunAsUserName; int Verbose = 2; bool DontInitGroups = false; diff --git a/usr/src/cmd/sendmail/cf/m4/proto.m4 b/usr/src/cmd/sendmail/cf/m4/proto.m4 index c6282754d7..692f2e6f30 100644 --- a/usr/src/cmd/sendmail/cf/m4/proto.m4 +++ b/usr/src/cmd/sendmail/cf/m4/proto.m4 @@ -18,7 +18,7 @@ divert(-1) # divert(0) -VERSIONID(`$Id: proto.m4,v 8.730 2007/02/01 18:50:03 ca Exp $') +VERSIONID(`$Id: proto.m4,v 8.732 2007/04/20 00:53:30 ca Exp $') # level CF_LEVEL config file format V`'CF_LEVEL/ifdef(`VENDOR_NAME', `VENDOR_NAME', `Sun') @@ -2967,9 +2967,9 @@ ifdef(`_ATMPF_', `dnl tempfail? R<$* _ATMPF_> $#error $@ 4.3.0 $: "451 Temporary system failure. Please try again later."', `dnl') dnl use the generic routine (for now) R<0> $@ OK no limit -R<$+> $: <$1> $| $(arith l $@ $&{client_rate} $@ $1 $) +R<$+> $: <$1> $| $(arith l $@ $1 $@ $&{client_rate} $) dnl log this? Connection rate $&{client_rate} exceeds limit $1. -R<$+> $| FALSE $#error $@ 4.3.2 $: _RATE_CONTROL_REPLY Connection rate limit exceeded. +R<$+> $| TRUE $#error $@ 4.3.2 $: _RATE_CONTROL_REPLY Connection rate limit exceeded. ')') ifdef(`_CONN_CONTROL_',`dnl @@ -2989,9 +2989,9 @@ ifdef(`_ATMPF_', `dnl tempfail? R<$* _ATMPF_> $#error $@ 4.3.0 $: "451 Temporary system failure. Please try again later."', `dnl') dnl use the generic routine (for now) R<0> $@ OK no limit -R<$+> $: <$1> $| $(arith l $@ $&{client_connections} $@ $1 $) +R<$+> $: <$1> $| $(arith l $@ $1 $@ $&{client_connections} $) dnl log this: Open connections $&{client_connections} exceeds limit $1. -R<$+> $| FALSE $#error $@ 4.3.2 $: _CONN_CONTROL_REPLY Too many open connections. +R<$+> $| TRUE $#error $@ 4.3.2 $: _CONN_CONTROL_REPLY Too many open connections. ')') undivert(9)dnl LOCAL_RULESETS diff --git a/usr/src/cmd/sendmail/cf/m4/version.m4 b/usr/src/cmd/sendmail/cf/m4/version.m4 index 68b206b176..ce70aefff7 100644 --- a/usr/src/cmd/sendmail/cf/m4/version.m4 +++ b/usr/src/cmd/sendmail/cf/m4/version.m4 @@ -12,8 +12,8 @@ divert(-1) # # ident "%Z%%M% %I% %E% SMI" # -VERSIONID(`$Id: version.m4,v 8.178 2007/04/03 21:21:18 ca Exp $') +VERSIONID(`$Id: version.m4,v 8.186 2007/10/31 16:04:13 ca Exp $') # divert(0) # Configuration version number -DZ8.14.1`'ifdef(`confCF_VERSION', `/confCF_VERSION') +DZ8.14.2`'ifdef(`confCF_VERSION', `/confCF_VERSION') diff --git a/usr/src/cmd/sendmail/include/sm/conf.h b/usr/src/cmd/sendmail/include/sm/conf.h index 7c65586f2c..6de0bd02d0 100644 --- a/usr/src/cmd/sendmail/include/sm/conf.h +++ b/usr/src/cmd/sendmail/include/sm/conf.h @@ -10,11 +10,11 @@ * the sendmail distribution. * * - * $Id: conf.h,v 1.132 2007/03/21 23:56:18 ca Exp $ + * $Id: conf.h,v 1.134 2007/09/24 23:05:37 ca Exp $ */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -465,6 +465,9 @@ typedef int pid_t; # if SOLARIS >= 21000 || (SOLARIS < 10000 && SOLARIS >= 210) # define HASUNSETENV 1 /* unsetenv() added in S10 */ # endif /* SOLARIS >= 21000 || (SOLARIS < 10000 && SOLARIS >= 210) */ +# if SOLARIS >= 21100 || (SOLARIS < 10000 && SOLARIS >= 211) +# define GETLDAPALIASBYNAME_VERSION 2 /* changed in S11 */ +# endif /* SOLARIS >= 21100 || (SOLARIS < 10000 && SOLARIS >= 211) */ # ifndef HASGETUSERSHELL # define HASGETUSERSHELL 0 /* getusershell(3) causes core dumps pre-2.7 */ # endif /* ! HASGETUSERSHELL */ diff --git a/usr/src/cmd/sendmail/include/sm/ldap.h b/usr/src/cmd/sendmail/include/sm/ldap.h index 61f73a1d1a..b189dff6d2 100644 --- a/usr/src/cmd/sendmail/include/sm/ldap.h +++ b/usr/src/cmd/sendmail/include/sm/ldap.h @@ -1,12 +1,12 @@ /* - * Copyright (c) 2001-2003, 2005, 2006 Sendmail, Inc. and its suppliers. + * Copyright (c) 2001-2003, 2005-2007 Sendmail, Inc. and its suppliers. * All rights reserved. * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the sendmail distribution. * - * $Id: ldap.h,v 1.32 2006/08/30 22:56:58 ca Exp $ + * $Id: ldap.h,v 1.33 2007/10/10 00:06:44 ca Exp $ */ #pragma ident "%Z%%M% %I% %E% SMI" @@ -93,6 +93,10 @@ struct sm_ldap_struct /* ldapmap_lookup options */ char ldap_attrsep; +# if _FFR_LDAP_NETWORK_TIMEOUT + struct timeval ldap_networktmo; +# endif /* _FFR_LDAP_NETWORK_TIMEOUT */ + /* Linked list of maps sharing the same LDAP binding */ void *ldap_next; }; diff --git a/usr/src/cmd/sendmail/include/sm/tailq.h b/usr/src/cmd/sendmail/include/sm/tailq.h index 9bcf4b3ce9..cee267d941 100644 --- a/usr/src/cmd/sendmail/include/sm/tailq.h +++ b/usr/src/cmd/sendmail/include/sm/tailq.h @@ -38,8 +38,12 @@ #pragma ident "%Z%%M% %I% %E% SMI" /* + * $Id: tailq.h,v 1.2 2007/06/29 23:09:57 ca Exp $ + * * This file is a modified copy of queue.h from a BSD system: * we only need tail queues here. + * We do not use queue.h directly because there is a conflict with + * some versions of that file on some OSs. * * A tail queue is headed by a pair of pointers, one to the head of the * list and the other to the tail of the list. The elements are doubly diff --git a/usr/src/cmd/sendmail/libmilter/monitor.c b/usr/src/cmd/sendmail/libmilter/monitor.c index eede8d7355..b73a4b9ef2 100644 --- a/usr/src/cmd/sendmail/libmilter/monitor.c +++ b/usr/src/cmd/sendmail/libmilter/monitor.c @@ -10,6 +10,8 @@ #pragma ident "%Z%%M% %I% %E% SMI" +#include <sm/gen.h> +SM_RCSID("@(#)$Id: monitor.c,v 8.7 2007/04/23 16:26:28 ca Exp $") #include "libmilter.h" #if _FFR_THREAD_MONITOR diff --git a/usr/src/cmd/sendmail/libsm/ldap.c b/usr/src/cmd/sendmail/libsm/ldap.c index c4778f9b95..1da86cbb53 100644 --- a/usr/src/cmd/sendmail/libsm/ldap.c +++ b/usr/src/cmd/sendmail/libsm/ldap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2006 Sendmail, Inc. and its suppliers. + * Copyright (c) 2001-2007 Sendmail, Inc. and its suppliers. * All rights reserved. * * By using this file, you agree to the terms and conditions set @@ -13,7 +13,7 @@ #define LDAP_DEPRECATED 1 #include <sm/gen.h> -SM_RCSID("@(#)$Id: ldap.c,v 1.78 2006/08/30 22:56:59 ca Exp $") +SM_RCSID("@(#)$Id: ldap.c,v 1.80 2007/10/12 00:19:44 ca Exp $") #if LDAPMAP # include <sys/types.h> @@ -1105,26 +1105,25 @@ sm_ldap_results(lmap, msgid, flags, delim, rpool, result, if (save_errno != LDAP_SUCCESS) { statp = EX_TEMPFAIL; - if (ret != 0) + switch (save_errno) { - switch (save_errno) - { #ifdef LDAP_SERVER_DOWN - case LDAP_SERVER_DOWN: + case LDAP_SERVER_DOWN: #endif /* LDAP_SERVER_DOWN */ - case LDAP_TIMEOUT: - case LDAP_UNAVAILABLE: + case LDAP_TIMEOUT: + case ETIMEDOUT: + case LDAP_UNAVAILABLE: - /* - ** server disappeared, - ** try reopen on next search - */ + /* + ** server disappeared, + ** try reopen on next search + */ - statp = EX_RESTART; - break; - } - save_errno += E_LDAPBASE; + statp = EX_RESTART; + break; } + if (ret != 0) + save_errno += E_LDAPBASE; SM_LDAP_ERROR_CLEANUP(); errno = save_errno; return statp; @@ -1274,6 +1273,7 @@ sm_ldap_results(lmap, msgid, flags, delim, rpool, result, case LDAP_SERVER_DOWN: #endif /* LDAP_SERVER_DOWN */ case LDAP_TIMEOUT: + case ETIMEDOUT: case LDAP_UNAVAILABLE: /* @@ -1372,6 +1372,9 @@ sm_ldap_setopts(ld, lmap) ldap_set_option(ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF); ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &lmap->ldap_sizelimit); ldap_set_option(ld, LDAP_OPT_TIMELIMIT, &lmap->ldap_timelimit); +# if _FFR_LDAP_NETWORK_TIMEOUT && defined(LDAP_OPT_NETWORK_TIMEOUT) + ldap_set_option(ld, LDAP_OPT_NETWORK_TIMEOUT, &lmap->ldap_networktmo); +# endif /* _FFR_LDAP_NETWORK_TIMEOUT && defined(LDAP_OPT_NETWORK_TIMEOUT) */ # ifdef LDAP_OPT_RESTART ldap_set_option(ld, LDAP_OPT_RESTART, LDAP_OPT_ON); # endif /* LDAP_OPT_RESTART */ diff --git a/usr/src/cmd/sendmail/src/conf.c b/usr/src/cmd/sendmail/src/conf.c index 2d1b20c2f9..688f07d54f 100644 --- a/usr/src/cmd/sendmail/src/conf.c +++ b/usr/src/cmd/sendmail/src/conf.c @@ -20,7 +20,7 @@ #include <sendmail.h> -SM_RCSID("@(#)$Id: conf.c,v 8.1128 2007/04/03 21:32:29 ca Exp $") +SM_RCSID("@(#)$Id: conf.c,v 8.1136 2007/10/10 00:06:45 ca Exp $") SM_IDSTR(i2, "%W% (Sun) %G%") #include <sm/sendmail.h> @@ -5324,17 +5324,8 @@ sm_syslog(level, id, fmt, va_alist) save_errno = errno; if (id == NULL) - { id = "NOQUEUE"; - idlen = strlen(id) + SyslogPrefixLen; - } - else if (strcmp(id, NOQID) == 0) - { - id = ""; - idlen = SyslogPrefixLen; - } - else - idlen = strlen(id) + SyslogPrefixLen; + idlen = strlen(id) + SyslogPrefixLen; buf = buf0; bufsize = sizeof(buf0); @@ -6032,6 +6023,10 @@ char *OsCompileOptions[] = char *FFRCompileOptions[] = { +#if _FFR_ADDR_TYPE_MODES + /* more info in {addr_type}, requires m4 changes! */ + "_FFR_ADDR_TYPE_MODES", +#endif /* _FFR_ADDR_TYPE_MODES */ #if _FFR_ALLOW_SASLINFO /* DefaultAuthInfo can be specified by user. */ /* DefaultAuthInfo doesn't really work in 8.13 anymore. */ @@ -6102,6 +6097,10 @@ char *FFRCompileOptions[] = "_FFR_DPO_CS", #endif /* _FFR_DPO_CS */ +#if _FFR_DPRINTF_MAP + /* dprintf map for logging */ + "_FFR_DPRINTF_MAP", +#endif /* _FFR_DPRINTF_MAP */ #if _FFR_DROP_TRUSTUSER_WARNING /* ** Don't issue this warning: @@ -6230,6 +6229,10 @@ char *FFRCompileOptions[] = /* Old mime7to8 code, the new is broken for at least one example. */ "_FFR_MIME7TO8_OLD", #endif /* _FFR_MAX_SLEEP_TIME */ +#if _FFR_MORE_MACROS + /* allow more long macro names ("unprintable" characters). */ + "_FFR_MORE_MACROS", +#endif /* _FFR_MORE_MACROS */ #if _FFR_MSG_ACCEPT /* allow to override "Message accepted for delivery" */ "_FFR_MSG_ACCEPT", @@ -6243,6 +6246,10 @@ char *FFRCompileOptions[] = /* Disable PIPELINING, delay client if used. */ "_FFR_NO_PIPE", #endif /* _FFR_NO_PIPE */ +#if _FFR_LDAP_NETWORK_TIMEOUT + /* set LDAP_OPT_NETWORK_TIMEOUT if available (-c) */ + "_FFR_LDAP_NETWORK_TIMEOUT", +#endif /* _FFR_LDAP_NETWORK_TIMEOUT */ #if _FFR_LOG_NTRIES /* log ntries=, from Nik Clayton of FreeBSD */ "_FFR_LOG_NTRIES", @@ -6288,6 +6295,18 @@ char *FFRCompileOptions[] = /* Random shuffle for queue sorting. */ "_FFR_RHS", #endif /* _FFR_RHS */ +#if _FFR_RUNPQG + /* + ** allow -qGqueue_group -qp to work, i.e., + ** restrict a persistent queue runner to a queue group. + */ + + "_FFR_RUNPQG", +#endif /* _FFR_RUNPQG */ +#if _FFR_SESSID + /* session id (for logging) */ + "_FFR_SESSID", +#endif /* _FFR_SESSID */ #if _FFR_SHM_STATUS /* Donated code (unused). */ "_FFR_SHM_STATUS", diff --git a/usr/src/cmd/sendmail/src/deliver.c b/usr/src/cmd/sendmail/src/deliver.c index 4135aafec5..8d59cb71b0 100644 --- a/usr/src/cmd/sendmail/src/deliver.c +++ b/usr/src/cmd/sendmail/src/deliver.c @@ -16,7 +16,7 @@ #include <sendmail.h> #include <sm/time.h> -SM_RCSID("@(#)$Id: deliver.c,v 8.1012 2007/03/29 21:20:15 ca Exp $") +SM_RCSID("@(#)$Id: deliver.c,v 8.1015 2007/10/17 21:35:30 ca Exp $") #if HASSETUSERCONTEXT # include <login_cap.h> @@ -497,7 +497,7 @@ sendall(e, mode) time_t now; if (tTd(13, 29)) - sm_dprintf("No deliveries: auto-queuing\n"); + sm_dprintf("No deliveries: auto-queueing\n"); mode = SM_QUEUE; now = curtime(); @@ -3295,6 +3295,8 @@ do_transfer: ok = (*e->e_puthdr)(mci, e->e_header, e, M87F_OUTER); if (ok) ok = (*e->e_putbody)(mci, e, NULL); + if (ok && bitset(MCIF_INLONGLINE, mci->mci_flags)) + ok = putline("", mci); /* ** Ignore an I/O error that was caused by EPIPE. @@ -3406,6 +3408,7 @@ do_transfer: /* No recipients in list and no missing responses? */ if (tobuf[0] == '\0' # if PIPELINING + && bitset(MCIF_PIPELINED, mci->mci_flags) && mci->mci_nextaddr == NULL # endif /* PIPELINING */ ) diff --git a/usr/src/cmd/sendmail/src/envelope.c b/usr/src/cmd/sendmail/src/envelope.c index f38531ad47..6dc981b4fc 100644 --- a/usr/src/cmd/sendmail/src/envelope.c +++ b/usr/src/cmd/sendmail/src/envelope.c @@ -15,7 +15,7 @@ #include <sendmail.h> -SM_RCSID("@(#)$Id: envelope.c,v 8.302 2006/11/10 23:12:52 ca Exp $") +SM_RCSID("@(#)$Id: envelope.c,v 8.304 2007/04/18 17:15:49 ca Exp $") /* ** CLRSESSENVELOPE -- clear session oriented data in an envelope @@ -77,7 +77,7 @@ newenvelope(e, parent, rpool) register ENVELOPE *parent; SM_RPOOL_T *rpool; { - int sendmode; + int sendmode, dm; /* ** This code used to read: @@ -88,8 +88,16 @@ newenvelope(e, parent, rpool) ** This meant macvalue() could go into an infinite loop. */ + dm = DM_NOTSET; if (parent != NULL) + { + char *str; + sendmode = parent->e_sendmode; + str = macvalue(macid("{deliveryMode}"), parent); + if (str != NULL) + dm = (int) str[0]; + } else sendmode = DM_NOTSET; @@ -107,9 +115,18 @@ newenvelope(e, parent, rpool) e->e_parent = parent; assign_queueid(e); e->e_ctime = curtime(); +#if _FFR_SESSID + e->e_sessid = e->e_id; +#endif /* _FFR_SESSID */ if (parent != NULL) { e->e_msgpriority = parent->e_msgsize; +#if _FFR_SESSID + if (parent->e_sessid != NULL) + e->e_sessid = sm_rpool_strdup_x(rpool, + parent->e_sessid); +#endif /* _FFR_SESSID */ + if (parent->e_quarmsg == NULL) { e->e_quarmsg = NULL; @@ -130,6 +147,8 @@ newenvelope(e, parent, rpool) (void) sm_io_flush(CurEnv->e_xfp, SM_TIME_DEFAULT); if (sendmode != DM_NOTSET) e->e_sendmode = sendmode; + if (dm != DM_NOTSET) + set_delivery_mode(dm, e); return e; } diff --git a/usr/src/cmd/sendmail/src/headers.c b/usr/src/cmd/sendmail/src/headers.c index 4ee4200832..dabc7ec726 100644 --- a/usr/src/cmd/sendmail/src/headers.c +++ b/usr/src/cmd/sendmail/src/headers.c @@ -16,7 +16,7 @@ #include <sendmail.h> #include <sm/sendmail.h> -SM_RCSID("@(#)$Id: headers.c,v 8.310 2007/02/07 22:44:35 ca Exp $") +SM_RCSID("@(#)$Id: headers.c,v 8.312 2007/06/19 18:52:11 ca Exp $") static HDR *allocheader __P((char *, char *, int, SM_RPOOL_T *, bool)); static size_t fix_mime_header __P((HDR *, ENVELOPE *)); @@ -1867,7 +1867,8 @@ putheader(mci, hdr, e, flags) if (bitset(H_FROM, h->h_flags)) oldstyle = false; - commaize(h, p, oldstyle, mci, e); + commaize(h, p, oldstyle, mci, e, + PXLF_HEADER | PXLF_STRIPMQUOTE); } else { @@ -1979,6 +1980,7 @@ put_vanilla_header(h, v, mci) ** oldstyle -- true if this is an old style header. ** mci -- the connection information. ** e -- the envelope containing the message. +** putflags -- flags for putxline() ** ** Returns: ** true iff header field was written successfully @@ -1988,17 +1990,17 @@ put_vanilla_header(h, v, mci) */ bool -commaize(h, p, oldstyle, mci, e) +commaize(h, p, oldstyle, mci, e, putflags) register HDR *h; register char *p; bool oldstyle; register MCI *mci; register ENVELOPE *e; + int putflags; { register char *obp; int opos, omax, spaces; bool firstone = true; - int putflags = PXLF_HEADER | PXLF_STRIPMQUOTE; char **res; char obuf[MAXLINE + 3]; diff --git a/usr/src/cmd/sendmail/src/macro.c b/usr/src/cmd/sendmail/src/macro.c index ac7646414b..342120f7e5 100644 --- a/usr/src/cmd/sendmail/src/macro.c +++ b/usr/src/cmd/sendmail/src/macro.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2001, 2003, 2006 Sendmail, Inc. and its suppliers. + * Copyright (c) 1998-2001, 2003, 2006, 2007 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1988, 1993 @@ -15,7 +15,7 @@ #include <sendmail.h> -SM_RCSID("@(#)$Id: macro.c,v 8.102 2006/12/21 23:06:10 ca Exp $") +SM_RCSID("@(#)$Id: macro.c,v 8.107 2007/08/06 22:29:02 ca Exp $") #include <sm/sendmail.h> #if MAXMACROID != (BITMAPBITS - 1) @@ -23,8 +23,67 @@ SM_RCSID("@(#)$Id: macro.c,v 8.102 2006/12/21 23:06:10 ca Exp $") #endif /* MAXMACROID != (BITMAPBITS - 1) */ static char *MacroName[MAXMACROID + 1]; /* macro id to name table */ -int NextMacroId = 0240; /* codes for long named macros */ + +/* +** Codes for long named macros. +** See also macname(): + * if not ASCII printable, look up the name * + if (n <= 0x20 || n > 0x7f) +** First use 1 to NEXTMACROID_L, then use NEXTMACROID_H to MAXMACROID. +*/ + +#define NEXTMACROID_L 037 +#define NEXTMACROID_H 0240 + +#if _FFR_MORE_MACROS +/* table for next id in non-printable ASCII range: disallow some value */ +static int NextMIdTable[] = +{ + /* 0 nul */ 1, + /* 1 soh */ 2, + /* 2 stx */ 3, + /* 3 etx */ 4, + /* 4 eot */ 5, + /* 5 enq */ 6, + /* 6 ack */ 7, + /* 7 bel */ 8, + /* 8 bs */ 14, + /* 9 ht */ -1, + /* 10 nl */ -1, + /* 11 vt */ -1, + /* 12 np */ -1, + /* 13 cr */ -1, + /* 14 so */ 15, + /* 15 si */ 16, + /* 16 dle */ 17, + /* 17 dc1 */ 18, + /* 18 dc2 */ 19, + /* 19 dc3 */ 20, + /* 20 dc4 */ 21, + /* 21 nak */ 22, + /* 22 syn */ 23, + /* 23 etb */ 24, + /* 24 can */ 25, + /* 25 em */ 26, + /* 26 sub */ 27, + /* 27 esc */ 28, + /* 28 fs */ 29, + /* 29 gs */ 30, + /* 30 rs */ 31, + /* 31 us */ 32, + /* 32 sp */ -1, +}; + +#define NEXTMACROID(mid) ( \ + (mid < NEXTMACROID_L) ? (NextMIdTable[mid]) : \ + ((mid < NEXTMACROID_H) ? NEXTMACROID_H : (mid + 1))) + +int NextMacroId = 1; /* codes for long named macros */ /* see sendmail.h: Special characters in rewriting rules. */ +#else /* _FFR_MORE_MACROS */ +int NextMacroId = 0240; /* codes for long named macros */ +#define NEXTMACROID(mid) ((mid) + 1) +#endif /* _FFR_MORE_MACROS */ /* @@ -605,7 +664,7 @@ macid_parse(p, ep) syserr("Macro/class name ({%s}) too long (%d chars max)", mbuf, (int) (sizeof(mbuf) - 1)); } - else if (mbuf[1] == '\0') + else if (mbuf[1] == '\0' && mbuf[0] >= 0x20) { /* ${x} == $x */ mid = bitidx(mbuf[0]); @@ -629,7 +688,8 @@ macid_parse(p, ep) else { MacroName[NextMacroId] = s->s_name; - s->s_macro = mid = NextMacroId++; + s->s_macro = mid = NextMacroId; + NextMacroId = NEXTMACROID(NextMacroId); } } p++; diff --git a/usr/src/cmd/sendmail/src/main.c b/usr/src/cmd/sendmail/src/main.c index 67e8e52b13..8675a3e238 100644 --- a/usr/src/cmd/sendmail/src/main.c +++ b/usr/src/cmd/sendmail/src/main.c @@ -35,7 +35,7 @@ SM_UNUSED(static char copyright[]) = #pragma ident "%Z%%M% %I% %E% SMI" -SM_RCSID("@(#)$Id: main.c,v 8.962 2006/12/19 19:47:37 ca Exp $") +SM_RCSID("@(#)$Id: main.c,v 8.963 2007/06/29 20:07:37 ca Exp $") SM_IDSTR(i2, "%W% (Sun) %G%") #if NETINET || NETINET6 @@ -2371,7 +2371,33 @@ main(argc, argv, envp) if (QueueIntvl > 0) { - (void) runqueue(true, false, queuepersistent, true); +#if _FFR_RUNPQG + if (qgrp != NOQGRP) + { + int rwgflags = RWG_NONE; + + /* + ** To run a specific queue group mark it to + ** be run, select the work group it's in and + ** increment the work counter. + */ + + for (i = 0; i < NumQueue && Queue[i] != NULL; + i++) + Queue[i]->qg_nextrun = (time_t) -1; + Queue[qgrp]->qg_nextrun = 0; + if (Verbose) + rwgflags |= RWG_VERBOSE; + if (queuepersistent) + rwgflags |= RWG_PERSISTENT; + rwgflags |= RWG_FORCE; + (void) run_work_group(Queue[qgrp]->qg_wgrp, + rwgflags); + } + else +#endif /* _FFR_RUNPQG */ + (void) runqueue(true, false, queuepersistent, + true); /* ** If queuepersistent but not in daemon mode then diff --git a/usr/src/cmd/sendmail/src/map.c b/usr/src/cmd/sendmail/src/map.c index ed4fe19109..37b714522e 100644 --- a/usr/src/cmd/sendmail/src/map.c +++ b/usr/src/cmd/sendmail/src/map.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers. + * Copyright (c) 1998-2007 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1992, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1992, 1993 @@ -12,7 +12,7 @@ */ /* - * Copyright 1996-2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 1996-2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -20,7 +20,7 @@ #include <sendmail.h> -SM_RCSID("@(#)$Id: map.c,v 8.696 2007/04/03 21:33:14 ca Exp $") +SM_RCSID("@(#)$Id: map.c,v 8.699 2007/10/10 00:06:45 ca Exp $") SM_IDSTR(i2, "%W% (Sun) %G%") #if LDAPMAP @@ -3575,10 +3575,17 @@ ldapmap_lookup(map, name, av, statp) if (VendorCode == VENDOR_SUN && strcmp(map->map_mname, "aliases.ldap") == 0) { - char answer[MAXNAME + 1]; int rc; +#if defined(GETLDAPALIASBYNAME_VERSION) && (GETLDAPALIASBYNAME_VERSION >= 2) + extern char *__getldapaliasbyname(); + char *answer; + + answer = __getldapaliasbyname(name, &rc); +#else + char answer[MAXNAME + 1]; rc = __getldapaliasbyname(name, answer, sizeof(answer)); +#endif if (rc != 0) { if (tTd(38, 20)) @@ -3595,6 +3602,9 @@ ldapmap_lookup(map, name, av, statp) result = map_rewrite(map, name, strlen(name), NULL); else result = map_rewrite(map, answer, strlen(answer), av); +#if defined(GETLDAPALIASBYNAME_VERSION) && (GETLDAPALIASBYNAME_VERSION >= 2) + free(answer); +#endif return result; } #endif /* defined(SUN_EXTENSIONS) && defined(SUN_SIMPLIFIED_LDAP) && ... */ @@ -3973,17 +3983,16 @@ ldapmap_parseargs(map, args) break; switch (*++p) { - case 'N': - map->map_mflags |= MF_INCLNULL; - map->map_mflags &= ~MF_TRY0NULL; + case 'A': + map->map_mflags |= MF_APPEND; break; - case 'O': - map->map_mflags &= ~MF_TRY1NULL; + case 'a': + map->map_app = ++p; break; - case 'o': - map->map_mflags |= MF_OPTIONAL; + case 'D': + map->map_mflags |= MF_DEFER; break; case 'f': @@ -3994,16 +4003,25 @@ ldapmap_parseargs(map, args) map->map_mflags |= MF_MATCHONLY; break; - case 'A': - map->map_mflags |= MF_APPEND; + case 'N': + map->map_mflags |= MF_INCLNULL; + map->map_mflags &= ~MF_TRY0NULL; + break; + + case 'O': + map->map_mflags &= ~MF_TRY1NULL; + break; + + case 'o': + map->map_mflags |= MF_OPTIONAL; break; case 'q': map->map_mflags |= MF_KEEPQUOTES; break; - case 'a': - map->map_app = ++p; + case 'S': + map->map_spacesub = *++p; break; case 'T': @@ -4014,14 +4032,6 @@ ldapmap_parseargs(map, args) map->map_mflags |= MF_NODEFER; break; - case 'S': - map->map_spacesub = *++p; - break; - - case 'D': - map->map_mflags |= MF_DEFER; - break; - case 'z': if (*++p != '\\') map->map_coldelim = *p; @@ -4044,25 +4054,68 @@ ldapmap_parseargs(map, args) break; /* Start of ldapmap specific args */ - case 'V': - if (*++p != '\\') - lmap->ldap_attrsep = *p; - else - { - switch (*++p) - { - case 'n': - lmap->ldap_attrsep = '\n'; - break; + case '1': + map->map_mflags |= MF_SINGLEMATCH; + break; - case 't': - lmap->ldap_attrsep = '\t'; - break; +# if _FFR_LDAP_SINGLEDN + case '2': + map->map_mflags |= MF_SINGLEDN; + break; +# endif /* _FFR_LDAP_SINGLEDN */ - default: - lmap->ldap_attrsep = '\\'; - } + case 'b': /* search base */ + while (isascii(*++p) && isspace(*p)) + continue; + lmap->ldap_base = p; + break; + +# if _FFR_LDAP_NETWORK_TIMEOUT + case 'c': /* network (connect) timeout */ + while (isascii(*++p) && isspace(*p)) + continue; + lmap->ldap_networktmo.tv_sec = atoi(p); + break; +# endif /* _FFR_LDAP_NETWORK_TIMEOUT */ + + case 'd': /* Dn to bind to server as */ + while (isascii(*++p) && isspace(*p)) + continue; + lmap->ldap_binddn = p; + break; + + case 'H': /* Use LDAP URI */ +# if !USE_LDAP_INIT + syserr("Must compile with -DUSE_LDAP_INIT to use LDAP URIs (-H) in map %s", + map->map_mname); + return false; +# else /* !USE_LDAP_INIT */ + if (lmap->ldap_host != NULL) + { + syserr("Can not specify both an LDAP host and an LDAP URI in map %s", + map->map_mname); + return false; } + while (isascii(*++p) && isspace(*p)) + continue; + lmap->ldap_uri = p; + break; +# endif /* !USE_LDAP_INIT */ + + case 'h': /* ldap host */ + while (isascii(*++p) && isspace(*p)) + continue; + if (lmap->ldap_uri != NULL) + { + syserr("Can not specify both an LDAP host and an LDAP URI in map %s", + map->map_mname); + return false; + } + lmap->ldap_host = p; + break; + + case 'K': + lmap->ldap_multi_args = true; break; case 'k': /* search field */ @@ -4071,22 +4124,69 @@ ldapmap_parseargs(map, args) lmap->ldap_filter = p; break; - case 'v': /* attr to return */ + case 'l': /* time limit */ while (isascii(*++p) && isspace(*p)) continue; - lmap->ldap_attr[0] = p; - lmap->ldap_attr[1] = NULL; + lmap->ldap_timelimit = atoi(p); + lmap->ldap_timeout.tv_sec = lmap->ldap_timelimit; break; - case '1': - map->map_mflags |= MF_SINGLEMATCH; + case 'M': /* Method for binding */ + while (isascii(*++p) && isspace(*p)) + continue; + + if (sm_strncasecmp(p, "LDAP_AUTH_", 10) == 0) + p += 10; + + for (lam = LDAPAuthMethods; + lam != NULL && lam->lam_name != NULL; lam++) + { + if (sm_strncasecmp(p, lam->lam_name, + strlen(lam->lam_name)) == 0) + break; + } + if (lam->lam_name != NULL) + lmap->ldap_method = lam->lam_code; + else + { + /* bad config line */ + if (!bitset(MCF_OPTFILE, + map->map_class->map_cflags)) + { + char *ptr; + + if ((ptr = strchr(p, ' ')) != NULL) + *ptr = '\0'; + syserr("Method for binding must be [none|simple|krbv4] (not %s) in map %s", + p, map->map_mname); + if (ptr != NULL) + *ptr = ' '; + return false; + } + } break; -# if _FFR_LDAP_SINGLEDN - case '2': - map->map_mflags |= MF_SINGLEDN; + case 'n': /* retrieve attribute names only */ + lmap->ldap_attrsonly = LDAPMAP_TRUE; + break; + + /* + ** This is a string that is dependent on the + ** method used defined by 'M'. + */ + + case 'P': /* Secret password for binding */ + while (isascii(*++p) && isspace(*p)) + continue; + lmap->ldap_secret = p; + secretread = false; + break; + + case 'p': /* ldap port */ + while (isascii(*++p) && isspace(*p)) + continue; + lmap->ldap_port = atoi(p); break; -# endif /* _FFR_LDAP_SINGLEDN */ /* args stolen from ldapsearch.c */ case 'R': /* don't auto chase referrals */ @@ -4097,10 +4197,6 @@ ldapmap_parseargs(map, args) # endif /* LDAP_REFERRALS */ break; - case 'n': /* retrieve attribute names only */ - lmap->ldap_attrsonly = LDAPMAP_TRUE; - break; - case 'r': /* alias dereferencing */ while (isascii(*++p) && isspace(*p)) continue; @@ -4171,114 +4267,33 @@ ldapmap_parseargs(map, args) } break; - case 'h': /* ldap host */ - while (isascii(*++p) && isspace(*p)) - continue; - if (lmap->ldap_uri != NULL) - { - syserr("Can not specify both an LDAP host and an LDAP URI in map %s", - map->map_mname); - return false; - } - lmap->ldap_host = p; - break; - - case 'b': /* search base */ - while (isascii(*++p) && isspace(*p)) - continue; - lmap->ldap_base = p; - break; - - case 'p': /* ldap port */ - while (isascii(*++p) && isspace(*p)) - continue; - lmap->ldap_port = atoi(p); - break; - - case 'l': /* time limit */ - while (isascii(*++p) && isspace(*p)) - continue; - lmap->ldap_timelimit = atoi(p); - lmap->ldap_timeout.tv_sec = lmap->ldap_timelimit; - break; - - case 'Z': - while (isascii(*++p) && isspace(*p)) - continue; - lmap->ldap_sizelimit = atoi(p); - break; - - case 'd': /* Dn to bind to server as */ - while (isascii(*++p) && isspace(*p)) - continue; - lmap->ldap_binddn = p; - break; - - case 'M': /* Method for binding */ - while (isascii(*++p) && isspace(*p)) - continue; - - if (sm_strncasecmp(p, "LDAP_AUTH_", 10) == 0) - p += 10; - - for (lam = LDAPAuthMethods; - lam != NULL && lam->lam_name != NULL; lam++) - { - if (sm_strncasecmp(p, lam->lam_name, - strlen(lam->lam_name)) == 0) - break; - } - if (lam->lam_name != NULL) - lmap->ldap_method = lam->lam_code; + case 'V': + if (*++p != '\\') + lmap->ldap_attrsep = *p; else { - /* bad config line */ - if (!bitset(MCF_OPTFILE, - map->map_class->map_cflags)) + switch (*++p) { - char *ptr; + case 'n': + lmap->ldap_attrsep = '\n'; + break; - if ((ptr = strchr(p, ' ')) != NULL) - *ptr = '\0'; - syserr("Method for binding must be [none|simple|krbv4] (not %s) in map %s", - p, map->map_mname); - if (ptr != NULL) - *ptr = ' '; - return false; + case 't': + lmap->ldap_attrsep = '\t'; + break; + + default: + lmap->ldap_attrsep = '\\'; } } - break; - /* - ** This is a string that is dependent on the - ** method used defined above. - */ - - case 'P': /* Secret password for binding */ - while (isascii(*++p) && isspace(*p)) - continue; - lmap->ldap_secret = p; - secretread = false; - break; - - case 'H': /* Use LDAP URI */ -# if !USE_LDAP_INIT - syserr("Must compile with -DUSE_LDAP_INIT to use LDAP URIs (-H) in map %s", - map->map_mname); - return false; -# else /* !USE_LDAP_INIT */ - if (lmap->ldap_host != NULL) - { - syserr("Can not specify both an LDAP host and an LDAP URI in map %s", - map->map_mname); - return false; - } + case 'v': /* attr to return */ while (isascii(*++p) && isspace(*p)) continue; - lmap->ldap_uri = p; + lmap->ldap_attr[0] = p; + lmap->ldap_attr[1] = NULL; break; -# endif /* !USE_LDAP_INIT */ case 'w': /* -w should be for passwd, -P should be for version */ @@ -4305,8 +4320,10 @@ ldapmap_parseargs(map, args) # endif /* LDAP_VERSION_MIN */ break; - case 'K': - lmap->ldap_multi_args = true; + case 'Z': + while (isascii(*++p) && isspace(*p)) + continue; + lmap->ldap_sizelimit = atoi(p); break; default: diff --git a/usr/src/cmd/sendmail/src/milter.c b/usr/src/cmd/sendmail/src/milter.c index 18b11292d2..36f308a025 100644 --- a/usr/src/cmd/sendmail/src/milter.c +++ b/usr/src/cmd/sendmail/src/milter.c @@ -12,7 +12,7 @@ #include <sendmail.h> -SM_RCSID("@(#)$Id: milter.c,v 8.267 2007/02/27 22:21:12 ca Exp $") +SM_RCSID("@(#)$Id: milter.c,v 8.269 2007/06/06 17:26:12 ca Exp $") #if MILTER # include <sm/sendmail.h> @@ -53,7 +53,8 @@ static void milter_quit_filter __P((struct milter *, ENVELOPE *)); static void milter_abort_filter __P((struct milter *, ENVELOPE *)); static void milter_send_macros __P((struct milter *, char **, int, ENVELOPE *)); -static int milter_negotiate __P((struct milter *, ENVELOPE *)); +static int milter_negotiate __P((struct milter *, ENVELOPE *, + milters_T *)); static void milter_per_connection_check __P((ENVELOPE *)); static char *milter_headers __P((struct milter *, ENVELOPE *, char *)); static void milter_addheader __P((struct milter *, char *, ssize_t, @@ -1793,41 +1794,6 @@ milter_reset_df(e) } /* -** MILTER_CAN_DELRCPTS -- can any milter filters delete recipients? -** -** Parameters: -** none -** -** Returns: -** true if any filter deletes recipients, false otherwise -*/ - -bool -milter_can_delrcpts() -{ - bool can = false; - int i; - - if (tTd(64, 10)) - sm_dprintf("milter_can_delrcpts:"); - - for (i = 0; InputFilters[i] != NULL; i++) - { - struct milter *m = InputFilters[i]; - - if (bitset(SMFIF_DELRCPT, m->mf_fflags)) - { - can = true; - break; - } - } - if (tTd(64, 10)) - sm_dprintf("%s\n", can ? "true" : "false"); - - return can; -} - -/* ** MILTER_QUIT_FILTER -- close down a single filter ** ** Parameters: @@ -2408,15 +2374,17 @@ milter_getsymlist(m, buf, rlen, offset) ** Parameters: ** m -- milter filter structure. ** e -- current envelope. +** milters -- milters structure. ** ** Returns: ** 0 on success, -1 otherwise */ static int -milter_negotiate(m, e) +milter_negotiate(m, e, milters) struct milter *m; ENVELOPE *e; + milters_T *milters; { char rcmd; mi_int32 fvers, fflags, pflags; @@ -2585,6 +2553,12 @@ milter_negotiate(m, e) milter_getsymlist(m, response, rlen, MILTER_OPTLEN); } + if (bitset(SMFIF_DELRCPT, m->mf_fflags)) + milters->mis_flags |= MIS_FL_DEL_RCPT; + if (!bitset(SMFIP_NORCPT, m->mf_pflags) && + !bitset(SMFIP_NR_RCPT, m->mf_pflags)) + milters->mis_flags |= MIS_FL_REJ_RCPT; + if (tTd(64, 5)) sm_dprintf("milter_negotiate(%s): received: version %u, fflags 0x%x, pflags 0x%x\n", m->mf_name, m->mf_fvers, m->mf_fflags, m->mf_pflags); @@ -3786,6 +3760,7 @@ milter_replbody(response, rlen, newfilter, e) ** Parameters: ** e -- current envelope. ** state -- return state from response. +** milters -- milters structure. ** ** Returns: ** true iff at least one filter is active @@ -3793,15 +3768,17 @@ milter_replbody(response, rlen, newfilter, e) /* ARGSUSED */ bool -milter_init(e, state) +milter_init(e, state, milters) ENVELOPE *e; char *state; + milters_T *milters; { int i; if (tTd(64, 10)) sm_dprintf("milter_init\n"); + memset(milters, '\0', sizeof(*milters)); *state = SMFIR_CONTINUE; if (InputFilters[0] == NULL) { @@ -3823,7 +3800,7 @@ milter_init(e, state) } if (m->mf_sock < 0 || - milter_negotiate(m, e) < 0 || + milter_negotiate(m, e, milters) < 0 || m->mf_state == SMFS_ERROR) { if (tTd(64, 5)) diff --git a/usr/src/cmd/sendmail/src/mime.c b/usr/src/cmd/sendmail/src/mime.c index 8f3f15adb2..fa7b83c874 100644 --- a/usr/src/cmd/sendmail/src/mime.c +++ b/usr/src/cmd/sendmail/src/mime.c @@ -16,7 +16,7 @@ #include <sendmail.h> #include <string.h> -SM_RCSID("@(#)$Id: mime.c,v 8.146 2006/08/16 16:52:11 ca Exp $") +SM_RCSID("@(#)$Id: mime.c,v 8.147 2007/09/26 23:29:11 ca Exp $") /* ** MIME support. @@ -527,10 +527,14 @@ mime8to7(mci, header, e, boundaries, flags, level) while (sm_io_fgets(e->e_dfp, SM_TIME_DEFAULT, buf, sizeof(buf)) != NULL) { - bt = mimeboundary(buf, boundaries); - if (bt != MBT_NOTSEP) - break; - if (!putline(buf, mci)) + if (!bitset(MCIF_INLONGLINE, mci->mci_flags)) + { + bt = mimeboundary(buf, boundaries); + if (bt != MBT_NOTSEP) + break; + } + if (!putxline(buf, strlen(buf), mci, + PXLF_MAPFROM|PXLF_NOADDEOL)) goto writeerr; } if (sm_io_eof(e->e_dfp)) diff --git a/usr/src/cmd/sendmail/src/parseaddr.c b/usr/src/cmd/sendmail/src/parseaddr.c index 9098118688..68e02a1341 100644 --- a/usr/src/cmd/sendmail/src/parseaddr.c +++ b/usr/src/cmd/sendmail/src/parseaddr.c @@ -15,7 +15,7 @@ #include <sendmail.h> -SM_RCSID("@(#)$Id: parseaddr.c,v 8.400 2006/12/21 00:24:06 ca Exp $") +SM_RCSID("@(#)$Id: parseaddr.c,v 8.401 2007/09/27 23:33:59 ca Exp $") #include <sm/sendmail.h> #include "map.h" @@ -219,7 +219,7 @@ parseaddr(addr, a, flags, delim, delimptr, e, isrcpt) if (e->e_sendmode == SM_DEFER) msg = "Deferring message until queue run"; if (tTd(20, 1)) - sm_dprintf("parseaddr: queuing message\n"); + sm_dprintf("parseaddr: queueing message\n"); message(msg); if (e->e_message == NULL && e->e_sendmode != SM_DEFER) e->e_message = sm_rpool_strdup_x(e->e_rpool, msg); diff --git a/usr/src/cmd/sendmail/src/queue.c b/usr/src/cmd/sendmail/src/queue.c index 831eeaac96..9a5fc07123 100644 --- a/usr/src/cmd/sendmail/src/queue.c +++ b/usr/src/cmd/sendmail/src/queue.c @@ -16,7 +16,7 @@ #include <sendmail.h> #include <sm/sem.h> -SM_RCSID("@(#)$Id: queue.c,v 8.972 2007/03/29 22:55:17 ca Exp $") +SM_RCSID("@(#)$Id: queue.c,v 8.975 2007/06/18 20:08:40 ca Exp $") #include <dirent.h> @@ -429,7 +429,7 @@ queueup(e, announce, msync) break; if (LogLevel > 0 && (i % 32) == 0) sm_syslog(LOG_ALERT, e->e_id, - "queueup: cannot create %s, uid=%d: %s", + "queueup: cannot create %s, euid=%d: %s", tf, (int) geteuid(), sm_errstring(errno)); } @@ -847,8 +847,8 @@ queueup(e, announce, msync) if (bitset(H_FROM, h->h_flags)) oldstyle = false; - - commaize(h, h->h_value, oldstyle, &mcibuf, e); + commaize(h, h->h_value, oldstyle, &mcibuf, e, + PXLF_HEADER); TrafficLogFile = savetrace; } @@ -2149,6 +2149,14 @@ run_work_group(wgrp, flags) maxrunners = Queue[qgrp]->qg_maxqrun; + /* + ** If no runners are configured for this group but + ** the queue is "forced" then lets use 1 runner. + */ + + if (maxrunners == 0 && bitset(RWG_FORCE, flags)) + maxrunners = 1; + /* No need to have more runners then there are jobs */ if (maxrunners > njobs) maxrunners = njobs; diff --git a/usr/src/cmd/sendmail/src/readcf.c b/usr/src/cmd/sendmail/src/readcf.c index cd13c02b94..49105a6c6c 100644 --- a/usr/src/cmd/sendmail/src/readcf.c +++ b/usr/src/cmd/sendmail/src/readcf.c @@ -16,7 +16,7 @@ #include <sendmail.h> #include <sm/sendmail.h> -SM_RCSID("@(#)$Id: readcf.c,v 8.663 2006/10/05 20:58:59 ca Exp $") +SM_RCSID("@(#)$Id: readcf.c,v 8.664 2007/07/10 17:01:22 ca Exp $") #if NETINET || NETINET6 # include <arpa/inet.h> @@ -2247,6 +2247,10 @@ static struct optioninfo # define O_EIGHT_BIT_ADDR_OK 0xdf { "EightBitAddrOK", O_EIGHT_BIT_ADDR_OK, OI_NONE }, #endif /* _FFR_EIGHT_BIT_ADDR_OK */ +#if _FFR_ADDR_TYPE_MODES +# define O_ADDR_TYPE_MODES 0xe0 + { "AddrTypeModes", O_ADDR_TYPE_MODES, OI_NONE }, +#endif /* _FFR_ADDR_TYPE_MODES */ { NULL, '\0', OI_NONE } }; @@ -3809,6 +3813,12 @@ setoption(opt, val, safe, sticky, e) break; #endif /* _FFR_EIGHT_BIT_ADDR_OK */ +#if _FFR_ADDR_TYPE_MODES + case O_ADDR_TYPE_MODES: + AddrTypeModes = atobool(val); + break; +#endif /* _FFR_ADDR_TYPE_MODES */ + default: if (tTd(37, 1)) { diff --git a/usr/src/cmd/sendmail/src/recipient.c b/usr/src/cmd/sendmail/src/recipient.c index 846a6c35b0..11244c5552 100644 --- a/usr/src/cmd/sendmail/src/recipient.c +++ b/usr/src/cmd/sendmail/src/recipient.c @@ -15,7 +15,7 @@ #include <sendmail.h> -SM_RCSID("@(#)$Id: recipient.c,v 8.348 2007/03/19 21:33:09 ca Exp $") +SM_RCSID("@(#)$Id: recipient.c,v 8.349 2007/07/10 17:01:22 ca Exp $") static void includetimeout __P((int)); static ADDRESS *self_reference __P((ADDRESS *)); @@ -379,6 +379,12 @@ removefromlist(list, sendq, e) { (void) sm_strlcpy(bufp, denlstring(list, false, true), i); +#if _FFR_ADDR_TYPE_MODES + if (AddrTypeModes) + macdefine(&e->e_macro, A_PERM, macid("{addr_type}"), + "e r d"); + else +#endif /* _FFR_ADDR_TYPE_MODES */ macdefine(&e->e_macro, A_PERM, macid("{addr_type}"), "e r"); for (p = bufp; *p != '\0'; ) { diff --git a/usr/src/cmd/sendmail/src/sendmail.h b/usr/src/cmd/sendmail/src/sendmail.h index 5fbba2b3f0..66a126ccf4 100644 --- a/usr/src/cmd/sendmail/src/sendmail.h +++ b/usr/src/cmd/sendmail/src/sendmail.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers. + * Copyright (c) 1998-2007 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1988, 1993 @@ -54,7 +54,7 @@ #ifdef _DEFINE # ifndef lint -SM_UNUSED(static char SmailId[]) = "@(#)$Id: sendmail.h,v 8.1042 2007/02/27 22:21:13 ca Exp $"; +SM_UNUSED(static char SmailId[]) = "@(#)$Id: sendmail.h,v 8.1052 2007/10/05 23:06:30 ca Exp $"; # endif /* ! lint */ #endif /* _DEFINE */ @@ -326,7 +326,8 @@ typedef struct address ADDRESS; (s) == QS_RETRY) #define QS_IS_ATTEMPTED(s) ((s) == QS_QUEUEUP || \ (s) == QS_RETRY || \ - (s) == QS_SENT) + (s) == QS_SENT || \ + (s) == QS_DISCARDED) #define QS_IS_DEAD(s) ((s) >= QS_DONTSEND) @@ -730,6 +731,7 @@ MCI #if _FFR_IGNORE_EXT_ON_HELO # define MCIF_HELO 0x00800000 /* we used HELO: ignore extensions */ #endif /* _FFR_IGNORE_EXT_ON_HELO */ +#define MCIF_INLONGLINE 0x01000000 /* in the middle of a long line */ #define MCIF_ONLY_EHLO 0x10000000 /* use only EHLO in smtpinit */ /* states */ @@ -826,7 +828,7 @@ extern struct hdrinfo HdrInfo[]; /* functions */ extern void addheader __P((char *, char *, int, ENVELOPE *, bool)); extern unsigned long chompheader __P((char *, int, HDR **, ENVELOPE *)); -extern bool commaize __P((HDR *, char *, bool, MCI *, ENVELOPE *)); +extern bool commaize __P((HDR *, char *, bool, MCI *, ENVELOPE *, int)); extern HDR *copyheader __P((HDR *, SM_RPOOL_T *)); extern void eatheader __P((ENVELOPE *, bool, bool)); extern char *hvalue __P((char *, HDR *)); @@ -896,6 +898,9 @@ struct envelope char *e_bodytype; /* type of message body */ SM_FILE_T *e_dfp; /* data file */ char *e_id; /* code for this entry in queue */ +#if _FFR_SESSID + char *e_sessid; /* session ID for this envelope */ +#endif /* _FFR_SESSID */ int e_qgrp; /* queue group (index into queues) */ int e_qdir; /* index into queue directories */ int e_dfqgrp; /* data file queue group index */ @@ -1727,6 +1732,17 @@ struct milter #endif /* _FFR_MILTER_CHECK */ }; +struct milters +{ + mi_int32 mis_flags; /* filter flags */ +}; +typedef struct milters milters_T; + +#define MIS_FL_NONE 0x00000000 /* no requirements... */ +#define MIS_FL_DEL_RCPT 0x00000001 /* can delete rcpt */ +#define MIS_FL_REJ_RCPT 0x00000002 /* can reject rcpt */ + + /* MTA flags */ # define SMF_REJECT 'R' /* Reject connection on filter fail */ # define SMF_TEMPFAIL 'T' /* tempfail connection on failure */ @@ -2084,10 +2100,7 @@ extern unsigned char tTdvect[100]; /* trace vector */ ** The "no queue id" queue id for sm_syslog */ -#define NOQID "*~*" - -/* use id or NOQID (to avoid NOQUEUE in logfile) */ -#define E_ID(id) ((id) == NULL ? NOQID : (id)) +#define NOQID "" #define CURHOSTNAME (CurHostName == NULL ? "local" : CurHostName) @@ -2163,6 +2176,9 @@ extern unsigned char tTdvect[100]; /* trace vector */ ** Global variables. */ +#if _FFR_ADDR_TYPE_MODES +EXTERN bool AddrTypeModes; /* addr_type: extra "mode" information */ +#endif /* _FFR_ADDR_TYPE_MODES */ EXTERN bool AllowBogusHELO; /* allow syntax errors on HELO command */ EXTERN bool CheckAliases; /* parse addresses during newaliases */ #if _FFR_QUEUE_RUN_PARANOIA @@ -2437,8 +2453,7 @@ extern int opencontrolsocket __P((void)); extern void milter_config __P((char *, struct milter **, int)); extern void milter_setup __P((char *)); extern void milter_set_option __P((char *, char *, bool)); -extern bool milter_can_delrcpts __P((void)); -extern bool milter_init __P((ENVELOPE *, char *)); +extern bool milter_init __P((ENVELOPE *, char *, milters_T *)); extern void milter_quit __P((ENVELOPE *)); extern void milter_abort __P((ENVELOPE *)); extern char *milter_connect __P((char *, SOCKADDR, ENVELOPE *, char *)); diff --git a/usr/src/cmd/sendmail/src/sm_resolve.c b/usr/src/cmd/sendmail/src/sm_resolve.c index fee6748d01..bb308640d5 100644 --- a/usr/src/cmd/sendmail/src/sm_resolve.c +++ b/usr/src/cmd/sendmail/src/sm_resolve.c @@ -48,7 +48,7 @@ # if NAMED_BIND # include "sm_resolve.h" -SM_RCSID("$Id: sm_resolve.c,v 8.34 2006/08/15 23:24:58 ca Exp $") +SM_RCSID("$Id: sm_resolve.c,v 8.35 2007/06/25 16:20:14 ca Exp $") static struct stot { @@ -170,6 +170,7 @@ parse_dns_reply(data, len) int len; { unsigned char *p; + ushort ans_cnt, ui; int status; size_t l; char host[MAXHOSTNAMELEN]; @@ -198,11 +199,15 @@ parse_dns_reply(data, len) dns_free_data(r); return NULL; } + + ans_cnt = ntohs((ushort) r->dns_r_h.ancount); + p += status; GETSHORT(r->dns_r_q.dns_q_type, p); GETSHORT(r->dns_r_q.dns_q_class, p); rr = &r->dns_r_head; - while (p < data + len) + ui = 0; + while (p < data + len && ui < ans_cnt) { int type, class, ttl, size, txtlen; @@ -212,6 +217,7 @@ parse_dns_reply(data, len) dns_free_data(r); return NULL; } + ++ui; p += status; GETSHORT(type, p); GETSHORT(class, p); diff --git a/usr/src/cmd/sendmail/src/srvrsmtp.c b/usr/src/cmd/sendmail/src/srvrsmtp.c index 1a723ac28b..764715ba92 100644 --- a/usr/src/cmd/sendmail/src/srvrsmtp.c +++ b/usr/src/cmd/sendmail/src/srvrsmtp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers. + * Copyright (c) 1998-2007 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1988, 1993 @@ -19,7 +19,7 @@ # include <libmilter/mfdef.h> #endif /* MILTER */ -SM_RCSID("@(#)$Id: srvrsmtp.c,v 8.960 2007/02/07 20:18:47 ca Exp $") +SM_RCSID("@(#)$Id: srvrsmtp.c,v 8.967 2007/10/01 16:22:14 ca Exp $") #include <sm/time.h> #include <sm/fdset.h> @@ -351,14 +351,18 @@ static SM_DEBUG_T DebugLeakSmtp = SM_DEBUG_INITIALIZER("leak_smtp", typedef struct { - bool sm_gotmail; /* mail command received */ - unsigned int sm_nrcpts; /* number of successful RCPT commands */ - bool sm_discard; + bool sm_gotmail; /* mail command received */ + unsigned int sm_nrcpts; /* number of successful RCPT commands */ + bool sm_discard; #if MILTER - bool sm_milterize; - bool sm_milterlist; /* any filters in the list? */ + bool sm_milterize; + bool sm_milterlist; /* any filters in the list? */ + milters_T sm_milters; + + /* e_nrcpts from envelope before recipient() call */ + unsigned int sm_e_nrcpts_orig; #endif /* MILTER */ - char *sm_quarmsg; /* carry quarantining across messages */ + char *sm_quarmsg; /* carry quarantining across messages */ } SMTP_T; static bool smtp_data __P((SMTP_T *, ENVELOPE *)); @@ -909,7 +913,7 @@ smtp(nullserver, d_flags, e) char state; /* initialize mail filter connection */ - smtp.sm_milterlist = milter_init(e, &state); + smtp.sm_milterlist = milter_init(e, &state, &smtp.sm_milters); switch (state) { case SMFIR_REJECT: @@ -1287,7 +1291,7 @@ smtp(nullserver, d_flags, e) { authenticating = SASL_NOT_AUTH; - /* rfc 2254 4. */ + /* RFC 2554 4. */ message("501 5.0.0 AUTH aborted"); RESET_SASLCONN; continue; @@ -1306,7 +1310,7 @@ smtp(nullserver, d_flags, e) { authenticating = SASL_NOT_AUTH; - /* rfc 2254 4. */ + /* RFC 2554 4. */ message("501 5.5.4 cannot decode AUTH parameter %s", inp); # if SASL >= 20000 @@ -1660,7 +1664,21 @@ smtp(nullserver, d_flags, e) break; } - if (ismore) + /* + ** RFC 2554 4. + ** Unlike a zero-length client answer to a + ** 334 reply, a zero- length initial response + ** is sent as a single equals sign ("="). + */ + + if (ismore && *q == '=' && *(q + 1) == '\0') + { + /* will be free()d, don't use in=""; */ + in = xalloc(1); + *in = '\0'; + inlen = 0; + } + else if (ismore) { /* could this be shorter? XXX */ # if SASL >= 20000 @@ -2505,6 +2523,7 @@ smtp(nullserver, d_flags, e) (void) memset(&addr_st, '\0', sizeof(addr_st)); a = NULL; milter_rcpt_added = false; + smtp.sm_e_nrcpts_orig = e->e_nrcpts; #endif if (BadRcptThrottle > 0 && n_badrcpts >= BadRcptThrottle) @@ -2560,13 +2579,18 @@ smtp(nullserver, d_flags, e) #if MILTER /* ** Do not expand recipients at RCPT time (in the call - ** to recipient()). If they are expanded, it - ** is impossible for removefromlist() to figure - ** out the expanded members of the original - ** recipient and mark them as QS_DONTSEND. + ** to recipient()) if a milter can delete or reject + ** a RCPT. If they are expanded, it is impossible + ** for removefromlist() to figure out the expanded + ** members of the original recipient and mark them + ** as QS_DONTSEND. */ - e->e_flags |= EF_VRFYONLY; + if (!(smtp.sm_milterlist && smtp.sm_milterize && + !bitset(EF_DISCARD, e->e_flags)) && + (smtp.sm_milters.mis_flags & + (MIS_FL_DEL_RCPT|MIS_FL_REJ_RCPT)) != 0) + e->e_flags |= EF_VRFYONLY; milter_cmd_done = false; milter_cmd_safe = false; #endif /* MILTER */ @@ -2801,6 +2825,8 @@ smtp(nullserver, d_flags, e) { (void) removefromlist(addr, &e->e_sendqueue, e); milter_cmd_fail = false; + if (smtp.sm_e_nrcpts_orig < e->e_nrcpts) + e->e_nrcpts = smtp.sm_e_nrcpts_orig; } #endif /* MILTER */ } @@ -3559,8 +3585,19 @@ smtp_data(smtp, e) if (aborting) { + ADDRESS *q; + /* Log who the mail would have gone to */ logundelrcpts(e, e->e_message, 8, false); + + /* + ** If something above refused the message, we still haven't + ** accepted responsibility for it. Don't send DSNs. + */ + + for (q = e->e_sendqueue; q != NULL; q = q->q_next) + q->q_flags &= ~Q_PINGFLAGS; + flush_errors(true); buffer_errors(); goto abortmessage; @@ -4028,8 +4065,7 @@ reset_mail_esmtp_args(e) macdefine(&e->e_macro, A_PERM, macid("{dsn_envid}"), NULL); /* "ret" */ - e->e_flags &= EF_RET_PARAM; - e->e_flags &= EF_NO_BODY_RETN; + e->e_flags &= ~(EF_RET_PARAM|EF_NO_BODY_RETN); macdefine(&e->e_macro, A_TEMP, macid("{dsn_ret}"), NULL); #if SASL diff --git a/usr/src/cmd/sendmail/src/usersmtp.c b/usr/src/cmd/sendmail/src/usersmtp.c index 7aec92169f..746ac7c1d4 100644 --- a/usr/src/cmd/sendmail/src/usersmtp.c +++ b/usr/src/cmd/sendmail/src/usersmtp.c @@ -15,7 +15,7 @@ #include <sendmail.h> -SM_RCSID("@(#)$Id: usersmtp.c,v 8.469 2006/12/13 20:11:15 ca Exp $") +SM_RCSID("@(#)$Id: usersmtp.c,v 8.470 2007/10/17 21:35:30 ca Exp $") #include <sysexits.h> @@ -2705,8 +2705,9 @@ smtpdata(m, mci, e, ctladdr, xstart) } /* terminate the message */ - if (sm_io_fprintf(mci->mci_out, SM_TIME_DEFAULT, ".%s", m->m_eol) == - SM_IO_EOF) + if (sm_io_fprintf(mci->mci_out, SM_TIME_DEFAULT, "%s.%s", + bitset(MCIF_INLONGLINE, mci->mci_flags) ? m->m_eol : "", + m->m_eol) == SM_IO_EOF) goto writeerr; if (TrafficLogFile != NULL) (void) sm_io_fprintf(TrafficLogFile, SM_TIME_DEFAULT, diff --git a/usr/src/cmd/sendmail/src/util.c b/usr/src/cmd/sendmail/src/util.c index 4e7a22c3ea..01114a90b8 100644 --- a/usr/src/cmd/sendmail/src/util.c +++ b/usr/src/cmd/sendmail/src/util.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers. + * Copyright (c) 1998-2007 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1988, 1993 @@ -15,7 +15,7 @@ #include <sendmail.h> -SM_RCSID("@(#)$Id: util.c,v 8.410 2006/12/18 18:36:44 ca Exp $") +SM_RCSID("@(#)$Id: util.c,v 8.413 2007/09/26 23:29:11 ca Exp $") #include <sm/sendmail.h> #include <sysexits.h> @@ -1156,7 +1156,8 @@ putxline(l, len, mci, pxflags) /* output last part */ if (l[0] == '.' && slop == 0 && - bitnset(M_XDOT, mci->mci_mailer->m_flags)) + bitnset(M_XDOT, mci->mci_mailer->m_flags) && + !bitset(MCIF_INLONGLINE, mci->mci_flags)) { if (sm_io_putc(mci->mci_out, SM_TIME_DEFAULT, '.') == SM_IO_EOF) @@ -1171,7 +1172,8 @@ putxline(l, len, mci, pxflags) else if (l[0] == 'F' && slop == 0 && bitset(PXLF_MAPFROM, pxflags) && strncmp(l, "From ", 5) == 0 && - bitnset(M_ESCFROM, mci->mci_mailer->m_flags)) + bitnset(M_ESCFROM, mci->mci_mailer->m_flags) && + !bitset(MCIF_INLONGLINE, mci->mci_flags)) { if (sm_io_putc(mci->mci_out, SM_TIME_DEFAULT, '>') == SM_IO_EOF) @@ -1190,13 +1192,19 @@ putxline(l, len, mci, pxflags) if (TrafficLogFile != NULL) (void) sm_io_putc(TrafficLogFile, SM_TIME_DEFAULT, '\n'); - if ((!bitset(PXLF_NOADDEOL, pxflags) || !noeol) && - sm_io_fputs(mci->mci_out, SM_TIME_DEFAULT, - mci->mci_mailer->m_eol) == SM_IO_EOF) + if ((!bitset(PXLF_NOADDEOL, pxflags) || !noeol)) { - dead = true; - break; + mci->mci_flags &= ~MCIF_INLONGLINE; + if (sm_io_fputs(mci->mci_out, SM_TIME_DEFAULT, + mci->mci_mailer->m_eol) == SM_IO_EOF) + { + dead = true; + break; + } } + else + mci->mci_flags |= MCIF_INLONGLINE; + if (l < end && *l == '\n') { if (*++l != ' ' && *l != '\t' && *l != '\0' && @@ -2815,7 +2823,14 @@ count_open_connections(hostaddr) if (hostaddr == NULL) return 0; - n = 0; + + /* + ** Initialize to 1 instead of 0 because this code gets called + ** before proc_list_add() gets called, so we (the daemon child + ** for this connection) don't count ourselves. + */ + + n = 1; for (i = 0; i < ProcListSize; i++) { if (ProcListVec[i].proc_pid == NO_PID) diff --git a/usr/src/cmd/sendmail/src/version.c b/usr/src/cmd/sendmail/src/version.c index f87ebc592f..46bee6f60f 100644 --- a/usr/src/cmd/sendmail/src/version.c +++ b/usr/src/cmd/sendmail/src/version.c @@ -15,6 +15,6 @@ #include <sm/gen.h> -SM_RCSID("@(#)$Id: version.c,v 8.191 2007/04/03 21:21:18 ca Exp $") +SM_RCSID("@(#)$Id: version.c,v 8.199 2007/10/31 16:04:12 ca Exp $") -char Version[] = "8.14.1+Sun"; +char Version[] = "8.14.2+Sun"; |
