diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2015-07-09 05:23:17 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2015-07-09 05:23:17 +0000 |
commit | 574e70a7ab89c27012f2e53ff74c081ef90091e1 (patch) | |
tree | d72b291cbd1817d0c82d74e0443d43d3086fb304 /contrib/sendmail/libmilter | |
parent | 6fbe38a3cd2c5a390bea25327ee11f7e89fac99d (diff) | |
download | FreeBSD-src-574e70a7ab89c27012f2e53ff74c081ef90091e1.zip FreeBSD-src-574e70a7ab89c27012f2e53ff74c081ef90091e1.tar.gz |
MFC: Merge sendmail 8.15.2
Approved by: re (gjb)
Diffstat (limited to 'contrib/sendmail/libmilter')
-rw-r--r-- | contrib/sendmail/libmilter/docs/smfi_setsymlist.html | 5 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/engine.c | 52 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/handler.c | 2 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/listener.c | 15 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/signal.c | 6 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/smfi.c | 2 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/worker.c | 2 |
7 files changed, 53 insertions, 31 deletions
diff --git a/contrib/sendmail/libmilter/docs/smfi_setsymlist.html b/contrib/sendmail/libmilter/docs/smfi_setsymlist.html index 1b879c4..c270d0b 100644 --- a/contrib/sendmail/libmilter/docs/smfi_setsymlist.html +++ b/contrib/sendmail/libmilter/docs/smfi_setsymlist.html @@ -62,6 +62,9 @@ milter wants to receive from the MTA. <TR><TD>macros</TD> <TD>list of macros (separated by space). Example: "{rcpt_mailer} {rcpt_host}" + <BR> + An empty string ("", not NULL) can be used to specify that no macros + should be sent. </TD></TR> </TABLE> @@ -74,7 +77,7 @@ milter wants to receive from the MTA. <TD>MI_FAILURE is returned if <UL> <LI>there is not enough free memory to make a copy of the macro list, -<LI><CODE>macros</CODE> is <CODE>NULL</CODE> or empty, +<LI><CODE>macros</CODE> is <CODE>NULL</CODE>, <LI><CODE>stage</CODE> is not a valid protocol stage, <LI>the macro list for <CODE>stage</CODE> has been set before. diff --git a/contrib/sendmail/libmilter/engine.c b/contrib/sendmail/libmilter/engine.c index e557a59..808ffdb 100644 --- a/contrib/sendmail/libmilter/engine.c +++ b/contrib/sendmail/libmilter/engine.c @@ -42,13 +42,8 @@ struct cmdfct_t typedef struct cmdfct_t cmdfct; /* possible values for cm_argt */ -#define CM_ARG0 0 /* no args */ -#define CM_ARG1 1 /* one arg (string) */ -#define CM_ARG2 2 /* two args (strings) */ -#define CM_ARGA 4 /* one string and _SOCK_ADDR */ -#define CM_ARGO 5 /* two integers */ -#define CM_ARGV 8 /* \0 separated list of args, NULL-terminated */ -#define CM_ARGN 9 /* \0 separated list of args (strings) */ +#define CM_BUF 0 +#define CM_NULLOK 1 /* possible values for cm_todo */ #define CT_CONT 0x0000 /* continue reading commands */ @@ -200,21 +195,21 @@ static int next_states[] = /* commands received by milter */ static cmdfct cmds[] = { - {SMFIC_ABORT, CM_ARG0, ST_ABRT, CT_CONT, CI_NONE, st_abortfct } -, {SMFIC_MACRO, CM_ARGV, ST_NONE, CT_KEEP, CI_NONE, st_macros } -, {SMFIC_BODY, CM_ARG1, ST_BODY, CT_CONT, CI_NONE, st_bodychunk } -, {SMFIC_CONNECT, CM_ARG2, ST_CONN, CT_CONT, CI_CONN, st_connectinfo } -, {SMFIC_BODYEOB, CM_ARG1, ST_ENDM, CT_CONT, CI_EOM, st_bodyend } -, {SMFIC_HELO, CM_ARG1, ST_HELO, CT_CONT, CI_HELO, st_helo } -, {SMFIC_HEADER, CM_ARG2, ST_HDRS, CT_CONT, CI_NONE, st_header } -, {SMFIC_MAIL, CM_ARGV, ST_MAIL, CT_CONT, CI_MAIL, st_sender } -, {SMFIC_OPTNEG, CM_ARGO, ST_OPTS, CT_CONT, CI_NONE, st_optionneg } -, {SMFIC_EOH, CM_ARG0, ST_EOHS, CT_CONT, CI_EOH, st_eoh } -, {SMFIC_QUIT, CM_ARG0, ST_QUIT, CT_END, CI_NONE, st_quit } -, {SMFIC_DATA, CM_ARG0, ST_DATA, CT_CONT, CI_DATA, st_data } -, {SMFIC_RCPT, CM_ARGV, ST_RCPT, CT_IGNO, CI_RCPT, st_rcpt } -, {SMFIC_UNKNOWN, CM_ARG1, ST_UNKN, CT_IGNO, CI_NONE, st_unknown } -, {SMFIC_QUIT_NC, CM_ARG0, ST_Q_NC, CT_CONT, CI_NONE, st_quit } + {SMFIC_ABORT, CM_NULLOK, ST_ABRT, CT_CONT, CI_NONE, st_abortfct} +, {SMFIC_MACRO, CM_BUF, ST_NONE, CT_KEEP, CI_NONE, st_macros } +, {SMFIC_BODY, CM_BUF, ST_BODY, CT_CONT, CI_NONE, st_bodychunk} +, {SMFIC_CONNECT, CM_BUF, ST_CONN, CT_CONT, CI_CONN, st_connectinfo} +, {SMFIC_BODYEOB, CM_NULLOK, ST_ENDM, CT_CONT, CI_EOM, st_bodyend } +, {SMFIC_HELO, CM_BUF, ST_HELO, CT_CONT, CI_HELO, st_helo } +, {SMFIC_HEADER, CM_BUF, ST_HDRS, CT_CONT, CI_NONE, st_header } +, {SMFIC_MAIL, CM_BUF, ST_MAIL, CT_CONT, CI_MAIL, st_sender } +, {SMFIC_OPTNEG, CM_BUF, ST_OPTS, CT_CONT, CI_NONE, st_optionneg} +, {SMFIC_EOH, CM_NULLOK, ST_EOHS, CT_CONT, CI_EOH, st_eoh } +, {SMFIC_QUIT, CM_NULLOK, ST_QUIT, CT_END, CI_NONE, st_quit } +, {SMFIC_DATA, CM_NULLOK, ST_DATA, CT_CONT, CI_DATA, st_data } +, {SMFIC_RCPT, CM_BUF, ST_RCPT, CT_IGNO, CI_RCPT, st_rcpt } +, {SMFIC_UNKNOWN, CM_BUF, ST_UNKN, CT_IGNO, CI_NONE, st_unknown } +, {SMFIC_QUIT_NC, CM_NULLOK, ST_Q_NC, CT_CONT, CI_NONE, st_quit } }; /* @@ -390,6 +385,15 @@ mi_engine(ctx) continue; } } + if (cmds[i].cm_argt != CM_NULLOK && buf == NULL) + { + /* stop for now */ + if (ctx->ctx_dbg > 1) + sm_dprintf("[%lu] cmd='%c', buf=NULL\n", + (long) ctx->ctx_id, cmd); + ret = MI_FAILURE; + break; + } arg.a_len = len; arg.a_buf = buf; if (newstate != ST_NONE) @@ -726,7 +730,7 @@ sendreply(r, sd, timeout_ptr, ctx) } /* -** CLR_MACROS -- clear set of macros starting from a given index +** MI_CLR_MACROS -- clear set of macros starting from a given index ** ** Parameters: ** ctx -- context structure @@ -1816,7 +1820,7 @@ dec_arg2(buf, len, s1, s2) } /* -** SENDOK -- is it ok for the filter to send stuff to the MTA? +** MI_SENDOK -- is it ok for the filter to send stuff to the MTA? ** ** Parameters: ** ctx -- context structure diff --git a/contrib/sendmail/libmilter/handler.c b/contrib/sendmail/libmilter/handler.c index 5b4073b..7622839 100644 --- a/contrib/sendmail/libmilter/handler.c +++ b/contrib/sendmail/libmilter/handler.c @@ -15,7 +15,7 @@ SM_RCSID("@(#)$Id: handler.c,v 8.40 2013-11-22 20:51:36 ca Exp $") #if !_FFR_WORKERS_POOL /* -** HANDLE_SESSION -- Handle a connected session in its own context +** MI_HANDLE_SESSION -- Handle a connected session in its own context ** ** Parameters: ** ctx -- context structure diff --git a/contrib/sendmail/libmilter/listener.c b/contrib/sendmail/libmilter/listener.c index b0a1362..11d92bb 100644 --- a/contrib/sendmail/libmilter/listener.c +++ b/contrib/sendmail/libmilter/listener.c @@ -728,6 +728,7 @@ mi_listener(conn, dbg, smfi, timeout, backlog) int acnt = 0; /* error count for accept() failures */ int scnt = 0; /* error count for select() failures */ int save_errno = 0; + int fdflags; #if !_FFR_WORKERS_POOL sthread_t thread_id; #endif /* !_FFR_WORKERS_POOL */ @@ -885,6 +886,20 @@ mi_listener(conn, dbg, smfi, timeout, backlog) } #endif /* _FFR_DUP_FD */ + /* + ** Need to set close-on-exec for connfd in case a user's + ** filter starts other applications. + ** Note: errors will not stop processing (for now). + */ + + if ((fdflags = fcntl(connfd, F_GETFD, 0)) == -1 || + fcntl(connfd, F_SETFD, fdflags | FD_CLOEXEC) == -1) + { + smi_log(SMI_LOG_ERR, + "%s: Unable to set close-on-exec: %s", + smfi->xxfi_name, sm_errstring(errno)); + } + if (setsockopt(connfd, SOL_SOCKET, SO_KEEPALIVE, (void *) &sockopt, sizeof sockopt) < 0) { diff --git a/contrib/sendmail/libmilter/signal.c b/contrib/sendmail/libmilter/signal.c index 4f8ec6e..8d4c8b2 100644 --- a/contrib/sendmail/libmilter/signal.c +++ b/contrib/sendmail/libmilter/signal.c @@ -104,11 +104,11 @@ mi_signal_thread(name) for (;;) { sigerr = sig = 0; -#if defined(SOLARIS) || defined(__svr5__) +#if SIGWAIT_TAKES_1_ARG if ((sig = sigwait(&set)) < 0) -#else /* defined(SOLARIS) || defined(__svr5__) */ +#else if ((sigerr = sigwait(&set, &sig)) != 0) -#endif /* defined(SOLARIS) || defined(__svr5__) */ +#endif { /* some OS return -1 and set errno: copy it */ if (sigerr <= 0) diff --git a/contrib/sendmail/libmilter/smfi.c b/contrib/sendmail/libmilter/smfi.c index 2148f3c..d6c63a2 100644 --- a/contrib/sendmail/libmilter/smfi.c +++ b/contrib/sendmail/libmilter/smfi.c @@ -325,7 +325,7 @@ smfi_setsymlist(ctx, where, macros) { SM_ASSERT(ctx != NULL); - if (macros == NULL || *macros == '\0') + if (macros == NULL) return MI_FAILURE; if (where < SMFIM_FIRST || where > SMFIM_LAST) return MI_FAILURE; diff --git a/contrib/sendmail/libmilter/worker.c b/contrib/sendmail/libmilter/worker.c index 75a1f7c..bf7086a 100644 --- a/contrib/sendmail/libmilter/worker.c +++ b/contrib/sendmail/libmilter/worker.c @@ -254,7 +254,7 @@ nonblocking(int fd, const char *name) } /* -** MI_POOL_CONTROLER_INIT -- Launch the worker pool controller +** MI_POOL_CONTROLLER_INIT -- Launch the worker pool controller ** Must be called before starting sessions. ** ** Parameters: |