diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2011-06-14 04:20:18 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2011-06-14 04:20:18 +0000 |
commit | b73afeb2a402ad777e43387c907da53a40696c88 (patch) | |
tree | 76ab24e8fa418fcd903ec416f76b86ad8e8725ff /contrib/sendmail/libmilter | |
parent | b8dcfe0228713cd46d96c831843ee6c8bbcb84e3 (diff) | |
parent | 8601cea5b1f7986bb1bf047627c2e1c4169d2655 (diff) | |
download | FreeBSD-src-b73afeb2a402ad777e43387c907da53a40696c88.zip FreeBSD-src-b73afeb2a402ad777e43387c907da53a40696c88.tar.gz |
Merge sendmail 8.14.5 to HEAD
MFC after: 4 days
Diffstat (limited to 'contrib/sendmail/libmilter')
-rw-r--r-- | contrib/sendmail/libmilter/docs/overview.html | 4 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/docs/smfi_stop.html | 4 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/docs/xxfi_envrcpt.html | 7 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/engine.c | 22 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/sm_gethost.c | 14 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/worker.c | 65 |
6 files changed, 80 insertions, 36 deletions
diff --git a/contrib/sendmail/libmilter/docs/overview.html b/contrib/sendmail/libmilter/docs/overview.html index 5c6f21c..d6e3bba 100644 --- a/contrib/sendmail/libmilter/docs/overview.html +++ b/contrib/sendmail/libmilter/docs/overview.html @@ -4,7 +4,7 @@ </HEAD> <BODY> <!-- -$Id: overview.html,v 1.20 2009/11/13 18:15:05 ca Exp $ +$Id: overview.html,v 1.21 2010/12/14 20:59:52 ca Exp $ --> <H1>Technical Overview</H1> @@ -126,7 +126,7 @@ messages may be sent in a single connection. Note also that a message or connection may be aborted by either the remote host or the MTA at any point during the SMTP transaction. -f this occurs during a message (between the MAIL command and the final "."), +If this occurs during a message (between the MAIL command and the final "."), the filter's <A HREF="xxfi_abort.html">xxfi_abort</A> routine will be called. <A HREF="xxfi_close.html">xxfi_close</A> is called any time the diff --git a/contrib/sendmail/libmilter/docs/smfi_stop.html b/contrib/sendmail/libmilter/docs/smfi_stop.html index 87ecdb2..5d25882 100644 --- a/contrib/sendmail/libmilter/docs/smfi_stop.html +++ b/contrib/sendmail/libmilter/docs/smfi_stop.html @@ -2,7 +2,7 @@ <HEAD><TITLE>smfi_stop</TITLE></HEAD> <BODY> <!-- -$Id: smfi_stop.html,v 1.6 2006/12/21 18:30:35 ca Exp $ +$Id: smfi_stop.html,v 1.7 2010/12/13 16:16:01 ca Exp $ --> <H1>smfi_stop</H1> @@ -42,7 +42,7 @@ which may then exit or warm-restart. <TABLE border="1" cellspacing=0> <TR bgcolor="#dddddd"><TH>Argument</TH><TH>Description</TH></TR> <TR valign="top"><TD>void</TD> - <TD>Takes no arguement. + <TD>Takes no argument. </TD></TR> </TABLE> </TD></TR> diff --git a/contrib/sendmail/libmilter/docs/xxfi_envrcpt.html b/contrib/sendmail/libmilter/docs/xxfi_envrcpt.html index 9fb4ce8..67a8cf5 100644 --- a/contrib/sendmail/libmilter/docs/xxfi_envrcpt.html +++ b/contrib/sendmail/libmilter/docs/xxfi_envrcpt.html @@ -2,7 +2,7 @@ <HEAD><TITLE>xxfi_envrcpt</TITLE></HEAD> <BODY> <!-- -$Id: xxfi_envrcpt.html,v 1.15 2007/01/25 01:00:20 ca Exp $ +$Id: xxfi_envrcpt.html,v 1.16 2010/07/14 04:41:03 ca Exp $ --> <H1>xxfi_envrcpt</H1> @@ -71,7 +71,8 @@ Handle the envelope RCPT command. </TR> <TR valign="top"> <TD>SMFIS_ACCEPT</TD> - <TD>Accept recipient. <A href="xxfi_abort.html">xxfi_abort</A> will not be called. + <TD>Accept this message. + <A href="xxfi_abort.html">xxfi_abort</A> will not be called. </TD> </TR> </TABLE> @@ -87,7 +88,7 @@ Handle the envelope RCPT command. <HR size="1"> <FONT size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. +Copyright (c) 2000, 2003, 2010 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 a2d3e1e..92c8e6d 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.166 2009/11/06 00:57:07 ca Exp $") +SM_RCSID("@(#)$Id: engine.c,v 8.167 2011/03/03 06:09:15 ca Exp $") #include "libmilter.h" @@ -284,7 +284,7 @@ mi_engine(ctx) if (mi_stop() == MILTER_ABRT) { if (ctx->ctx_dbg > 3) - sm_dprintf("[%ld] milter_abort\n", + sm_dprintf("[%lu] milter_abort\n", (long) ctx->ctx_id); ret = MI_FAILURE; break; @@ -315,7 +315,7 @@ mi_engine(ctx) cmd < SMFIC_VALIDCMD) { if (ctx->ctx_dbg > 5) - sm_dprintf("[%ld] mi_engine: mi_rd_cmd error (%x)\n", + sm_dprintf("[%lu] mi_engine: mi_rd_cmd error (%x)\n", (long) ctx->ctx_id, (int) cmd); /* @@ -328,7 +328,7 @@ mi_engine(ctx) break; } if (ctx->ctx_dbg > 4) - sm_dprintf("[%ld] got cmd '%c' len %d\n", + sm_dprintf("[%lu] got cmd '%c' len %d\n", (long) ctx->ctx_id, cmd, (int) len); for (i = 0; i < ncmds; i++) { @@ -339,7 +339,7 @@ mi_engine(ctx) { /* unknown command */ if (ctx->ctx_dbg > 1) - sm_dprintf("[%ld] cmd '%c' unknown\n", + sm_dprintf("[%lu] cmd '%c' unknown\n", (long) ctx->ctx_id, cmd); ret = MI_FAILURE; break; @@ -348,7 +348,7 @@ mi_engine(ctx) { /* stop for now */ if (ctx->ctx_dbg > 1) - sm_dprintf("[%ld] cmd '%c' not impl\n", + sm_dprintf("[%lu] cmd '%c' not impl\n", (long) ctx->ctx_id, cmd); ret = MI_FAILURE; break; @@ -357,14 +357,14 @@ mi_engine(ctx) /* is new state ok? */ newstate = cmds[i].cm_next; if (ctx->ctx_dbg > 5) - sm_dprintf("[%ld] cur %x new %x nextmask %x\n", + sm_dprintf("[%lu] cur %x new %x nextmask %x\n", (long) ctx->ctx_id, curstate, newstate, next_states[curstate]); if (newstate != ST_NONE && !trans_ok(curstate, newstate)) { if (ctx->ctx_dbg > 1) - sm_dprintf("[%ld] abort: cur %d (%x) new %d (%x) next %x\n", + sm_dprintf("[%lu] abort: cur %d (%x) new %d (%x) next %x\n", (long) ctx->ctx_id, curstate, MI_MASK(curstate), newstate, MI_MASK(newstate), @@ -434,7 +434,7 @@ mi_engine(ctx) else if (r == _SMFIS_ABORT) { if (ctx->ctx_dbg > 5) - sm_dprintf("[%ld] function returned abort\n", + sm_dprintf("[%lu] function returned abort\n", (long) ctx->ctx_id); ret = MI_FAILURE; break; @@ -1122,7 +1122,7 @@ st_optionneg(g) fix_stm(ctx); if (ctx->ctx_dbg > 3) - sm_dprintf("[%ld] milter_negotiate:" + sm_dprintf("[%lu] milter_negotiate:" " mta_actions=0x%lx, mta_flags=0x%lx" " actions=0x%lx, flags=0x%lx\n" , (long) ctx->ctx_id @@ -1131,7 +1131,7 @@ st_optionneg(g) #if _FFR_MILTER_CHECK if (ctx->ctx_dbg > 3) - sm_dprintf("[%ld] milter_negotiate:" + sm_dprintf("[%lu] milter_negotiate:" " testmode=%d, pflags2mta=%X, internal_pflags=%X\n" , (long) ctx->ctx_id, testmode , ctx->ctx_pflags2mta, internal_pflags); diff --git a/contrib/sendmail/libmilter/sm_gethost.c b/contrib/sendmail/libmilter/sm_gethost.c index 5706b89..8f2b339 100644 --- a/contrib/sendmail/libmilter/sm_gethost.c +++ b/contrib/sendmail/libmilter/sm_gethost.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2001, 2004 Sendmail, Inc. and its suppliers. + * Copyright (c) 1999-2001, 2004, 2010 Sendmail, Inc. and its suppliers. * All rights reserved. * * By using this file, you agree to the terms and conditions set @@ -9,7 +9,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: sm_gethost.c,v 8.27 2004/08/20 21:12:37 ca Exp $") +SM_RCSID("@(#)$Id: sm_gethost.c,v 8.29 2010/07/27 01:09:31 ca Exp $") #include <sendmail.h> #if NETINET || NETINET6 @@ -30,7 +30,7 @@ SM_RCSID("@(#)$Id: sm_gethost.c,v 8.27 2004/08/20 21:12:37 ca Exp $") #if NETINET6 && NEEDSGETIPNODE -static struct hostent *getipnodebyname __P((char *, int, int, int *)); +static struct hostent *sm_getipnodebyname __P((const char *, int, int, int *)); # ifndef AI_ADDRCONFIG # define AI_ADDRCONFIG 0 /* dummy */ @@ -43,8 +43,8 @@ static struct hostent *getipnodebyname __P((char *, int, int, int *)); # endif /* ! AI_DEFAULT */ static struct hostent * -getipnodebyname(name, family, flags, err) - char *name; +sm_getipnodebyname(name, family, flags, err) + const char *name; int family; int flags; int *err; @@ -77,6 +77,8 @@ freehostent(h) return; } +#else /* NEEDSGETIPNODE && NETINET6 */ +#define sm_getipnodebyname getipnodebyname #endif /* NEEDSGETIPNODE && NETINET6 */ struct hostent * @@ -107,7 +109,7 @@ mi_gethostbyname(name, family) # if ADDRCONFIG_IS_BROKEN flags &= ~AI_ADDRCONFIG; # endif /* ADDRCONFIG_IS_BROKEN */ - h = getipnodebyname(name, family, flags, &err); + h = sm_getipnodebyname(name, family, flags, &err); SM_SET_H_ERRNO(err); # else /* NETINET6 */ h = gethostbyname(name); diff --git a/contrib/sendmail/libmilter/worker.c b/contrib/sendmail/libmilter/worker.c index 28d404f..aa1bd57 100644 --- a/contrib/sendmail/libmilter/worker.c +++ b/contrib/sendmail/libmilter/worker.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2004, 2007, 2009 Sendmail, Inc. and its suppliers. + * Copyright (c) 2003-2004, 2007, 2009-2011 Sendmail, Inc. and its suppliers. * All rights reserved. * * By using this file, you agree to the terms and conditions set @@ -11,7 +11,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: worker.c,v 8.17 2009/06/15 15:34:54 ca Exp $") +SM_RCSID("@(#)$Id: worker.c,v 8.19 2011/02/14 23:33:48 ca Exp $") #include "libmilter.h" @@ -165,7 +165,9 @@ mi_start_session(ctx) { static long id = 0; - SM_ASSERT(Tskmgr.tm_signature == TM_SIGNATURE); + /* this can happen if the milter is shutting down */ + if (Tskmgr.tm_signature != TM_SIGNATURE) + return MI_FAILURE; SM_ASSERT(ctx != NULL); POOL_LEV_DPRINTF(4, ("PIPE r=[%d] w=[%d]", RD_PIPE, WR_PIPE)); TASKMGR_LOCK(); @@ -216,6 +218,41 @@ mi_close_session(ctx) } /* +** NONBLOCKING -- set nonblocking mode for a file descriptor. +** +** Parameters: +** fd -- file descriptor +** name -- name for (error) logging +** +** Returns: +** MI_SUCCESS/MI_FAILURE +*/ + +static int +nonblocking(int fd, const char *name) +{ + int r; + + errno = 0; + r = fcntl(fd, F_GETFL, 0); + if (r == -1) + { + smi_log(SMI_LOG_ERR, "fcntl(%s, F_GETFL)=%s", + name, sm_errstring(errno)); + return MI_FAILURE; + } + errno = 0; + r = fcntl(fd, F_SETFL, r | O_NONBLOCK); + if (r == -1) + { + smi_log(SMI_LOG_ERR, "fcntl(%s, F_SETFL, O_NONBLOCK)=%s", + name, sm_errstring(errno)); + return MI_FAILURE; + } + return MI_SUCCESS; +} + +/* ** MI_POOL_CONTROLER_INIT -- Launch the worker pool controller ** Must be called before starting sessions. ** @@ -246,6 +283,12 @@ mi_pool_controller_init() sm_errstring(errno)); return MI_FAILURE; } + r = nonblocking(WR_PIPE, "WR_PIPE"); + if (r != MI_SUCCESS) + return r; + r = nonblocking(RD_PIPE, "RD_PIPE"); + if (r != MI_SUCCESS) + return r; (void) smutex_init(&Tskmgr.tm_w_mutex); (void) scond_init(&Tskmgr.tm_w_cond); @@ -495,25 +538,23 @@ mi_pool_controller(arg) /* has a worker signaled an end of task ? */ if (WAIT_FD(i) == RD_PIPE) { - char evt = 0; - int r = 0; + char evts[256]; + ssize_t r; POOL_LEV_DPRINTF(4, ("PIPE WILL READ evt = %08X %08X", pfd[i].events, pfd[i].revents)); - if ((pfd[i].revents & MI_POLL_RD_FLAGS) != 0) + r = 1; + while ((pfd[i].revents & MI_POLL_RD_FLAGS) != 0 + && r != -1) { - r = read(RD_PIPE, &evt, sizeof(evt)); - if (r == sizeof(evt)) - { - /* Do nothing */ - } + r = read(RD_PIPE, evts, sizeof(evts)); } POOL_LEV_DPRINTF(4, ("PIPE DONE READ i=[%d] fd=[%d] r=[%d] evt=[%d]", - i, RD_PIPE, r, evt)); + i, RD_PIPE, (int) r, evts[0])); if ((pfd[i].revents & ~MI_POLL_RD_FLAGS) != 0) { |