summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/libmilter
diff options
context:
space:
mode:
authorgshapiro <gshapiro@FreeBSD.org>2004-02-14 21:53:31 +0000
committergshapiro <gshapiro@FreeBSD.org>2004-02-14 21:53:31 +0000
commit238623a0204c90e8d61dbde7b3b499a5036f2e5d (patch)
tree136f3e97b372409d2104603a771ff37e36631243 /contrib/sendmail/libmilter
parent96b960fca637a0765d566591885b7d42576e723f (diff)
downloadFreeBSD-src-238623a0204c90e8d61dbde7b3b499a5036f2e5d.zip
FreeBSD-src-238623a0204c90e8d61dbde7b3b499a5036f2e5d.tar.gz
Import sendmail 8.12.11
Diffstat (limited to 'contrib/sendmail/libmilter')
-rw-r--r--contrib/sendmail/libmilter/docs/smfi_addrcpt.html2
-rw-r--r--contrib/sendmail/libmilter/docs/smfi_delrcpt.html2
-rw-r--r--contrib/sendmail/libmilter/docs/smfi_setreply.html6
-rw-r--r--contrib/sendmail/libmilter/docs/xxfi_connect.html24
-rw-r--r--contrib/sendmail/libmilter/docs/xxfi_envrcpt.html4
-rw-r--r--contrib/sendmail/libmilter/engine.c61
-rw-r--r--contrib/sendmail/libmilter/libmilter.h4
-rw-r--r--contrib/sendmail/libmilter/listener.c68
-rw-r--r--contrib/sendmail/libmilter/main.c13
-rw-r--r--contrib/sendmail/libmilter/signal.c4
10 files changed, 146 insertions, 42 deletions
diff --git a/contrib/sendmail/libmilter/docs/smfi_addrcpt.html b/contrib/sendmail/libmilter/docs/smfi_addrcpt.html
index 3b2eb56..16f86c9 100644
--- a/contrib/sendmail/libmilter/docs/smfi_addrcpt.html
+++ b/contrib/sendmail/libmilter/docs/smfi_addrcpt.html
@@ -48,7 +48,7 @@ Add a recipient for the current message.
<td>smfi_addrcpt will fail and return MI_FAILURE if:
<ul><li>rcpt is NULL.
- <li>Adding headers in the current connection state is invalid.
+ <li>Adding recipients in the current connection state is invalid.
<li>A network error occurs.
<li>SMFIF_ADDRCPT was not set when <a href="smfi_register.html">smfi_register</a> was called.
</ul>
diff --git a/contrib/sendmail/libmilter/docs/smfi_delrcpt.html b/contrib/sendmail/libmilter/docs/smfi_delrcpt.html
index 451f36a..9608e61 100644
--- a/contrib/sendmail/libmilter/docs/smfi_delrcpt.html
+++ b/contrib/sendmail/libmilter/docs/smfi_delrcpt.html
@@ -49,7 +49,7 @@ Remove a recipient from the current message's envelope.
<td>smfi_delrcpt will fail and return MI_FAILURE if:
<ul>
<li>rcpt is NULL.
- <li>Adding headers in the current connection state is invalid.
+ <li>Deleting recipients in the current connection state is invalid.
<li>A network error occurs.
<li>SMFIF_DELRCPT was not set when <a href="smfi_register.html">smfi_register</a> was called.
</ul>
diff --git a/contrib/sendmail/libmilter/docs/smfi_setreply.html b/contrib/sendmail/libmilter/docs/smfi_setreply.html
index 646a8f1..d5b0e24 100644
--- a/contrib/sendmail/libmilter/docs/smfi_setreply.html
+++ b/contrib/sendmail/libmilter/docs/smfi_setreply.html
@@ -75,6 +75,12 @@ Otherwise, it return MI_SUCCESS.
<td>
<ul>
<li>Values passed to smfi_setreply are not checked for standards compliance.
+<li>The message parameter should contain only printable characters,
+other characters may lead to undefined behavior.
+For example, CR or LF will cause the call to fail,
+single '%' characters will cause the text to be ignored
+(if there really should be a '%' in the string,
+use '%%' just like for <tt>printf(3)</tt>).
<li>For details about reply codes and their meanings, please see RFC's
<a href="http://www.rfc-editor.org/rfc/rfc821.txt">821</a>/
<a href="http://www.rfc-editor.org/rfc/rfc2821.txt">2821</a>
diff --git a/contrib/sendmail/libmilter/docs/xxfi_connect.html b/contrib/sendmail/libmilter/docs/xxfi_connect.html
index af58bf9..85d02e4 100644
--- a/contrib/sendmail/libmilter/docs/xxfi_connect.html
+++ b/contrib/sendmail/libmilter/docs/xxfi_connect.html
@@ -62,11 +62,29 @@ is passed to smfi_register().
<td><table border="1" cellspacing=0>
<tr bgcolor="#dddddd"><th>Return value</th><th>Description</th></tr>
<tr valign="top">
- <td>SMFIS_DISCARD</td>
- <td>Not meaningful, as
- this is only meaningful from message-oriented routines.
+ <td>SMFIS_ACCEPT</td>
+ <td>Accept all commands and messages from this client without any
+ further contact with the filter. </td>
</td>
</tr>
+ <tr valign="top">
+ <td>SMFIS_CONTINUE</td>
+ <td>Continue normal processing. </td>
+ </tr>
+ <tr valign="top">
+ <td>SMFIS_DISCARD</td>
+ <td>Undefined behaviour; do not use. </td>
+ </tr>
+ <tr valign="top">
+ <td>SMFIS_TEMPFAIL</td>
+ <td>Reject all commands and messages from this client with a
+ temporary failure reply code. </td>
+ </tr>
+ <tr valign="top">
+ <td>SMFIS_REJECT</td>
+ <td>Reject all commands and messages from this client with a
+ permanent failure reply code. </td>
+ </tr>
</table>
</tr>
-->
diff --git a/contrib/sendmail/libmilter/docs/xxfi_envrcpt.html b/contrib/sendmail/libmilter/docs/xxfi_envrcpt.html
index 9d32e90..a96ac95 100644
--- a/contrib/sendmail/libmilter/docs/xxfi_envrcpt.html
+++ b/contrib/sendmail/libmilter/docs/xxfi_envrcpt.html
@@ -52,12 +52,12 @@ Handle the envelope RCPT command.
<tr valign="top">
<td>SMFIS_TEMPFAIL</td>
<td>Temporarily fail for this particular recipient; further recipients
- maystill be sent. <a href="xxfi_abort.html">xxfi_abort</a> is not called.
+ may still be sent. <a href="xxfi_abort.html">xxfi_abort</a> is not called.
</td>
</tr>
<tr valign="top">
<td>SMFIS_REJECT</td>
- <td>Reject this particular recipient; further recipients maystill be sent.
+ <td>Reject this particular recipient; further recipients may still be sent.
<a href="xxfi_abort.html">xxfi_abort</a> is not called.
</td>
</tr>
diff --git a/contrib/sendmail/libmilter/engine.c b/contrib/sendmail/libmilter/engine.c
index 623b2c2..6bd225c 100644
--- a/contrib/sendmail/libmilter/engine.c
+++ b/contrib/sendmail/libmilter/engine.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2002 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1999-2003 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.109.2.5 2003/08/04 18:14:33 ca Exp $")
+SM_RCSID("@(#)$Id: engine.c,v 8.109.2.8 2003/12/01 23:57:45 msk Exp $")
#include "libmilter.h"
@@ -59,14 +59,21 @@ typedef struct cmdfct_t cmdfct;
#define CT_END 0x0008 /* start replying */
/* index in macro array: macros only for these commands */
-#define CI_NONE (-1)
-#define CI_CONN 0
-#define CI_HELO 1
-#define CI_MAIL 2
-#define CI_RCPT 3
-#if CI_RCPT >= MAX_MACROS_ENTRIES
+#define CI_NONE (-1)
+#define CI_CONN 0
+#define CI_HELO 1
+#define CI_MAIL 2
+#define CI_RCPT 3
+#if _FFR_MILTER_MACROS_EOM
+# define CI_EOM 4
+# if CI_EOM >= MAX_MACROS_ENTRIES
+ERROR: do not compile with CI_EOM >= MAX_MACROS_ENTRIES
+# endif
+#else /* _FFR_MILTER_MACROS_EOM */
+# if CI_RCPT >= MAX_MACROS_ENTRIES
ERROR: do not compile with CI_RCPT >= MAX_MACROS_ENTRIES
-#endif
+# endif
+#endif /* _FFR_MILTER_MACROS_EOM */
/* function prototypes */
static int st_abortfct __P((genarg *));
@@ -156,7 +163,11 @@ static cmdfct cmds[] =
{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 },
+#if _FFR_MILTER_MACROS_EOM
+{SMFIC_BODYEOB, CM_ARG1, ST_ENDM, CT_CONT, CI_EOM, st_bodyend },
+#else /* _FFR_MILTER_MACROS_EOM */
{SMFIC_BODYEOB, CM_ARG1, ST_ENDM, CT_CONT, CI_NONE, st_bodyend },
+#endif /* _FFR_MILTER_MACROS_EOM */
{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 },
@@ -599,7 +610,7 @@ st_connectinfo(g)
l = g->a_len;
while (s[i] != '\0' && i <= l)
++i;
- if (i >= l)
+ if (i + 1 >= l)
return _SMFIS_ABORT;
/* Move past trailing \0 in host string */
@@ -608,9 +619,7 @@ st_connectinfo(g)
(void) memset(&sockaddr, '\0', sizeof sockaddr);
if (family != SMFIA_UNKNOWN)
{
- (void) memcpy((void *) &port, (void *) (s + i),
- sizeof port);
- if ((i += sizeof port) >= l)
+ if (i + sizeof port >= l)
{
smi_log(SMI_LOG_ERR,
"%s: connect[%d]: wrong len %d >= %d",
@@ -618,6 +627,9 @@ st_connectinfo(g)
(int) g->a_ctx->ctx_id, (int) i, (int) l);
return _SMFIS_ABORT;
}
+ (void) memcpy((void *) &port, (void *) (s + i),
+ sizeof port);
+ i += sizeof port;
/* make sure string is terminated */
if (s[l - 1] != '\0')
@@ -729,7 +741,12 @@ st_helo(g)
mi_clr_macros(g->a_ctx, g->a_idx + 1);
if (g->a_ctx->ctx_smfi != NULL &&
(fi_helo = g->a_ctx->ctx_smfi->xxfi_helo) != NULL)
+ {
+ /* paranoia: check for terminating '\0' */
+ if (g->a_len == 0 || g->a_buf[g->a_len - 1] != '\0')
+ return MI_FAILURE;
return (*fi_helo)(g->a_ctx, g->a_buf);
+ }
return SMFIS_CONTINUE;
}
/*
@@ -847,6 +864,11 @@ st_macros(g)
case SMFIC_RCPT:
i = CI_RCPT;
break;
+#if _FFR_MILTER_MACROS_EOM
+ case SMFIC_BODYEOB:
+ i = CI_EOM;
+ break;
+#endif /* _FFR_MILTER_MACROS_EOM */
default:
free(argv);
return _SMFIS_FAIL;
@@ -1089,10 +1111,16 @@ dec_argv(buf, len)
for (i = 0, elem = 0; i < len && elem < nelem; i++)
{
if (buf[i] == '\0')
- s[++elem] = &(buf[i + 1]);
+ {
+ ++elem;
+ if (i + 1 >= len)
+ s[elem] = NULL;
+ else
+ s[elem] = &(buf[i + 1]);
+ }
}
- /* overwrite last entry */
+ /* overwrite last entry (already done above, just paranoia) */
s[elem] = NULL;
return s;
}
@@ -1117,6 +1145,9 @@ dec_arg2(buf, len, s1, s2)
{
size_t i;
+ /* paranoia: check for terminating '\0' */
+ if (len == 0 || buf[len - 1] != '\0')
+ return MI_FAILURE;
*s1 = buf;
for (i = 1; i < len && buf[i] != '\0'; i++)
continue;
diff --git a/contrib/sendmail/libmilter/libmilter.h b/contrib/sendmail/libmilter/libmilter.h
index 7b2fbb8..13bddce 100644
--- a/contrib/sendmail/libmilter/libmilter.h
+++ b/contrib/sendmail/libmilter/libmilter.h
@@ -19,7 +19,7 @@
#ifdef _DEFINE
# define EXTERN
# define INIT(x) = x
-SM_IDSTR(MilterlId, "@(#)$Id: libmilter.h,v 8.33.2.12 2003/09/08 21:39:55 yuri Exp $")
+SM_IDSTR(MilterlId, "@(#)$Id: libmilter.h,v 8.33.2.13 2003/10/20 21:51:50 msk Exp $")
#else /* _DEFINE */
# define EXTERN extern
# define INIT(x)
@@ -176,7 +176,7 @@ extern void mi_clean_signals __P((void));
extern struct hostent *mi_gethostbyname __P((char *, int));
extern int mi_inet_pton __P((int, const char *, void *));
extern void mi_closener __P((void));
-extern int mi_opensocket __P((char *, int, int, smfiDesc_ptr));
+extern int mi_opensocket __P((char *, int, int, bool, smfiDesc_ptr));
/* communication functions */
extern char *mi_rd_cmd __P((socket_t, struct timeval *, char *, size_t *, char *));
diff --git a/contrib/sendmail/libmilter/listener.c b/contrib/sendmail/libmilter/listener.c
index 5eb5f32..bb7a297 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.12 2003/08/04 18:47:29 ca Exp $")
+SM_RCSID("@(#)$Id: listener.c,v 8.85.2.17 2003/10/21 17:22:57 ca Exp $")
/*
** listener.c -- threaded network listener
@@ -18,6 +18,9 @@ SM_RCSID("@(#)$Id: listener.c,v 8.85.2.12 2003/08/04 18:47:29 ca Exp $")
#include "libmilter.h"
#include <sm/errstring.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
# if NETINET || NETINET6
# include <arpa/inet.h>
@@ -28,26 +31,29 @@ static int L_family;
static SOCKADDR_LEN_T L_socksize;
static socket_t listenfd = INVALID_SOCKET;
-static socket_t mi_milteropen __P((char *, int, char *));
+static socket_t mi_milteropen __P((char *, int, bool, char *));
/*
** MI_OPENSOCKET -- create the socket where this filter and the MTA will meet
**
-** Parameters:
+** Parameters:
** conn -- connection description
** backlog -- listen backlog
-** dbg -- debug level
+** dbg -- debug level
+** rmsocket -- if true, try to unlink() the socket first
+** (UNIX domain sockets only)
** smfi -- filter structure to use
**
-** Return value:
-** MI_SUCCESS/MI_FAILURE
+** Return value:
+** MI_SUCCESS/MI_FAILURE
*/
int
-mi_opensocket(conn, backlog, dbg, smfi)
+mi_opensocket(conn, backlog, dbg, rmsocket, smfi)
char *conn;
int backlog;
int dbg;
+ bool rmsocket;
smfiDesc_ptr smfi;
{
if (smfi == NULL || conn == NULL)
@@ -64,7 +70,7 @@ mi_opensocket(conn, backlog, dbg, smfi)
}
(void) smutex_init(&L_Mutex);
(void) smutex_lock(&L_Mutex);
- listenfd = mi_milteropen(conn, backlog, smfi->xxfi_name);
+ listenfd = mi_milteropen(conn, backlog, rmsocket, smfi->xxfi_name);
if (!ValidSocket(listenfd))
{
smi_log(SMI_LOG_FATAL,
@@ -91,6 +97,8 @@ mi_opensocket(conn, backlog, dbg, smfi)
** Parameters:
** conn -- connection description
** backlog -- listen backlog
+** rmsocket -- if true, try to unlink() the socket first
+** (UNIX domain sockets only)
** name -- name for logging
**
** Returns:
@@ -105,9 +113,10 @@ static char *sockpath = NULL;
#endif /* NETUNIX */
static socket_t
-mi_milteropen(conn, backlog, name)
+mi_milteropen(conn, backlog, rmsocket, name)
char *conn;
int backlog;
+ bool rmsocket;
char *name;
{
socket_t sock;
@@ -457,6 +466,41 @@ mi_milteropen(conn, backlog, name)
return INVALID_SOCKET;
}
+#if NETUNIX
+ if (addr.sa.sa_family == AF_UNIX && rmsocket)
+ {
+ struct stat s;
+
+ if (stat(colon, &s) != 0)
+ {
+ if (errno != ENOENT)
+ {
+ smi_log(SMI_LOG_ERR,
+ "%s: Unable to stat() %s: %s",
+ name, colon, sm_errstring(errno));
+ (void) closesocket(sock);
+ return INVALID_SOCKET;
+ }
+ }
+ else if (!S_ISSOCK(s.st_mode))
+ {
+ smi_log(SMI_LOG_ERR,
+ "%s: %s is not a UNIX domain socket",
+ name, colon);
+ (void) closesocket(sock);
+ return INVALID_SOCKET;
+ }
+ else if (unlink(colon) != 0)
+ {
+ smi_log(SMI_LOG_ERR,
+ "%s: Unable to remove %s: %s",
+ name, colon, sm_errstring(errno));
+ (void) closesocket(sock);
+ return INVALID_SOCKET;
+ }
+ }
+#endif /* NETUNIX */
+
if (bind(sock, &addr.sa, L_socksize) < 0)
{
smi_log(SMI_LOG_ERR,
@@ -591,9 +635,11 @@ mi_closener()
** Parameters:
** conn -- connection description
** dbg -- debug level
+** rmsocket -- if true, try to unlink() the socket first
+** (UNIX domain sockets only)
** smfi -- filter structure to use
** timeout -- timeout for reads/writes
-** backlog -- listen queue backlog size
+** backlog -- listen queue backlog size
**
** Returns:
** MI_SUCCESS -- Exited normally
@@ -673,7 +719,7 @@ mi_listener(conn, dbg, smfi, timeout, backlog)
FD_RD_VAR(rds, excs);
struct timeval chktime;
- if (mi_opensocket(conn, backlog, dbg, smfi) == MI_FAILURE)
+ if (mi_opensocket(conn, backlog, dbg, false, smfi) == MI_FAILURE)
return MI_FAILURE;
clilen = L_socksize;
diff --git a/contrib/sendmail/libmilter/main.c b/contrib/sendmail/libmilter/main.c
index 4e62c45..36b99f0 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.2.10 2003/01/23 22:34:24 ca Exp $")
+SM_RCSID("@(#)$Id: main.c,v 8.64.2.13 2003/10/20 22:27:13 ca Exp $")
#define _DEFINE 1
#include "libmilter.h"
@@ -86,7 +86,7 @@ smfi_stop()
}
/*
-** default values for some variables.
+** Default values for some variables.
** Most of these can be changed with the functions below.
*/
@@ -101,19 +101,22 @@ static int backlog = MI_SOMAXCONN;
** able to start up
**
** Parameters:
-** None.
+** rmsocket -- if true, instructs libmilter to attempt
+** to remove the socket before creating it;
+** only applies for "local:" or "unix:" sockets
**
** Return:
** MI_SUCCESS/MI_FAILURE
*/
int
-smfi_opensocket()
+smfi_opensocket(rmsocket)
+ bool rmsocket;
{
if (smfi == NULL || conn == NULL)
return MI_FAILURE;
- return mi_opensocket(conn, backlog, dbg, smfi);
+ return mi_opensocket(conn, backlog, dbg, rmsocket, smfi);
}
#endif /* _FFR_SMFI_OPENSOCKET */
diff --git a/contrib/sendmail/libmilter/signal.c b/contrib/sendmail/libmilter/signal.c
index e167959..94e7f15 100644
--- a/contrib/sendmail/libmilter/signal.c
+++ b/contrib/sendmail/libmilter/signal.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2002 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1999-2003 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.37.2.3 2003/08/04 18:14:33 ca Exp $")
+SM_RCSID("@(#)$Id: signal.c,v 8.37.2.4 2003/11/19 00:22:40 ca Exp $")
#include "libmilter.h"
OpenPOWER on IntegriCloud