diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2002-04-10 03:05:00 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2002-04-10 03:05:00 +0000 |
commit | 9e3bd35cd79720a6547b183a6a6fb97ab1ae7b84 (patch) | |
tree | 348e6162af337e0b74db963f6e4dcc567e2f99e9 /contrib/sendmail/libmilter | |
parent | 1a7e50d796833cbb4346a251bc88555ea2c58e94 (diff) | |
download | FreeBSD-src-9e3bd35cd79720a6547b183a6a6fb97ab1ae7b84.zip FreeBSD-src-9e3bd35cd79720a6547b183a6a6fb97ab1ae7b84.tar.gz |
Import sendmail 8.12.3
Diffstat (limited to 'contrib/sendmail/libmilter')
-rw-r--r-- | contrib/sendmail/libmilter/Makefile.m4 | 5 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/comm.c | 74 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/docs/installation.html | 17 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/docs/smfi_setbacklog.html | 60 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/docs/smfi_setreply.html | 10 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/engine.c | 15 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/listener.c | 10 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/main.c | 6 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/signal.c | 4 | ||||
-rw-r--r-- | contrib/sendmail/libmilter/smfi.c | 46 |
10 files changed, 177 insertions, 70 deletions
diff --git a/contrib/sendmail/libmilter/Makefile.m4 b/contrib/sendmail/libmilter/Makefile.m4 index f767441..ea1124d 100644 --- a/contrib/sendmail/libmilter/Makefile.m4 +++ b/contrib/sendmail/libmilter/Makefile.m4 @@ -31,8 +31,9 @@ divert(bldTARGETS_SECTION) MFAPI= ${SRCDIR}/inc`'lude/libmilter/mfapi.h MFDEF= ${SRCDIR}/inc`'lude/libmilter/mfdef.h install-mfapi: ${MFAPI} - ${INSTALL} -c -o ${INCOWN} -g ${INCGRP} -m ${INCMODE} ${MFAPI} ${DESTDIR}${INCLUDEDIR} - ${INSTALL} -c -o ${INCOWN} -g ${INCGRP} -m ${INCMODE} ${MFDEF} ${DESTDIR}${INCLUDEDIR} + if [ ! -d ${DESTDIR}${INCLUDEDIR}/libmilter ]; then mkdir -p ${DESTDIR}${INCLUDEDIR}/libmilter; else :; fi + ${INSTALL} -c -o ${INCOWN} -g ${INCGRP} -m ${INCMODE} ${MFAPI} ${DESTDIR}${INCLUDEDIR}/libmilter/mfapi.h + ${INSTALL} -c -o ${INCOWN} -g ${INCGRP} -m ${INCMODE} ${MFDEF} ${DESTDIR}${INCLUDEDIR}/libmilter/mfdef.h divert(0) bldFINISH diff --git a/contrib/sendmail/libmilter/comm.c b/contrib/sendmail/libmilter/comm.c index 3347808..0bf7e5c 100644 --- a/contrib/sendmail/libmilter/comm.c +++ b/contrib/sendmail/libmilter/comm.c @@ -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 @@ -9,7 +9,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: comm.c,v 8.48 2001/11/07 17:43:04 ca Exp $") +SM_RCSID("@(#)$Id: comm.c,v 8.54 2002/03/06 16:03:26 ca Exp $") #include "libmilter.h" #include <sm/errstring.h> @@ -206,6 +206,39 @@ mi_rd_cmd(sd, timeout, cmd, rlen, name) ** MI_SUCCESS/MI_FAILURE */ +/* +** we don't care much about the timeout here, it's very long anyway +** FD_SETSIZE is only checked in mi_rd_cmd. +** XXX l == 0 ? +*/ + +#define MI_WR(data) \ + while (sl > 0) \ + { \ + FD_ZERO(&wrtset); \ + FD_SET((unsigned int) sd, &wrtset); \ + ret = select(sd + 1, NULL, &wrtset, NULL, timeout); \ + if (ret == 0) \ + return MI_FAILURE; \ + if (ret < 0) \ + { \ + if (errno == EINTR) \ + continue; \ + else \ + return MI_FAILURE; \ + } \ + l = MI_SOCK_WRITE(sd, (void *) ((data) + i), sl); \ + if (l < 0) \ + { \ + if (errno == EINTR) \ + continue; \ + else \ + return MI_FAILURE; \ + } \ + i += l; \ + sl -= l; \ + } + int mi_wr_cmd(sd, timeout, cmd, buf, len) socket_t sd; @@ -229,48 +262,15 @@ mi_wr_cmd(sd, timeout, cmd, buf, len) i = 0; sl = MILTER_LEN_BYTES + 1; - do - { - FD_ZERO(&wrtset); - FD_SET((unsigned int) sd, &wrtset); - if ((ret = select(sd + 1, NULL, &wrtset, NULL, timeout)) == 0) - return MI_FAILURE; - } while (ret < 0 && errno == EINTR); - if (ret < 0) - return MI_FAILURE; - /* use writev() instead to send the whole stuff at once? */ - while ((l = MI_SOCK_WRITE(sd, (void *) (data + i), - sl - i)) < (ssize_t) sl) - { - if (l < 0) - return MI_FAILURE; - i += l; - sl -= l; - } + MI_WR(data); if (len > 0 && buf == NULL) return MI_FAILURE; if (len == 0 || buf == NULL) return MI_SUCCESS; i = 0; sl = len; - do - { - FD_ZERO(&wrtset); - FD_SET((unsigned int) sd, &wrtset); - if ((ret = select(sd + 1, NULL, &wrtset, NULL, timeout)) == 0) - return MI_FAILURE; - } while (ret < 0 && errno == EINTR); - if (ret < 0) - return MI_FAILURE; - while ((l = MI_SOCK_WRITE(sd, (void *) (buf + i), - sl - i)) < (ssize_t) sl) - { - if (l < 0) - return MI_FAILURE; - i += l; - sl -= l; - } + MI_WR(buf); return MI_SUCCESS; } diff --git a/contrib/sendmail/libmilter/docs/installation.html b/contrib/sendmail/libmilter/docs/installation.html index 8ebe4ee..8ce8611 100644 --- a/contrib/sendmail/libmilter/docs/installation.html +++ b/contrib/sendmail/libmilter/docs/installation.html @@ -37,20 +37,21 @@ run-time linker. <H2><a name="config">Configuring Sendmail</A></H2> -First, you must compile sendmail versions before 8.12 with _FFR_MILTER -defined. To do this, add the following lines to your build +First, you must compile sendmail with MILTER defined. +If you use a sendmail version older than 8.12 please see +the instructions for your version. +To do this, add the following lines to your build configuration file (devtools/Site/config.site.m4) <pre> -APPENDDEF(`conf_sendmail_ENVDEF', `-D_FFR_MILTER=1') -APPENDDEF(`conf_libmilter_ENVDEF', `-D_FFR_MILTER=1') +APPENDDEF(`conf_sendmail_ENVDEF', `-DMILTER') </pre> then type <code>./Build -c</code> in your sendmail directory. <P> Next, you must add the desired filters to your sendmail configuration -(.mc) file. With versions before 8.12, the file must then be -processed with _FFR_MILTER defined. Mail filters have three equates: +(.mc) file. +Mail filters have three equates: The required <code>S=</code> equate specifies the socket where sendmail should look for the filter; The optional <code>F=</code> and <code>T=</code> equates specify flags and timeouts, respectively. All @@ -117,7 +118,7 @@ third uses an IP socket on port 999. define(`confINPUT_MAIL_FILTERS', `filter2,filter1,filter3') <hr width="30%"> - m4 <b>-D_FFR_MILTER</b> ../m4/cf.m4 myconfig.mc > myconfig.cf + m4 ../m4/cf.m4 myconfig.mc > myconfig.cf </pre> By default, the filters would be run in the order declared, i.e. "filter1, filter2, filter3"; however, since @@ -160,7 +161,7 @@ For information about available macros and their meanings, please consult the sendmail documentation. <hr size="1"> <font size="-1"> -Copyright (c) 2000-2001 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/docs/smfi_setbacklog.html b/contrib/sendmail/libmilter/docs/smfi_setbacklog.html new file mode 100644 index 0000000..79f0fd0 --- /dev/null +++ b/contrib/sendmail/libmilter/docs/smfi_setbacklog.html @@ -0,0 +1,60 @@ +<html> +<head><title>smfi_setbacklog</title></head> +<body> +<h1>smfi_setbacklog</h1> + +<table border="0" cellspacing=4 cellpadding=4> +<!---------- Synopsis -----------> +<tr><th valign="top" align=left width=150>SYNOPSIS</th><td> +<pre> +#include <libmilter/mfapi.h> +int smfi_setbacklog( + int obacklog +); +</pre> +Set the filter's listen backlog value. +</td></tr> + +<!----------- Description ----------> +<tr><th valign="top" align=left>DESCRIPTION</th><td> +<table border="1" cellspacing=1 cellpadding=4> +<tr align="left" valign=top> +<th width="80">Called When</th> +<td>smfi_setbacklog should only be called before <a href="smfi_main.html">smfi_main</a>.</td> +</tr> +<tr align="left" valign=top> +<th width="80">Effects</th> +<td>Sets the incoming socket backlog used by listen(). If smfi_setbacklog is not called, the operating system default is used.</td> +</tr> +</table> + +<!----------- Arguments ----------> +<tr><th valign="top" align=left>ARGUMENTS</th><td> + <table border="1" cellspacing=0> + <tr bgcolor="#dddddd"><th>Argument</th><th>Description</th></tr> + <tr valign="top"><td>obacklog</td> + <td>The number of incoming connections to allow in the listen queue. + </td></tr> + </table> +</td></tr> + +<!----------- Return values ----------> +<tr> +<th valign="top" align=left>RETURN VALUES</th> + +<td>smfi_setbacklog returns MI_FAILURE if obacklog is less than or equal +to zero.</td> +</tr> + +</table> + +<hr size="1"> +<font size="-1"> +Copyright (c) 2002 Sendmail, Inc. and its suppliers. +All rights reserved. +<br> +By using this file, you agree to the terms and conditions set +forth in the <a href="LICENSE.txt">LICENSE</a>. +</font> +</body> +</html> diff --git a/contrib/sendmail/libmilter/docs/smfi_setreply.html b/contrib/sendmail/libmilter/docs/smfi_setreply.html index 962f167..29cbbf8 100644 --- a/contrib/sendmail/libmilter/docs/smfi_setreply.html +++ b/contrib/sendmail/libmilter/docs/smfi_setreply.html @@ -72,8 +72,12 @@ Otherwise, it return MI_SUCCESS. <ul> <li>Values passed to smfi_setreply are not checked for standards compliance. <li>For details about reply codes and their meanings, please see RFC's -<a href="http://www.cis.ohio-state.edu/htbin/rfc/rfc821.html">821</a> -and <a href="http://www.cis.ohio-state.edu/htbin/rfc/rfc2034.html">2034</a>. +<a href="http://www.rfc-editor.org/rfc/rfc821.txt">821</a> +and <a href="http://www.rfc-editor.org/rfc/rfc2034.txt">2034</a>. +<li>If the reply code (rcode) given is a '4XX' code but SMFI_REJECT is used +for the message, the custom reply is not used. +<li>Similarly, if the reply code (rcode) given is a '5XX' code but +SMFI_TEMPFAIL is used for the message, the custom reply is not used. </ul> </td> </tr> @@ -82,7 +86,7 @@ and <a href="http://www.cis.ohio-state.edu/htbin/rfc/rfc2034.html">2034</a>. <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 aabfe6c..7414072 100644 --- a/contrib/sendmail/libmilter/engine.c +++ b/contrib/sendmail/libmilter/engine.c @@ -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 @@ -9,7 +9,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: engine.c,v 8.102 2001/12/13 17:10:00 ca Exp $") +SM_RCSID("@(#)$Id: engine.c,v 8.109 2002/03/13 17:18:44 gshapiro Exp $") #include "libmilter.h" @@ -406,7 +406,9 @@ sendreply(r, sd, timeout_ptr, ctx) break; case SMFIS_TEMPFAIL: case SMFIS_REJECT: - if (ctx->ctx_reply != NULL) + if (ctx->ctx_reply != NULL && + ((r == SMFIS_TEMPFAIL && *ctx->ctx_reply == '4') || + (r == SMFIS_REJECT && *ctx->ctx_reply == '5'))) { ret = mi_wr_cmd(sd, timeout_ptr, SMFIR_REPLYCODE, ctx->ctx_reply, @@ -605,7 +607,6 @@ st_connectinfo(g) { (void) memcpy((void *) &port, (void *) (s + i), sizeof port); - port = ntohs(port); if ((i += sizeof port) >= l) { smi_log(SMI_LOG_ERR, @@ -614,11 +615,15 @@ st_connectinfo(g) (int) g->a_ctx->ctx_id, i, l); return _SMFIS_ABORT; } + + /* make sure string is terminated */ + if (s[l - 1] != '\0') + return _SMFIS_ABORT; # if NETINET if (family == SMFIA_INET) { if (inet_aton(s + i, (struct in_addr *) &sockaddr.sin.sin_addr) - == INADDR_NONE) + != 1) { smi_log(SMI_LOG_ERR, "%s: connect[%d]: inet_aton failed", diff --git a/contrib/sendmail/libmilter/listener.c b/contrib/sendmail/libmilter/listener.c index 9b75ce0..7b4d7b7 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.81 2002/01/08 23:14:23 ca Exp $") +SM_RCSID("@(#)$Id: listener.c,v 8.82 2002/01/22 18:46:47 ca Exp $") /* ** listener.c -- threaded network listener @@ -77,11 +77,11 @@ mi_milteropen(conn, backlog, socksize, family, name) { *colon = '\0'; - if (*p == '\0') + if (*p == '\0') { #if NETUNIX /* default to AF_UNIX */ - addr.sa.sa_family = AF_UNIX; + addr.sa.sa_family = AF_UNIX; *socksize = sizeof (struct sockaddr_un); #else /* NETUNIX */ # if NETINET @@ -138,7 +138,7 @@ mi_milteropen(conn, backlog, socksize, family, name) colon = p; #if NETUNIX /* default to AF_UNIX */ - addr.sa.sa_family = AF_UNIX; + addr.sa.sa_family = AF_UNIX; *socksize = sizeof (struct sockaddr_un); #else /* NETUNIX */ # if NETINET @@ -476,7 +476,7 @@ mi_closener() struct stat fileinfo; removable = sockpath != NULL && -#if _FFR_MILTER_ROOT_UNSAFE +#if _FFR_MILTER_ROOT_UNSAFE geteuid() != 0 && #endif /* _FFR_MILTER_ROOT_UNSAFE */ fstat(listenfd, &sockinfo) == 0 && diff --git a/contrib/sendmail/libmilter/main.c b/contrib/sendmail/libmilter/main.c index ee440e3..1f91369 100644 --- a/contrib/sendmail/libmilter/main.c +++ b/contrib/sendmail/libmilter/main.c @@ -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 @@ -9,7 +9,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: main.c,v 8.53 2001/11/29 02:21:02 ca Exp $") +SM_RCSID("@(#)$Id: main.c,v 8.55 2002/02/25 17:54:41 gshapiro Exp $") #define _DEFINE 1 #include "libmilter.h" @@ -161,7 +161,7 @@ smfi_setconn(oconn) ** SMFI_SETBACKLOG -- set backlog ** ** Parameters: -** odbg -- new backlog. +** obacklog -- new backlog. ** ** Returns: ** MI_SUCCESS/MI_FAILURE diff --git a/contrib/sendmail/libmilter/signal.c b/contrib/sendmail/libmilter/signal.c index b160f5d..43a8567 100644 --- a/contrib/sendmail/libmilter/signal.c +++ b/contrib/sendmail/libmilter/signal.c @@ -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 @@ -9,7 +9,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: signal.c,v 8.35 2002/01/10 01:34:55 ca Exp $") +SM_RCSID("@(#)$Id: signal.c,v 8.37 2002/03/23 00:55:19 ca Exp $") #include "libmilter.h" diff --git a/contrib/sendmail/libmilter/smfi.c b/contrib/sendmail/libmilter/smfi.c index fd564d5..63ee541 100644 --- a/contrib/sendmail/libmilter/smfi.c +++ b/contrib/sendmail/libmilter/smfi.c @@ -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 @@ -9,7 +9,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: smfi.c,v 8.57 2001/11/20 18:47:49 ca Exp $") +SM_RCSID("@(#)$Id: smfi.c,v 8.63 2002/02/07 01:16:13 msk Exp $") #include <sm/varargs.h> #include "libmilter.h" @@ -111,6 +111,7 @@ smfi_chgheader(ctx, headerf, hdridx, headerv) free(buf); return r; } + /* ** SMFI_ADDRCPT -- send an additional recipient to the MTA ** @@ -139,6 +140,7 @@ smfi_addrcpt(ctx, rcpt) len = strlen(rcpt) + 1; return mi_wr_cmd(ctx->ctx_sd, &timeout, SMFIR_ADDRCPT, rcpt, len); } + /* ** SMFI_DELRCPT -- send a recipient to be removed to the MTA ** @@ -167,6 +169,7 @@ smfi_delrcpt(ctx, rcpt) len = strlen(rcpt) + 1; return mi_wr_cmd(ctx->ctx_sd, &timeout, SMFIR_DELRCPT, rcpt, len); } + /* ** SMFI_REPLACEBODY -- send a body chunk to the MTA ** @@ -210,6 +213,7 @@ smfi_replacebody(ctx, bodyp, bodylen) } return MI_SUCCESS; } + #if _FFR_QUARANTINE /* ** SMFI_QUARANTINE -- quarantine an envelope @@ -430,18 +434,20 @@ smfi_setmlreply(ctx, rcode, xcode, va_alist) tl = strlen(txt); if (tl > MAXREPLYLEN) - return MI_FAILURE; + break; /* this text, reply codes, \r\n */ len += tl + 2 + rlen; if (++args > MAXREPLIES) - return MI_FAILURE; + break; /* XXX check also for unprintable chars? */ if (strpbrk(txt, "\r\n") != NULL) - return MI_FAILURE; + break; } SM_VA_END(ap); + if (txt != NULL) + return MI_FAILURE; /* trailing '\0' */ ++len; @@ -493,6 +499,7 @@ smfi_setpriv(ctx, privatedata) ctx->ctx_privdata = privatedata; return MI_SUCCESS; } + /* ** SMFI_GETPRIV -- get private data ** @@ -511,6 +518,7 @@ smfi_getpriv(ctx) return NULL; return ctx->ctx_privdata; } + /* ** SMFI_GETSYMVAL -- get the value of a macro ** @@ -574,3 +582,31 @@ smfi_getsymval(ctx, symname) } return NULL; } + +#if _FFR_SMFI_PROGRESS +/* +** SMFI_PROGRESS -- send "progress" message to the MTA to prevent premature +** timeouts during long milter-side operations +** +** Parameters: +** ctx -- Opaque context structure +** +** Return value: +** MI_SUCCESS/MI_FAILURE +*/ + +int +smfi_progress(ctx) + SMFICTX *ctx; +{ + struct timeval timeout; + + if (ctx == NULL) + return MI_FAILURE; + + timeout.tv_sec = ctx->ctx_timeout; + timeout.tv_usec = 0; + + return mi_wr_cmd(ctx->ctx_sd, &timeout, SMFIR_PROGRESS, NULL, 0); +} +#endif /* _FFR_SMFI_PROGRESS */ |