summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/libmilter
diff options
context:
space:
mode:
authorgshapiro <gshapiro@FreeBSD.org>2003-02-08 20:31:29 +0000
committergshapiro <gshapiro@FreeBSD.org>2003-02-08 20:31:29 +0000
commit842b56b9cabf175e7842ec5a3b29ff68353b3177 (patch)
tree2e81c43d391ed220f6656502de14ddfbb0de4ecd /contrib/sendmail/libmilter
parent39e311b2e17a53f7ed02fcbe3820ca77b65486d5 (diff)
downloadFreeBSD-src-842b56b9cabf175e7842ec5a3b29ff68353b3177.zip
FreeBSD-src-842b56b9cabf175e7842ec5a3b29ff68353b3177.tar.gz
Import sendmail 8.12.7
Diffstat (limited to 'contrib/sendmail/libmilter')
-rw-r--r--contrib/sendmail/libmilter/README4
-rw-r--r--contrib/sendmail/libmilter/comm.c16
-rw-r--r--contrib/sendmail/libmilter/docs/smfi_settimeout.html7
-rw-r--r--contrib/sendmail/libmilter/engine.c42
-rw-r--r--contrib/sendmail/libmilter/handler.c6
-rw-r--r--contrib/sendmail/libmilter/libmilter.h6
-rw-r--r--contrib/sendmail/libmilter/listener.c33
-rw-r--r--contrib/sendmail/libmilter/main.c14
-rw-r--r--contrib/sendmail/libmilter/signal.c5
9 files changed, 69 insertions, 64 deletions
diff --git a/contrib/sendmail/libmilter/README b/contrib/sendmail/libmilter/README
index f38f68a..efc0b65 100644
--- a/contrib/sendmail/libmilter/README
+++ b/contrib/sendmail/libmilter/README
@@ -39,7 +39,7 @@ The following command presumes that the sample code from the end of this
README is saved to a file named 'sample.c' and built in the local platform-
specific build subdirectory (SRCDIR/obj.*/libmilter).
- cc -I../../sendmail -I../../include -o sample sample.c libmilter.a ../libsm/libsm.a -pthread
+ cc -I../../include -o sample sample.c libmilter.a ../libsm/libsm.a -pthread
It is recommended that you build your filters in a location outside of
the sendmail source tree. Modify the compiler include references (-I)
@@ -457,4 +457,4 @@ main(argc, argv)
/* eof */
-$Revision: 8.35 $, Last updated $Date: 2002/01/07 21:29:20 $
+$Revision: 8.35.2.1 $, Last updated $Date: 2002/10/21 14:31:57 $
diff --git a/contrib/sendmail/libmilter/comm.c b/contrib/sendmail/libmilter/comm.c
index 73d51b1..707a7ce 100644
--- a/contrib/sendmail/libmilter/comm.c
+++ b/contrib/sendmail/libmilter/comm.c
@@ -9,7 +9,7 @@
*/
#include <sm/gen.h>
-SM_RCSID("@(#)$Id: comm.c,v 8.54.2.2 2002/08/16 17:09:13 ca Exp $")
+SM_RCSID("@(#)$Id: comm.c,v 8.54.2.4 2002/12/03 17:32:45 ca Exp $")
#include "libmilter.h"
#include <sm/errstring.h>
@@ -55,14 +55,6 @@ mi_rd_cmd(sd, timeout, cmd, rlen, name)
*cmd = '\0';
*rlen = 0;
- if (sd >= FD_SETSIZE)
- {
- smi_log(SMI_LOG_ERR, "%s: fd %d is larger than FD_SETSIZE %d",
- name, sd, FD_SETSIZE);
- *cmd = SMFIC_SELECT;
- return NULL;
- }
-
i = 0;
for (;;)
{
@@ -87,7 +79,7 @@ mi_rd_cmd(sd, timeout, cmd, rlen, name)
{
smi_log(SMI_LOG_ERR,
"%s, mi_rd_cmd: read returned %d: %s",
- name, len, sm_errstring(errno));
+ name, (int) len, sm_errstring(errno));
*cmd = SMFIC_RECVERR;
return NULL;
}
@@ -160,7 +152,7 @@ mi_rd_cmd(sd, timeout, cmd, rlen, name)
{
smi_log(SMI_LOG_ERR,
"%s: mi_rd_cmd: read returned %d: %s",
- name, len, sm_errstring(errno));
+ name, (int) len, sm_errstring(errno));
ret = -1;
break;
}
@@ -224,7 +216,7 @@ mi_rd_cmd(sd, timeout, cmd, rlen, name)
/*
** we don't care much about the timeout here, it's very long anyway
-** FD_SETSIZE is only checked in mi_rd_cmd.
+** FD_SETSIZE is checked when socket is created.
** XXX l == 0 ?
*/
diff --git a/contrib/sendmail/libmilter/docs/smfi_settimeout.html b/contrib/sendmail/libmilter/docs/smfi_settimeout.html
index a9e870a..6fee166 100644
--- a/contrib/sendmail/libmilter/docs/smfi_settimeout.html
+++ b/contrib/sendmail/libmilter/docs/smfi_settimeout.html
@@ -24,7 +24,10 @@ Set the filter's connection timeout value.
</tr>
<tr align="left" valign=top>
<th width="80">Effects</th>
-<td>Sets the number of seconds libmilter will wait for an MTA connection before timing out a socket. If smfi_settimeout is not called, a default timeout of 1800 seconds is used.</td>
+<td>Sets the number of seconds libmilter will wait for an MTA connection before
+timing out a socket.
+If smfi_settimeout is not called, a default timeout of 7210 seconds is used.
+</td>
</tr>
</table>
@@ -50,7 +53,7 @@ no wait, <b>not</b> "wait forever".
<hr size="1">
<font size="-1">
-Copyright (c) 2000 Sendmail, Inc. and its suppliers.
+Copyright (c) 2000, 2002 Sendmail, Inc. and its suppliers.
All rights reserved.
<br>
By using this file, you agree to the terms and conditions set
diff --git a/contrib/sendmail/libmilter/engine.c b/contrib/sendmail/libmilter/engine.c
index 221a99f..970b005 100644
--- a/contrib/sendmail/libmilter/engine.c
+++ b/contrib/sendmail/libmilter/engine.c
@@ -9,7 +9,7 @@
*/
#include <sm/gen.h>
-SM_RCSID("@(#)$Id: engine.c,v 8.109.2.1 2002/07/29 16:40:47 ca Exp $")
+SM_RCSID("@(#)$Id: engine.c,v 8.109.2.4 2002/12/03 17:27:32 ca Exp $")
#include "libmilter.h"
@@ -116,22 +116,22 @@ static int dec_arg2 __P((char *, size_t, char **, char **));
** this function is coded in trans_ok(), see below.
*/
-#define MASK(x) (0x0001 << (x)) /* generate a bit "mask" for a state */
-#define NX_INIT (MASK(ST_OPTS))
-#define NX_OPTS (MASK(ST_CONN))
-#define NX_CONN (MASK(ST_HELO) | MASK(ST_MAIL))
-#define NX_HELO (MASK(ST_HELO) | MASK(ST_MAIL))
-#define NX_MAIL (MASK(ST_RCPT) | MASK(ST_ABRT))
-#define NX_RCPT (MASK(ST_HDRS) | MASK(ST_EOHS) | \
- MASK(ST_BODY) | MASK(ST_ENDM) | \
- MASK(ST_RCPT) | MASK(ST_ABRT))
-#define NX_HDRS (MASK(ST_EOHS) | MASK(ST_HDRS) | MASK(ST_ABRT))
-#define NX_EOHS (MASK(ST_BODY) | MASK(ST_ENDM) | MASK(ST_ABRT))
-#define NX_BODY (MASK(ST_ENDM) | MASK(ST_BODY) | MASK(ST_ABRT))
-#define NX_ENDM (MASK(ST_QUIT) | MASK(ST_MAIL))
+#define MI_MASK(x) (0x0001 << (x)) /* generate a bit "mask" for a state */
+#define NX_INIT (MI_MASK(ST_OPTS))
+#define NX_OPTS (MI_MASK(ST_CONN))
+#define NX_CONN (MI_MASK(ST_HELO) | MI_MASK(ST_MAIL))
+#define NX_HELO (MI_MASK(ST_HELO) | MI_MASK(ST_MAIL))
+#define NX_MAIL (MI_MASK(ST_RCPT) | MI_MASK(ST_ABRT))
+#define NX_RCPT (MI_MASK(ST_HDRS) | MI_MASK(ST_EOHS) | \
+ MI_MASK(ST_BODY) | MI_MASK(ST_ENDM) | \
+ MI_MASK(ST_RCPT) | MI_MASK(ST_ABRT))
+#define NX_HDRS (MI_MASK(ST_EOHS) | MI_MASK(ST_HDRS) | MI_MASK(ST_ABRT))
+#define NX_EOHS (MI_MASK(ST_BODY) | MI_MASK(ST_ENDM) | MI_MASK(ST_ABRT))
+#define NX_BODY (MI_MASK(ST_ENDM) | MI_MASK(ST_BODY) | MI_MASK(ST_ABRT))
+#define NX_ENDM (MI_MASK(ST_QUIT) | MI_MASK(ST_MAIL))
#define NX_QUIT 0
#define NX_ABRT 0
-#define NX_SKIP MASK(ST_SKIP)
+#define NX_SKIP MI_MASK(ST_SKIP)
static int next_states[] =
{
@@ -255,7 +255,7 @@ mi_engine(ctx)
}
if (ctx->ctx_dbg > 4)
sm_dprintf("[%d] got cmd '%c' len %d\n",
- (int) ctx->ctx_id, cmd, len);
+ (int) ctx->ctx_id, cmd, (int) len);
for (i = 0; i < ncmds; i++)
{
if (cmd == cmds[i].cm_cmd)
@@ -292,8 +292,8 @@ mi_engine(ctx)
if (ctx->ctx_dbg > 1)
sm_dprintf("[%d] abort: cur %d (%x) new %d (%x) next %x\n",
(int) ctx->ctx_id,
- curstate, MASK(curstate),
- newstate, MASK(newstate),
+ curstate, MI_MASK(curstate),
+ newstate, MI_MASK(newstate),
next_states[curstate]);
/* call abort only if in a mail transaction */
@@ -511,7 +511,7 @@ st_optionneg(g)
smi_log(SMI_LOG_ERR,
"%s: st_optionneg[%d]: len too short %d < %d",
g->a_ctx->ctx_smfi->xxfi_name,
- (int) g->a_ctx->ctx_id, g->a_len,
+ (int) g->a_ctx->ctx_id, (int) g->a_len,
MILTER_OPTLEN);
return _SMFIS_ABORT;
}
@@ -615,7 +615,7 @@ st_connectinfo(g)
smi_log(SMI_LOG_ERR,
"%s: connect[%d]: wrong len %d >= %d",
g->a_ctx->ctx_smfi->xxfi_name,
- (int) g->a_ctx->ctx_id, i, l);
+ (int) g->a_ctx->ctx_id, (int) i, (int) l);
return _SMFIS_ABORT;
}
@@ -990,7 +990,7 @@ trans_ok(old, new)
do
{
/* is this state transition allowed? */
- if ((MASK(new) & next_states[s]) != 0)
+ if ((MI_MASK(new) & next_states[s]) != 0)
return true;
/*
diff --git a/contrib/sendmail/libmilter/handler.c b/contrib/sendmail/libmilter/handler.c
index a7b4760..5bbb97b 100644
--- a/contrib/sendmail/libmilter/handler.c
+++ b/contrib/sendmail/libmilter/handler.c
@@ -9,7 +9,7 @@
*/
#include <sm/gen.h>
-SM_RCSID("@(#)$Id: handler.c,v 8.30 2002/04/29 15:06:48 ca Exp $")
+SM_RCSID("@(#)$Id: handler.c,v 8.30.2.2 2002/12/18 23:15:35 ca Exp $")
#include "libmilter.h"
@@ -35,8 +35,8 @@ mi_handle_session(ctx)
ctx->ctx_id = (sthread_t) sthread_get_id();
/*
- ** detach so resources are free when the thread returns
- ** if we ever "wait" for threads, this call must be removed
+ ** Detach so resources are free when the thread returns.
+ ** If we ever "wait" for threads, this call must be removed.
*/
if (pthread_detach(ctx->ctx_id) != 0)
diff --git a/contrib/sendmail/libmilter/libmilter.h b/contrib/sendmail/libmilter/libmilter.h
index fedc24f..2b7b791 100644
--- a/contrib/sendmail/libmilter/libmilter.h
+++ b/contrib/sendmail/libmilter/libmilter.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2001 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1999-2002 Sendmail, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
@@ -19,7 +19,7 @@
#ifdef _DEFINE
# define EXTERN
# define INIT(x) = x
-SM_IDSTR(MilterlId, "@(#)$Id: libmilter.h,v 8.33 2002/04/30 23:52:24 msk Exp $")
+SM_IDSTR(MilterlId, "@(#)$Id: libmilter.h,v 8.33.2.7 2002/12/18 23:15:35 ca Exp $")
#else /* _DEFINE */
# define EXTERN extern
# define INIT(x)
@@ -118,4 +118,4 @@ extern int mi_wr_cmd __P((socket_t, struct timeval *, int, char *, size_t));
extern bool mi_sendok __P((SMFICTX_PTR, int));
-#endif /* !_LIBMILTER_H */
+#endif /* ! _LIBMILTER_H */
diff --git a/contrib/sendmail/libmilter/listener.c b/contrib/sendmail/libmilter/listener.c
index e809a7b..532920a 100644
--- a/contrib/sendmail/libmilter/listener.c
+++ b/contrib/sendmail/libmilter/listener.c
@@ -9,7 +9,7 @@
*/
#include <sm/gen.h>
-SM_RCSID("@(#)$Id: listener.c,v 8.85.2.1 2002/08/09 22:13:36 gshapiro Exp $")
+SM_RCSID("@(#)$Id: listener.c,v 8.85.2.7 2002/12/10 04:02:25 ca Exp $")
/*
** listener.c -- threaded network listener
@@ -17,6 +17,7 @@ SM_RCSID("@(#)$Id: listener.c,v 8.85.2.1 2002/08/09 22:13:36 gshapiro Exp $")
#include "libmilter.h"
#include <sm/errstring.h>
+#include <sm/fdset.h>
# if NETINET || NETINET6
@@ -73,7 +74,13 @@ mi_opensocket(conn, backlog, dbg, smfi)
(void) smutex_unlock(&L_Mutex);
return MI_FAILURE;
}
-
+ if (!SM_FD_OK_SELECT(listenfd))
+ {
+ smi_log(SMI_LOG_ERR, "%s: fd %d is larger than FD_SETSIZE %d",
+ smfi->xxfi_name, listenfd, FD_SETSIZE);
+ (void) smutex_unlock(&L_Mutex);
+ return MI_FAILURE;
+ }
return MI_SUCCESS;
}
@@ -482,7 +489,7 @@ mi_milteropen(conn, backlog, name)
{
smi_log(SMI_LOG_ERR,
"%s: can't malloc(%d) for sockpath: %s",
- name, len, sm_errstring(errno));
+ name, (int) len, sm_errstring(errno));
(void) closesocket(sock);
return INVALID_SOCKET;
}
@@ -630,9 +637,10 @@ mi_closener()
if (rs != 0) \
{ \
smi_log(SMI_LOG_ERR, \
- "MI_SLEEP(): select() returned non-zero result %d, errno = %d", \
+ "MI_SLEEP(): select() returned non-zero result %d, errno = %d", \
rs, errno); \
} \
+ break; \
} \
} \
}
@@ -668,16 +676,7 @@ mi_listener(conn, dbg, smfi, timeout, backlog)
return MI_FAILURE;
clilen = L_socksize;
-
- if (listenfd >= FD_SETSIZE)
- {
- smi_log(SMI_LOG_ERR, "%s: fd %d is larger than FD_SETSIZE %d",
- smfi->xxfi_name, listenfd, FD_SETSIZE);
- (void) smutex_unlock(&L_Mutex);
- return MI_FAILURE;
- }
(void) smutex_unlock(&L_Mutex);
-
while (mi_stop() == MILTER_CONT)
{
(void) smutex_lock(&L_Mutex);
@@ -755,6 +754,14 @@ mi_listener(conn, dbg, smfi, timeout, backlog)
save_errno = EINVAL;
}
+ /* check if acceptable for select() */
+ if (ValidSocket(connfd) && !SM_FD_OK_SELECT(connfd))
+ {
+ (void) closesocket(connfd);
+ connfd = INVALID_SOCKET;
+ save_errno = ERANGE;
+ }
+
if (!ValidSocket(connfd))
{
if (save_errno == EINTR)
diff --git a/contrib/sendmail/libmilter/main.c b/contrib/sendmail/libmilter/main.c
index 6fc3f95..1828deb 100644
--- a/contrib/sendmail/libmilter/main.c
+++ b/contrib/sendmail/libmilter/main.c
@@ -9,7 +9,7 @@
*/
#include <sm/gen.h>
-SM_RCSID("@(#)$Id: main.c,v 8.64 2002/06/04 02:32:32 geir Exp $")
+SM_RCSID("@(#)$Id: main.c,v 8.64.2.8 2002/12/18 23:13:45 ca Exp $")
#define _DEFINE 1
#include "libmilter.h"
@@ -98,13 +98,13 @@ static int backlog = MI_SOMAXCONN;
#if _FFR_SMFI_OPENSOCKET
/*
** SMFI_OPENSOCKET -- try the socket setup to make sure we'll be
-** able to start up
+** able to start up
**
-** Parameters:
-** None.
+** Parameters:
+** None.
**
-** Return:
-** MI_SUCCESS/MI_FAILURE
+** Return:
+** MI_SUCCESS/MI_FAILURE
*/
int
@@ -236,6 +236,6 @@ smfi_main()
/* Startup the listener */
if (mi_listener(conn, dbg, smfi, timeout, backlog) != MI_SUCCESS)
r = MI_FAILURE;
-
return r;
}
+
diff --git a/contrib/sendmail/libmilter/signal.c b/contrib/sendmail/libmilter/signal.c
index 43a8567..aeb307a 100644
--- a/contrib/sendmail/libmilter/signal.c
+++ b/contrib/sendmail/libmilter/signal.c
@@ -9,7 +9,7 @@
*/
#include <sm/gen.h>
-SM_RCSID("@(#)$Id: signal.c,v 8.37 2002/03/23 00:55:19 ca Exp $")
+SM_RCSID("@(#)$Id: signal.c,v 8.37.2.2 2002/10/23 16:52:00 ca Exp $")
#include "libmilter.h"
@@ -107,6 +107,9 @@ mi_signal_thread(name)
if (sigwait(&set, &sig) != 0)
#endif /* defined(SOLARIS) || defined(__svr5__) */
{
+ /* this can happen on OSF/1 (at least) */
+ if (errno == EINTR)
+ continue;
smi_log(SMI_LOG_ERR,
"%s: sigwait returned error: %d",
(char *)name, errno);
OpenPOWER on IntegriCloud