summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/src
diff options
context:
space:
mode:
authorgshapiro <gshapiro@FreeBSD.org>2005-06-07 04:14:59 +0000
committergshapiro <gshapiro@FreeBSD.org>2005-06-07 04:14:59 +0000
commitd912a4d5b04fce27a92e203dbfc0eca7ccc988b2 (patch)
treef6b7fd793c0ba6e3aba4a512163b703257ce1e8a /contrib/sendmail/src
parentc93fbf7bf16de84e88169509f733b1423d2c4108 (diff)
parent125167ce170bc64dfd57dd664a3bdde3580230c7 (diff)
downloadFreeBSD-src-d912a4d5b04fce27a92e203dbfc0eca7ccc988b2.zip
FreeBSD-src-d912a4d5b04fce27a92e203dbfc0eca7ccc988b2.tar.gz
This commit was generated by cvs2svn to compensate for changes in r147078,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/sendmail/src')
-rw-r--r--contrib/sendmail/src/README7
-rw-r--r--contrib/sendmail/src/TRACEFLAGS3
-rw-r--r--contrib/sendmail/src/collect.c5
-rw-r--r--contrib/sendmail/src/daemon.c92
-rw-r--r--contrib/sendmail/src/deliver.c16
-rw-r--r--contrib/sendmail/src/domain.c9
-rw-r--r--contrib/sendmail/src/envelope.c4
-rw-r--r--contrib/sendmail/src/map.c42
-rw-r--r--contrib/sendmail/src/milter.c28
-rw-r--r--contrib/sendmail/src/parseaddr.c19
-rw-r--r--contrib/sendmail/src/queue.c303
-rw-r--r--contrib/sendmail/src/sendmail.h11
-rw-r--r--contrib/sendmail/src/srvrsmtp.c42
-rw-r--r--contrib/sendmail/src/tls.c7
-rw-r--r--contrib/sendmail/src/usersmtp.c4
-rw-r--r--contrib/sendmail/src/version.c4
16 files changed, 411 insertions, 185 deletions
diff --git a/contrib/sendmail/src/README b/contrib/sendmail/src/README
index 1d0b117..0440657 100644
--- a/contrib/sendmail/src/README
+++ b/contrib/sendmail/src/README
@@ -9,7 +9,7 @@
# the sendmail distribution.
#
#
-# $Id: README,v 8.385 2004/11/25 06:52:06 msk Exp $
+# $Id: README,v 8.386 2005/03/04 23:24:08 ca Exp $
#
This directory contains the source files for sendmail(TM).
@@ -375,6 +375,9 @@ LA_TYPE The type of load average your kernel supports. These
LA_DEVSHORT (13) reads a short from a system file (default:
/dev/table/avenrun) and scales it in the same manner
as LA_SHORT.
+ LA_LONGLONG (17) to read /dev/kmem for the symbol avenrun and
+ interpret as a long long integer (e.g., for 64 bit
+ systems).
LA_INT, LA_SHORT, LA_FLOAT, and LA_READKSYM have several
other parameters that they try to divine: the name of your
kernel, the name of the variable in the kernel to examine,
@@ -1823,4 +1826,4 @@ util.c Some general purpose routines used by sendmail.
version.c The version number and information about this
version of sendmail.
-(Version $Revision: 8.385 $, last update $Date: 2004/11/25 06:52:06 $ )
+(Version $Revision: 8.386 $, last update $Date: 2005/03/04 23:24:08 $ )
diff --git a/contrib/sendmail/src/TRACEFLAGS b/contrib/sendmail/src/TRACEFLAGS
index 9927922..3e0a14c 100644
--- a/contrib/sendmail/src/TRACEFLAGS
+++ b/contrib/sendmail/src/TRACEFLAGS
@@ -1,4 +1,4 @@
-# $Id: TRACEFLAGS,v 8.42 2003/06/13 22:29:11 lijian Exp $
+# $Id: TRACEFLAGS,v 8.43 2005/02/16 23:38:51 ca Exp $
0, 4 main.c main canonical name, UUCP node name, a.k.a.s
0, 15 main.c main print configuration
0, 44 util.c printav print address of each string
@@ -83,6 +83,7 @@
#endif /* _FFR_QUEUE_SCHED_DBG */
70 queue.c quarantining
71,>99 milter.c quarantine on errors
+73 queue.c shared memory updates
80 content length
81 sun remote mode
91 mci.c syslogging of MCI cache information
diff --git a/contrib/sendmail/src/collect.c b/contrib/sendmail/src/collect.c
index ac13007..101bcd0 100644
--- a/contrib/sendmail/src/collect.c
+++ b/contrib/sendmail/src/collect.c
@@ -13,7 +13,7 @@
#include <sendmail.h>
-SM_RCSID("@(#)$Id: collect.c,v 8.260 2004/11/30 23:29:15 ca Exp $")
+SM_RCSID("@(#)$Id: collect.c,v 8.261 2005/02/16 23:38:51 ca Exp $")
static void collecttimeout __P((int));
static void eatfrom __P((char *volatile, ENVELOPE *));
@@ -728,6 +728,7 @@ readerr:
{
/* skip next few clauses */
/* EMPTY */
+ /* Note: updfs() is not called in this case! */
}
else if (sm_io_setinfo(df, SM_BF_COMMIT, NULL) < 0 && errno != EINVAL)
{
@@ -781,7 +782,7 @@ readerr:
df = NULL;
/* remove from available space in filesystem */
- updfs(e, false, true);
+ updfs(e, 0, 1, "collect");
}
/* An EOF when running SMTP is an error */
diff --git a/contrib/sendmail/src/daemon.c b/contrib/sendmail/src/daemon.c
index 0077e92..69a5f61 100644
--- a/contrib/sendmail/src/daemon.c
+++ b/contrib/sendmail/src/daemon.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993
@@ -13,7 +13,7 @@
#include <sendmail.h>
-SM_RCSID("@(#)$Id: daemon.c,v 8.653 2004/11/18 23:45:01 ca Exp $")
+SM_RCSID("@(#)$Id: daemon.c,v 8.658 2005/02/02 18:19:28 ca Exp $")
#if defined(SOCK_STREAM) || defined(__GNU_LIBRARY__)
# define USE_SOCK_STREAM 1
@@ -77,10 +77,22 @@ struct daemon
char *d_inputfilterlist;
struct milter *d_inputfilters[MAXFILTERS];
#endif /* MILTER */
+#if _FFR_SS_PER_DAEMON
+ int d_supersafe;
+#endif /* _FFR_SS_PER_DAEMON */
+#if _FFR_DM_PER_DAEMON
+ int d_dm; /* DeliveryMode */
+#endif /* _FFR_DM_PER_DAEMON */
};
typedef struct daemon DAEMON_T;
+#define SAFE_NOTSET (-1) /* SuperSafe (per daemon) option not set */
+/* see also sendmail.h: SuperSafe values */
+
+#define DM_NOTSET (-1) /* DeliveryMode (per daemon) option not set */
+/* see also sendmail.h: values for e_sendmode -- send modes */
+
static void connecttimeout __P((int));
static int opendaemonsocket __P((DAEMON_T *, bool));
static unsigned short setupdaemon __P((SOCKADDR *));
@@ -742,6 +754,17 @@ getrequests(e)
/* don't schedule queue runs if ETRN */
QueueIntvl = 0;
+#if _FFR_SS_PER_DAEMON
+ if (Daemons[curdaemon].d_supersafe !=
+ SAFE_NOTSET)
+ SuperSafe = Daemons[curdaemon].d_supersafe;
+#endif /* _FFR_SS_PER_DAEMON */
+#if _FFR_DM_PER_DAEMON
+ if (Daemons[curdaemon].d_dm != DM_NOTSET)
+ set_delivery_mode(
+ Daemons[curdaemon].d_dm, e);
+#endif /* _FFR_DM_PER_DAEMON */
+
sm_setproctitle(true, e, "startup with %s",
anynet_ntoa(&RealHostAddr));
@@ -1453,9 +1476,37 @@ setsockaddroptions(p, d)
continue;
if (isascii(*f) && islower(*f))
*f = toupper(*f);
+#if _FFR_SS_PER_DAEMON
+ d->d_supersafe = SAFE_NOTSET;
+#endif /* _FFR_SS_PER_DAEMON */
+#if _FFR_DM_PER_DAEMON
+ d->d_dm = DM_NOTSET;
+#endif /* _FFR_DM_PER_DAEMON */
switch (*f)
{
+ case 'A': /* address */
+ addr = v;
+ break;
+
+#if _FFR_DM_PER_DAEMON
+ case 'D': /* DeliveryMode */
+ switch (*v)
+ {
+ case SM_QUEUE:
+ case SM_DEFER:
+ case SM_DELIVER:
+ case SM_FORK:
+ d->d_dm = *v;
+ break;
+ default:
+ syserr("554 5.3.5 Unknown delivery mode %c",
+ *v);
+ break;
+ }
+ break;
+#endif /* _FFR_DM_PER_DAEMON */
+
case 'F': /* address family */
if (isascii(*v) && isdigit(*v))
d->d_addr.sa.sa_family = atoi(v);
@@ -1491,20 +1542,12 @@ setsockaddroptions(p, d)
v);
break;
- case 'A': /* address */
- addr = v;
- break;
-
#if MILTER
case 'I':
d->d_inputfilterlist = v;
break;
#endif /* MILTER */
- case 'P': /* port */
- port = v;
- break;
-
case 'L': /* listen queue size */
d->d_listenqueue = atoi(v);
break;
@@ -1513,17 +1556,38 @@ setsockaddroptions(p, d)
d->d_mflags = getmodifiers(v, d->d_flags);
break;
- case 'S': /* send buffer size */
- d->d_tcpsndbufsize = atoi(v);
+ case 'N': /* name */
+ d->d_name = v;
+ break;
+
+ case 'P': /* port */
+ port = v;
break;
case 'R': /* receive buffer size */
d->d_tcprcvbufsize = atoi(v);
break;
- case 'N': /* name */
- d->d_name = v;
+ case 'S': /* send buffer size */
+ d->d_tcpsndbufsize = atoi(v);
+ break;
+
+#if _FFR_SS_PER_DAEMON
+ case 'T': /* SuperSafe */
+ if (tolower(*v) == 'i')
+ d->d_supersafe = SAFE_INTERACTIVE;
+ else if (tolower(*v) == 'p')
+# if MILTER
+ d->d_supersafe = SAFE_REALLY_POSTMILTER;
+# else /* MILTER */
+ (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
+ "Warning: SuperSafe=PostMilter requires Milter support (-DMILTER)\n");
+# endif /* MILTER */
+ else
+ d->d_supersafe = atobool(v) ? SAFE_REALLY
+ : SAFE_NO;
break;
+#endif /* _FFR_SS_PER_DAEMON */
default:
syserr("554 5.3.5 PortOptions parameter \"%s\" unknown",
diff --git a/contrib/sendmail/src/deliver.c b/contrib/sendmail/src/deliver.c
index 96e16a3..a6b67c8 100644
--- a/contrib/sendmail/src/deliver.c
+++ b/contrib/sendmail/src/deliver.c
@@ -14,7 +14,7 @@
#include <sendmail.h>
#include <sys/time.h>
-SM_RCSID("@(#)$Id: deliver.c,v 8.983 2005/01/07 17:43:22 ca Exp $")
+SM_RCSID("@(#)$Id: deliver.c,v 8.986 2005/03/05 02:28:50 ca Exp $")
#if HASSETUSERCONTEXT
# include <login_cap.h>
@@ -4267,6 +4267,16 @@ logdelivery(m, mci, dsn, status, ctladdr, xstart, e)
bp += strlen(bp);
}
+#if _FFR_LOG_NTRIES
+ /* ntries */
+ if (e->e_ntries >= 0)
+ {
+ (void) sm_snprintf(bp, SPACELEFT(buf, bp),
+ ", ntries=%d", e->e_ntries + 1);
+ bp += strlen(bp);
+ }
+#endif /* _FFR_LOG_NTRIES */
+
# define STATLEN (((SYSLOG_BUFSIZE) - 100) / 4)
# if (STATLEN) < 63
# undef STATLEN
@@ -5673,6 +5683,10 @@ hostsignature(m, host)
!(m->m_argv[0] != NULL && strcmp(m->m_argv[0], "TCP") == 0))
return "localhost";
+ /* an empty host does not have MX records */
+ if (*host == '\0')
+ return "_empty_";
+
/*
** Check to see if this uses IPC -- if not, it can't have MX records.
*/
diff --git a/contrib/sendmail/src/domain.c b/contrib/sendmail/src/domain.c
index c215821..e12baad 100644
--- a/contrib/sendmail/src/domain.c
+++ b/contrib/sendmail/src/domain.c
@@ -14,9 +14,9 @@
#include <sendmail.h>
#if NAMED_BIND
-SM_RCSID("@(#)$Id: domain.c,v 8.195 2004/08/04 21:11:31 ca Exp $ (with name server)")
+SM_RCSID("@(#)$Id: domain.c,v 8.197 2005/03/04 00:54:42 ca Exp $ (with name server)")
#else /* NAMED_BIND */
-SM_RCSID("@(#)$Id: domain.c,v 8.195 2004/08/04 21:11:31 ca Exp $ (without name server)")
+SM_RCSID("@(#)$Id: domain.c,v 8.197 2005/03/04 00:54:42 ca Exp $ (without name server)")
#endif /* NAMED_BIND */
#if NAMED_BIND
@@ -232,6 +232,9 @@ getmxrr(host, mxhosts, mxprefs, droplocalhost, rcode, tryfallback, pttl)
if (tTd(8, 2))
sm_dprintf("getmxrr(%s, droplocalhost=%d)\n",
host, droplocalhost);
+ *rcode = EX_OK;
+ if (pttl != NULL)
+ *pttl = SM_DEFAULT_TTL;
if (*host == '\0')
return 0;
@@ -242,8 +245,6 @@ getmxrr(host, mxhosts, mxprefs, droplocalhost, rcode, tryfallback, pttl)
fallbackMX = NULL;
}
- *rcode = EX_OK;
-
if (mxprefs != NULL)
prefs = mxprefs;
else
diff --git a/contrib/sendmail/src/envelope.c b/contrib/sendmail/src/envelope.c
index 1aedd3e..af6370b 100644
--- a/contrib/sendmail/src/envelope.c
+++ b/contrib/sendmail/src/envelope.c
@@ -13,7 +13,7 @@
#include <sendmail.h>
-SM_RCSID("@(#)$Id: envelope.c,v 8.293 2004/02/18 00:46:18 gshapiro Exp $")
+SM_RCSID("@(#)$Id: envelope.c,v 8.294 2005/02/16 23:38:51 ca Exp $")
/*
** CLRSESSENVELOPE -- clear session oriented data in an envelope
@@ -518,7 +518,7 @@ simpledrop:
if (xunlink(queuename(e, ANYQFL_LETTER)) == 0)
{
/* add to available space in filesystem */
- updfs(e, true, !panic);
+ updfs(e, -1, panic ? 0 : -1, "dropenvelope");
}
if (e->e_ntries > 0 && LogLevel > 9)
diff --git a/contrib/sendmail/src/map.c b/contrib/sendmail/src/map.c
index 46bf15f..056d76e 100644
--- a/contrib/sendmail/src/map.c
+++ b/contrib/sendmail/src/map.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-2003 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1992, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1992, 1993
@@ -13,7 +13,7 @@
#include <sendmail.h>
-SM_RCSID("@(#)$Id: map.c,v 8.666 2004/08/17 16:50:19 gshapiro Exp $")
+SM_RCSID("@(#)$Id: map.c,v 8.669 2005/02/09 01:46:35 ca Exp $")
#if LDAPMAP
# include <sm/ldap.h>
@@ -5657,12 +5657,14 @@ stab_map_lookup(map, name, av, pstat)
map->map_mname, name);
s = stab(name, ST_ALIAS, ST_FIND);
- if (s != NULL)
- return s->s_alias;
- return NULL;
+ if (s == NULL)
+ return NULL;
+ if (bitset(MF_MATCHONLY, map->map_mflags))
+ return map_rewrite(map, name, strlen(name), NULL);
+ else
+ return map_rewrite(map, s->s_alias, strlen(s->s_alias), av);
}
-
/*
** STAB_MAP_STORE -- store in symtab (actually using during init, not rebuild)
*/
@@ -7554,8 +7556,9 @@ socket_map_lookup(map, name, av, statp)
int *statp;
{
unsigned int nettolen, replylen, recvlen;
- char *replybuf, *rval, *value, *status;
+ char *replybuf, *rval, *value, *status, *key;
SM_FILE_T *f;
+ char keybuf[MAXNAME + 1];
replybuf = NULL;
rval = NULL;
@@ -7564,11 +7567,24 @@ socket_map_lookup(map, name, av, statp)
sm_dprintf("socket_map_lookup(%s, %s) %s\n",
map->map_mname, name, map->map_file);
- nettolen = strlen(map->map_mname) + 1 + strlen(name);
+ if (!bitset(MF_NOFOLDCASE, map->map_mflags))
+ {
+ nettolen = strlen(name);
+ if (nettolen > sizeof keybuf - 1)
+ nettolen = sizeof keybuf - 1;
+ memmove(keybuf, name, nettolen);
+ keybuf[nettolen] = '\0';
+ makelower(keybuf);
+ key = keybuf;
+ }
+ else
+ key = name;
+
+ nettolen = strlen(map->map_mname) + 1 + strlen(key);
SM_ASSERT(nettolen > strlen(map->map_mname));
- SM_ASSERT(nettolen > strlen(name));
+ SM_ASSERT(nettolen > strlen(key));
if ((sm_io_fprintf(f, SM_TIME_DEFAULT, "%u:%s %s,",
- nettolen, map->map_mname, name) == SM_IO_EOF) ||
+ nettolen, map->map_mname, key) == SM_IO_EOF) ||
(sm_io_flush(f, SM_TIME_DEFAULT) != 0) ||
(sm_io_error(f)))
{
@@ -7638,7 +7654,7 @@ socket_map_lookup(map, name, av, statp)
/* collect the return value */
if (bitset(MF_MATCHONLY, map->map_mflags))
- rval = map_rewrite(map, name, strlen(name), NULL);
+ rval = map_rewrite(map, key, strlen(key), NULL);
else
rval = map_rewrite(map, value, strlen(value), av);
}
@@ -7647,13 +7663,13 @@ socket_map_lookup(map, name, av, statp)
*statp = EX_NOTFOUND;
if (tTd(38, 20))
sm_dprintf("socket_map_lookup(%s): %s not found\n",
- map->map_mname, name);
+ map->map_mname, key);
}
else
{
if (tTd(38, 5))
sm_dprintf("socket_map_lookup(%s, %s): server returned error: type=%s, reason=%s\n",
- map->map_mname, name, status,
+ map->map_mname, key, status,
value ? value : "");
if ((strcmp(status, "TEMP") == 0) ||
(strcmp(status, "TIMEOUT") == 0))
diff --git a/contrib/sendmail/src/milter.c b/contrib/sendmail/src/milter.c
index 21374b8..0fba8a1 100644
--- a/contrib/sendmail/src/milter.c
+++ b/contrib/sendmail/src/milter.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2004 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1999-2005 Sendmail, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
@@ -10,7 +10,7 @@
#include <sendmail.h>
-SM_RCSID("@(#)$Id: milter.c,v 8.228 2004/11/09 18:54:55 ca Exp $")
+SM_RCSID("@(#)$Id: milter.c,v 8.229 2005/03/02 02:32:34 ca Exp $")
#if MILTER
# include <libmilter/mfapi.h>
@@ -350,6 +350,16 @@ milter_read(m, cmd, rlen, to, e)
char *buf;
char data[MILTER_LEN_BYTES + 1];
+ if (m->mf_sock < 0)
+ {
+ if (MilterLogLevel > 0)
+ sm_syslog(LOG_ERR, e->e_id,
+ "milter_read(%s): socket closed",
+ m->mf_name);
+ milter_error(m, e);
+ return NULL;
+ }
+
*rlen = 0;
*cmd = '\0';
@@ -487,6 +497,15 @@ milter_write(m, cmd, buf, len, to, e)
milter_error(m, e);
return NULL;
}
+ if (m->mf_sock < 0)
+ {
+ if (MilterLogLevel > 0)
+ sm_syslog(LOG_ERR, e->e_id,
+ "milter_write(%s): socket closed",
+ m->mf_name);
+ milter_error(m, e);
+ return NULL;
+ }
if (tTd(64, 20))
sm_dprintf("milter_write(%s): cmd %c, len %ld\n",
@@ -1852,7 +1871,7 @@ milter_send_macros(m, macros, cmd, e)
}
(void) milter_write(m, SMFIC_MACRO, buf, s,
m->mf_timeout[SMFTO_WRITE], e);
- sm_free(buf); /* XXX */
+ sm_free(buf);
}
/*
@@ -3760,8 +3779,11 @@ milter_data(e, state)
}
if (MilterEOMMacros[0] != NULL)
+ {
milter_send_macros(m, MilterEOMMacros,
SMFIC_BODYEOB, e);
+ MILTER_CHECK_RESULTS();
+ }
/* send the final body chunk */
(void) milter_write(m, SMFIC_BODYEOB, NULL, 0,
diff --git a/contrib/sendmail/src/parseaddr.c b/contrib/sendmail/src/parseaddr.c
index 9050b97..4852ab5 100644
--- a/contrib/sendmail/src/parseaddr.c
+++ b/contrib/sendmail/src/parseaddr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-2003 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993
@@ -13,7 +13,7 @@
#include <sendmail.h>
-SM_RCSID("@(#)$Id: parseaddr.c,v 8.379 2004/08/06 22:19:36 ca Exp $")
+SM_RCSID("@(#)$Id: parseaddr.c,v 8.381 2005/02/04 22:01:45 ca Exp $")
static void allocaddr __P((ADDRESS *, int, char *, ENVELOPE *));
static int callsubr __P((char**, int, ENVELOPE *));
@@ -2194,9 +2194,22 @@ cataddr(pvp, evp, buf, sz, spacesub)
break;
}
- /* Don't silently truncate long strings */
+#if 0
+ /*
+ ** Silently truncate long strings: even though this doesn't
+ ** seem like a good idea it is necessary because header checks
+ ** send the whole header value to rscheck() and hence rewrite().
+ ** The latter however sometimes uses a "short" buffer (e.g.,
+ ** cbuf[MAXNAME + 1]) to call cataddr() which then triggers this
+ ** error function. One possible fix to the problem is to pass
+ ** flags to rscheck() and rewrite() to distinguish the various
+ ** calls and only trigger the error if necessary. For now just
+ ** undo the change from 8.13.0.
+ */
+
if (sz <= 0)
usrerr("cataddr: string too long");
+#endif
*p = '\0';
}
/*
diff --git a/contrib/sendmail/src/queue.c b/contrib/sendmail/src/queue.c
index 51d6b63..972e240 100644
--- a/contrib/sendmail/src/queue.c
+++ b/contrib/sendmail/src/queue.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993
@@ -12,8 +12,9 @@
*/
#include <sendmail.h>
+#include <sm/sem.h>
-SM_RCSID("@(#)$Id: queue.c,v 8.939 2004/08/03 19:57:23 ca Exp $")
+SM_RCSID("@(#)$Id: queue.c,v 8.944 2005/02/17 23:58:58 ca Exp $")
#include <dirent.h>
@@ -401,6 +402,7 @@ queueup(e, announce, msync)
/* NOTREACHED */
}
e->e_lockfp = tfp;
+ upd_qs(e, 1, 0, "queueup");
}
/* if newid, write the queue file directly (instead of temp file) */
@@ -6496,13 +6498,79 @@ disk_status(out, prefix)
#endif /* _FFR_CONTROL_MSTAT */
#if SM_CONF_SHM
+
+/*
+** INIT_SEM -- initialize semaphore system
+**
+** Parameters:
+** owner -- is this the owner of semaphores?
+**
+** Returns:
+** none.
+*/
+
+#if _FFR_USE_SEM_LOCKING
+#if SM_CONF_SEM
+static int SemId = -1; /* Semaphore Id */
+int SemKey = SM_SEM_KEY;
+#endif /* SM_CONF_SEM */
+#endif /* _FFR_USE_SEM_LOCKING */
+
+static void init_sem __P((bool));
+
+static void
+init_sem(owner)
+ bool owner;
+{
+#if _FFR_USE_SEM_LOCKING
+#if SM_CONF_SEM
+ SemId = sm_sem_start(SemKey, 1, 0, owner);
+ if (SemId < 0)
+ {
+ sm_syslog(LOG_ERR, NOQID,
+ "func=init_sem, sem_key=%ld, sm_sem_start=%d",
+ (long) SemKey, SemId);
+ return;
+ }
+#endif /* SM_CONF_SEM */
+#endif /* _FFR_USE_SEM_LOCKING */
+ return;
+}
+
+/*
+** STOP_SEM -- stop semaphore system
+**
+** Parameters:
+** owner -- is this the owner of semaphores?
+**
+** Returns:
+** none.
+*/
+
+static void stop_sem __P((bool));
+
+static void
+stop_sem(owner)
+ bool owner;
+{
+#if _FFR_USE_SEM_LOCKING
+#if SM_CONF_SEM
+ if (owner && SemId >= 0)
+ sm_sem_stop(SemId);
+#endif /* SM_CONF_SEM */
+#endif /* _FFR_USE_SEM_LOCKING */
+ return;
+}
+
/*
** UPD_QS -- update information about queue when adding/deleting an entry
**
** Parameters:
** e -- envelope.
-** delete -- delete/add entry.
-** avail -- update the space available as well.
+** count -- add/remove entry (+1/0/-1: add/no change/remove)
+** space -- update the space available as well.
+** (>0/0/<0: add/no change/remove)
+** where -- caller (for logging)
**
** Returns:
** none.
@@ -6513,13 +6581,17 @@ disk_status(out, prefix)
*/
void
-upd_qs(e, delete, avail)
+upd_qs(e, count, space, where)
ENVELOPE *e;
- bool delete;
- bool avail;
+ int count;
+ int space;
+ char *where;
{
short fidx;
int idx;
+# if _FFR_USE_SEM_LOCKING
+ int r;
+# endif /* _FFR_USE_SEM_LOCKING */
long s;
if (ShmId == SM_SHM_NO_ID || e == NULL)
@@ -6527,14 +6599,21 @@ upd_qs(e, delete, avail)
if (e->e_qgrp == NOQGRP || e->e_qdir == NOQDIR)
return;
idx = Queue[e->e_qgrp]->qg_qpaths[e->e_qdir].qp_idx;
+ if (tTd(73,2))
+ sm_dprintf("func=upd_qs, count=%d, space=%d, where=%s, idx=%d, entries=%d\n",
+ count, space, where, idx, QSHM_ENTRIES(idx));
/* XXX in theory this needs to be protected with a mutex */
- if (QSHM_ENTRIES(idx) >= 0)
+ if (QSHM_ENTRIES(idx) >= 0 && count != 0)
{
- if (delete)
- --QSHM_ENTRIES(idx);
- else
- ++QSHM_ENTRIES(idx);
+# if _FFR_USE_SEM_LOCKING
+ r = sm_sem_acq(SemId, 0, 1);
+# endif /* _FFR_USE_SEM_LOCKING */
+ QSHM_ENTRIES(idx) += count;
+# if _FFR_USE_SEM_LOCKING
+ if (r >= 0)
+ r = sm_sem_rel(SemId, 0, 1);
+# endif /* _FFR_USE_SEM_LOCKING */
}
fidx = Queue[e->e_qgrp]->qg_qpaths[e->e_qdir].qp_fsysidx;
@@ -6542,7 +6621,7 @@ upd_qs(e, delete, avail)
return;
/* update available space also? (might be loseqfile) */
- if (!avail)
+ if (space == 0)
return;
/* convert size to blocks; this causes rounding errors */
@@ -6551,7 +6630,7 @@ upd_qs(e, delete, avail)
return;
/* XXX in theory this needs to be protected with a mutex */
- if (delete)
+ if (space > 0)
FILE_SYS_AVAIL(fidx) += s;
else
FILE_SYS_AVAIL(fidx) -= s;
@@ -6676,6 +6755,8 @@ init_shm(qn, owner, hash)
unsigned int hash;
{
int i;
+ int count;
+ int save_errno;
#if _FFR_SELECT_SHM
bool keyselect;
#endif /* _FFR_SELECT_SHM */
@@ -6689,120 +6770,129 @@ init_shm(qn, owner, hash)
#endif /* _FFR_SELECT_SHM */
/* This allows us to disable shared memory at runtime. */
- if (ShmKey != 0)
- {
- int count;
- int save_errno;
+ if (ShmKey == 0)
+ return;
- count = 0;
- shms = SM_T_SIZE + qn * sizeof(QUEUE_SHM_T);
+ count = 0;
+ shms = SM_T_SIZE + qn * sizeof(QUEUE_SHM_T);
#if _FFR_SELECT_SHM
- keyselect = ShmKey == SEL_SHM_KEY;
- if (keyselect)
+ keyselect = ShmKey == SEL_SHM_KEY;
+ if (keyselect)
+ {
+ if (owner)
+ ShmKey = FIRST_SHM_KEY;
+ else
{
- if (owner)
- ShmKey = FIRST_SHM_KEY;
- else
- {
- ShmKey = read_key_file(ShmKeyFile, ShmKey);
- keyselect = false;
- if (ShmKey == SEL_SHM_KEY)
- goto error;
- }
+ ShmKey = read_key_file(ShmKeyFile, ShmKey);
+ keyselect = false;
+ if (ShmKey == SEL_SHM_KEY)
+ goto error;
}
+ }
#endif /* _FFR_SELECT_SHM */
- for (;;)
+ for (;;)
+ {
+ /* allow read/write access for group? */
+ Pshm = sm_shmstart(ShmKey, shms,
+ SHM_R|SHM_W|(SHM_R>>3)|(SHM_W>>3),
+ &ShmId, owner);
+ save_errno = errno;
+ if (Pshm != NULL || !sm_file_exists(save_errno))
+ break;
+ if (++count >= 3)
{
- /* XXX: maybe allow read access for group? */
- Pshm = sm_shmstart(ShmKey, shms, SHM_R|SHM_W, &ShmId,
- owner);
- save_errno = errno;
- if (Pshm != NULL || !sm_file_exists(save_errno))
- break;
- if (++count >= 3)
- {
#if _FFR_SELECT_SHM
- if (keyselect)
- {
- ++ShmKey;
+ if (keyselect)
+ {
+ ++ShmKey;
- /* back where we started? */
- if (ShmKey == SEL_SHM_KEY)
- break;
- continue;
- }
-#endif /* _FFR_SELECT_SHM */
- break;
+ /* back where we started? */
+ if (ShmKey == SEL_SHM_KEY)
+ break;
+ continue;
}
-#if _FFR_SELECT_SHM
- /* only sleep if we are at the first key */
- if (!keyselect || ShmKey == SEL_SHM_KEY)
#endif /* _FFR_SELECT_SHM */
- sleep(count);
+ break;
}
- if (Pshm != NULL)
- {
- int *p;
+#if _FFR_SELECT_SHM
+ /* only sleep if we are at the first key */
+ if (!keyselect || ShmKey == SEL_SHM_KEY)
+#endif /* _FFR_SELECT_SHM */
+ sleep(count);
+ }
+ if (Pshm != NULL)
+ {
+ int *p;
#if _FFR_SELECT_SHM
- if (keyselect)
- (void) write_key_file(ShmKeyFile, (long) ShmKey);
+ if (keyselect)
+ (void) write_key_file(ShmKeyFile, (long) ShmKey);
#endif /* _FFR_SELECT_SHM */
- p = (int *) Pshm;
- if (owner)
+ if (owner && RunAsUid != 0)
+ {
+ i = sm_shmsetowner(ShmId, RunAsUid, RunAsGid,
+ 0660);
+ if (i != 0)
+ sm_syslog(LOG_ERR, NOQID,
+ "key=%ld, sm_shmsetowner=%d, RunAsUid=%d, RunAsGid=%d",
+ (long) ShmKey, i,
+ RunAsUid, RunAsGid);
+ }
+ p = (int *) Pshm;
+ if (owner)
+ {
+ *p = (int) shms;
+ *((pid_t *) SHM_OFF_PID(Pshm)) = CurrentPid;
+ p = (int *) SHM_OFF_TAG(Pshm);
+ *p = hash;
+ }
+ else
+ {
+ if (*p != (int) shms)
{
- *p = (int) shms;
- *((pid_t *) SHM_OFF_PID(Pshm)) = CurrentPid;
- p = (int *) SHM_OFF_TAG(Pshm);
- *p = hash;
+ save_errno = EINVAL;
+ cleanup_shm(false);
+ goto error;
}
- else
+ p = (int *) SHM_OFF_TAG(Pshm);
+ if (*p != (int) hash)
{
- if (*p != (int) shms)
- {
- save_errno = EINVAL;
- cleanup_shm(false);
- goto error;
- }
- p = (int *) SHM_OFF_TAG(Pshm);
- if (*p != (int) hash)
- {
- save_errno = EINVAL;
- cleanup_shm(false);
- goto error;
- }
-
- /*
- ** XXX how to check the pid?
- ** Read it from the pid-file? That does
- ** not need to exist.
- ** We could disable shm if we can't confirm
- ** that it is the right one.
- */
+ save_errno = EINVAL;
+ cleanup_shm(false);
+ goto error;
}
- PtrFileSys = (FILESYS *) OFF_FILE_SYS(Pshm);
- PNumFileSys = (int *) OFF_NUM_FILE_SYS(Pshm);
- QShm = (QUEUE_SHM_T *) OFF_QUEUE_SHM(Pshm);
- PRSATmpCnt = (int *) OFF_RSA_TMP_CNT(Pshm);
- *PRSATmpCnt = 0;
- if (owner)
- {
- /* initialize values in shared memory */
- NumFileSys = 0;
- for (i = 0; i < qn; i++)
- QShm[i].qs_entries = -1;
- }
- return;
+ /*
+ ** XXX how to check the pid?
+ ** Read it from the pid-file? That does
+ ** not need to exist.
+ ** We could disable shm if we can't confirm
+ ** that it is the right one.
+ */
}
- error:
- if (LogLevel > (owner ? 8 : 11))
+
+ PtrFileSys = (FILESYS *) OFF_FILE_SYS(Pshm);
+ PNumFileSys = (int *) OFF_NUM_FILE_SYS(Pshm);
+ QShm = (QUEUE_SHM_T *) OFF_QUEUE_SHM(Pshm);
+ PRSATmpCnt = (int *) OFF_RSA_TMP_CNT(Pshm);
+ *PRSATmpCnt = 0;
+ if (owner)
{
- sm_syslog(owner ? LOG_ERR : LOG_NOTICE, NOQID,
- "can't %s shared memory, key=%ld: %s",
- owner ? "initialize" : "attach to",
- (long) ShmKey, sm_errstring(save_errno));
+ /* initialize values in shared memory */
+ NumFileSys = 0;
+ for (i = 0; i < qn; i++)
+ QShm[i].qs_entries = -1;
}
+ init_sem(owner);
+ return;
+ }
+ error:
+ if (LogLevel > (owner ? 8 : 11))
+ {
+ sm_syslog(owner ? LOG_ERR : LOG_NOTICE, NOQID,
+ "can't %s shared memory, key=%ld: %s",
+ owner ? "initialize" : "attach to",
+ (long) ShmKey, sm_errstring(save_errno));
}
}
#endif /* SM_CONF_SHM */
@@ -7013,6 +7103,7 @@ cleanup_shm(owner)
Pshm = NULL;
ShmId = SM_SHM_NO_ID;
}
+ stop_sem(owner);
}
#endif /* SM_CONF_SHM */
diff --git a/contrib/sendmail/src/sendmail.h b/contrib/sendmail/src/sendmail.h
index 370fae8..ea48a75 100644
--- a/contrib/sendmail/src/sendmail.h
+++ b/contrib/sendmail/src/sendmail.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993
@@ -52,7 +52,7 @@
#ifdef _DEFINE
# ifndef lint
-SM_UNUSED(static char SmailId[]) = "@(#)$Id: sendmail.h,v 8.990 2004/11/09 19:45:46 ca Exp $";
+SM_UNUSED(static char SmailId[]) = "@(#)$Id: sendmail.h,v 8.993 2005/03/07 18:03:17 ca Exp $";
# endif /* ! lint */
#endif /* _DEFINE */
@@ -2578,10 +2578,11 @@ extern void unsetenv __P((char *));
/* update file system information: +/- some blocks */
#if SM_CONF_SHM
-extern void upd_qs __P((ENVELOPE *, bool, bool));
-# define updfs(e, delete, avail) upd_qs(e, delete, avail)
+extern void upd_qs __P((ENVELOPE *, bool, bool, char *));
+# define updfs(e, count, space, where) upd_qs(e, count, space, where)
#else /* SM_CONF_SHM */
-# define updfs(e, delete, avail)
+# define updfs(e, count, space, where)
+# define upd_qs(e, count, space, where)
#endif /* SM_CONF_SHM */
extern char *username __P((void));
diff --git a/contrib/sendmail/src/srvrsmtp.c b/contrib/sendmail/src/srvrsmtp.c
index ff06bf2..bfa2872 100644
--- a/contrib/sendmail/src/srvrsmtp.c
+++ b/contrib/sendmail/src/srvrsmtp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993
@@ -17,7 +17,7 @@
# include <libmilter/mfdef.h>
#endif /* MILTER */
-SM_RCSID("@(#)$Id: srvrsmtp.c,v 8.902 2004/11/18 21:46:01 ca Exp $")
+SM_RCSID("@(#)$Id: srvrsmtp.c,v 8.906 2005/03/16 00:36:09 ca Exp $")
#include <sys/time.h>
#include <sm/fdset.h>
@@ -80,13 +80,13 @@ static int reset_saslconn __P((sasl_conn_t **_conn, char *_hostname,
char *_auth_id, sasl_ssf_t *_ext_ssf));
# define RESET_SASLCONN \
- result = reset_saslconn(&conn, AuthRealm, remoteip, localip, auth_id, \
- &ext_ssf); \
- if (result != SASL_OK) \
- { \
- /* This is pretty fatal */ \
- goto doquit; \
- }
+ do \
+ { \
+ result = reset_saslconn(&conn, AuthRealm, remoteip, \
+ localip, auth_id, &ext_ssf); \
+ if (result != SASL_OK) \
+ sasl_ok = false; \
+ } while (0)
# else /* SASL >= 20000 */
static int reset_saslconn __P((sasl_conn_t **_conn, char *_hostname,
@@ -94,12 +94,13 @@ static int reset_saslconn __P((sasl_conn_t **_conn, char *_hostname,
struct sockaddr_in *_saddr_l,
sasl_external_properties_t *_ext_ssf));
# define RESET_SASLCONN \
- result = reset_saslconn(&conn, AuthRealm, &saddr_r, &saddr_l, &ext_ssf); \
- if (result != SASL_OK) \
- { \
- /* This is pretty fatal */ \
- goto doquit; \
- }
+ do \
+ { \
+ result = reset_saslconn(&conn, AuthRealm, &saddr_r, \
+ &saddr_l, &ext_ssf); \
+ if (result != SASL_OK) \
+ sasl_ok = false; \
+ } while (0)
# endif /* SASL >= 20000 */
#endif /* SASL */
@@ -664,6 +665,7 @@ smtp(nullserver, d_flags, e)
*/
# if SASL >= 20000
+ localip[0] = remoteip[0] = '\0';
# if NETINET || NETINET6
in = macvalue(macid("{daemon_family}"), e);
if (in != NULL && (
@@ -747,8 +749,6 @@ smtp(nullserver, d_flags, e)
/* XXX should these be options settable via .cf ? */
/* ssp.min_ssf = 0; is default due to memset() */
-# if STARTTLS
-# endif /* STARTTLS */
{
ssp.max_ssf = MaxSLBits;
ssp.maxbufsize = MAXOUTLEN;
@@ -4618,12 +4618,12 @@ help(topic, e)
*/
static int
-reset_saslconn(sasl_conn_t ** conn, char *hostname,
+reset_saslconn(sasl_conn_t **conn, char *hostname,
# if SASL >= 20000
char *remoteip, char *localip,
char *auth_id, sasl_ssf_t * ext_ssf)
# else /* SASL >= 20000 */
- struct sockaddr_in * saddr_r, struct sockaddr_in * saddr_l,
+ struct sockaddr_in *saddr_r, struct sockaddr_in *saddr_l,
sasl_external_properties_t * ext_ssf)
# endif /* SASL >= 20000 */
{
@@ -4646,12 +4646,12 @@ reset_saslconn(sasl_conn_t ** conn, char *hostname,
# if SASL >= 20000
# if NETINET || NETINET6
- if (remoteip != NULL)
+ if (remoteip != NULL && *remoteip != '\0')
result = sasl_setprop(*conn, SASL_IPREMOTEPORT, remoteip);
if (result != SASL_OK)
return result;
- if (localip != NULL)
+ if (localip != NULL && *localip != '\0')
result = sasl_setprop(*conn, SASL_IPLOCALPORT, localip);
if (result != SASL_OK)
return result;
diff --git a/contrib/sendmail/src/tls.c b/contrib/sendmail/src/tls.c
index 1867097..3b915cb 100644
--- a/contrib/sendmail/src/tls.c
+++ b/contrib/sendmail/src/tls.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000-2004 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 2000-2005 Sendmail, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
@@ -10,7 +10,7 @@
#include <sendmail.h>
-SM_RCSID("@(#)$Id: tls.c,v 8.96 2004/08/04 21:17:58 ca Exp $")
+SM_RCSID("@(#)$Id: tls.c,v 8.97 2005/03/08 22:20:52 ca Exp $")
#if STARTTLS
# include <openssl/err.h>
@@ -1155,7 +1155,8 @@ tls_get_info(ssl, srv, host, mac, certreq)
NID_commonName, buf, sizeof buf);
macdefine(mac, A_TEMP, macid("{cn_issuer}"),
xtextify(buf, "<>\")"));
- if (X509_digest(cert, EVP_md5(), md, &n))
+ n = 0;
+ if (X509_digest(cert, EVP_md5(), md, &n) != 0 && n > 0)
{
char md5h[EVP_MAX_MD_SIZE * 3];
static const char hexcodes[] = "0123456789ABCDEF";
diff --git a/contrib/sendmail/src/usersmtp.c b/contrib/sendmail/src/usersmtp.c
index 24b0954..bd3de97 100644
--- a/contrib/sendmail/src/usersmtp.c
+++ b/contrib/sendmail/src/usersmtp.c
@@ -13,7 +13,7 @@
#include <sendmail.h>
-SM_RCSID("@(#)$Id: usersmtp.c,v 8.460 2005/01/11 00:24:19 ca Exp $")
+SM_RCSID("@(#)$Id: usersmtp.c,v 8.463 2005/03/16 00:36:09 ca Exp $")
#include <sysexits.h>
@@ -1596,8 +1596,6 @@ attemptauth(m, mci, e, sai)
(void) memset(&ssp, '\0', sizeof ssp);
/* XXX should these be options settable via .cf ? */
-# if STARTTLS
-#endif /* STARTTLS */
{
ssp.max_ssf = MaxSLBits;
ssp.maxbufsize = MAXOUTLEN;
diff --git a/contrib/sendmail/src/version.c b/contrib/sendmail/src/version.c
index af2baa2..9fcf31c 100644
--- a/contrib/sendmail/src/version.c
+++ b/contrib/sendmail/src/version.c
@@ -13,6 +13,6 @@
#include <sm/gen.h>
-SM_RCSID("@(#)$Id: version.c,v 8.140 2005/01/12 04:32:32 ca Exp $")
+SM_RCSID("@(#)$Id: version.c,v 8.145 2005/03/25 18:44:44 ca Exp $")
-char Version[] = "8.13.3";
+char Version[] = "8.13.4";
OpenPOWER on IntegriCloud