diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-04-18 00:49:30 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-04-18 00:49:30 +0000 |
commit | 3001c6f5135796bf49346dd969e8445342d2251b (patch) | |
tree | d710aec0cc173e2b9a67ff56f56f47a1f3b32bc0 /gnu/usr.sbin/sendmail/libmilter | |
parent | 7bc62683b217ae48e11df50f14c39728b723a832 (diff) |
update to sendmail 8.12.3
Diffstat (limited to 'gnu/usr.sbin/sendmail/libmilter')
-rw-r--r-- | gnu/usr.sbin/sendmail/libmilter/comm.c | 74 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libmilter/docs/installation.html | 17 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libmilter/docs/smfi_setbacklog.html | 60 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libmilter/docs/smfi_setreply.html | 10 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libmilter/engine.c | 15 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libmilter/listener.c | 10 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libmilter/main.c | 6 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libmilter/signal.c | 4 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/libmilter/smfi.c | 38 |
9 files changed, 169 insertions, 65 deletions
diff --git a/gnu/usr.sbin/sendmail/libmilter/comm.c b/gnu/usr.sbin/sendmail/libmilter/comm.c index 48818b13ca6..6f82be7c1c4 100644 --- a/gnu/usr.sbin/sendmail/libmilter/comm.c +++ b/gnu/usr.sbin/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("@(#)$Sendmail: comm.c,v 8.48 2001/11/07 17:43:04 ca Exp $") +SM_RCSID("@(#)$Sendmail: 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/gnu/usr.sbin/sendmail/libmilter/docs/installation.html b/gnu/usr.sbin/sendmail/libmilter/docs/installation.html index 8ebe4eef16a..8ce8611e6d0 100644 --- a/gnu/usr.sbin/sendmail/libmilter/docs/installation.html +++ b/gnu/usr.sbin/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/gnu/usr.sbin/sendmail/libmilter/docs/smfi_setbacklog.html b/gnu/usr.sbin/sendmail/libmilter/docs/smfi_setbacklog.html new file mode 100644 index 00000000000..79f0fd02ade --- /dev/null +++ b/gnu/usr.sbin/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/gnu/usr.sbin/sendmail/libmilter/docs/smfi_setreply.html b/gnu/usr.sbin/sendmail/libmilter/docs/smfi_setreply.html index 962f1673bcc..29cbbf8dff3 100644 --- a/gnu/usr.sbin/sendmail/libmilter/docs/smfi_setreply.html +++ b/gnu/usr.sbin/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/gnu/usr.sbin/sendmail/libmilter/engine.c b/gnu/usr.sbin/sendmail/libmilter/engine.c index e12f84788f1..ace740a1db1 100644 --- a/gnu/usr.sbin/sendmail/libmilter/engine.c +++ b/gnu/usr.sbin/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("@(#)$Sendmail: engine.c,v 8.102 2001/12/13 17:10:00 ca Exp $") +SM_RCSID("@(#)$Sendmail: 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/gnu/usr.sbin/sendmail/libmilter/listener.c b/gnu/usr.sbin/sendmail/libmilter/listener.c index c81ebbaafa7..2a1fbaaa3fd 100644 --- a/gnu/usr.sbin/sendmail/libmilter/listener.c +++ b/gnu/usr.sbin/sendmail/libmilter/listener.c @@ -9,7 +9,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Sendmail: listener.c,v 8.81 2002/01/08 23:14:23 ca Exp $") +SM_RCSID("@(#)$Sendmail: 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/gnu/usr.sbin/sendmail/libmilter/main.c b/gnu/usr.sbin/sendmail/libmilter/main.c index 042d1a35bad..2c843e91402 100644 --- a/gnu/usr.sbin/sendmail/libmilter/main.c +++ b/gnu/usr.sbin/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("@(#)$Sendmail: main.c,v 8.53 2001/11/29 02:21:02 ca Exp $") +SM_RCSID("@(#)$Sendmail: 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/gnu/usr.sbin/sendmail/libmilter/signal.c b/gnu/usr.sbin/sendmail/libmilter/signal.c index 5a2c49bd5ec..a8774bc6317 100644 --- a/gnu/usr.sbin/sendmail/libmilter/signal.c +++ b/gnu/usr.sbin/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("@(#)$Sendmail: signal.c,v 8.35 2002/01/10 01:34:55 ca Exp $") +SM_RCSID("@(#)$Sendmail: signal.c,v 8.37 2002/03/23 00:55:19 ca Exp $") #include "libmilter.h" diff --git a/gnu/usr.sbin/sendmail/libmilter/smfi.c b/gnu/usr.sbin/sendmail/libmilter/smfi.c index da5c5c58ef4..5d52fc08db0 100644 --- a/gnu/usr.sbin/sendmail/libmilter/smfi.c +++ b/gnu/usr.sbin/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("@(#)$Sendmail: smfi.c,v 8.57 2001/11/20 18:47:49 ca Exp $") +SM_RCSID("@(#)$Sendmail: 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 @@ -495,6 +499,7 @@ smfi_setpriv(ctx, privatedata) ctx->ctx_privdata = privatedata; return MI_SUCCESS; } + /* ** SMFI_GETPRIV -- get private data ** @@ -513,6 +518,7 @@ smfi_getpriv(ctx) return NULL; return ctx->ctx_privdata; } + /* ** SMFI_GETSYMVAL -- get the value of a macro ** @@ -576,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 */ |