diff options
Diffstat (limited to 'contrib/sendmail/libmilter')
49 files changed, 0 insertions, 8083 deletions
diff --git a/contrib/sendmail/libmilter/Makefile b/contrib/sendmail/libmilter/Makefile deleted file mode 100644 index 04277eb6e2c9..000000000000 --- a/contrib/sendmail/libmilter/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# $Id: Makefile,v 8.1 1999/11/04 00:03:40 ca Exp $ - -SHELL= /bin/sh -BUILD= ./Build -OPTIONS= $(CONFIG) $(FLAGS) - -all: FRC - $(SHELL) $(BUILD) $(OPTIONS) $@ -clean: FRC - $(SHELL) $(BUILD) $(OPTIONS) $@ -install: FRC - $(SHELL) $(BUILD) $(OPTIONS) $@ - -fresh: FRC - $(SHELL) $(BUILD) $(OPTIONS) -c - -FRC: diff --git a/contrib/sendmail/libmilter/Makefile.m4 b/contrib/sendmail/libmilter/Makefile.m4 deleted file mode 100644 index d824298ed501..000000000000 --- a/contrib/sendmail/libmilter/Makefile.m4 +++ /dev/null @@ -1,40 +0,0 @@ -dnl $Id: Makefile.m4,v 8.30.2.1 2002/06/21 21:58:28 ca Exp $ -include(confBUILDTOOLSDIR`/M4/switch.m4') - -dnl only required for compilation of EXTRAS -define(`confREQUIRE_LIBSM', `true') -define(`confMT', `true') - -# sendmail dir -SMSRCDIR= ifdef(`confSMSRCDIR', `confSMSRCDIR', `${SRCDIR}/sendmail') -PREPENDDEF(`confINCDIRS', `-I${SMSRCDIR} ') - -bldPRODUCT_START(`library', `libmilter') -define(`bldINSTALLABLE', `true') -define(`LIBMILTER_EXTRAS', `errstring.c strl.c') -APPENDDEF(`confENVDEF', `-DNOT_SENDMAIL -Dsm_snprintf=snprintf') -define(`bldSOURCES', `main.c engine.c listener.c handler.c comm.c smfi.c signal.c sm_gethost.c LIBMILTER_EXTRAS ') -define(`confBEFORE', `LIBMILTER_EXTRAS') -bldPUSH_INSTALL_TARGET(`install-mfapi') -bldPRODUCT_END - -PUSHDIVERT(3) -errstring.c: - ${LN} ${LNOPTS} ${SRCDIR}/libsm/errstring.c . - -strl.c: - ${LN} ${LNOPTS} ${SRCDIR}/libsm/strl.c . -POPDIVERT - - -divert(bldTARGETS_SECTION) -# Install the API header files -MFAPI= ${SRCDIR}/inc`'lude/libmilter/mfapi.h -MFDEF= ${SRCDIR}/inc`'lude/libmilter/mfdef.h -install-mfapi: ${MFAPI} - 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/README b/contrib/sendmail/libmilter/README deleted file mode 100644 index efc0b65d85b1..000000000000 --- a/contrib/sendmail/libmilter/README +++ /dev/null @@ -1,460 +0,0 @@ -This directory contains the source files for libmilter. - -The sendmail Mail Filter API (Milter) is designed to allow third-party -programs access to mail messages as they are being processed in order to -filter meta-information and content. - -This README file describes the steps needed to compile and run a filter, -through reference to a sample filter which is attached at the end of this -file. It is necessary to first build libmilter.a, which can be done by -issuing the './Build' command in SRCDIR/libmilter . - -NOTE: If you intend to use filters in sendmail, you must compile sendmail -with -DMILTER defined. You can do this by adding the following to -your devtools/Site/site.config.m4 file: - - APPENDDEF(`conf_sendmail_ENVDEF', `-DMILTER') - -+----------------+ -| SECURITY HINTS | -+----------------+ - -Note: we strongly recommend not to run any milter as root. Libmilter -does not need root access to communicate with sendmail. It is a -good security practice to run a program only with root privileges -if really necessary. A milter should probably check first whether -it runs as root and refuse to start in that case. There is a -compile time option _FFR_MILTER_ROOT_UNSAFE which keeps libmilter -from unlinking a socket when running as root. It is recommended -to turn on this option: - - APPENDDEF(`conf_libmilter_ENVDEF', `-D_FFR_MILTER_ROOT_UNSAFE ') - - -+-------------------+ -| BUILDING A FILTER | -+-------------------+ - -The following command presumes that the sample code from the end of this -README is saved to a file named 'sample.c' and built in the local platform- -specific build subdirectory (SRCDIR/obj.*/libmilter). - - cc -I../../include -o sample sample.c libmilter.a ../libsm/libsm.a -pthread - -It is recommended that you build your filters in a location outside of -the sendmail source tree. Modify the compiler include references (-I) -and the library locations accordingly. Also, some operating systems may -require additional libraries. For example, SunOS 5.X requires '-lresolv --lsocket -lnsl'. Depending on your operating system you may need a library -instead of the option -pthread, e.g., -lpthread. - -Filters must be thread-safe! Many operating systems now provide support for -POSIX threads in the standard C libraries. The compiler flag to link with -threading support differs according to the compiler and linker used. Check -the Makefile in your appropriate obj.*/libmilter build subdirectory if you -are unsure of the local flag used. - -Note that since filters use threads, it may be necessary to alter per -process limits in your filter. For example, you might look at using -setrlimit() to increase the number of open file descriptors if your filter -is going to be busy. - - -+----------------------------------------+ -| SPECIFYING FILTERS IN SENDMAIL CONFIGS | -+----------------------------------------+ - -Filters are specified with a key letter ``X'' (for ``eXternal''). - -For example: - - Xfilter1, S=local:/var/run/f1.sock, F=R - Xfilter2, S=inet6:999@localhost, F=T, T=C:10m;S:1s;R:1s;E:5m - Xfilter3, S=inet:3333@localhost - -specifies three filters. Filters can be specified in your .mc file using -the following: - - INPUT_MAIL_FILTER(`filter1', `S=local:/var/run/f1.sock, F=R') - INPUT_MAIL_FILTER(`filter2', `S=inet6:999@localhost, F=T, T=C:10m;S:1s;R:1s;E:5m') - INPUT_MAIL_FILTER(`filter3', `S=inet:3333@localhost') - -The first attaches to a Unix-domain socket in the /var/run directory; the -second uses an IPv6 socket on port 999 of localhost, and the third uses an -IPv4 socket on port 3333 of localhost. The current flags (F=) are: - - R Reject connection if filter unavailable - T Temporary fail connection if filter unavailable - -If neither F=R nor F=T is specified, the message is passed through sendmail -in case of filter errors as if the failing filters were not present. - -Finally, you can override the default timeouts used by sendmail when -talking to the filters using the T= equate. There are four fields inside -of the T= equate: - -Letter Meaning - C Timeout for connecting to a filter (if 0, use system timeout) - S Timeout for sending information from the MTA to a filter - R Timeout for reading reply from the filter - E Overall timeout between sending end-of-message to filter - and waiting for the final acknowledgment - -Note the separator between each is a ';' as a ',' already separates equates -and therefore can't separate timeouts. The default values (if not set in -the config) are: - -T=C:5m;S:10s;R:10s;E:5m - -where 's' is seconds and 'm' is minutes. - -Which filters are invoked and their sequencing is handled by the -InputMailFilters option. Note: if InputMailFilters is not defined no filters -will be used. - - O InputMailFilters=filter1, filter2, filter3 - -This is is set automatically according to the order of the -INPUT_MAIL_FILTER commands in your .mc file. Alternatively, you can -reset its value by setting confINPUT_MAIL_FILTERS in your .mc file. -This options causes the three filters to be called in the same order -they were specified. It allows for possible future filtering on output -(although this is not intended for this release). - -Also note that a filter can be defined without adding it to the input -filter list by using MAIL_FILTER() instead of INPUT_MAIL_FILTER() in your -.mc file. - -To test sendmail with the sample filter, the following might be added (in -the appropriate locations) to your .mc file: - - INPUT_MAIL_FILTER(`sample', `S=local:/var/run/f1.sock') - - -+------------------+ -| TESTING A FILTER | -+------------------+ - -Once you have compiled a filter, modified your .mc file and restarted -the sendmail process, you will want to test that the filter performs as -intended. - -The sample filter takes one argument -p, which indicates the local port -on which to create a listening socket for the filter. Maintaining -consistency with the suggested options for sendmail.cf, this would be the -UNIX domain socket located in /var/run/f1.sock. - - % ./sample -p local:/var/run/f1.sock - -If the sample filter returns immediately to a command line, there was either -an error with your command or a problem creating the specified socket. -Further logging can be captured through the syslogd daemon. Using the -'netstat -a' command can ensure that your filter process is listening on -the appropriate local socket. - -Email messages must be injected via SMTP to be filtered. There are two -simple means of doing this; either using the 'sendmail -bs' command, or -by telnetting to port 25 of the machine configured for milter. Once -connected via one of these options, the session can be continued through -the use of standard SMTP commands. - -% sendmail -bs -220 test.sendmail.com ESMTP Sendmail 8.11.0/8.11.0; Tue, 10 Nov 1970 13:05:23 -0500 (EST) -HELO localhost -250 test.sendmail.com Hello testy@localhost, pleased to meet you -MAIL From:<testy> -250 2.1.0 <testy>... Sender ok -RCPT To:<root> -250 2.1.5 <root>... Recipient ok -DATA -354 Enter mail, end with "." on a line by itself -From: testy@test.sendmail.com -To: root@test.sendmail.com -Subject: testing sample filter - -Sample body -. -250 2.0.0 dB73Zxi25236 Message accepted for delivery -QUIT -221 2.0.0 test.sendmail.com closing connection - -In the above example, the lines beginning with numbers are output by the -mail server, and those without are your input. If everything is working -properly, you will find a file in /tmp by the name of msg.XXXXXXXX (where -the Xs represent any combination of letters and numbers). This file should -contain the message body and headers from the test email entered above. - -If the sample filter did not log your test email, there are a number of -methods to narrow down the source of the problem. Check your system -logs written by syslogd and see if there are any pertinent lines. You -may need to reconfigure syslogd to capture all relevant data. Additionally, -the logging level of sendmail can be raised with the LogLevel option. -See the sendmail(8) manual page for more information. - - -+--------------+ -| REQUIREMENTS | -+--------------+ - -libmilter requires pthread support in the operating system. Moreover, it -requires that the library functions it uses are thread safe; which is true -for the operating systems libmilter has been developed and tested on. On -some operating systems this requires special compile time options (e.g., -not just -pthread). libmilter is currently known to work on (modulo problems -in the pthread support of some specific versions): - -FreeBSD 3.x, 4.x -SunOS 5.x (x >= 5) -AIX 4.3.x -HP UX 11.x -Linux (recent versions/distributions) - -libmilter is currently not supported on: - -IRIX 6.x -Ultrix - -Feedback about problems (and possible fixes) is welcome. - -+--------------------------+ -| SOURCE FOR SAMPLE FILTER | -+--------------------------+ - -Note that the filter below may not be thread safe on some operating -systems. You should check your system man pages for the functions used -below to verify the functions are thread safe. - -/* A trivial filter that logs all email to a file. */ - -#include <sys/types.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sysexits.h> -#include <unistd.h> - -#include "libmilter/mfapi.h" - -#ifndef true -typedef int bool; -# define false 0 -# define true 1 -#endif /* ! true */ - -struct mlfiPriv -{ - char *mlfi_fname; - FILE *mlfi_fp; -}; - -#define MLFIPRIV ((struct mlfiPriv *) smfi_getpriv(ctx)) - -extern sfsistat mlfi_cleanup(SMFICTX *, bool); - -sfsistat -mlfi_envfrom(ctx, envfrom) - SMFICTX *ctx; - char **envfrom; -{ - struct mlfiPriv *priv; - int fd = -1; - - /* allocate some private memory */ - priv = malloc(sizeof *priv); - if (priv == NULL) - { - /* can't accept this message right now */ - return SMFIS_TEMPFAIL; - } - memset(priv, '\0', sizeof *priv); - - /* open a file to store this message */ - priv->mlfi_fname = strdup("/tmp/msg.XXXXXXXX"); - if (priv->mlfi_fname == NULL) - { - free(priv); - return SMFIS_TEMPFAIL; - } - if ((fd = mkstemp(priv->mlfi_fname)) < 0 || - (priv->mlfi_fp = fdopen(fd, "w+")) == NULL) - { - if (fd >= 0) - (void) close(fd); - free(priv->mlfi_fname); - free(priv); - return SMFIS_TEMPFAIL; - } - - /* save the private data */ - smfi_setpriv(ctx, priv); - - /* continue processing */ - return SMFIS_CONTINUE; -} - -sfsistat -mlfi_header(ctx, headerf, headerv) - SMFICTX *ctx; - char *headerf; - char *headerv; -{ - /* write the header to the log file */ - fprintf(MLFIPRIV->mlfi_fp, "%s: %s\r\n", headerf, headerv); - - /* continue processing */ - return SMFIS_CONTINUE; -} - -sfsistat -mlfi_eoh(ctx) - SMFICTX *ctx; -{ - /* output the blank line between the header and the body */ - fprintf(MLFIPRIV->mlfi_fp, "\r\n"); - - /* continue processing */ - return SMFIS_CONTINUE; -} - -sfsistat -mlfi_body(ctx, bodyp, bodylen) - SMFICTX *ctx; - u_char *bodyp; - size_t bodylen; -{ - /* output body block to log file */ - if (fwrite(bodyp, bodylen, 1, MLFIPRIV->mlfi_fp) <= 0) - { - /* write failed */ - (void) mlfi_cleanup(ctx, false); - return SMFIS_TEMPFAIL; - } - - /* continue processing */ - return SMFIS_CONTINUE; -} - -sfsistat -mlfi_eom(ctx) - SMFICTX *ctx; -{ - return mlfi_cleanup(ctx, true); -} - -sfsistat -mlfi_close(ctx) - SMFICTX *ctx; -{ - return SMFIS_ACCEPT; -} - -sfsistat -mlfi_abort(ctx) - SMFICTX *ctx; -{ - return mlfi_cleanup(ctx, false); -} - -sfsistat -mlfi_cleanup(ctx, ok) - SMFICTX *ctx; - bool ok; -{ - sfsistat rstat = SMFIS_CONTINUE; - struct mlfiPriv *priv = MLFIPRIV; - char *p; - char host[512]; - char hbuf[1024]; - - if (priv == NULL) - return rstat; - - /* close the archive file */ - if (priv->mlfi_fp != NULL && fclose(priv->mlfi_fp) == EOF) - { - /* failed; we have to wait until later */ - rstat = SMFIS_TEMPFAIL; - (void) unlink(priv->mlfi_fname); - } - else if (ok) - { - /* add a header to the message announcing our presence */ - if (gethostname(host, sizeof host) < 0) - snprintf(host, sizeof host, "localhost"); - p = strrchr(priv->mlfi_fname, '/'); - if (p == NULL) - p = priv->mlfi_fname; - else - p++; - snprintf(hbuf, sizeof hbuf, "%s@%s", p, host); - smfi_addheader(ctx, "X-Archived", hbuf); - } - else - { - /* message was aborted -- delete the archive file */ - (void) unlink(priv->mlfi_fname); - } - - /* release private memory */ - free(priv->mlfi_fname); - free(priv); - smfi_setpriv(ctx, NULL); - - /* return status */ - return rstat; -} - -struct smfiDesc smfilter = -{ - "SampleFilter", /* filter name */ - SMFI_VERSION, /* version code -- do not change */ - SMFIF_ADDHDRS, /* flags */ - NULL, /* connection info filter */ - NULL, /* SMTP HELO command filter */ - mlfi_envfrom, /* envelope sender filter */ - NULL, /* envelope recipient filter */ - mlfi_header, /* header filter */ - mlfi_eoh, /* end of header */ - mlfi_body, /* body block filter */ - mlfi_eom, /* end of message */ - mlfi_abort, /* message aborted */ - mlfi_close /* connection cleanup */ -}; - - -int -main(argc, argv) - int argc; - char *argv[]; -{ - int c; - const char *args = "p:"; - - /* Process command line options */ - while ((c = getopt(argc, argv, args)) != -1) - { - switch (c) - { - case 'p': - if (optarg == NULL || *optarg == '\0') - { - (void) fprintf(stderr, "Illegal conn: %s\n", - optarg); - exit(EX_USAGE); - } - (void) smfi_setconn(optarg); - break; - - } - } - if (smfi_register(smfilter) == MI_FAILURE) - { - fprintf(stderr, "smfi_register failed\n"); - exit(EX_UNAVAILABLE); - } - return smfi_main(); -} - -/* eof */ - -$Revision: 8.35.2.1 $, Last updated $Date: 2002/10/21 14:31:57 $ diff --git a/contrib/sendmail/libmilter/comm.c b/contrib/sendmail/libmilter/comm.c deleted file mode 100644 index aa48cf78791d..000000000000 --- a/contrib/sendmail/libmilter/comm.c +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (c) 1999-2003 Sendmail, Inc. and its suppliers. - * All rights reserved. - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the sendmail distribution. - * - */ - -#include <sm/gen.h> -SM_RCSID("@(#)$Id: comm.c,v 8.54.2.6 2003/01/03 22:14:40 ca Exp $") - -#include "libmilter.h" -#include <sm/errstring.h> - -/* -** MI_RD_CMD -- read a command -** -** Parameters: -** sd -- socket descriptor -** timeout -- maximum time to wait -** cmd -- single character command read from sd -** rlen -- pointer to length of result -** name -- name of milter -** -** Returns: -** buffer with rest of command -** (malloc()ed here, should be free()d) -** hack: encode error in cmd -*/ - -char * -mi_rd_cmd(sd, timeout, cmd, rlen, name) - socket_t sd; - struct timeval *timeout; - char *cmd; - size_t *rlen; - char *name; -{ - ssize_t len; - mi_int32 expl; - ssize_t i; - FD_RD_VAR(rds, excs); - int ret; - int save_errno; - char *buf; - char data[MILTER_LEN_BYTES + 1]; - - *cmd = '\0'; - *rlen = 0; - - i = 0; - for (;;) - { - FD_RD_INIT(sd, rds, excs); - ret = FD_RD_READY(sd, rds, excs, timeout); - if (ret == 0) - break; - else if (ret < 0) - { - if (errno == EINTR) - continue; - break; - } - if (FD_IS_RD_EXC(sd, rds, excs)) - { - *cmd = SMFIC_SELECT; - return NULL; - } - - len = MI_SOCK_READ(sd, data + i, sizeof data - i); - if (MI_SOCK_READ_FAIL(len)) - { - smi_log(SMI_LOG_ERR, - "%s, mi_rd_cmd: read returned %d: %s", - name, (int) len, sm_errstring(errno)); - *cmd = SMFIC_RECVERR; - return NULL; - } - if (len == 0) - { - *cmd = SMFIC_EOF; - return NULL; - } - if (len >= (ssize_t) sizeof data - i) - break; - i += len; - } - if (ret == 0) - { - *cmd = SMFIC_TIMEOUT; - return NULL; - } - else if (ret < 0) - { - smi_log(SMI_LOG_ERR, - "%s: mi_rd_cmd: select returned %d: %s", - name, ret, sm_errstring(errno)); - *cmd = SMFIC_RECVERR; - return NULL; - } - - *cmd = data[MILTER_LEN_BYTES]; - data[MILTER_LEN_BYTES] = '\0'; - (void) memcpy((void *) &expl, (void *) &(data[0]), MILTER_LEN_BYTES); - expl = ntohl(expl) - 1; - if (expl <= 0) - return NULL; - if (expl > MILTER_CHUNK_SIZE) - { - *cmd = SMFIC_TOOBIG; - return NULL; - } -#if _FFR_ADD_NULL - buf = malloc(expl + 1); -#else /* _FFR_ADD_NULL */ - buf = malloc(expl); -#endif /* _FFR_ADD_NULL */ - if (buf == NULL) - { - *cmd = SMFIC_MALLOC; - return NULL; - } - - i = 0; - for (;;) - { - FD_RD_INIT(sd, rds, excs); - ret = FD_RD_READY(sd, rds, excs, timeout); - if (ret == 0) - break; - else if (ret < 0) - { - if (errno == EINTR) - continue; - break; - } - if (FD_IS_RD_EXC(sd, rds, excs)) - { - *cmd = SMFIC_SELECT; - free(buf); - return NULL; - } - len = MI_SOCK_READ(sd, buf + i, expl - i); - if (MI_SOCK_READ_FAIL(len)) - { - smi_log(SMI_LOG_ERR, - "%s: mi_rd_cmd: read returned %d: %s", - name, (int) len, sm_errstring(errno)); - ret = -1; - break; - } - if (len == 0) - { - *cmd = SMFIC_EOF; - free(buf); - return NULL; - } - if (len > expl - i) - { - *cmd = SMFIC_RECVERR; - free(buf); - return NULL; - } - if (len >= expl - i) - { - *rlen = expl; -#if _FFR_ADD_NULL - /* makes life simpler for common string routines */ - buf[expl] = '\0'; -#endif /* _FFR_ADD_NULL */ - return buf; - } - i += len; - } - - save_errno = errno; - free(buf); - - /* select returned 0 (timeout) or < 0 (error) */ - if (ret == 0) - { - *cmd = SMFIC_TIMEOUT; - return NULL; - } - if (ret < 0) - { - smi_log(SMI_LOG_ERR, - "%s: mi_rd_cmd: select returned %d: %s", - name, ret, sm_errstring(save_errno)); - *cmd = SMFIC_RECVERR; - return NULL; - } - *cmd = SMFIC_UNKNERR; - return NULL; -} -/* -** MI_WR_CMD -- write a cmd to sd -** -** Parameters: -** sd -- socket descriptor -** timeout -- maximum time to wait (currently unused) -** cmd -- single character command to write -** buf -- buffer with further data -** len -- length of buffer (without cmd!) -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -/* -** we don't care much about the timeout here, it's very long anyway -** FD_SETSIZE is checked when socket is created. -** XXX l == 0 ? -*/ - -#define MI_WR(data) \ - while (sl > 0) \ - { \ - FD_WR_INIT(sd, wrs); \ - ret = FD_WR_READY(sd, wrs, 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; - struct timeval *timeout; - int cmd; - char *buf; - size_t len; -{ - size_t sl, i; - ssize_t l; - mi_int32 nl; - int ret; - FD_WR_VAR(wrs); - char data[MILTER_LEN_BYTES + 1]; - - if (len > MILTER_CHUNK_SIZE) - return MI_FAILURE; - nl = htonl(len + 1); /* add 1 for the cmd char */ - (void) memcpy(data, (void *) &nl, MILTER_LEN_BYTES); - data[MILTER_LEN_BYTES] = (char) cmd; - i = 0; - sl = MILTER_LEN_BYTES + 1; - - /* use writev() instead to send the whole stuff at once? */ - - MI_WR(data); - if (len > 0 && buf == NULL) - return MI_FAILURE; - if (len == 0 || buf == NULL) - return MI_SUCCESS; - i = 0; - sl = len; - MI_WR(buf); - return MI_SUCCESS; -} diff --git a/contrib/sendmail/libmilter/docs/api.html b/contrib/sendmail/libmilter/docs/api.html deleted file mode 100644 index 936abed0d0db..000000000000 --- a/contrib/sendmail/libmilter/docs/api.html +++ /dev/null @@ -1,194 +0,0 @@ -<html> -<head><title>Milter API</title></head> -<body> -<h1>Milter API</h1> - -<h2>Contents</h2> -<ul> - <li>Library Control Functions - <li>Data Access Functions - <li>Message Modification Functions - <li>Callbacks -</ul> - -<h2>Library Control Functions</h2> - -Before handing control to libmilter (by calling <a -href="smfi_main.html">smfi_main</a>), a filter may call the following -functions to set libmilter parameters. In particular, the filter must -call <a href="smfi_register.html">smfi_register</a> to register its -callbacks. Each function will return either MI_SUCCESS or MI_FAILURE to -indicate the status of the operation. -<p> -None of these functions communicate with the MTA. All alter the -library's state, some of which is communicated to the MTA inside <a -href="smfi_main.html">smfi_main</a>. -<p> -<table border="1" cellspacing=0 cellpadding=2><tr bgcolor="#dddddd"><th>Function</th><th>Description</th></tr> - -<tr><td><a href="smfi_register.html">smfi_register</a></td><td>Register a filter.</td></tr> - -<tr><td><a href="smfi_setconn.html">smfi_setconn</a></td><td>Specify socket to use.</td></tr> - -<tr><td><a href="smfi_settimeout.html">smfi_settimeout</a></td><td>Set timeout.</td></tr> - -<tr><td><a href="smfi_main.html">smfi_main</a></td><td>Hand control to libmilter.</td></tr> - -</table> - -<h2>Data Access Functions</h2> - -The following functions may be called from within the filter-defined callbacks -to access information about the current connection or message. -<p> -<table border="1" cellspacing=0 cellpadding=2><tr bgcolor="#dddddd"><th>Function</th><th>Description</th></tr> -<tr><td><a href="smfi_getsymval.html">smfi_getsymval</a></td><td>Return the value -of a symbol.</td></tr> - -<tr><td><a href="smfi_getpriv.html">smfi_getpriv</a></td><td>Get the private data -pointer.</td></tr> - -<tr><td><a href="smfi_setpriv.html">smfi_setpriv</a></td><td>Set the private data -pointer.</td></tr> - -<tr><td><a href="smfi_setreply.html">smfi_setreply</a></td><td>Set the specific -reply code to be used.</td></tr> - -</table> - -<h2>Message Modification Functions</h2> - -The following functions change a message's contents and attributes. -<b>They may only be called in <a href="xxfi_eom.html">xxfi_eom</a></b>. -All of these functions may invoke additional communication with the MTA. -They will return either MI_SUCCESS or MI_FAILURE to indicate the status of -the operation. - -<p> -A filter must have set the appropriate flag (listed below) in the -description passed to <a href="smfi_register.html">smfi_register</a> -to call any message modification function. Failure to do so will -cause the MTA to treat a call to the function as a failure of the -filter, terminating its connection. - -<p> -Note that the status returned indicates only whether or not the -filter's message was successfully sent to the MTA, not whether or not -the MTA performed the requested operation. For example, <a -href="smfi_addheader.html">smfi_addheader</a>, when called with an -illegal header name, will return MI_SUCCESS even though the MTA may -later refuse to add the illegal header. -<p> -<table border="1" cellspacing=0 cellpadding=2><tr bgcolor="#dddddd"><th>Function</th><th>Description</th><th>SMFIF_* flag</tr> -<tr><td><a href="smfi_addheader.html">smfi_addheader</a></td><td>Add a header to -the message.</td><td>SMFIF_ADDHDRS</td></tr> - -<tr><td><a href="smfi_chgheader.html">smfi_chgheader</a></td><td>Change or delete a header.</td><td>SMFIF_CHGHDRS</td></tr> - -<tr><td><a href="smfi_addrcpt.html">smfi_addrcpt</a></td><td>Add a recipient to -the envelope.</td><td>SMFIF_ADDRCPT</td></tr> - -<tr><td><a href="smfi_delrcpt.html">smfi_delrcpt</a></td><td>Delete a recipient -from the envelope.</td><td>SMFIF_DELRCPT</td></tr> - -<tr><td><a href="smfi_replacebody.html">smfi_replacebody</a></td><td>Replace the -body of the message.</td><td>SMFIF_CHGBODY</td></tr> - -</table> - -<h2>Callbacks</h2> - -The filter should implement one or more of the following callbacks, -which are registered via <a href="smfi_register.html">smfi_register</a>: -<p> -<table border="1" cellspacing=0 cellpadding=2><tr bgcolor="#dddddd"><th>Function</th><th>Description</th></tr> - -<tr><td><a href="xxfi_connect.html">xxfi_connect</a></td><td>connection info</td></tr> - -<tr><td><a href="xxfi_helo.html">xxfi_helo</a></td><td>SMTP HELO/EHLO command</td></tr> - -<tr><td><a href="xxfi_envfrom.html">xxfi_envfrom</a></td><td>envelope sender</td></tr> - -<tr><td><a href="xxfi_envrcpt.html">xxfi_envrcpt</a></td><td>envelope recipient</td></tr> - -<tr><td><a href="xxfi_header.html">xxfi_header</a></td><td>header</td></tr> - -<tr><td><a href="xxfi_eoh.html">xxfi_eoh</a></td><td>end of header</td></tr> - -<tr><td><a href="xxfi_body.html">xxfi_body</a></td><td>body block</td></tr> - -<tr><td><a href="xxfi_eom.html">xxfi_eom</a></td><td>end of message</td></tr> - -<tr><td><a href="xxfi_abort.html">xxfi_abort</a></td><td>message aborted</td></tr> - -<tr><td><a href="xxfi_close.html">xxfi_close</a></td><td>connection cleanup</td></tr> - -</table> - -<p> -The above callbacks should all return one of the following return values, -having the indicated meanings. Any return other than one of the below -values constitutes an error, and will cause sendmail to terminate its -connection to the offending filter. - -<p><a name="conn-spec"></a>Milter distinguishes between recipient-, -message-, and connection-oriented routines. Recipient-oriented -callbacks may affect the processing of a single message recipient; -message-oriented callbacks, a single message; connection-oriented -callbacks, an entire connection (during which multiple messages may be -delivered to multiple sets of recipients). -<a href="xxfi_envrcpt.html">xxfi_envrcpt</a> is recipient-oriented. -<a href="xxfi_connect.html">xxfi_connect</a>, -<a href="xxfi_helo.html">xxfi_helo</a> and -<a href="xxfi_close.html">xxfi_close</a> are connection-oriented. All -other callbacks are message-oriented. - -<p> -<table border="1" cellspacing=0 cellpadding=2> - <tr bgcolor="#dddddd"><th>Return value</th><th>Description</th></tr> - <tr valign="top"> - <td>SMFIS_CONTINUE</td> - <td>Continue processing the current connection, message, or recipient. - </td> - </tr> - <tr valign="top"> - <td>SMFIS_REJECT</td> - <td>For a connection-oriented routine, reject this connection; call <a href="xxfi_close.html">xxfi_close</a>.<br> - For a message-oriented routine (except - <a href="xxfi_eom.html">xxfi_eom</a> or - <a href="xxfi_abort.html">xxfi_abort</a>), reject this message.<br> - For a recipient-oriented routine, reject the current recipient (but continue processing the current message). - </td> - </tr> - <tr valign="top"> - <td>SMFIS_DISCARD</td> - <td>For a message- or recipient-oriented routine, accept this message, but silently discard it.<br> - SMFIS_DISCARD should not be returned by a connection-oriented routine. - </td> - </tr> - <tr valign="top"> - <td>SMFIS_ACCEPT</td> - <td>For a connection-oriented routine, accept this connection without further filter processing; call <a href="xxfi_close.html">xxfi_close</a>.<br> - For a message- or recipient-oriented routine, accept this message without further filtering.<br> - </td> - </tr> - <tr valign="top"> - <td>SMFIS_TEMPFAIL</td> - <td>Return a temporary failure, i.e., the corresponding SMTP command will return an appropriate 4xx status code. - For a message-oriented routine (except <a href="xxfi_envfrom.html">xxfi_envfrom</a>), fail for this message. <br> - For a connection-oriented routine, fail for this connection; call <a href="xxfi_close.html">xxfi_close</a>. <br> - For a recipient-oriented routine, only fail for the current recipient; continue message processing. - </td> - </tr> -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/design.html b/contrib/sendmail/libmilter/docs/design.html deleted file mode 100644 index 91804861e0a0..000000000000 --- a/contrib/sendmail/libmilter/docs/design.html +++ /dev/null @@ -1,144 +0,0 @@ -<html> -<head> -<title>Architecture</title> -</head> -<body> - -<h1>Architecture</h1> - -<h2>Contents</h2> - -<ul> - <li>Design Goals - <li>Implementing Filtering Policies - <li>MTA - Filter Communication -</ul> - -<h2>Goals</h2> - -The Sendmail Content Management API (Milter) provides an interface for -third-party software to validate and modify messages as they pass -through the mail transport system. Filters can process messages' -connection (IP) information, envelope protocol elements, message -headers, and/or message body contents, and modify a message's -recipients, headers, and body. The MTA configuration file specifies -which filters are to be applied, and in what order, allowing an -administrator to combine multiple independently-developed filters. - -<p> -We expect to see both vendor-supplied, configurable mail filtering -applications and a multiplicity of script-like filters designed by and -for MTA administrators. A certain degree of coding sophistication and -domain knowledge on the part of the filter provider is assumed. This -allows filters to exercise fine-grained control at the SMTP level. -However, as will be seen in the example, many filtering applications -can be written with relatively little protocol knowledge. - -<p> -Given these expectations, the API is designed to achieve the following -goals: - -<OL> - <LI>Safety/security. - Filter processes should not need to run as root - (of course, they can if required, but that is a local issue); - this will simplify coding - and limit the impact of security flaws in the filter program. -<p> - <LI>Reliability. - Coding failures in a Milter process that cause that process - to hang or core-dump - should not stop mail delivery. - Faced with such a failure, - sendmail should use a default mechanism, - either behaving as if the filter were not present - or as if a required resource were unavailable. - The latter failure mode will generally have sendmail return - a 4xx SMTP code (although in later phases of the SMTP protocol - it may cause the mail to be queued for later processing). -<p> - <LI>Simplicity. - The API should make implementation of a new filter - no more difficult than absolutely necessary. - Subgoals include: - <UL> - <LI>Encourage good thread practice - by defining thread-clean interfaces including local data hooks. - <LI>Provide all interfaces required - while avoiding unnecessary pedanticism. - </UL> -<p> - <LI>Performance. - Simple filters should not seriously impact overall MTA performance. -</OL> - -<h2>Implementing Filtering Policies</h2> - -Milter is designed to allow a server administrator to combine -third-party filters to implement a desired mail filtering policy. For -example, if a site wished to scan incoming mail for viruses on several -platforms, eliminate unsolicited commercial email, and append a mandated -footer to selected incoming messages, the administrator could configure -the MTA to filter messages first through a server based anti-virus -engine, then via a large-scale spam-catching service, and finally -append the desired footer if the message still met requisite criteria. -Any of these filters could be added or changed independently. - -<p> -Thus the site administrator, not the filter writer, controls the -overall mail filtering environment. In particular, he/she must decide -which filters are run, in what order they are run, and how they -communicate with the MTA. These parameters, as well as the -actions to be taken if a filter becomes unavailable, are selectable -during MTA configuration. <a href="installation.html">Further -details</a> are available later in this document. - -<h2>MTA - Filter communication</h2> - -Filters run as separate processes, outside of the sendmail address -space. The benefits of this are threefold: - -<OL> - <LI>The filter need not run with "root" permissions, thereby - avoiding a large family of potential security problems.</LI> - - <LI>Failures in a particular filter will not affect the MTA or - other filters.</LI> - - <LI>The filter can potentially have higher performance because of - the parallelism inherent in multiple processes.</LI> -</OL> - -<p> -Each filter may communicate with multiple MTAs at the same time over -local or remote connections, using multiple threads of execution. <a -href="#figure-1">Figure 1</a> illustrates a possible network of -communication channels between a site's filters, its MTAs, and other -MTAs on the network: -</p> -<div align="center"> -<a name="figure-1"><img src="figure1.jpg" ALT=""></A><br> -<b>Figure 1: A set of MTA's interacting with a set of filters.</b> -</div> -<p> -The Milter library (libmilter) implements the communication protocol. -It accepts connections from various MTAs, passes the relevant data to -the filter through callbacks, then makes appropriate responses based -on return codes. A filter may also send data to the MTA as a result -of library calls. <a href="#figure-2">Figure 2</a> shows a single -filter process processing messages from two MTAs: -</p> -<div align="center"> -<img src="figure2.jpg" ALT=""><br> -<b>Figure 2: A filter handling simultaneous requests from two MTA's.</b> -</div> -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/figure1.fig b/contrib/sendmail/libmilter/docs/figure1.fig deleted file mode 100644 index e0cbdc8e8aa2..000000000000 --- a/contrib/sendmail/libmilter/docs/figure1.fig +++ /dev/null @@ -1,56 +0,0 @@ -#FIG 3.2 -Landscape -Center -Inches -Letter -100.00 -Single --2 -1200 2 -6 975 225 5025 3375 -6 1500 1275 2700 2025 -2 2 0 2 1 7 50 0 -1 0.000 0 0 7 0 0 5 - 1650 1425 2550 1425 2550 1875 1650 1875 1650 1425 -4 0 1 50 0 0 20 0.0000 4 195 645 1800 1725 MTA\001 --6 -6 1950 2625 3150 3375 -2 2 0 2 4 7 50 0 -1 0.000 0 0 7 0 0 5 - 2100 2775 3000 2775 3000 3225 2100 3225 2100 2775 -4 0 4 50 0 0 20 0.0000 4 195 645 2250 3075 MTA\001 --6 -6 1050 225 2250 975 -2 2 0 2 14 7 50 0 -1 0.000 0 0 7 0 0 5 - 1200 375 2100 375 2100 825 1200 825 1200 375 -4 0 14 50 0 0 20 0.0000 4 195 645 1350 675 MTA\001 --6 -2 1 0 2 1 7 50 0 -1 0.000 0 0 7 0 0 2 - 2550 1575 3750 2625 -2 1 0 2 1 7 50 0 -1 0.000 0 0 7 0 0 2 - 2550 1575 3750 1575 -2 1 0 2 1 7 50 0 -1 0.000 0 0 7 0 0 2 - 2550 1575 3750 825 -2 1 0 2 4 7 50 0 -1 0.000 0 0 7 0 0 2 - 3000 2925 3750 2625 -2 1 0 2 14 7 50 0 -1 0.000 0 0 7 0 0 2 - 2100 525 3750 825 -2 1 0 2 14 7 50 0 -1 0.000 0 0 7 0 0 2 - 2100 525 3750 2625 -2 1 0 4 0 7 50 0 -1 0.000 0 0 7 0 0 2 - 1050 3075 2100 3075 -2 1 0 4 0 7 50 0 -1 0.000 0 0 7 0 0 2 - 1050 1725 1650 1725 -2 1 0 4 0 7 50 0 -1 0.000 0 0 7 0 0 2 - 1050 675 1200 675 -2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5 - 3750 2475 4950 2475 4950 2925 3750 2925 3750 2475 -2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5 - 3750 1425 4950 1425 4950 1875 3750 1875 3750 1425 -2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5 - 3750 525 4950 525 4950 975 3750 975 3750 525 -4 0 0 50 0 1 20 0.0000 4 210 795 3900 2775 Filter 3\001 -4 0 0 50 0 1 20 0.0000 4 210 795 3900 1725 Filter 2\001 -4 0 0 50 0 1 20 0.0000 4 210 795 3900 825 Filter 1\001 --6 -2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 - 300 525 1050 525 1050 3225 300 3225 300 525 -4 0 0 50 0 2 24 1.5708 4 255 1950 825 2850 INTERNET\001 diff --git a/contrib/sendmail/libmilter/docs/figure1.jpg b/contrib/sendmail/libmilter/docs/figure1.jpg Binary files differdeleted file mode 100644 index 1a5f1dec386a..000000000000 --- a/contrib/sendmail/libmilter/docs/figure1.jpg +++ /dev/null diff --git a/contrib/sendmail/libmilter/docs/figure1.ps b/contrib/sendmail/libmilter/docs/figure1.ps deleted file mode 100644 index ae317607e4d2..000000000000 --- a/contrib/sendmail/libmilter/docs/figure1.ps +++ /dev/null @@ -1,173 +0,0 @@ -%!PS-Adobe-2.0 -%%Title: figure1.fig -%%Creator: fig2dev Version 3.2.3 Patchlevel -%%CreationDate: Tue Jun 6 14:00:04 2000 -%%For: sean@host232.Sendmail.COM (Sean O'rourke,5400) -%%Orientation: Landscape -%%Pages: 1 -%%BoundingBox: 0 0 612 792 -%%BeginSetup -%%IncludeFeature: *PageSize Letter -%%EndSetup -%%Magnification: 1.0000 -%%EndComments -/$F2psDict 200 dict def -$F2psDict begin -$F2psDict /mtrx matrix put -/col-1 {0 setgray} bind def -/col0 {0.000 0.000 0.000 srgb} bind def -/col1 {0.000 0.000 1.000 srgb} bind def -/col2 {0.000 1.000 0.000 srgb} bind def -/col3 {0.000 1.000 1.000 srgb} bind def -/col4 {1.000 0.000 0.000 srgb} bind def -/col5 {1.000 0.000 1.000 srgb} bind def -/col6 {1.000 1.000 0.000 srgb} bind def -/col7 {1.000 1.000 1.000 srgb} bind def -/col8 {0.000 0.000 0.560 srgb} bind def -/col9 {0.000 0.000 0.690 srgb} bind def -/col10 {0.000 0.000 0.820 srgb} bind def -/col11 {0.530 0.810 1.000 srgb} bind def -/col12 {0.000 0.560 0.000 srgb} bind def -/col13 {0.000 0.690 0.000 srgb} bind def -/col14 {0.000 0.820 0.000 srgb} bind def -/col15 {0.000 0.560 0.560 srgb} bind def -/col16 {0.000 0.690 0.690 srgb} bind def -/col17 {0.000 0.820 0.820 srgb} bind def -/col18 {0.560 0.000 0.000 srgb} bind def -/col19 {0.690 0.000 0.000 srgb} bind def -/col20 {0.820 0.000 0.000 srgb} bind def -/col21 {0.560 0.000 0.560 srgb} bind def -/col22 {0.690 0.000 0.690 srgb} bind def -/col23 {0.820 0.000 0.820 srgb} bind def -/col24 {0.500 0.190 0.000 srgb} bind def -/col25 {0.630 0.250 0.000 srgb} bind def -/col26 {0.750 0.380 0.000 srgb} bind def -/col27 {1.000 0.500 0.500 srgb} bind def -/col28 {1.000 0.630 0.630 srgb} bind def -/col29 {1.000 0.750 0.750 srgb} bind def -/col30 {1.000 0.880 0.880 srgb} bind def -/col31 {1.000 0.840 0.000 srgb} bind def - -end -save -newpath 0 792 moveto 0 0 lineto 612 0 lineto 612 792 lineto closepath clip newpath -198.0 238.0 translate - 90 rotate -1 -1 scale - -/cp {closepath} bind def -/ef {eofill} bind def -/gr {grestore} bind def -/gs {gsave} bind def -/sa {save} bind def -/rs {restore} bind def -/l {lineto} bind def -/m {moveto} bind def -/rm {rmoveto} bind def -/n {newpath} bind def -/s {stroke} bind def -/sh {show} bind def -/slc {setlinecap} bind def -/slj {setlinejoin} bind def -/slw {setlinewidth} bind def -/srgb {setrgbcolor} bind def -/rot {rotate} bind def -/sc {scale} bind def -/sd {setdash} bind def -/ff {findfont} bind def -/sf {setfont} bind def -/scf {scalefont} bind def -/sw {stringwidth} bind def -/tr {translate} bind def -/tnt {dup dup currentrgbcolor - 4 -2 roll dup 1 exch sub 3 -1 roll mul add - 4 -2 roll dup 1 exch sub 3 -1 roll mul add - 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} - bind def -/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul - 4 -2 roll mul srgb} bind def -/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def -/$F2psEnd {$F2psEnteredState restore end} def - -$F2psBegin -%%Page: 1 1 -10 setmiterlimit - 0.06000 0.06000 sc -%%Page: 1 1 -/Times-Bold ff 360.00 scf sf -825 2850 m -gs 1 -1 sc 90.0 rot (INTERNET) col0 sh gr -/Times-Roman ff 300.00 scf sf -1800 1725 m -gs 1 -1 sc (MTA) col1 sh gr -% Polyline -15.000 slw -n 2100 2775 m 3000 2775 l 3000 3225 l 2100 3225 l - cp gs col4 s gr -/Times-Roman ff 300.00 scf sf -2250 3075 m -gs 1 -1 sc (MTA) col4 sh gr -% Polyline -n 1200 375 m 2100 375 l 2100 825 l 1200 825 l - cp gs col14 s gr -/Times-Roman ff 300.00 scf sf -1350 675 m -gs 1 -1 sc (MTA) col14 sh gr -% Polyline -n 2550 1575 m - 3750 2625 l gs col1 s gr -% Polyline -n 2550 1575 m - 3750 1575 l gs col1 s gr -% Polyline -n 2550 1575 m - 3750 825 l gs col1 s gr -% Polyline -n 3000 2925 m - 3750 2625 l gs col4 s gr -% Polyline -n 2100 525 m - 3750 825 l gs col14 s gr -% Polyline -n 2100 525 m - 3750 2625 l gs col14 s gr -% Polyline -45.000 slw -n 1050 3075 m - 2100 3075 l gs col0 s gr -% Polyline -n 1050 1725 m - 1650 1725 l gs col0 s gr -% Polyline -n 1050 675 m - 1200 675 l gs col0 s gr -% Polyline -15.000 slw -n 3750 2475 m 4950 2475 l 4950 2925 l 3750 2925 l - cp gs col0 s gr -% Polyline -n 3750 1425 m 4950 1425 l 4950 1875 l 3750 1875 l - cp gs col0 s gr -% Polyline -n 3750 525 m 4950 525 l 4950 975 l 3750 975 l - cp gs col0 s gr -/Times-Italic ff 300.00 scf sf -3900 2775 m -gs 1 -1 sc (Filter 3) col0 sh gr -/Times-Italic ff 300.00 scf sf -3900 1725 m -gs 1 -1 sc (Filter 2) col0 sh gr -/Times-Italic ff 300.00 scf sf -3900 825 m -gs 1 -1 sc (Filter 1) col0 sh gr -% Polyline -7.500 slw -n 300 525 m 1050 525 l 1050 3225 l 300 3225 l - cp gs col0 s gr -% Polyline -15.000 slw -n 1650 1425 m 2550 1425 l 2550 1875 l 1650 1875 l - cp gs col1 s gr -$F2psEnd -rs -showpage diff --git a/contrib/sendmail/libmilter/docs/figure2.fig b/contrib/sendmail/libmilter/docs/figure2.fig deleted file mode 100644 index c93bfe3d5e58..000000000000 --- a/contrib/sendmail/libmilter/docs/figure2.fig +++ /dev/null @@ -1,67 +0,0 @@ -#FIG 3.2 -Landscape -Center -Inches -Letter -100.00 -Single --2 -1200 2 -5 1 0 1 0 7 50 0 -1 0.000 0 0 1 0 2981.250 1200.000 2700 1050 3300 1200 2700 1350 - 1 1 1.00 60.00 120.00 -6 4200 900 6450 1350 -2 2 0 1 1 7 50 0 -1 0.000 0 0 7 0 0 5 - 4200 900 6450 900 6450 1350 4200 1350 4200 900 -4 0 1 50 0 0 16 0.0000 4 195 2040 4350 1200 xxfi_header callback\001 --6 -6 4200 2250 6450 2700 -2 2 0 1 4 7 50 0 -1 0.000 0 0 7 0 0 5 - 4200 2250 6450 2250 6450 2700 4200 2700 4200 2250 -4 0 4 50 0 0 16 0.0000 4 195 2040 4350 2550 xxfi_header callback\001 --6 -6 600 2100 1800 2850 -2 2 0 2 4 7 50 0 -1 0.000 0 0 7 0 0 5 - 750 2250 1650 2250 1650 2700 750 2700 750 2250 -4 0 4 50 0 0 20 0.0000 4 195 645 900 2550 MTA\001 --6 -6 600 750 1800 1500 -2 2 0 2 1 7 50 0 -1 0.000 0 0 7 0 0 5 - 750 900 1650 900 1650 1350 750 1350 750 900 -4 0 1 50 0 0 20 0.0000 4 195 645 900 1200 MTA\001 --6 -2 1 0 2 1 7 50 0 -1 0.000 0 0 -1 1 0 2 - 1 1 2.00 120.00 240.00 - 4200 1200 3600 1200 -2 1 0 2 1 7 50 0 -1 0.000 0 0 -1 1 0 2 - 1 1 2.00 120.00 240.00 - 3450 900 4050 900 -2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5 - 2400 300 6600 300 6600 3300 2400 3300 2400 300 -2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 - 2550 750 3450 750 3450 2700 2550 2700 2550 750 -2 1 0 2 4 7 50 0 -1 0.000 0 0 -1 1 0 2 - 1 1 2.00 120.00 240.00 - 3450 2700 4050 2700 -2 1 0 2 4 7 50 0 -1 0.000 0 0 -1 1 0 2 - 1 1 2.00 120.00 240.00 - 4200 2400 3600 2400 -2 1 0 2 4 7 50 0 -1 0.000 0 0 -1 1 0 2 - 1 1 2.00 120.00 240.00 - 1650 2700 2250 2700 -2 1 0 2 4 7 50 0 -1 0.000 0 0 -1 1 0 2 - 1 1 2.00 120.00 240.00 - 2400 2400 1800 2400 -2 1 0 2 1 7 50 0 -1 0.000 0 0 -1 1 0 2 - 1 1 2.00 120.00 240.00 - 1650 900 2250 900 -2 1 0 2 1 7 50 0 -1 0.000 0 0 -1 1 0 2 - 1 1 2.00 120.00 240.00 - 2400 1200 1800 1200 -4 0 0 50 0 0 20 0.0000 4 195 630 3900 600 Filter\001 -4 0 4 50 0 0 12 0.0000 4 180 1620 3450 3000 callback (arguments)\001 -4 0 4 50 0 0 12 0.0000 4 180 1575 3900 1950 optional library calls,\001 -4 0 4 50 0 0 12 0.0000 4 135 855 3900 2175 return code\001 -4 0 4 50 0 0 12 0.0000 4 135 780 1500 2100 responses\001 -4 0 0 50 0 0 16 0.0000 4 165 645 2700 2085 Milter\001 -4 0 0 50 0 0 16 0.0000 4 225 675 2700 2400 library\001 -4 0 4 50 0 0 12 0.0000 4 135 510 1500 3000 header\001 diff --git a/contrib/sendmail/libmilter/docs/figure2.jpg b/contrib/sendmail/libmilter/docs/figure2.jpg Binary files differdeleted file mode 100644 index 8b11485cde9d..000000000000 --- a/contrib/sendmail/libmilter/docs/figure2.jpg +++ /dev/null diff --git a/contrib/sendmail/libmilter/docs/figure2.ps b/contrib/sendmail/libmilter/docs/figure2.ps deleted file mode 100644 index 861a193c6f0a..000000000000 --- a/contrib/sendmail/libmilter/docs/figure2.ps +++ /dev/null @@ -1,242 +0,0 @@ -%!PS-Adobe-2.0 -%%Title: figure2.fig -%%Creator: fig2dev Version 3.2.3 Patchlevel -%%CreationDate: Tue Jun 6 13:57:47 2000 -%%For: sean@host232.Sendmail.COM (Sean O'rourke,5400) -%%Orientation: Landscape -%%Pages: 1 -%%BoundingBox: 0 0 612 792 -%%BeginSetup -%%IncludeFeature: *PageSize Letter -%%EndSetup -%%Magnification: 1.5000 -%%EndComments -/$F2psDict 200 dict def -$F2psDict begin -$F2psDict /mtrx matrix put -/col-1 {0 setgray} bind def -/col0 {0.000 0.000 0.000 srgb} bind def -/col1 {0.000 0.000 1.000 srgb} bind def -/col2 {0.000 1.000 0.000 srgb} bind def -/col3 {0.000 1.000 1.000 srgb} bind def -/col4 {1.000 0.000 0.000 srgb} bind def -/col5 {1.000 0.000 1.000 srgb} bind def -/col6 {1.000 1.000 0.000 srgb} bind def -/col7 {1.000 1.000 1.000 srgb} bind def -/col8 {0.000 0.000 0.560 srgb} bind def -/col9 {0.000 0.000 0.690 srgb} bind def -/col10 {0.000 0.000 0.820 srgb} bind def -/col11 {0.530 0.810 1.000 srgb} bind def -/col12 {0.000 0.560 0.000 srgb} bind def -/col13 {0.000 0.690 0.000 srgb} bind def -/col14 {0.000 0.820 0.000 srgb} bind def -/col15 {0.000 0.560 0.560 srgb} bind def -/col16 {0.000 0.690 0.690 srgb} bind def -/col17 {0.000 0.820 0.820 srgb} bind def -/col18 {0.560 0.000 0.000 srgb} bind def -/col19 {0.690 0.000 0.000 srgb} bind def -/col20 {0.820 0.000 0.000 srgb} bind def -/col21 {0.560 0.000 0.560 srgb} bind def -/col22 {0.690 0.000 0.690 srgb} bind def -/col23 {0.820 0.000 0.820 srgb} bind def -/col24 {0.500 0.190 0.000 srgb} bind def -/col25 {0.630 0.250 0.000 srgb} bind def -/col26 {0.750 0.380 0.000 srgb} bind def -/col27 {1.000 0.500 0.500 srgb} bind def -/col28 {1.000 0.630 0.630 srgb} bind def -/col29 {1.000 0.750 0.750 srgb} bind def -/col30 {1.000 0.880 0.880 srgb} bind def -/col31 {1.000 0.840 0.000 srgb} bind def - -end -save -newpath 0 792 moveto 0 0 lineto 612 0 lineto 612 792 lineto closepath clip newpath -144.0 65.5 translate - 90 rotate -1 -1 scale - -/cp {closepath} bind def -/ef {eofill} bind def -/gr {grestore} bind def -/gs {gsave} bind def -/sa {save} bind def -/rs {restore} bind def -/l {lineto} bind def -/m {moveto} bind def -/rm {rmoveto} bind def -/n {newpath} bind def -/s {stroke} bind def -/sh {show} bind def -/slc {setlinecap} bind def -/slj {setlinejoin} bind def -/slw {setlinewidth} bind def -/srgb {setrgbcolor} bind def -/rot {rotate} bind def -/sc {scale} bind def -/sd {setdash} bind def -/ff {findfont} bind def -/sf {setfont} bind def -/scf {scalefont} bind def -/sw {stringwidth} bind def -/tr {translate} bind def -/tnt {dup dup currentrgbcolor - 4 -2 roll dup 1 exch sub 3 -1 roll mul add - 4 -2 roll dup 1 exch sub 3 -1 roll mul add - 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} - bind def -/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul - 4 -2 roll mul srgb} bind def -/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def -/$F2psEnd {$F2psEnteredState restore end} def - -$F2psBegin -%%Page: 1 1 -10 setmiterlimit - 0.09000 0.09000 sc -%%Page: 1 1 -/Times-Roman ff 180.00 scf sf -1500 3000 m -gs 1 -1 sc (header) col4 sh gr -/Times-Roman ff 240.00 scf sf -4350 1200 m -gs 1 -1 sc (xxfi_header callback) col1 sh gr -% Polyline -7.500 slw -n 4200 2250 m 6450 2250 l 6450 2700 l 4200 2700 l - cp gs col4 s gr -/Times-Roman ff 240.00 scf sf -4350 2550 m -gs 1 -1 sc (xxfi_header callback) col4 sh gr -% Polyline -15.000 slw -n 750 2250 m 1650 2250 l 1650 2700 l 750 2700 l - cp gs col4 s gr -/Times-Roman ff 300.00 scf sf -900 2550 m -gs 1 -1 sc (MTA) col4 sh gr -% Polyline -n 750 900 m 1650 900 l 1650 1350 l 750 1350 l - cp gs col1 s gr -/Times-Roman ff 300.00 scf sf -900 1200 m -gs 1 -1 sc (MTA) col1 sh gr -% Arc -7.500 slw -gs clippath -2713 1319 m 2667 1357 l 2761 1475 l 2710 1363 l 2808 1437 l cp -eoclip -n 2981.2 1200.0 318.8 -151.9 151.9 arc -gs col0 s gr - gr - -% arrowhead -n 2808 1437 m 2710 1363 l 2761 1475 l 2808 1437 l cp gs 0.00 setgray ef gr col0 s -% Polyline -15.000 slw -gs clippath -3585 1140 m 3585 1260 l 3872 1260 l 3632 1200 l 3872 1140 l cp -eoclip -n 4200 1200 m - 3600 1200 l gs col1 s gr gr - -% arrowhead -n 3872 1140 m 3632 1200 l 3872 1260 l 3872 1140 l cp gs col1 1.00 shd ef gr col1 s -% Polyline -gs clippath -4065 960 m 4065 840 l 3778 840 l 4018 900 l 3778 960 l cp -eoclip -n 3450 900 m - 4050 900 l gs col1 s gr gr - -% arrowhead -n 3778 960 m 4018 900 l 3778 840 l 3778 960 l cp gs col1 1.00 shd ef gr col1 s -% Polyline -n 2400 300 m 6600 300 l 6600 3300 l 2400 3300 l - cp gs col0 s gr -% Polyline -7.500 slw -n 2550 750 m 3450 750 l 3450 2700 l 2550 2700 l - cp gs col0 s gr -% Polyline -15.000 slw -gs clippath -4065 2760 m 4065 2640 l 3778 2640 l 4018 2700 l 3778 2760 l cp -eoclip -n 3450 2700 m - 4050 2700 l gs col4 s gr gr - -% arrowhead -n 3778 2760 m 4018 2700 l 3778 2640 l 3778 2760 l cp gs col4 1.00 shd ef gr col4 s -% Polyline -gs clippath -3585 2340 m 3585 2460 l 3872 2460 l 3632 2400 l 3872 2340 l cp -eoclip -n 4200 2400 m - 3600 2400 l gs col4 s gr gr - -% arrowhead -n 3872 2340 m 3632 2400 l 3872 2460 l 3872 2340 l cp gs col4 1.00 shd ef gr col4 s -% Polyline -gs clippath -2265 2760 m 2265 2640 l 1978 2640 l 2218 2700 l 1978 2760 l cp -eoclip -n 1650 2700 m - 2250 2700 l gs col4 s gr gr - -% arrowhead -n 1978 2760 m 2218 2700 l 1978 2640 l 1978 2760 l cp gs col4 1.00 shd ef gr col4 s -% Polyline -gs clippath -1785 2340 m 1785 2460 l 2072 2460 l 1832 2400 l 2072 2340 l cp -eoclip -n 2400 2400 m - 1800 2400 l gs col4 s gr gr - -% arrowhead -n 2072 2340 m 1832 2400 l 2072 2460 l 2072 2340 l cp gs col4 1.00 shd ef gr col4 s -% Polyline -gs clippath -2265 960 m 2265 840 l 1978 840 l 2218 900 l 1978 960 l cp -eoclip -n 1650 900 m - 2250 900 l gs col1 s gr gr - -% arrowhead -n 1978 960 m 2218 900 l 1978 840 l 1978 960 l cp gs col1 1.00 shd ef gr col1 s -% Polyline -gs clippath -1785 1140 m 1785 1260 l 2072 1260 l 1832 1200 l 2072 1140 l cp -eoclip -n 2400 1200 m - 1800 1200 l gs col1 s gr gr - -% arrowhead -n 2072 1140 m 1832 1200 l 2072 1260 l 2072 1140 l cp gs col1 1.00 shd ef gr col1 s -/Times-Roman ff 300.00 scf sf -3900 600 m -gs 1 -1 sc (Filter) col0 sh gr -/Times-Roman ff 180.00 scf sf -3450 3000 m -gs 1 -1 sc (callback \(arguments\)) col4 sh gr -/Times-Roman ff 180.00 scf sf -3900 1950 m -gs 1 -1 sc (optional library calls,) col4 sh gr -/Times-Roman ff 180.00 scf sf -3900 2175 m -gs 1 -1 sc (return code) col4 sh gr -/Times-Roman ff 180.00 scf sf -1500 2100 m -gs 1 -1 sc (responses) col4 sh gr -/Times-Roman ff 240.00 scf sf -2700 2085 m -gs 1 -1 sc (Milter) col0 sh gr -/Times-Roman ff 240.00 scf sf -2700 2400 m -gs 1 -1 sc (library) col0 sh gr -% Polyline -7.500 slw -n 4200 900 m 6450 900 l 6450 1350 l 4200 1350 l - cp gs col1 s gr -$F2psEnd -rs -showpage diff --git a/contrib/sendmail/libmilter/docs/index.html b/contrib/sendmail/libmilter/docs/index.html deleted file mode 100644 index 93eb3f83432b..000000000000 --- a/contrib/sendmail/libmilter/docs/index.html +++ /dev/null @@ -1,92 +0,0 @@ -<html> -<head> -<title>Filtering Mail with Sendmail</title> -</head> -<body> -<!-- -$Id: index.html,v 1.10.4.1 2003/03/05 19:54:19 ca Exp $ ---> - -<h1>Filtering Mail with Sendmail</h1> - -<!-- -<P><b>Disclaimer</b>: -This preliminary API description is provided for review only. This -specification may change based on feedback from reviewers, and does -not bind Sendmail to offer this functionality in any release. ---> - -<h2>Introduction</h2> - -<P> -Sendmail's Content Management API (milter) provides third-party -programs to access mail messages as they are being processed by the -Mail Transfer Agent (MTA), allowing them to examine and modify message -content and meta-information. Filtering policies implemented by -Milter-conformant filters may then be centrally configured and -composed in an end-user's MTA configuration file. - -<p> -Possible uses for filters include spam rejection, virus -filtering, and content control. In general, Milter seeks to address -site-wide filtering concerns in a scalable way. Individual users' mail -filtering needs (e.g. sorting messages by subject) are left to -client-level programs such as <a href="http://www.procmail.org">Procmail</a>. - -<P> -This document is a technical introduction intended for those -interested in developing Milter filters. It includes: -<ul> -<li>A description of Milter's design goals. - -<li>An explanation of Milter application architecture, including -interactions between the support library and user code, and between -filters and the MTA. - -<li>A specification of the C application programming interface. -<li>An example of a simple Milter filter. -</ul> - -<h2>Contents</h2> - -<ul> -<li><a href="design.html">Architecture</a> -<ul> - <li>Design Goals - <li>Implementing Filtering Policies - <li>MTA - Filter communication -</ul> -<li><a href="overview.html">Technical Overview</a> -<ul> - <li>Initialization - <li>Control flow - <li>Multithreading - <li>Resource Management - <li>Signal Handling -</ul> -<li><a href="api.html">API Documentation</a> -<ul> - <li>Library Control Functions - <li>Data Access Functions - <li>Message Modification Functions - <li>Callbacks -</ul> -<li><a href="installation.html">Installation and Configuration</a> -<ul> - <li>Compiling and Installing Your Filter - <li>Configuring Sendmail -</ul> -<li><a href="sample.html">A Sample Filter</a> -<!-- <li><a href="other.html">Other Sources of Information</a> --> -</ul> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2001, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/installation.html b/contrib/sendmail/libmilter/docs/installation.html deleted file mode 100644 index 370f1d3baf07..000000000000 --- a/contrib/sendmail/libmilter/docs/installation.html +++ /dev/null @@ -1,166 +0,0 @@ -<html> -<head><title>Installation and Configuration</title> -</head> -<body> -<h1>Installation</h1> -<h2>Contents</h2> -<ul> - <li><a href="#compile">Compiling and Installing Your Filter</a> - <li><a href="#config">Configuring Sendmail</a> -</ul> - -<h2><a name="compile">Compiling and Installing Your Filter</A></h2> - -To compile a filter, modify the Makefile provided with the sample program, or: -<ul> - <li>Put the include and Sendmail directories in your include path - (e.g. -I/path/to/include -I/path/to/sendmail). - - <li>Make sure libmilter.a is in your library path, and link your - application with it (e.g. "-lmilter"). - - <li>Compile with pthreads, either by using -pthread for gcc, or - linking with a pthreads support library (-lpthread). -</ul> -Your compile command line will look like -<pre> -cc -I/path/to/include -I/path/to/sendmail -c myfile.c -</pre> -and your linking command line will look something like -<pre> -cc -o myfilter [object-files] -L[library-location] -lmilter -pthread -</pre> - -<H2><a name="config">Configuring Sendmail</A></H2> - -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', `-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. -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 -equates names, equate field names, and flag values are case sensitive. - -<P> -The current flags (<code>F=</code>) are: -<p> -<table cellspacing="1" cellpadding=4 border=1> -<tr bgcolor="#dddddd" align=left valign=top> -<th>Flag</TH> <th align="center">Meaning</TH> -</TR> -<tr align="left" valign=top> -<TD>R</TD> <TD>Reject connection if filter unavailable</TD> -</TR> -<tr align="left" valign=top> -<TD>T</TD> <TD>Temporary fail connection if filter unavailable</TD> -</TR> -</TABLE> - -If a filter is unavailable or unresponsive and no flags have been -specified, the MTA will continue normal handling of the current -connection. The MTA will try to contact the filter again on each new -connection. - -<P> -There are three fields inside of the <code>T=</code> equate: S, R, and -E. Note the separator between each is a ";" (semicolon), as "," -(comma) already separates equates. The value of each field is a -decimal number followed by a single letter designating the units ("s" -for seconds, "m" for minutes). The fields have the following -meanings: -<p> -<TABLE cellspacing="1" cellpadding=4 border=1> -<TR bgcolor="#dddddd" align=left valign=top> -<TH>Flag</TH> <TH align="center">Meaning</TH> -</TR> -<TR align="left" valign=top> -<TD>C</TD> <TD>Timeout for connecting to a filter. If set to 0, the - system's <CODE>connect()</CODE> timeout will be used. - Default: 5m</TD> -</TR> -<TR align="left" valign=top> -<TD>S</TD> <TD>Timeout for sending information from the MTA to a - filter. Default: 10s</TD> -</TR> -<TR align="left" valign=top> -<TD>R</TD> <TD>Timeout for reading reply from the filter. Default: 10s</TD> -</TR> -<TR align="left" valign=top> -<TD>E</TD> <TD>Overall timeout between sending end-of-message to - filter and waiting for the final acknowledgment. Default: 5m</TD> -</TR> -</TABLE> - -<p> -The following sendmail.mc example specifies three filters. The first -two rendezvous on Unix-domain sockets in the /var/run directory; the -third uses an IP socket on port 999. -<pre> - INPUT_MAIL_FILTER(`filter1', `S=unix:/var/run/f1.sock, F=R') - INPUT_MAIL_FILTER(`filter2', `S=unix:/var/run/f2.sock, F=T, T=S:1s;R:1s;E:5m') - INPUT_MAIL_FILTER(`filter3', `S=inet:999@localhost, T=C:2m') - - define(`confINPUT_MAIL_FILTERS', `filter2,filter1,filter3') -<hr width="30%"> - 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 -<code>confINPUT_MAIL_FILTERS</code> is defined, the filters will be -run "filter2, filter1, filter3". Also note that a filter can be -defined without adding it to the input filter list by using -MAIL_FILTER() instead of INPUT_MAIL_FILTER(). - -<p> -The above macros will result in the following lines being added to -your .cf file: -<PRE> - Xfilter1, S=unix:/var/run/f1.sock, F=R - Xfilter2, S=unix:/var/run/f2.sock, F=T, T=S:1s;R:1s;E:5m - Xfilter3, S=inet:999@localhost, T=C:2m - - O InputMailFilters=filter2,filter1,filter3 -</PRE> -<p> -Finally, the sendmail macros accessible via <a -href="smfi_getsymval.html">smfi_getsymval</a> can be configured by -defining the following m4 variables (or cf options): -<table cellspacing="1" cellpadding=4 border=1> -<tr bgcolor="#dddddd" align=left valign=top> -<th align="center">In .mc file</th> <th align="center">In .cf file</TH> -<th align="center">Default Value</th> -</tr> -<tr><td>confMILTER_MACROS_CONNECT</td><td>Milter.macros.connect</td> -<td><code>j, _, {daemon_name}, {if_name}, {if_addr}</code></td></tr> -<tr><td>confMILTER_MACROS_HELO</td><td>Milter.macros.helo</td> -<td><code>{tls_version}, {cipher}, {cipher_bits}, {cert_subject}, -{cert_issuer}</code></td></tr> -<tr><td>confMILTER_MACROS_ENVFROM</td><td>Milter.macros.envfrom</td> -<td><code>i, {auth_type}, {auth_authen}, {auth_ssf}, {auth_author}, -{mail_mailer}, {mail_host}, {mail_addr}</code></td></tr> -<tr><td>confMILTER_MACROS_ENVRCPT</td><td>Milter.macros.envrcpt</td> -<td><code>{rcpt_mailer}, {rcpt_host}, {rcpt_addr}</code></td></tr> -</table> -For information about available macros and their meanings, please -consult the sendmail documentation. -<hr size="1"> -<font size="-1"> -Copyright (c) 2000-2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> </html> diff --git a/contrib/sendmail/libmilter/docs/other.html b/contrib/sendmail/libmilter/docs/other.html deleted file mode 100644 index 4647c5380872..000000000000 --- a/contrib/sendmail/libmilter/docs/other.html +++ /dev/null @@ -1,15 +0,0 @@ -<html> -<head><title>Other Resources</title> -</head> -<body> -FAQ? Mailing list? More sample filters? -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/overview.html b/contrib/sendmail/libmilter/docs/overview.html deleted file mode 100644 index 981856446c22..000000000000 --- a/contrib/sendmail/libmilter/docs/overview.html +++ /dev/null @@ -1,194 +0,0 @@ -<html> -<head> -<title>Technical Overview</title> -</head> -<body> -<!-- -$Id: overview.html,v 1.12.4.1 2003/03/05 19:54:20 ca Exp $ ---> - -<h1>Technical Overview</h1> - -<h2>Contents</h2> - -<ul> - <li>Initialization - <li>Control flow - <li>Multithreading - <li>Resource Management - <li>Signal Handling -</ul> - -<h2>Initialization</h2> - -In addition to its own initialization, libmilter expects a filter to initialize several parameters before calling <a href="smfi_main.html">smfi_main</a>: -<ul> - <li>The callbacks the filter wishes to be called, and the types of - message modification it intends to perform (required, see <a - href="smfi_register.html">smfi_register</a>). - - <li>The socket address to be used when communicating with the MTA - (required, see <a href="smfi_setconn.html">smfi_setconn</a>). - - <li>The number of seconds to wait for MTA connections before - timing out (optional, see <a - href="smfi_settimeout.html">smfi_settimeout</a>). -</ul> -<p> -If the filter fails to initialize libmilter, or if one or more of the -parameters it has passed are invalid, a subsequent call to smfi_main -will fail. - -<h2>Control flow</h2> - -<p> -The following pseudocode describes the filtering process from the -perspective of a set of <code>N</code> MTA's, each corresponding to a -connection. Callbacks are shown beside the processing stages in which -they are invoked; if no callbacks are defined for a particular stage, -that stage may be bypassed. Though it is not shown, processing may be -aborted at any time during a message, in which case the <a -href="xxfi_abort.html">xxfi_abort</a> callback is invoked and control -returns to <code>MESSAGE</code>. -<p> -<pre> -For each of N connections -{ - For each filter - process connection/helo (<a href="xxfi_connect.html">xxfi_connect</a>, <a href="xxfi_helo.html">xxfi_helo</a>) -MESSAGE:For each message in this connection (sequentially) - { - For each filter - process sender (<a href="xxfi_envfrom.html">xxfi_envfrom</a>) - For each recipient - { - For each filter - process recipient (<a href="xxfi_envrcpt.html">xxfi_envrcpt</a>) - } - For each filter - { - For each header - process header (<a href="xxfi_header.html">xxfi_header</a>) - process end of headers (<a href="xxfi_eoh.html">xxfi_eoh</a>) - For each body block - process this body block (<a href="xxfi_body.html">xxfi_body</a>) - process end of message (<a href="xxfi_eom.html">xxfi_eom</a>) - } - } - For each filter - process end of connection (<a href="xxfi_close.html">xxfi_close</a>) -} -</pre> - -<P>Note: Filters are contacted in order defined in config file.</P> - -<P> -To write a filter, a vendor supplies callbacks to process relevant -parts of a message transaction. The library then controls all -sequencing, threading, and protocol exchange with the MTA. <a -href="#figure-3">Figure 3</a> outlines control flow for a filter -process, showing where different callbacks are invoked. -</p> -<div align="center"><a name="figure-3"></a> -<table border=1 cellspacing=0 cellpadding=2 width="70%"> -<tr bgcolor="#dddddd"><th>SMTP Commands</th><th>Milter Callbacks</th></tr> -<tr><td>(open SMTP connection)</td><td>xxfi_connect</td></tr> -<tr><td>HELO ...</td><td>xxfi_helo</td></tr> -<tr><td>MAIL From: ...</td><td>xxfi_envfrom</td></tr> -<tr><td>RCPT To: ...</td><td>xxfi_envrcpt</td></tr> -<tr><td>[more RCPTs]</td><td>[xxfi_envrcpt]</td></tr> -<tr><td>DATA</td><td> </td></tr> -<tr><td>Header: ...</td><td>xxfi_header</td></tr> -<tr><td>[more headers]</td><td>[xxfi_header]</td></tr> -<tr><td> </td><td>xxfi_eoh</td></tr> -<tr><td>body... </td><td>xxfi_body</td></tr> -<tr><td>[more body...]</td><td>[xxfi_body]</td></tr> -<tr><td>.</td><td>xxfi_eom</td></tr> -<tr><td>QUIT</td><td>xxfi_close</td></tr> -<tr><td>(close SMTP connection)</td><td> </td></tr> -</table> -<b>Figure 3: Milter callbacks related to an SMTP transaction.</b> -</div> -<p> -Note that although only a single message is shown above, multiple -messages may be sent in a single connection. Note also that a message -and/or connection may be aborted by either the remote host or the MTA -at any point during the SMTP transaction. 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 -connection closes. - -<h2>Multithreading</h2> - -<p> -A single filter process may handle any number of connections -simultaneously. All filtering callbacks must therefore be reentrant, -and use some appropriate external synchronization methods to access -global data. Furthermore, since there is not a one-to-one -correspondence between threads and connections (N connections mapped -onto M threads, M <= N), connection-specific data must be accessed -through the handles provided by the Milter library. The programmer -cannot rely on library-supplied thread-specific data blocks -(e.g. pthread_getspecific()) to store connection-specific data. See -the API documentation for <a -href="smfi_setpriv.html">smfi_setpriv</a> and <a -href="smfi_getpriv.html">smfi_getpriv</a> for details. - -<h2>Resource management</h2> - -Since filters are likely to be long-lived, and to handle many -connections, proper deallocation of per-connection resources is -important. The lifetime of a connection is bracketed by calls to the -callbacks <a href="xxfi_connect.html">xxfi_connect</a> and <a -href="xxfi_close.html">xxfi_close</a>. Therefore connection-specific -resources (accessed via <a href="smfi_getpriv.html">smfi_getpriv</a> -and <a href="smfi_setpriv.html">smfi_setpriv</a>) may be allocated in -<a href="xxfi_connect.html">xxfi_connect</a>, and should be freed in -<a href="xxfi_close.html">xxfi_close</a>. For further information see -the <a href="api.html#conn-msg">discussion</a> of message- versus -connection-oriented routines. In particular, note that there is only -one connection-specific data pointer per connection. -<p> - -Each message is bracketed by calls to <a -href="xxfi_envfrom.html">xxfi_envfrom</a> and <a -href="xxfi_eom.html">xxfi_eom</a> (or <a -href="xxfi_abort.html">xxfi_abort</a>), implying that message-specific -resources can be allocated and reclaimed in these routines. Since the -messages in a connection are processed sequentially by each filter, -there will be only one active message associated with a given -connection and filter (and connection-private data block). These -resources must still be accessed through <a -href="smfi_getpriv.html">smfi_getpriv</a> and <a -href="smfi_setpriv.html">smfi_setpriv</a>, and must be reclaimed -in <a href="xxfi_abort.html">xxfi_abort</a>. - -<h2>Signal Handling</h2> - -libmilter takes care of signal handling, the filters are -not influenced directly by signals. -There are basically two types of signal handlers: - -<ol> -<li><TT>Stop</TT>: no new connections from the MTA will be accepted, -but existing connections are allowed to continue. -<li><TT>Abort</TT>: all filters will be stopped as soon as the next -communication with the MTA happens. -</ol> - -Filters are not terminated asynchronously (except by -signals that can't be caught). -In the case of <TT>Abort</TT> the -<a href="xxfi_abort.html">xxfi_abort</a> callback is invoked. - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2001, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/sample.html b/contrib/sendmail/libmilter/docs/sample.html deleted file mode 100644 index 7f669b793de6..000000000000 --- a/contrib/sendmail/libmilter/docs/sample.html +++ /dev/null @@ -1,490 +0,0 @@ -<html> -<head><title>A Sample Filter</title></head> -<body> -<h1>A Sample Filter</h1> - -The following sample logs each message to a separate temporary file, -adds a recipient given with the -a flag, and rejects a disallowed -recipient address given with the -r flag. It recognizes the following -options: -<p> -<center> -<table border="1" cellpadding=2 cellspacing=1> -<tr><td><code>-p port</code></td><td>The port through which the MTA will connect to the filter.</td></tr> -<tr><td><code>-t sec</code></td><td>The timeout value.</td></tr> -<tr><td><code>-r addr</code></td><td>A recipient to reject.</td></tr> -<tr><td><code>-a addr</code></td><td>A recipient to add.</td></tr> -</table> -</center> -<hr> -<pre> -#include <sys/types.h> -#include <sys/stat.h> -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sysexits.h> -#include <unistd.h> - -#include "libmilter/mfapi.h" - -#ifndef bool -# define bool int -# define TRUE 1 -# define FALSE 0 -#endif /* ! bool */ - - -struct mlfiPriv -{ - char *mlfi_fname; - char *mlfi_connectfrom; - char *mlfi_helofrom; - FILE *mlfi_fp; -}; - -#define MLFIPRIV ((struct mlfiPriv *) <a href="smfi_getpriv.html">smfi_getpriv</a>(ctx)) - -extern sfsistat mlfi_cleanup(SMFICTX *, bool); - -/* recipients to add and reject (set with -a and -r options) */ -char *add = NULL; -char *reject = NULL; - -sfsistat -<a href="xxfi_connect.html">mlfi_connect</a>(ctx, hostname, hostaddr) - SMFICTX *ctx; - char *hostname; - _SOCK_ADDR *hostaddr; -{ - struct mlfiPriv *priv; - char *ident; - - /* allocate some private memory */ - priv = malloc(sizeof *priv); - if (priv == NULL) - { - /* can't accept this message right now */ - return SMFIS_TEMPFAIL; - } - memset(priv, '\0', sizeof *priv); - - /* save the private data */ - <a href="smfi_setpriv.html">smfi_setpriv</a>(ctx, priv); - - ident = <a href="smfi_getsymval.html">smfi_getsymval</a>(ctx, "_"); - if (ident == NULL) - ident = "???"; - if ((priv->mlfi_connectfrom = strdup(ident)) == NULL) - { - (void) mlfi_cleanup(ctx, FALSE); - return SMFIS_TEMPFAIL; - } - - /* continue processing */ - return SMFIS_CONTINUE; -} - -sfsistat -<a href="xxfi_helo.html">mlfi_helo</a>(ctx, helohost) - SMFICTX *ctx; - char *helohost; -{ - size_t len; - char *tls; - char *buf; - struct mlfiPriv *priv = MLFIPRIV; - - tls = <a href="smfi_getsymval.html">smfi_getsymval</a>(ctx, "{tls_version}"); - if (tls == NULL) - tls = "No TLS"; - if (helohost == NULL) - helohost = "???"; - len = strlen(tls) + strlen(helohost) + 3; - if ((buf = (char*) malloc(len)) == NULL) - { - (void) mlfi_cleanup(ctx, FALSE); - return SMFIS_TEMPFAIL; - } - snprintf(buf, len, "%s, %s", helohost, tls); - if (priv->mlfi_helofrom != NULL) - free(priv->mlfi_helofrom); - priv->mlfi_helofrom = buf; - - /* continue processing */ - return SMFIS_CONTINUE; -} - -sfsistat -<a href="xxfi_envfrom.html">mlfi_envfrom</a>(ctx, argv) - SMFICTX *ctx; - char **argv; -{ - struct mlfiPriv *priv = MLFIPRIV; - char *mailaddr = <a href="smfi_getsymval.html">smfi_getsymval</a>(ctx, "{mail_addr}"); - int argc = 0; - - /* open a file to store this message */ - if ((priv->mlfi_fname = strdup("/tmp/msg.XXXXXX")) == NULL) - { - (void) mlfi_cleanup(ctx, FALSE); - return SMFIS_TEMPFAIL; - } - - if (mkstemp(priv->mlfi_fname) == -1) - { - (void) mlfi_cleanup(ctx, FALSE); - return SMFIS_TEMPFAIL; - } - - if ((priv->mlfi_fp = fopen(priv->mlfi_fname, "w+")) == NULL) - { - (void) mlfi_cleanup(ctx, FALSE); - return SMFIS_TEMPFAIL; - } - - /* count the arguments */ - while (*argv++ != NULL) - ++argc; - - /* log the connection information we stored earlier: */ - if (fprintf(priv->mlfi_fp, "Connect from %s (%s)\n\n", - priv->mlfi_helofrom, priv->mlfi_connectfrom) == EOF) - { - (void) mlfi_cleanup(ctx, FALSE); - return SMFIS_TEMPFAIL; - } - /* log the sender */ - if (fprintf(priv->mlfi_fp, "FROM %s (%d argument%s)\n", - mailaddr ? mailaddr : "???", argc, - (argc == 1) ? "" : "s") == EOF) - { - (void) mlfi_cleanup(ctx, FALSE); - return SMFIS_TEMPFAIL; - } - - /* continue processing */ - return SMFIS_CONTINUE; -} - -sfsistat -<a href="xxfi_envrcpt.html">mlfi_envrcpt</a>(ctx, argv) - SMFICTX *ctx; - char **argv; -{ - struct mlfiPriv *priv = MLFIPRIV; - char *rcptaddr = <a href="smfi_getsymval.html">smfi_getsymval</a>(ctx, "{rcpt_addr}"); - int argc = 0; - - /* count the arguments */ - while (*argv++ != NULL) - ++argc; - - /* log this recipient */ - if (reject != NULL && rcptaddr != NULL && - (strcasecmp(rcptaddr, reject) == 0)) - { - if (fprintf(priv->mlfi_fp, "RCPT %s -- REJECTED\n", - rcptaddr) == EOF) - { - (void) mlfi_cleanup(ctx, FALSE); - return SMFIS_TEMPFAIL; - } - return SMFIS_REJECT; - } - if (fprintf(priv->mlfi_fp, "RCPT %s (%d argument%s)\n", - rcptaddr ? rcptaddr : "???", argc, - (argc == 1) ? "" : "s") == EOF) - { - (void) mlfi_cleanup(ctx, FALSE); - return SMFIS_TEMPFAIL; - } - - /* continue processing */ - return SMFIS_CONTINUE; -} - -sfsistat -<a href="xxfi_header.html">mlfi_header</a>(ctx, headerf, headerv) - SMFICTX *ctx; - char *headerf; - unsigned char *headerv; -{ - /* write the header to the log file */ - if (fprintf(MLFIPRIV->mlfi_fp, "%s: %s\n", headerf, headerv) == EOF) - { - (void) mlfi_cleanup(ctx, FALSE); - return SMFIS_TEMPFAIL; - } - - /* continue processing */ - return SMFIS_CONTINUE; -} - -sfsistat -<a href="xxfi_eoh.html">mlfi_eoh</a>(ctx) - SMFICTX *ctx; -{ - /* output the blank line between the header and the body */ - if (fprintf(MLFIPRIV->mlfi_fp, "\n") == EOF) - { - (void) mlfi_cleanup(ctx, FALSE); - return SMFIS_TEMPFAIL; - } - - /* continue processing */ - return SMFIS_CONTINUE; -} - -sfsistat -<a href="xxfi_body.html">mlfi_body</a>(ctx, bodyp, bodylen) - SMFICTX *ctx; - unsigned char *bodyp; - size_t bodylen; -{ - struct mlfiPriv *priv = MLFIPRIV; - - /* output body block to log file */ - if (fwrite(bodyp, bodylen, 1, priv->mlfi_fp) != 1) - { - /* write failed */ - fprintf(stderr, "Couldn't write file %s: %s\n", - priv->mlfi_fname, strerror(errno)); - (void) mlfi_cleanup(ctx, FALSE); - return SMFIS_TEMPFAIL; - } - - /* continue processing */ - return SMFIS_CONTINUE; -} - -sfsistat -<a href="xxfi_eom.html">mlfi_eom</a>(ctx) - SMFICTX *ctx; -{ - bool ok = TRUE; - - /* change recipients, if requested */ - if (add != NULL) - ok = (<a href="smfi_addrcpt.html">smfi_addrcpt</a>(ctx, add) == MI_SUCCESS); - return mlfi_cleanup(ctx, ok); -} - -sfsistat -<a href="xxfi_abort.html">mlfi_abort</a>(ctx) - SMFICTX *ctx; -{ - return mlfi_cleanup(ctx, FALSE); -} - -sfsistat -mlfi_cleanup(ctx, ok) - SMFICTX *ctx; - bool ok; -{ - sfsistat rstat = SMFIS_CONTINUE; - struct mlfiPriv *priv = MLFIPRIV; - char *p; - char host[512]; - char hbuf[1024]; - - if (priv == NULL) - return rstat; - - /* close the archive file */ - if (priv->mlfi_fp != NULL && fclose(priv->mlfi_fp) == EOF) - { - /* failed; we have to wait until later */ - fprintf(stderr, "Couldn't close archive file %s: %s\n", - priv->mlfi_fname, strerror(errno)); - rstat = SMFIS_TEMPFAIL; - (void) unlink(priv->mlfi_fname); - } - else if (ok) - { - /* add a header to the message announcing our presence */ - if (gethostname(host, sizeof host) < 0) - snprintf(host, sizeof host, "localhost"); - p = strrchr(priv->mlfi_fname, '/'); - if (p == NULL) - p = priv->mlfi_fname; - else - p++; - snprintf(hbuf, sizeof hbuf, "%s@%s", p, host); - if (<a href="smfi_addheader.html">smfi_addheader</a>(ctx, "X-Archived", hbuf) != MI_SUCCESS) - { - /* failed; we have to wait until later */ - fprintf(stderr, - "Couldn't add header: X-Archived: %s\n", - hbuf); - ok = FALSE; - rstat = SMFIS_TEMPFAIL; - (void) unlink(priv->mlfi_fname); - } - } - else - { - /* message was aborted -- delete the archive file */ - fprintf(stderr, "Message aborted. Removing %s\n", - priv->mlfi_fname); - rstat = SMFIS_TEMPFAIL; - (void) unlink(priv->mlfi_fname); - } - - /* release private memory */ - if (priv->mlfi_fname != NULL) - free(priv->mlfi_fname); - - /* return status */ - return rstat; -} - -sfsistat -<a href="xxfi_close.html">mlfi_close</a>(ctx) - SMFICTX *ctx; -{ - struct mlfiPriv *priv = MLFIPRIV; - - if (priv == NULL) - return SMFIS_CONTINUE; - if (priv->mlfi_connectfrom != NULL) - free(priv->mlfi_connectfrom); - if (priv->mlfi_helofrom != NULL) - free(priv->mlfi_helofrom); - free(priv); - <a href="smfi_setpriv.html">smfi_setpriv</a>(ctx, NULL); - return SMFIS_CONTINUE; -} - -struct smfiDesc smfilter = -{ - "SampleFilter", /* filter name */ - SMFI_VERSION, /* version code -- do not change */ - SMFIF_ADDHDRS, /* flags */ - <a href="xxfi_connect.html">mlfi_connect</a>, /* connection info filter */ - <a href="xxfi_helo.html">mlfi_helo</a>, /* SMTP HELO command filter */ - <a href="xxfi_envfrom.html">mlfi_envfrom</a>, /* envelope sender filter */ - <a href="xxfi_envrcpt.html">mlfi_envrcpt</a>, /* envelope recipient filter */ - <a href="xxfi_header.html">mlfi_header</a>, /* header filter */ - <a href="xxfi_eoh.html">mlfi_eoh</a>, /* end of header */ - <a href="xxfi_body.html">mlfi_body</a>, /* body block filter */ - <a href="xxfi_eom.html">mlfi_eom</a>, /* end of message */ - <a href="xxfi_abort.html">mlfi_abort</a>, /* message aborted */ - <a href="xxfi_close.html">mlfi_close</a>, /* connection cleanup */ -}; - -static void -usage(prog) - char *prog; -{ - fprintf(stderr, - "Usage: %s [-p socket-addr] [-t timeout] [-r reject-addr] [-a add-addr]\n", - prog); -} - -int -main(argc, argv) - int argc; - char **argv; -{ - int c; - const char *args = "p:t:r:a:h"; - extern char *optarg; - - /* Process command line options */ - while ((c = getopt(argc, argv, args)) != -1) - { - switch (c) - { - case 'p': - if (optarg == NULL || *optarg == '\0') - { - (void) fprintf(stderr, "Illegal conn: %s\n", - optarg); - exit(EX_USAGE); - } - if (<a href="smfi_setconn.html">smfi_setconn</a>(optarg) == MI_FAILURE) - { - (void) fprintf(stderr, - "smfi_setconn failed\n"); - exit(EX_SOFTWARE); - } - - /* - ** If we're using a local socket, make sure it - ** doesn't already exist. Don't ever run this - ** code as root!! - */ - - if (strncasecmp(optarg, "unix:", 5) == 0) - unlink(optarg + 5); - else if (strncasecmp(optarg, "local:", 6) == 0) - unlink(optarg + 6); - break; - - case 't': - if (optarg == NULL || *optarg == '\0') - { - (void) fprintf(stderr, "Illegal timeout: %s\n", - optarg); - exit(EX_USAGE); - } - if (<a href="smfi_settimeout.html">smfi_settimeout</a>(atoi(optarg)) == MI_FAILURE) - { - (void) fprintf(stderr, - "smfi_settimeout failed\n"); - exit(EX_SOFTWARE); - } - break; - - case 'r': - if (optarg == NULL) - { - (void) fprintf(stderr, - "Illegal reject rcpt: %s\n", - optarg); - exit(EX_USAGE); - } - reject = optarg; - break; - - case 'a': - if (optarg == NULL) - { - (void) fprintf(stderr, - "Illegal add rcpt: %s\n", - optarg); - exit(EX_USAGE); - } - add = optarg; - smfilter.xxfi_flags |= SMFIF_ADDRCPT; - break; - - case 'h': - default: - usage(argv[0]); - exit(EX_USAGE); - } - } - if (<a href="smfi_register.html">smfi_register</a>(smfilter) == MI_FAILURE) - { - fprintf(stderr, "smfi_register failed\n"); - exit(EX_UNAVAILABLE); - } - return <a href="smfi_main.html">smfi_main</a>(); -} - -/* eof */ - -</pre> -<hr size="1"> -<font size="-1"> -Copyright (c) 2000-2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/smfi_addheader.html b/contrib/sendmail/libmilter/docs/smfi_addheader.html deleted file mode 100644 index a49c648780ff..000000000000 --- a/contrib/sendmail/libmilter/docs/smfi_addheader.html +++ /dev/null @@ -1,115 +0,0 @@ -<html> -<head><title>smfi_addheader</title></head> -<body> -<h1>smfi_addheader</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_addheader( - SMFICTX *ctx, - char *headerf, - char *headerv -); -</pre> -Add a header to the current message. -</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>Called only from <a href="xxfi_eom.html">xxfi_eom</a>.</td> -</tr> -<tr align="left" valign=top> -<th width="80">Effects</th> -<td>Adds a header to the current message.</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>ctx</td> - <td>Opaque context structure. - </td></tr> - <tr valign="top"><td>headerf</td> - <td>The header name, a non-NULL, null-terminated string. - </td></tr> - <tr valign="top"><td>headerv</td> - <td>The header value to be added, a non-NULL, null-terminated string. This may be the empty string. - </td></tr> - </table> -</td></tr> - -<!----------- Return values ----------> -<tr> -<th valign="top" align=left>RETURN VALUES</th> - -<td>smfi_addheader returns MI_FAILURE if: -<ul><li>headerf or headerv is NULL. - <li>Adding headers in the current connection state is invalid. - <li>Memory allocation fails. - <li>A network error occurs. - <li>SMFIF_ADDHDRS was not set when <a href="smfi_register.html">smfi_register</a> was called. -</ul> -Otherwise, it returns MI_SUCCESS. -</td> -</tr> - -<!----------- Notes ----------> -<tr align="left" valign=top> -<th>NOTES</th> -<td> -<ul><li>smfi_addheader does not change a message's existing headers. -To change a header's current value, use <a -href="smfi_chgheader.html">smfi_chgheader</a>. - <li>A filter which calls smfi_addheader must have set the SMFIF_ADDHDRS flag in the smfiDesc_str passed to <a href="smfi_register.html">smfi_register</a>. - <li>For smfi_chgheader, filter order is important. <b>Later filters will see the header changes made by earlier ones.</b> - <li>Neither the name nor the value of the header is checked for - standards compliance. However, each line of the header must be under - 2048 characters and should be under 998 characters. If longer headers - are needed, make them multi-line. To make a multi-line header, insert - a line feed (ASCII 0x0a, or <tt>\n</tt> in C) followed by at least - one whitespace character such as a space (ASCII 0x20) or tab (ASCII 0x09, - or <tt>\t</tt> in C). The line feed should NOT be preceded by a - carriage return (ASCII 0x0d); the MTA will add this automatically. - <b>It is the filter writer's responsibility to ensure that no standards - are violated.</b> -</ul> -</td> -</tr> - -<!----------- Example code ----------> -<tr> -<th valign="top" align=left>EXAMPLE</th> - -<td> - <pre> - int ret; - SMFICTX *ctx; - - ... - - ret = smfi_addheader(ctx, "Content-Type", - "multipart/mixed;\n\tboundary=\"foobar\""); - </pre> -</td> -</tr> - -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000-2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/smfi_addrcpt.html b/contrib/sendmail/libmilter/docs/smfi_addrcpt.html deleted file mode 100644 index 3b2eb56ccba6..000000000000 --- a/contrib/sendmail/libmilter/docs/smfi_addrcpt.html +++ /dev/null @@ -1,80 +0,0 @@ -<html> -<head><title>smfi_addrcpt</title></head> -<body> -<h1>smfi_addrcpt</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_addrcpt( - SMFICTX *ctx, - char *rcpt -); -</pre> -Add a recipient for the current message. -</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>Called only from <a href="xxfi_eom.html">xxfi_eom</a>.</td> -</tr> -<tr align="left" valign=top> -<th width="80">Effects</th> -<td>Add a recipient to the message envelope.</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>ctx</td> - <td>Opaque context structure. - </td></tr> - <tr valign="top"><td>rcpt</td> - <td>The new recipient's address. - </td></tr> - </table> -</td></tr> - -<!----------- Return values ----------> -<tr> -<th valign="top" align=left>RETURN VALUES</th> - -<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>A network error occurs. - <li>SMFIF_ADDRCPT was not set when <a href="smfi_register.html">smfi_register</a> was called. -</ul> -Otherwise, it will return MI_SUCCESS. -</td> -</tr> - -<!----------- Notes ----------> -<tr align="left" valign=top> -<th>NOTES</th> -<td> -A filter which calls smfi_addrcpt must have set the SMFIF_ADDRCPT flag -in the smfiDesc_str passed to -<a href="smfi_register.html">smfi_register</a>. -</td> -</tr> - -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/smfi_chgheader.html b/contrib/sendmail/libmilter/docs/smfi_chgheader.html deleted file mode 100644 index fc7ba97bd42d..000000000000 --- a/contrib/sendmail/libmilter/docs/smfi_chgheader.html +++ /dev/null @@ -1,117 +0,0 @@ -<html> -<head><title>smfi_chgheader</title></head> -<body> -<h1>smfi_chgheader</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_chgheader( - SMFICTX *ctx, - char *headerf, - mi_int32 hdridx, - char *headerv -); -</pre> -Change or delete a message header. -</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>Called only from <a href="xxfi_eom.html">xxfi_eom</a>.</td> -</tr> -<tr align="left" valign=top> -<th width="80">Effects</th> -<td>Changes a header's value for the current message.</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>ctx</td> - <td>Opaque context structure. - </td></tr> - <tr valign="top"><td>headerf</td> - <td>The header name, a non-NULL, null-terminated string. - </td></tr> - <tr valign="top"><td>hdridx</td> - <td>Header index value (1-based). A hdridx value of 1 will modify the first occurrence of a header named headerf. If hdridx is greater than the number of times headerf appears, a new copy of headerf will be added. - </td></tr> - <tr valign="top"><td>headerv</td> - <td>The new value of the given header. headerv == NULL implies that the header should be deleted. - </td></tr> - </table> -</td></tr> - -<!----------- Return values ----------> -<tr> -<th valign="top" align=left>RETURN VALUES</th> - -<td> -smfi_chgheader will return MI_FAILURE if -<ul><li>headerf is NULL - <li>Modifying headers in the current connection state is invalid. - <li>Memory allocation fails. - <li>A network error occurs. - <li>SMFIF_CHGHDRS was not set when <a href="smfi_register.html">smfi_register</a> was called. -</ul> -Otherwise, it returns MI_SUCCESS. -</tr> - -<!----------- Notes ----------> -<tr align="left" valign=top> -<th>NOTES</th> -<td> -<ul><li>While smfi_chgheader may be used to add new headers, it is more efficient and far safer to use <a href="smfi_addheader.html">smfi_addheader</a>. - <li>A filter which calls smfi_chgheader must have set the SMFIF_CHGHDRS flag in the smfiDesc_str passed to <a href="smfi_register.html">smfi_register</a>. - <li>For smfi_chgheader, filter order is important. <b>Later filters will see the header changes made by earlier ones.</b> - <li>Neither the name nor the value of the header is checked for - standards compliance. However, each line of the header must be under - 2048 characters and should be under 998 characters. If longer headers - are needed, make them multi-line. To make a multi-line header, insert - a line feed (ASCII 0x0a, or <tt>\n</tt> in C) followed by at least - one whitespace character such as a space (ASCII 0x20) or tab (ASCII 0x09, - or <tt>\t</tt> in C). The line feed should NOT be preceded by a - carriage return (ASCII 0x0d); the MTA will add this automatically. - <b>It is the filter writer's responsibility to ensure that no standards - are violated.</b> -</ul> -</td> -</tr> - -<!----------- Example code ----------> -<tr> -<th valign="top" align=left>EXAMPLE</th> - -<td> - <pre> - int ret; - SMFICTX *ctx; - - ... - - ret = smfi_chgheader(ctx, "Content-Type", - "multipart/mixed;\n\tboundary=\"foobar\""); - </pre> -</td> -</tr> - -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000-2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/smfi_delrcpt.html b/contrib/sendmail/libmilter/docs/smfi_delrcpt.html deleted file mode 100644 index 451f36a6a945..000000000000 --- a/contrib/sendmail/libmilter/docs/smfi_delrcpt.html +++ /dev/null @@ -1,79 +0,0 @@ -<html> -<head><title>smfi_delrcpt</title></head> -<body> -<h1>smfi_delrcpt</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_delrcpt( - SMFICTX *ctx; - char *rcpt; -); -</pre> -Remove a recipient from the current message's envelope. -</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>Called only from <a href="xxfi_eom.html">xxfi_eom</a>.</td> -</tr> -<tr align="left" valign=top> -<th width="80">Effects</th> -<td>smfi_delrcpt removes the named recipient from the current message's envelope.</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>ctx</td> - <td>Opaque context structure. - </td></tr> - <tr valign="top"><td>rcpt</td> - <td>The recipient address to be removed, a non-NULL, null-terminated string. - </td></tr> - </table> -</td></tr> - -<!----------- Return values ----------> -<tr> -<th valign="top" align=left>RETURN VALUES</th> - -<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>A network error occurs. - <li>SMFIF_DELRCPT was not set when <a href="smfi_register.html">smfi_register</a> was called. -</ul> -Otherwise, it will return MI_SUCCESS -</td> -</tr> - -<!----------- Notes ----------> -<tr align="left" valign=top> -<th>NOTES</th> -<td> -The addresses to be removed must match exactly. For example, an address and its expanded form do not match. -</td> -</tr> - -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/smfi_getpriv.html b/contrib/sendmail/libmilter/docs/smfi_getpriv.html deleted file mode 100644 index 85c994cd89f5..000000000000 --- a/contrib/sendmail/libmilter/docs/smfi_getpriv.html +++ /dev/null @@ -1,59 +0,0 @@ -<html> -<head><title>smfi_getpriv</title></head> -<body> -<h1>smfi_getpriv</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> -void* smfi_getpriv( - SMFICTX *ctx -); -</pre> -Get the connection-specific data pointer for this connection. -</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_getpriv may be called in any of the xxfi_* callbacks.</td> -</tr> -<tr align="left" valign=top> -<th width="80">Effects</th> -<td>None.</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>ctx</td> - <td>Opaque context structure. - </td></tr> - </table> -</td></tr> - -<!----------- Return values ----------> -<tr> -<th valign="top" align=left>RETURN VALUES</th> - -<td>smfi_getpriv returns the private data pointer stored by a prior call to <a href="smfi_setpriv.html">smfi_setpriv</a>, or NULL if none has been set.</td> -</tr> - -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/smfi_getsymval.html b/contrib/sendmail/libmilter/docs/smfi_getsymval.html deleted file mode 100644 index 7f3db6ae0ce0..000000000000 --- a/contrib/sendmail/libmilter/docs/smfi_getsymval.html +++ /dev/null @@ -1,96 +0,0 @@ -<html> -<head><title>smfi_getsymval</title></head> -<body> -<h1>smfi_getsymval</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> -char* smfi_getsymval( - SMFICTX *ctx, - char *symname -); -</pre> -Get the value of a sendmail macro. -</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_getsymval may be called from within any of the xxfi_* callbacks. Which macros are defined will depend on when it is called.</td> -</tr> -<tr align="left" valign=top> -<th width="80">Effects</th> -<td>None.</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>ctx</td> - <td>The opaque context structure. - </td></tr> - <tr valign="top"><td>symname</td> - <td>The name of a sendmail macro. - Single letter macros can optionally be enclosed in braces ("{" and "}"), - longer macro names must be enclosed in braces, just as in a - <tt>sendmail.cf</tt> file. - <a href="#notes">See below</a> for default macros. - </td></tr> - </table> -</td></tr> - -<!----------- Return values ----------> -<tr> -<th valign="top" align=left>RETURN VALUES</th> - -<td>smfi_getsymval returns the value of the given macro as a null-terminated string, or NULL if the macro is not defined.</td> -</tr> - -<!----------- Notes ----------> -<tr align="left" valign=top> -<th><a name="notes">NOTES</A></th> -<td> -By default, the following macros are valid in the given contexts: - -<table border="1" cellspacing=0> -<tr bgcolor="#dddddd"><th>Sent With</th><th>Macros</th></tr> -<tr><td>xxfi_connect</td> <td>daemon_name, if_name, if_addr, j, _</td></tr> -<tr><td>xxfi_helo</td> <td>tls_version, cipher, cipher_bits, cert_subject, cert_issuer</td></tr> -<tr><td>xxfi_envfrom</td> <td>i, auth_type, auth_authen, auth_ssf, auth_author, - mail_mailer, mail_host, mail_addr</td></tr> -<tr><td>xxfi_envrcpt</td> <td>rcpt_mailer, rcpt_host, rcpt_addr</td></tr> -</table> -<p> -All macros stay in effect from the point they are received until the -end of the connection for the first two sets, the end of the message -for the third (xxfi_envfrom), and just for each recipient for the -final set (xxfi_envrcpt). -<p> -The macro list can be changed using the confMILTER_MACROS_* options in -sendmail.mc. The scopes of such macros will be determined by when -they are set by sendmail. For descriptions of macros' values, please -see the "Sendmail Installation and Operation Guide" provided with your -sendmail distribution. - -</td> -</tr> - -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2002-2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/smfi_main.html b/contrib/sendmail/libmilter/docs/smfi_main.html deleted file mode 100644 index 674ef69a282f..000000000000 --- a/contrib/sendmail/libmilter/docs/smfi_main.html +++ /dev/null @@ -1,48 +0,0 @@ -<html> -<head><title>smfi_main</title></head> -<body> -<h1>smfi_main</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_main( -); -</pre> -Hand control to libmilter event loop. -</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_main is called after a filter's initialization is complete.</td> -</tr> -<tr align="left" valign=top> -<th width="80">Effects</th> -<td>smfi_main hands control to the Milter event loop.</td> -</tr> -</table> - -<!----------- Return values ----------> -<tr> -<th valign="top" align=left>RETURN VALUES</th> - -<td>smfi_main will return MI_FAILURE if it fails to establish a connection. This may occur for any of a variety of reasons (e.g. invalid address passed to <a href="smfi_setconn.html">smfi_setconn</a>). The reason for the failure will be logged. Otherwise, smfi_main will return MI_SUCCESS.</td> -</tr> - -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/smfi_register.html b/contrib/sendmail/libmilter/docs/smfi_register.html deleted file mode 100644 index 2e9ee3dbc956..000000000000 --- a/contrib/sendmail/libmilter/docs/smfi_register.html +++ /dev/null @@ -1,160 +0,0 @@ -<html> -<head><title>smfi_register</title></head> -<body> -<h1>smfi_register</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_register( - smfiDesc_str descr -); -</pre> -Register a set of filter callbacks. -</td></tr> - -<!----------- Description ----------> -<tr><th valign="top" align=left>DESCRIPTION</th><td> -<table border="1" cellspacing=1 cellpadding=1> -<tr align="left" valign=top> -<th width="80">Called When</th> -<td>smfi_register must be called before smfi_main</td> -</tr> -<tr align="left" valign=top> -<th width="80">Effects</th> -<td>smfi_register creates a filter using the information given in the -smfiDesc_str argument. Multiple calls to smfi_register within a -single process are not allowed.</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>descr</td> - <td> -A filter descriptor of type smfiDesc_str describing the filter's -functions. The structure has the following members: -<pre> -struct smfiDesc -{ - char *xxfi_name; /* filter name */ - int xxfi_version; /* version code -- do not change */ - unsigned long xxfi_flags; /* <a href="#flags">flags</a> */ - - /* connection info filter */ - sfsistat (*<a href="xxfi_connect.html">xxfi_connect</a>)(SMFICTX *, char *, _SOCK_ADDR *); - /* SMTP HELO command filter */ - sfsistat (*<a href="xxfi_helo.html">xxfi_helo</a>)(SMFICTX *, char *); - /* envelope sender filter */ - sfsistat (*<a href="xxfi_envfrom.html">xxfi_envfrom</a>)(SMFICTX *, char **); - /* envelope recipient filter */ - sfsistat (*<a href="xxfi_envrcpt.html">xxfi_envrcpt</a>)(SMFICTX *, char **); - /* header filter */ - sfsistat (*<a href="xxfi_header.html">xxfi_header</a>)(SMFICTX *, char *, char *); - /* end of header */ - sfsistat (*<a href="xxfi_eoh.html">xxfi_eoh</a>)(SMFICTX *); - /* body block */ - sfsistat (*<a href="xxfi_body.html">xxfi_body</a>)(SMFICTX *, unsigned char *, size_t); - /* end of message */ - sfsistat (*<a href="xxfi_eom.html">xxfi_eom</a>)(SMFICTX *); - /* message aborted */ - sfsistat (*<a href="xxfi_abort.html">xxfi_abort</a>)(SMFICTX *); - /* connection cleanup */ - sfsistat (*<a href="xxfi_close.html">xxfi_close</a>)(SMFICTX *); -}; -</pre> - -A NULL value for any callback function indicates that the filter does -not wish to process the given type of information, simply returning -SMFIS_CONTINUE. - </td></tr> - </table> -</td></tr> - -<!----------- Return values ----------> -<tr> -<th valign="top" align=left>RETURN VALUES</th> - -<td> -smfi_register may return MI_FAILURE for any of the following reasons: -<ul> -<li>memory allocation failed. -<li>incompatible version or illegal flags value. -</ul> - -</td> -</tr> - -<!----------- Notes ----------> -<tr align="left" valign=top> -<th>NOTES</th> -<td> - -<a name="flags"></A> -The xxfi_flags field should contain the bitwise OR of zero or more of -the following values, describing the actions the filter may take: -<TABLE BORDER CELLPADDING="1" cellspacing=1> -<tr valign="top" bgcolor="#dddddd"><th align="left">Flag</th><th align="center">Description</th></tr> - <TR align="left" valign=top> - <TD> - SMFIF_ADDHDRS - </TD> - <TD> - This filter may add headers. - </TD> - </TR> - <TR align="left" valign=top> - <TD> - SMFIF_CHGHDRS - </TD> - <TD> - This filter may change and/or delete headers. - </TD> - </TR> - <TR align="left" valign=top> - <TD VALIGN="TOP"> - SMFIF_CHGBODY - </TD> - <TD> - This filter may replace the body during filtering. - This may have significant performance impact - if other filters do body filtering after this filter. - </TD> - </TR> - <TR> - <TD VALIGN="TOP"> - SMFIF_ADDRCPT - </TD> - <TD> - This filter may add recipients to the message. - </TD> - </TR> - <TR> - <TD VALIGN="TOP"> - SMFIF_DELRCPT - </TD> - <TD> - This filter may remove recipients from the message. - </TD> - </TR> -</TABLE> - -</td> -</tr> - -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000-2001, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/smfi_replacebody.html b/contrib/sendmail/libmilter/docs/smfi_replacebody.html deleted file mode 100644 index 2ef0f4933529..000000000000 --- a/contrib/sendmail/libmilter/docs/smfi_replacebody.html +++ /dev/null @@ -1,90 +0,0 @@ -<html> -<head><title>smfi_replacebody</title></head> -<body> -<h1>smfi_replacebody</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_replacebody( - SMFICTX *ctx, - unsigned char *bodyp, - int bodylen -); -</pre> -Replace message-body data. -</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>Called only from <a href="xxfi_eom.html">xxfi_eom</a>. smfi_replacebody may be called more than once.</td> -</tr> -<tr align="left" valign=top> -<th width="80">Effects</th> -<td>smfi_replacebody replaces the body of the current message. If called -more than once, subsequent calls result in data being appended to the new -body. -</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>ctx</td> - <td>Opaque context structure. - </td></tr> - <tr valign="top"><td>bodyp</td> - <td>A pointer to the start of the new body data, which does not have to be null-terminated. If bodyp is NULL, it is treated as having length == 0. Body data should be in CR/LF form. - </td></tr> - <tr valign="top"><td>bodylen</td> - <td>The number of data bytes pointed to by bodyp. - </td></tr> - </table> -</td></tr> - -<!----------- Return values ----------> -<tr> -<th valign="top" align=left>RETURN VALUES</th> - -<td>smfi_replacebody fails and returns MI_FAILURE if: -<ul> - <li>bodyp == NULL and bodylen > 0. - <li>Changing the body in the current connection state is invalid. - <li>A network error occurs. - <li>SMFIF_CHGBODY was not set when <a href="smfi_register.html">smfi_register</a> was called. -</ul> -Otherwise, it will return MI_SUCCESS. -</td> -</tr> - -<!----------- Notes ----------> -<tr align="left" valign=top> -<th>NOTES</th> -<td> -<ul> - <li>Since the message body may be very large, setting SMFIF_CHGBODY may significantly affect filter performance. - <li>If a filter sets SMFIF_CHGBODY but does not call smfi_replacebody, the original body remains unchanged. - <li>For smfi_replacebody, filter order is important. <b>Later filters will see the new body contents created by earlier ones.</b> -</ul> -</td> -</tr> - -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000-2001, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/smfi_setbacklog.html b/contrib/sendmail/libmilter/docs/smfi_setbacklog.html deleted file mode 100644 index d55926619002..000000000000 --- a/contrib/sendmail/libmilter/docs/smfi_setbacklog.html +++ /dev/null @@ -1,60 +0,0 @@ -<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-2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/smfi_setconn.html b/contrib/sendmail/libmilter/docs/smfi_setconn.html deleted file mode 100644 index b0aed7c2a681..000000000000 --- a/contrib/sendmail/libmilter/docs/smfi_setconn.html +++ /dev/null @@ -1,87 +0,0 @@ -<html> -<head><title>smfi_setconn</title></head> -<body> -<h1>smfi_setconn</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_setconn( - char *oconn; -); -</pre> -Set the socket through which this filter should communicate with sendmail. -</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_setconn must be called once before <a href="smfi_main.html">smfi_main</a>.</td> -</tr> -<tr align="left" valign=top> -<th width="80">Effects</th> -<td>Sets the socket through which the filter communicates with sendmail.</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>oconn</td> - <td>The address of the desired communication socket. - The address should be a NULL-terminated string in "proto:address" - format: - <ul> - <li><code>{unix|local}:/path/to/file</code> -- A named pipe. - <li><code>inet:port@{hostname|ip-address}</code> -- An IPV4 socket. - <li><code>inet6:port@{hostname|ip-address}</code> -- An IPV6 socket. - </ul> - </td></tr> - </table> -</td></tr> - -<!----------- Return values ----------> -<tr> -<th valign="top" align=left>RETURN VALUES</th> - -<td>smfi_setconn will not fail on an invalid address. -The failure will only be detected in <a href="smfi_main.html">smfi_main</a></td>. -Nevertheless, smfi_setconn may fail for other reasons, e.g., -due to a lack of memory. -</tr> - -<tr> -<th valign="top" align=left>NOTES</th> - -<td> -<ul> - <li>If possible, filters should not run as root when communicating - over unix/local domain sockets. - <li>Unix/local sockets should have their permissions set to - 0600 (read/write permission only for the socket's owner) or - 0660 (read/write permission for the socket's owner and group) - which is useful if the sendmail RunAsUser option is used. - The permissions for a unix/local domain socket are determined as - usual by <code>umask</code>, which should be set to 007 or 077 - before calling <code>smfi_setconn()</code>. -</ul> -</td> -</tr> - -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/smfi_setpriv.html b/contrib/sendmail/libmilter/docs/smfi_setpriv.html deleted file mode 100644 index 6bd79965da60..000000000000 --- a/contrib/sendmail/libmilter/docs/smfi_setpriv.html +++ /dev/null @@ -1,77 +0,0 @@ -<html> -<head><title>smfi_setpriv</title></head> -<body> -<h1>smfi_setpriv</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_setpriv( - SMFICTX *ctx, - void *privatedata -); -</pre> -Set the private data pointer for this connection. -</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_setpriv may be called in any of the xxfi_* callbacks.</td> -</tr> -<tr align="left" valign=top> -<th width="80">Effects</th> -<td>Sets the private data pointer for the context ctx.</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>ctx</td> - <td>Opaque context structure. - </td></tr> - <tr valign="top"><td>privatedata</td> - <td>Pointer to private data. This value will be returned by subsequent calls to <a href="smfi_getpriv.html">smfi_getpriv</a> using ctx. - </td></tr> - </table> -</td></tr> - -<!----------- Return values ----------> -<tr> -<th valign="top" align=left>RETURN VALUES</th> - -<td>smfi_setpriv returns MI_FAILURE if ctx is an invalid context. -Otherwise, it returns MI_SUCCESS.</td> -</tr> - -<tr> -<th valign="top" align=left>NOTES</th> - -<td>There is only one private data pointer per connection; multiple -calls to smfi_setpriv with different values will cause previous values -to be lost. -<P> -Before a filter terminates it should release the private data -and set the pointer to NULL. -</td> - -</tr> - -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000-2001, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/smfi_setreply.html b/contrib/sendmail/libmilter/docs/smfi_setreply.html deleted file mode 100644 index 87a47d7ad7ab..000000000000 --- a/contrib/sendmail/libmilter/docs/smfi_setreply.html +++ /dev/null @@ -1,97 +0,0 @@ -<html> -<head><title>smfi_setreply</title></head> -<body> -<h1>smfi_setreply</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_setreply( - SMFICTX *ctx, - char *rcode, - char *xcode, - char *message -); -</pre> -Set the default SMTP error reply code. -</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_setreply may be called from any of the xxfi_ callbacks -other than xxfi_connect.</td> -</tr> -<tr align="left" valign=top> -<th width="80">Effects</th> -<td>Directly set the SMTP error reply code for this connection. This code -will be used on subsequent error replies resulting from actions taken by -this filter.</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>ctx</td> - <td>Opaque context structure. - </td></tr> - <tr valign="top"><td>rcode</td> - <td>The three-digit (RFC 821) SMTP reply code, as a null-terminated string. rcode cannot be NULL, and must be a valid reply code. - </td></tr> - <tr valign="top"><td>xcode</td> - <td>The extended (RFC 2034) reply code. If xcode is NULL, no extended code is used. Otherwise, xcode must conform to RFC 2034. - </td></tr> - <tr valign="top"><td>message</td> - <td>The text part of the SMTP reply. If message is NULL, an empty message is used. - </td></tr> - </table> -</td></tr> - -<!----------- Return values ----------> -<tr> -<th valign="top" align=left>RETURN VALUES</th> - -<td>smfi_setreply will fail and return MI_FAILURE if: -<ul> - <li>The rcode or xcode argument is invalid. - <li>A memory-allocation failure occurs. -</ul> -Otherwise, it return MI_SUCCESS. -</td> -</tr> - -<!----------- Notes ----------> -<tr align="left" valign=top> -<th>NOTES</th> -<td> -<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.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> - -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2002-2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/smfi_settimeout.html b/contrib/sendmail/libmilter/docs/smfi_settimeout.html deleted file mode 100644 index c27f8176f5aa..000000000000 --- a/contrib/sendmail/libmilter/docs/smfi_settimeout.html +++ /dev/null @@ -1,63 +0,0 @@ -<html> -<head><title>smfi_settimeout</title></head> -<body> -<h1>smfi_settimeout</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_settimeout( - int otimeout -); -</pre> -Set the filter's connection timeout 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_settimeout 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 number of seconds libmilter will wait for an MTA connection before -timing out a socket. -If smfi_settimeout is not called, a default timeout of 7210 seconds 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>otimeout</td> - <td>The number of seconds to wait before timing out (> 0). Zero means -no wait, <b>not</b> "wait forever". - </td></tr> - </table> -</td></tr> - -<!----------- Return values ----------> -<tr> -<th valign="top" align=left>RETURN VALUES</th> - -<td>smfi_settimeout always returns MI_SUCCESS.</td> -</tr> - -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2002-2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/xxfi_abort.html b/contrib/sendmail/libmilter/docs/xxfi_abort.html deleted file mode 100644 index d47b50518bff..000000000000 --- a/contrib/sendmail/libmilter/docs/xxfi_abort.html +++ /dev/null @@ -1,80 +0,0 @@ -<html> -<head><title>xxfi_abort</title></head> -<body> -<h1>xxfi_abort</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> -sfsistat (*xxfi_abort)( - SMFICTX * ctx -); -</pre> -Handle the current message's being aborted. -</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>xxfi_abort may be called at any time during message processing (i.e. between some message-oriented routine and <a href="xxfi_eom.html">xxfi_eom</a>).</td> -</tr> -<tr align="left" valign=top> -<th>Default Behavior</th> -<td>Do nothing; return SMFIS_CONTINUE.</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>ctx</td> - <td>Opaque context structure. - </td></tr> - </table> -</td></tr> - -<!----------- Notes ----------> -<tr> -<th valign="top" align=left>NOTES</th> -<td> -<ul> -<li>xxfi_abort must reclaim any resources allocated on a per-message -basis, and must be tolerant of being called between any two -message-oriented callbacks. - -<li>Calls to xxfi_abort and <a href="xxfi_eom.html">xxfi_eom</a> are -mutually exclusive. - -<li>xxfi_abort is not responsible for reclaiming connection-specific -data, since <a href="xxfi_close.html">xxfi_close</a> is always called -when a connection is closed. - -<li>Since the current message is already being aborted, the return -value is currently ignored. - -<li>xxfi_abort is only called if the message is aborted outside the -filter's control <b>and</b> the filter has not completed its -message-oriented processing. For example, if a filter has already -returned SMFIS_ACCEPT, SMFIS_REJECT, or SMFIS_DISCARD from a -message-oriented routine, xxfi_abort will not be called even if the -message is later aborted outside its control. -</ul> -</td> -</tr> -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/xxfi_body.html b/contrib/sendmail/libmilter/docs/xxfi_body.html deleted file mode 100644 index 6aed207c8480..000000000000 --- a/contrib/sendmail/libmilter/docs/xxfi_body.html +++ /dev/null @@ -1,80 +0,0 @@ -<html> -<head><title>xxfi_body</title></head> -<body> -<h1>xxfi_body</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> -sfsistat (*xxfi_body)( - SMFICTX * ctx, - unsigned char * bodyp, - size_t len -); -</pre> -Handle a piece of a message's body. -</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>xxfi_body is called zero or more times between xxfi_eoh and xxfi_eom.</td> -</tr> -<tr align="left" valign=top> -<th>Default Behavior</th> -<td>Do nothing; return SMFIS_CONTINUE.</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>ctx</td> - <td>Opaque context structure. - </td></tr> - <tr valign="top"><td>bodyp</td> - <td>Pointer to the start of this block of body data. bodyp is not valid outside this call to xxfi_body. - </td></tr> - <tr valign="top"><td>len</td> - <td>The amount of data pointed to by bodyp. - </td></tr> - </table> -</td></tr> - -<!----------- Notes ----------> -<tr> -<th valign="top" align=left>NOTES</th> -<td> -<ul> -<li>bodyp points to a sequence of bytes. -It is <em>not</em> a C string (a sequence of characters that is terminated by '\0'). -Therefore, do not use the usual C string functions like strlen() on this byte block. -Moreover, the byte sequence may contain '\0' characters inside the block. -Hence even if a trailing '\0' is added, C string functions may still fail -to work as expected. -<li>Since message bodies can be very large, defining xxfi_body can -significantly impact filter performance. -<li>End-of-lines are represented as received from SMTP (normally CR/LF). -<li>Later filters will see body changes made by earlier ones. -<li>Message bodies may be sent in multiple chunks, with one call to - xxfi_body per chunk. -</ul> -</td> -</tr> -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000-2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/xxfi_close.html b/contrib/sendmail/libmilter/docs/xxfi_close.html deleted file mode 100644 index 30db78643d7f..000000000000 --- a/contrib/sendmail/libmilter/docs/xxfi_close.html +++ /dev/null @@ -1,66 +0,0 @@ -<html> -<head><title>xxfi_close</title></head> -<body> -<h1>xxfi_close</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> -sfsistat (*xxfi_close)( - SMFICTX * ctx -); -</pre> -The current connection is being closed. -</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>xxfi_close is always called once at the end of each connection.</td> -</tr> -<tr align="left" valign=top> -<th>Default Behavior</th> -<td>Do nothing; return SMFIS_CONTINUE.</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>ctx</td> - <td>Opaque context structure. - </td></tr> - </table> -</td></tr> - -<!----------- Notes ----------> -<tr> -<th valign="top" align=left>NOTES</th> -<td> -<ul> -<li>xxfi_close is called on close even if the previous mail -transaction was aborted. -<li>xxfi_close is responsible for freeing any resources allocated on a -per-connection basis. -<li>Since the connection is already closing, the return value is -currently ignored. -</ul> -</td> -</tr> -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/xxfi_connect.html b/contrib/sendmail/libmilter/docs/xxfi_connect.html deleted file mode 100644 index af58bf9cba80..000000000000 --- a/contrib/sendmail/libmilter/docs/xxfi_connect.html +++ /dev/null @@ -1,90 +0,0 @@ -<html> -<head><title>xxfi_connect</title></head> -<body> -<h1>xxfi_connect</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> -sfsistat (*xxfi_connect)( - SMFICTX *ctx, - char *hostname, - _SOCK_ADDR *hostaddr); -</pre> -</td></tr> -<!----------- Description ----------> -<tr><th valign="top" align=left>DESCRIPTION</th><td> -<table border="1" cellspacing=1 cellpadding=4> -<tr> -<th valign="top" align=left width=80>Called When</th> -<td>Once, at the start of each SMTP connection.</td> -</tr> -<tr> -<th valign="top" align=left width=80>Default Behavior</th> -<td>Do nothing; return SMFIS_CONTINUE.</td> -</tr> -</table> -<!-- -This callback function is invoked on each connection to the mail -filter program. The callback is to be implemented by the Milter -application developers. The name of the callback can be any valid -function name. The function pointer is to be assigned to the -smfiDesc.xxfi_connect and the pointer to the smfiDesc structure -is passed to smfi_register(). -</td></tr> ---> -<!----------- 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><td>ctx</td> - <td>the opaque context structure. - </td></tr> - <tr><td>hostname</td> - <td>the host name of the message sender, as determined by a - reverse lookup on the host address. If the reverse lookup - fails, hostname will contain the message sender's IP - address enclosed in square brackets (e.g. `[a.b.c.d]'). - </td></tr> - <tr><td>hostaddr</td> - <td>the host address, as determined by a getpeername() call on the SMTP socket. - NULL if the type is not supported in the current version or if - the SMTP connection is made via stdin. - </td></tr> - </table> -</td></tr> -<!----------- Return values ----------> -<!-- -<tr> -<th valign="top" align=left>SPECIAL RETURN VALUES</th> -<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> - </tr> -</table> -</tr> ---> -<!----------- Notes ----------> -<tr> -<th valign="top" align=left>NOTES</th> -<td>If an earlier filter rejects the connection in its xxfi_connect() -routine, this filter's xxfi_connect() will not be called.</td> -</tr> -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000-2001, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/xxfi_envfrom.html b/contrib/sendmail/libmilter/docs/xxfi_envfrom.html deleted file mode 100644 index 5eeaa376fdc9..000000000000 --- a/contrib/sendmail/libmilter/docs/xxfi_envfrom.html +++ /dev/null @@ -1,92 +0,0 @@ -<html> -<head><title>xxfi_envfrom</title></head> -<body> -<h1>xxfi_envfrom</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> -sfsistat (*xxfi_envfrom)( - SMFICTX * ctx, - char ** argv -); -</pre> -Handle the envelope FROM command. -</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>xxfi_envfrom is called once at the beginning of each message, before xxfi_envrcpt.</td> -</tr> -<tr align="left" valign=top> -<th>Default Behavior</th> -<td>Do nothing; return SMFIS_CONTINUE.</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>ctx</td> - <td>Opaque context structure. - </td></tr> - <tr valign="top"><td>argv</td> - <td>Null-terminated SMTP command arguments; - argv[0] is guaranteed to be the sender address. - Later arguments are the ESMTP arguments. - </td></tr> - </table> -</td></tr> - -<!----------- Return values ----------> -<tr> -<th valign="top" align=left>SPECIAL RETURN VALUES</th> -<td><table border="1" cellspacing=0> - <tr bgcolor="#dddddd"><th>Return value</th><th>Description</th></tr> - <tr valign="top"> - <td>SMFIS_TEMPFAIL</td> - <td>Reject this sender and message with a temporary error; a new sender (and hence a new message) may subsequently be specified. <a href="xxfi_abort.html">xxfi_abort</a> is not called. - </td> - </tr> - <tr valign="top"> - <td>SMFIS_REJECT</td> - <td>Reject this sender and message; a new sender/message may be specified. <a href="xxfi_abort.html">xxfi_abort</a> is not called. - </td> - </tr> - <tr valign="top"> - <td>SMFIS_DISCARD</td> - <td>Accept and silently discard this message. <a href="xxfi_abort.html">xxfi_abort</a> is not called. - </td> - </tr> - <tr valign="top"> - <td>SMFIS_ACCEPT</td> - <td>Accept this message. <a href="xxfi_abort.html">xxfi_abort</a> is not called. - </td> - </tr> -</table> -</tr> - -<!----------- Notes ----------> -<tr> -<th valign="top" align=left>NOTES</th> -<td>For more details on ESTMP responses, please see RFC -<a href="http://www.rfc-editor.org/rfc/rfc1869.txt">1869</a>.</td> -</tr> -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/xxfi_envrcpt.html b/contrib/sendmail/libmilter/docs/xxfi_envrcpt.html deleted file mode 100644 index 9d32e90962c4..000000000000 --- a/contrib/sendmail/libmilter/docs/xxfi_envrcpt.html +++ /dev/null @@ -1,94 +0,0 @@ -<html> -<head><title>xxfi_envrcpt</title></head> -<body> -<h1>xxfi_envrcpt</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> -sfsistat (*xxfi_envrcpt)( - SMFICTX * ctx, - char ** argv -); -</pre> -Handle the envelope RCPT command. -</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>xxfi_envrcpt is called once per recipient, hence one or more times per message, immediately after xxfi_envfrom.</td> -</tr> -<tr align="left" valign=top> -<th>Default Behavior</th> -<td>Do nothing; return SMFIS_CONTINUE.</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>ctx</td> - <td>Opaque context structure. - </td></tr> - <tr valign="top"><td>argv</td> - <td>Null-terminated SMTP command arguments; - argv[0] is guaranteed to be the recipient address. - Later arguments are the ESMTP arguments. - </td></tr> - </table> -</td></tr> - -<!----------- Return values ----------> -<tr> -<th valign="top" align=left>SPECIAL RETURN VALUES</th> -<td><table border="1" cellspacing=0> - <tr bgcolor="#dddddd"><th>Return value</th><th>Description</th></tr> - <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. - </td> - </tr> - <tr valign="top"> - <td>SMFIS_REJECT</td> - <td>Reject this particular recipient; further recipients maystill be sent. - <a href="xxfi_abort.html">xxfi_abort</a> is not called. - </td> - </tr> - <tr valign="top"> - <td>SMFIS_DISCARD</td> - <td>Accept and discard the message. <a href="xxfi_abort.html">xxfi_abort</a> will be called. - </td> - </tr> - <tr valign="top"> - <td>SMFIS_ACCEPT</td> - <td>Accept recipient. <a href="xxfi_abort.html">xxfi_abort</a> will not be called. - </td> - </tr> -</table> -</tr> - -<!----------- Notes ----------> -<tr> -<th valign="top" align=left>NOTES</th> -<td>For more details on ESTMP responses, please see RFC -<a href="http://www.rfc-editor.org/rfc/rfc1869.txt">1869</a>.</td> -</tr> -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/xxfi_eoh.html b/contrib/sendmail/libmilter/docs/xxfi_eoh.html deleted file mode 100644 index b745959594c0..000000000000 --- a/contrib/sendmail/libmilter/docs/xxfi_eoh.html +++ /dev/null @@ -1,53 +0,0 @@ -<html> -<head><title>xxfi_eoh</title></head> -<body> -<h1>xxfi_eoh</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> -sfsistat (*xxfi_eoh)( - SMFICTX * ctx -); -</pre> -Handle the end of message headers. -</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>xxfi_eoh is called once after all headers have been sent and processed. -</td> -</tr> -<tr align="left" valign=top> -<th>Default Behavior</th> -<td>Do nothing; return SMFIS_CONTINUE.</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>ctx</td> - <td>Opaque context structure. - </td></tr> - </table> -</td></tr> - -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/xxfi_eom.html b/contrib/sendmail/libmilter/docs/xxfi_eom.html deleted file mode 100644 index 1c99103cd1e8..000000000000 --- a/contrib/sendmail/libmilter/docs/xxfi_eom.html +++ /dev/null @@ -1,58 +0,0 @@ -<html> -<head><title>xxfi_eom</title></head> -<body> -<h1>xxfi_eom</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> -sfsistat (*xxfi_eom)( - SMFICTX * ctx -); -</pre> -End of a message. -</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>xxfi_eom is called once after all calls to <a href="xxfi_body.html">xxfi_body</a> for a given message.</td> -</tr> -<tr align="left" valign=top> -<th>Default Behavior</th> -<td>Do nothing; return SMFIS_CONTINUE.</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>ctx</td> - <td>Opaque context structure. - </td></tr> - </table> -</td></tr> - -<!----------- Notes ----------> -<tr> -<th valign="top" align=left>NOTES</th> -<td>A filter is required to make all its modifications to the message headers, body, and envelope in xxfi_eom. Modifications are made via the smfi_* routines. -</td> -</tr> -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/xxfi_header.html b/contrib/sendmail/libmilter/docs/xxfi_header.html deleted file mode 100644 index 1be49584c808..000000000000 --- a/contrib/sendmail/libmilter/docs/xxfi_header.html +++ /dev/null @@ -1,74 +0,0 @@ -<html> -<head><title>xxfi_header</title></head> -<body> -<h1>xxfi_header</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> -sfsistat (*xxfi_header)( - SMFICTX * ctx, - char * headerf, - char * headerv -); -</pre> -Handle a message header. -</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>xxfi_header is called zero or more times between xxfi_envrcpt and xxfi_eoh, once per message header.</td> -</tr> -<tr align="left" valign=top> -<th>Default Behavior</th> -<td>Do nothing; return SMFIS_CONTINUE.</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>ctx</td> - <td>Opaque context structure. - </td></tr> - <tr valign="top"><td>headerf</td> - <td> Header field name. - </td></tr> - <tr valign="top"><td>headerv</td> - <td>Header field value. The - content of the header may include folded white space (i.e. multiple - lines with following white space). The trailing line terminator (CR/LF) - is removed. - </td></tr> - </table> -</td></tr> - -<!----------- Notes ----------> -<tr> -<th valign="top" align=left>NOTES</th> -<td> -<ul> -<li>Later filters will see header changes/additions made by earlier ones. -<li>For much more detail about header format, please see -RFC <a href="http://www.rfc-editor.org/rfc/rfc822.html">822</a> -</ul> -</td> -</tr> -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/docs/xxfi_helo.html b/contrib/sendmail/libmilter/docs/xxfi_helo.html deleted file mode 100644 index 0eb8df6703cb..000000000000 --- a/contrib/sendmail/libmilter/docs/xxfi_helo.html +++ /dev/null @@ -1,59 +0,0 @@ -<html> -<head><title>xxfi_helo</title></head> -<body> -<h1>xxfi_helo</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> -sfsistat (*xxfi_helo)( - SMFICTX * ctx, - char * helohost -); -</pre> -Handle the HELO/EHLO command. -</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>xxfi_helo is called whenever the client -sends a HELO/EHLO command. It may therefore be called between zero and -three times</td> -</tr> -<tr align="left" valign=top> -<th>Default Behavior</th> -<td>Do nothing; return SMFIS_CONTINUE.</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>ctx</td> - <td>Opaque context structure. - </td></tr> - <tr valign="top"><td>helohost</td> - <td>Value passed to HELO/EHLO command, which should be - the domain name of the sending host (but is, in practice, - anything the sending host wants to send). - </td></tr> - </table> -</td></tr> - -</table> - -<hr size="1"> -<font size="-1"> -Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. -All rights reserved. -<br> -By using this file, you agree to the terms and conditions set -forth in the LICENSE. -</font> -</body> -</html> diff --git a/contrib/sendmail/libmilter/engine.c b/contrib/sendmail/libmilter/engine.c deleted file mode 100644 index 970b005cb2b1..000000000000 --- a/contrib/sendmail/libmilter/engine.c +++ /dev/null @@ -1,1152 +0,0 @@ -/* - * Copyright (c) 1999-2002 Sendmail, Inc. and its suppliers. - * All rights reserved. - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the sendmail distribution. - * - */ - -#include <sm/gen.h> -SM_RCSID("@(#)$Id: engine.c,v 8.109.2.4 2002/12/03 17:27:32 ca Exp $") - -#include "libmilter.h" - -#if NETINET || NETINET6 -# include <arpa/inet.h> -#endif /* NETINET || NETINET6 */ - -/* generic argument for functions in the command table */ -struct arg_struct -{ - size_t a_len; /* length of buffer */ - char *a_buf; /* argument string */ - int a_idx; /* index for macro array */ - SMFICTX_PTR a_ctx; /* context */ -}; - -typedef struct arg_struct genarg; - -/* structure for commands received from MTA */ -struct cmdfct_t -{ - char cm_cmd; /* command */ - int cm_argt; /* type of arguments expected */ - int cm_next; /* next state */ - int cm_todo; /* what to do next */ - int cm_macros; /* index for macros */ - int (*cm_fct) __P((genarg *)); /* function to execute */ -}; - -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) */ - -/* possible values for cm_todo */ -#define CT_CONT 0x0000 /* continue reading commands */ -#define CT_IGNO 0x0001 /* continue even when error */ - -/* not needed right now, done via return code instead */ -#define CT_KEEP 0x0004 /* keep buffer (contains symbols) */ -#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 -ERROR: do not compile with CI_RCPT >= MAX_MACROS_ENTRIES -#endif - -/* function prototypes */ -static int st_abortfct __P((genarg *)); -static int st_macros __P((genarg *)); -static int st_optionneg __P((genarg *)); -static int st_bodychunk __P((genarg *)); -static int st_connectinfo __P((genarg *)); -static int st_bodyend __P((genarg *)); -static int st_helo __P((genarg *)); -static int st_header __P((genarg *)); -static int st_sender __P((genarg *)); -static int st_rcpt __P((genarg *)); -static int st_eoh __P((genarg *)); -static int st_quit __P((genarg *)); -static int sendreply __P((sfsistat, socket_t, struct timeval *, SMFICTX_PTR)); -static void fix_stm __P((SMFICTX_PTR)); -static bool trans_ok __P((int, int)); -static char **dec_argv __P((char *, size_t)); -static int dec_arg2 __P((char *, size_t, char **, char **)); - -/* states */ -#define ST_NONE (-1) -#define ST_INIT 0 /* initial state */ -#define ST_OPTS 1 /* option negotiation */ -#define ST_CONN 2 /* connection info */ -#define ST_HELO 3 /* helo */ -#define ST_MAIL 4 /* mail from */ -#define ST_RCPT 5 /* rcpt to */ -#define ST_HDRS 6 /* headers */ -#define ST_EOHS 7 /* end of headers */ -#define ST_BODY 8 /* body */ -#define ST_ENDM 9 /* end of message */ -#define ST_QUIT 10 /* quit */ -#define ST_ABRT 11 /* abort */ -#define ST_LAST ST_ABRT -#define ST_SKIP 15 /* not a state but required for the state table */ - -/* in a mail transaction? must be before eom according to spec. */ -#define ST_IN_MAIL(st) ((st) >= ST_MAIL && (st) < ST_ENDM) - -/* -** set of next states -** each state (ST_*) corresponds to bit in an int value (1 << state) -** each state has a set of allowed transitions ('or' of bits of states) -** so a state transition is valid if the mask of the next state -** is set in the NX_* value -** this function is coded in trans_ok(), see below. -*/ - -#define MI_MASK(x) (0x0001 << (x)) /* generate a bit "mask" for a state */ -#define NX_INIT (MI_MASK(ST_OPTS)) -#define NX_OPTS (MI_MASK(ST_CONN)) -#define NX_CONN (MI_MASK(ST_HELO) | MI_MASK(ST_MAIL)) -#define NX_HELO (MI_MASK(ST_HELO) | MI_MASK(ST_MAIL)) -#define NX_MAIL (MI_MASK(ST_RCPT) | MI_MASK(ST_ABRT)) -#define NX_RCPT (MI_MASK(ST_HDRS) | MI_MASK(ST_EOHS) | \ - MI_MASK(ST_BODY) | MI_MASK(ST_ENDM) | \ - MI_MASK(ST_RCPT) | MI_MASK(ST_ABRT)) -#define NX_HDRS (MI_MASK(ST_EOHS) | MI_MASK(ST_HDRS) | MI_MASK(ST_ABRT)) -#define NX_EOHS (MI_MASK(ST_BODY) | MI_MASK(ST_ENDM) | MI_MASK(ST_ABRT)) -#define NX_BODY (MI_MASK(ST_ENDM) | MI_MASK(ST_BODY) | MI_MASK(ST_ABRT)) -#define NX_ENDM (MI_MASK(ST_QUIT) | MI_MASK(ST_MAIL)) -#define NX_QUIT 0 -#define NX_ABRT 0 -#define NX_SKIP MI_MASK(ST_SKIP) - -static int next_states[] = -{ - NX_INIT, - NX_OPTS, - NX_CONN, - NX_HELO, - NX_MAIL, - NX_RCPT, - NX_HDRS, - NX_EOHS, - NX_BODY, - NX_ENDM, - NX_QUIT, - NX_ABRT -}; - -/* 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_NONE, 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_NONE, st_eoh }, -{SMFIC_QUIT, CM_ARG0, ST_QUIT, CT_END, CI_NONE, st_quit }, -{SMFIC_RCPT, CM_ARGV, ST_RCPT, CT_IGNO, CI_RCPT, st_rcpt } -}; - -/* additional (internal) reply codes */ -#define _SMFIS_KEEP 20 -#define _SMFIS_ABORT 21 -#define _SMFIS_OPTIONS 22 -#define _SMFIS_NOREPLY 23 -#define _SMFIS_FAIL (-1) -#define _SMFIS_NONE (-2) - -/* -** MI_ENGINE -- receive commands and process them -** -** Parameters: -** ctx -- context structure -** -** Returns: -** MI_FAILURE/MI_SUCCESS -*/ -int -mi_engine(ctx) - SMFICTX_PTR ctx; -{ - size_t len; - int i; - socket_t sd; - int ret = MI_SUCCESS; - int ncmds = sizeof(cmds) / sizeof(cmdfct); - int curstate = ST_INIT; - int newstate; - bool call_abort; - sfsistat r; - char cmd; - char *buf = NULL; - genarg arg; - struct timeval timeout; - int (*f) __P((genarg *)); - sfsistat (*fi_abort) __P((SMFICTX *)); - sfsistat (*fi_close) __P((SMFICTX *)); - - arg.a_ctx = ctx; - sd = ctx->ctx_sd; - fi_abort = ctx->ctx_smfi->xxfi_abort; - mi_clr_macros(ctx, 0); - fix_stm(ctx); - r = _SMFIS_NONE; - do - { - /* call abort only if in a mail transaction */ - call_abort = ST_IN_MAIL(curstate); - timeout.tv_sec = ctx->ctx_timeout; - timeout.tv_usec = 0; - if (mi_stop() == MILTER_ABRT) - { - if (ctx->ctx_dbg > 3) - sm_dprintf("[%d] milter_abort\n", - (int) ctx->ctx_id); - ret = MI_FAILURE; - break; - } - - /* - ** Notice: buf is allocated by mi_rd_cmd() and it will - ** usually be free()d after it has been used in f(). - ** However, if the function returns _SMFIS_KEEP then buf - ** contains macros and will not be free()d. - ** Hence r must be set to _SMFIS_NONE if a new buf is - ** allocated to avoid problem with housekeeping, esp. - ** if the code "break"s out of the loop. - */ - - r = _SMFIS_NONE; - if ((buf = mi_rd_cmd(sd, &timeout, &cmd, &len, - ctx->ctx_smfi->xxfi_name)) == NULL && - cmd < SMFIC_VALIDCMD) - { - if (ctx->ctx_dbg > 5) - sm_dprintf("[%d] mi_engine: mi_rd_cmd error (%x)\n", - (int) ctx->ctx_id, (int) cmd); - - /* - ** eof is currently treated as failure -> - ** abort() instead of close(), otherwise use: - ** if (cmd != SMFIC_EOF) - */ - - ret = MI_FAILURE; - break; - } - if (ctx->ctx_dbg > 4) - sm_dprintf("[%d] got cmd '%c' len %d\n", - (int) ctx->ctx_id, cmd, (int) len); - for (i = 0; i < ncmds; i++) - { - if (cmd == cmds[i].cm_cmd) - break; - } - if (i >= ncmds) - { - /* unknown command */ - if (ctx->ctx_dbg > 1) - sm_dprintf("[%d] cmd '%c' unknown\n", - (int) ctx->ctx_id, cmd); - ret = MI_FAILURE; - break; - } - if ((f = cmds[i].cm_fct) == NULL) - { - /* stop for now */ - if (ctx->ctx_dbg > 1) - sm_dprintf("[%d] cmd '%c' not impl\n", - (int) ctx->ctx_id, cmd); - ret = MI_FAILURE; - break; - } - - /* is new state ok? */ - newstate = cmds[i].cm_next; - if (ctx->ctx_dbg > 5) - sm_dprintf("[%d] cur %x new %x nextmask %x\n", - (int) ctx->ctx_id, - curstate, newstate, next_states[curstate]); - - if (newstate != ST_NONE && !trans_ok(curstate, newstate)) - { - if (ctx->ctx_dbg > 1) - sm_dprintf("[%d] abort: cur %d (%x) new %d (%x) next %x\n", - (int) ctx->ctx_id, - curstate, MI_MASK(curstate), - newstate, MI_MASK(newstate), - next_states[curstate]); - - /* call abort only if in a mail transaction */ - if (fi_abort != NULL && call_abort) - (void) (*fi_abort)(ctx); - - /* - ** try to reach the new state from HELO - ** if it can't be reached, ignore the command. - */ - - curstate = ST_HELO; - if (!trans_ok(curstate, newstate)) - { - if (buf != NULL) - { - free(buf); - buf = NULL; - } - continue; - } - } - arg.a_len = len; - arg.a_buf = buf; - if (newstate != ST_NONE) - { - curstate = newstate; - ctx->ctx_state = curstate; - } - arg.a_idx = cmds[i].cm_macros; - - /* call function to deal with command */ - r = (*f)(&arg); - if (r != _SMFIS_KEEP && buf != NULL) - { - free(buf); - buf = NULL; - } - if (sendreply(r, sd, &timeout, ctx) != MI_SUCCESS) - { - ret = MI_FAILURE; - break; - } - - call_abort = ST_IN_MAIL(curstate); - if (r == SMFIS_ACCEPT) - { - /* accept mail, no further actions taken */ - curstate = ST_HELO; - } - else if (r == SMFIS_REJECT || r == SMFIS_DISCARD || - r == SMFIS_TEMPFAIL) - { - /* - ** further actions depend on current state - ** if the IGNO bit is set: "ignore" the error, - ** i.e., stay in the current state - */ - if (!bitset(CT_IGNO, cmds[i].cm_todo)) - curstate = ST_HELO; - } - else if (r == _SMFIS_ABORT) - { - if (ctx->ctx_dbg > 5) - sm_dprintf("[%d] function returned abort\n", - (int) ctx->ctx_id); - ret = MI_FAILURE; - break; - } - } while (!bitset(CT_END, cmds[i].cm_todo)); - - if (ret != MI_SUCCESS) - { - /* call abort only if in a mail transaction */ - if (fi_abort != NULL && call_abort) - (void) (*fi_abort)(ctx); - } - - /* close must always be called */ - if ((fi_close = ctx->ctx_smfi->xxfi_close) != NULL) - (void) (*fi_close)(ctx); - if (r != _SMFIS_KEEP && buf != NULL) - free(buf); - mi_clr_macros(ctx, 0); - return ret; -} -/* -** SENDREPLY -- send a reply to the MTA -** -** Parameters: -** r -- reply code -** sd -- socket descriptor -** timeout_ptr -- (ptr to) timeout to use for sending -** ctx -- context structure -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -static int -sendreply(r, sd, timeout_ptr, ctx) - sfsistat r; - socket_t sd; - struct timeval *timeout_ptr; - SMFICTX_PTR ctx; -{ - int ret = MI_SUCCESS; - - switch (r) - { - case SMFIS_CONTINUE: - ret = mi_wr_cmd(sd, timeout_ptr, SMFIR_CONTINUE, NULL, 0); - break; - case SMFIS_TEMPFAIL: - case SMFIS_REJECT: - 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, - strlen(ctx->ctx_reply) + 1); - free(ctx->ctx_reply); - ctx->ctx_reply = NULL; - } - else - { - ret = mi_wr_cmd(sd, timeout_ptr, r == SMFIS_REJECT ? - SMFIR_REJECT : SMFIR_TEMPFAIL, NULL, 0); - } - break; - case SMFIS_DISCARD: - ret = mi_wr_cmd(sd, timeout_ptr, SMFIR_DISCARD, NULL, 0); - break; - case SMFIS_ACCEPT: - ret = mi_wr_cmd(sd, timeout_ptr, SMFIR_ACCEPT, NULL, 0); - break; - case _SMFIS_OPTIONS: - { - char buf[MILTER_OPTLEN]; - mi_int32 v; - - v = htonl(ctx->ctx_smfi->xxfi_version); - (void) memcpy(&(buf[0]), (void *) &v, MILTER_LEN_BYTES); - v = htonl(ctx->ctx_smfi->xxfi_flags); - (void) memcpy(&(buf[MILTER_LEN_BYTES]), (void *) &v, - MILTER_LEN_BYTES); - v = htonl(ctx->ctx_pflags); - (void) memcpy(&(buf[MILTER_LEN_BYTES * 2]), (void *) &v, - MILTER_LEN_BYTES); - ret = mi_wr_cmd(sd, timeout_ptr, SMFIC_OPTNEG, buf, - MILTER_OPTLEN); - } - break; - default: /* don't send a reply */ - break; - } - return ret; -} - -/* -** CLR_MACROS -- clear set of macros starting from a given index -** -** Parameters: -** ctx -- context structure -** m -- index from which to clear all macros -** -** Returns: -** None. -*/ -void -mi_clr_macros(ctx, m) - SMFICTX_PTR ctx; - int m; -{ - int i; - - for (i = m; i < MAX_MACROS_ENTRIES; i++) - { - if (ctx->ctx_mac_ptr[i] != NULL) - { - free(ctx->ctx_mac_ptr[i]); - ctx->ctx_mac_ptr[i] = NULL; - } - if (ctx->ctx_mac_buf[i] != NULL) - { - free(ctx->ctx_mac_buf[i]); - ctx->ctx_mac_buf[i] = NULL; - } - } -} -/* -** ST_OPTIONNEG -- negotiate options -** -** Parameters: -** g -- generic argument structure -** -** Returns: -** abort/send options/continue -*/ - -static int -st_optionneg(g) - genarg *g; -{ - mi_int32 i, v; - - if (g == NULL || g->a_ctx->ctx_smfi == NULL) - return SMFIS_CONTINUE; - mi_clr_macros(g->a_ctx, g->a_idx + 1); - - /* check for minimum length */ - if (g->a_len < MILTER_OPTLEN) - { - smi_log(SMI_LOG_ERR, - "%s: st_optionneg[%d]: len too short %d < %d", - g->a_ctx->ctx_smfi->xxfi_name, - (int) g->a_ctx->ctx_id, (int) g->a_len, - MILTER_OPTLEN); - return _SMFIS_ABORT; - } - - (void) memcpy((void *) &i, (void *) &(g->a_buf[0]), - MILTER_LEN_BYTES); - v = ntohl(i); - if (v < g->a_ctx->ctx_smfi->xxfi_version) - { - /* hard failure for now! */ - smi_log(SMI_LOG_ERR, - "%s: st_optionneg[%d]: version mismatch MTA: %d < milter: %d", - g->a_ctx->ctx_smfi->xxfi_name, - (int) g->a_ctx->ctx_id, (int) v, - g->a_ctx->ctx_smfi->xxfi_version); - return _SMFIS_ABORT; - } - - (void) memcpy((void *) &i, (void *) &(g->a_buf[MILTER_LEN_BYTES]), - MILTER_LEN_BYTES); - v = ntohl(i); - - /* no flags? set to default value for V1 actions */ - if (v == 0) - v = SMFI_V1_ACTS; - i = g->a_ctx->ctx_smfi->xxfi_flags; - if ((v & i) != i) - { - smi_log(SMI_LOG_ERR, - "%s: st_optionneg[%d]: 0x%x does not fulfill action requirements 0x%x", - g->a_ctx->ctx_smfi->xxfi_name, - (int) g->a_ctx->ctx_id, v, i); - return _SMFIS_ABORT; - } - - (void) memcpy((void *) &i, (void *) &(g->a_buf[MILTER_LEN_BYTES * 2]), - MILTER_LEN_BYTES); - v = ntohl(i); - - /* no flags? set to default value for V1 protocol */ - if (v == 0) - v = SMFI_V1_PROT; - i = g->a_ctx->ctx_pflags; - if ((v & i) != i) - { - smi_log(SMI_LOG_ERR, - "%s: st_optionneg[%d]: 0x%x does not fulfill protocol requirements 0x%x", - g->a_ctx->ctx_smfi->xxfi_name, - (int) g->a_ctx->ctx_id, v, i); - return _SMFIS_ABORT; - } - - return _SMFIS_OPTIONS; -} -/* -** ST_CONNECTINFO -- receive connection information -** -** Parameters: -** g -- generic argument structure -** -** Returns: -** continue or filter-specified value -*/ - -static int -st_connectinfo(g) - genarg *g; -{ - size_t l; - size_t i; - char *s, family; - unsigned short port = 0; - _SOCK_ADDR sockaddr; - sfsistat (*fi_connect) __P((SMFICTX *, char *, _SOCK_ADDR *)); - - if (g == NULL) - return _SMFIS_ABORT; - mi_clr_macros(g->a_ctx, g->a_idx + 1); - if (g->a_ctx->ctx_smfi == NULL || - (fi_connect = g->a_ctx->ctx_smfi->xxfi_connect) == NULL) - return SMFIS_CONTINUE; - - s = g->a_buf; - i = 0; - l = g->a_len; - while (s[i] != '\0' && i <= l) - ++i; - if (i >= l) - return _SMFIS_ABORT; - - /* Move past trailing \0 in host string */ - i++; - family = s[i++]; - memset(&sockaddr, '\0', sizeof sockaddr); - if (family != SMFIA_UNKNOWN) - { - (void) memcpy((void *) &port, (void *) (s + i), - sizeof port); - if ((i += sizeof port) >= l) - { - smi_log(SMI_LOG_ERR, - "%s: connect[%d]: wrong len %d >= %d", - g->a_ctx->ctx_smfi->xxfi_name, - (int) g->a_ctx->ctx_id, (int) i, (int) 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) - != 1) - { - smi_log(SMI_LOG_ERR, - "%s: connect[%d]: inet_aton failed", - g->a_ctx->ctx_smfi->xxfi_name, - (int) g->a_ctx->ctx_id); - return _SMFIS_ABORT; - } - sockaddr.sa.sa_family = AF_INET; - if (port > 0) - sockaddr.sin.sin_port = port; - } - else -# endif /* NETINET */ -# if NETINET6 - if (family == SMFIA_INET6) - { - if (mi_inet_pton(AF_INET6, s + i, - &sockaddr.sin6.sin6_addr) != 1) - { - smi_log(SMI_LOG_ERR, - "%s: connect[%d]: mi_inet_pton failed", - g->a_ctx->ctx_smfi->xxfi_name, - (int) g->a_ctx->ctx_id); - return _SMFIS_ABORT; - } - sockaddr.sa.sa_family = AF_INET6; - if (port > 0) - sockaddr.sin6.sin6_port = port; - } - else -# endif /* NETINET6 */ -# if NETUNIX - if (family == SMFIA_UNIX) - { - if (sm_strlcpy(sockaddr.sunix.sun_path, s + i, - sizeof sockaddr.sunix.sun_path) >= - sizeof sockaddr.sunix.sun_path) - { - smi_log(SMI_LOG_ERR, - "%s: connect[%d]: path too long", - g->a_ctx->ctx_smfi->xxfi_name, - (int) g->a_ctx->ctx_id); - return _SMFIS_ABORT; - } - sockaddr.sunix.sun_family = AF_UNIX; - } - else -# endif /* NETUNIX */ - { - smi_log(SMI_LOG_ERR, - "%s: connect[%d]: unknown family %d", - g->a_ctx->ctx_smfi->xxfi_name, - (int) g->a_ctx->ctx_id, family); - return _SMFIS_ABORT; - } - } - return (*fi_connect)(g->a_ctx, g->a_buf, - family != SMFIA_UNKNOWN ? &sockaddr : NULL); -} -/* -** ST_EOH -- end of headers -** -** Parameters: -** g -- generic argument structure -** -** Returns: -** continue or filter-specified value -*/ - -static int -st_eoh(g) - genarg *g; -{ - sfsistat (*fi_eoh) __P((SMFICTX *)); - - if (g == NULL) - return _SMFIS_ABORT; - if (g->a_ctx->ctx_smfi != NULL && - (fi_eoh = g->a_ctx->ctx_smfi->xxfi_eoh) != NULL) - return (*fi_eoh)(g->a_ctx); - return SMFIS_CONTINUE; -} -/* -** ST_HELO -- helo/ehlo command -** -** Parameters: -** g -- generic argument structure -** -** Returns: -** continue or filter-specified value -*/ -static int -st_helo(g) - genarg *g; -{ - sfsistat (*fi_helo) __P((SMFICTX *, char *)); - - if (g == NULL) - return _SMFIS_ABORT; - 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) - return (*fi_helo)(g->a_ctx, g->a_buf); - return SMFIS_CONTINUE; -} -/* -** ST_HEADER -- header line -** -** Parameters: -** g -- generic argument structure -** -** Returns: -** continue or filter-specified value -*/ - -static int -st_header(g) - genarg *g; -{ - char *hf, *hv; - sfsistat (*fi_header) __P((SMFICTX *, char *, char *)); - - if (g == NULL) - return _SMFIS_ABORT; - if (g->a_ctx->ctx_smfi == NULL || - (fi_header = g->a_ctx->ctx_smfi->xxfi_header) == NULL) - return SMFIS_CONTINUE; - if (dec_arg2(g->a_buf, g->a_len, &hf, &hv) == MI_SUCCESS) - return (*fi_header)(g->a_ctx, hf, hv); - else - return _SMFIS_ABORT; -} - -#define ARGV_FCT(lf, rf, idx) \ - char **argv; \ - sfsistat (*lf) __P((SMFICTX *, char **)); \ - int r; \ - \ - if (g == NULL) \ - return _SMFIS_ABORT; \ - mi_clr_macros(g->a_ctx, g->a_idx + 1); \ - if (g->a_ctx->ctx_smfi == NULL || \ - (lf = g->a_ctx->ctx_smfi->rf) == NULL) \ - return SMFIS_CONTINUE; \ - if ((argv = dec_argv(g->a_buf, g->a_len)) == NULL) \ - return _SMFIS_ABORT; \ - r = (*lf)(g->a_ctx, argv); \ - free(argv); \ - return r; - -/* -** ST_SENDER -- MAIL FROM command -** -** Parameters: -** g -- generic argument structure -** -** Returns: -** continue or filter-specified value -*/ - -static int -st_sender(g) - genarg *g; -{ - ARGV_FCT(fi_envfrom, xxfi_envfrom, CI_MAIL) -} -/* -** ST_RCPT -- RCPT TO command -** -** Parameters: -** g -- generic argument structure -** -** Returns: -** continue or filter-specified value -*/ - -static int -st_rcpt(g) - genarg *g; -{ - ARGV_FCT(fi_envrcpt, xxfi_envrcpt, CI_RCPT) -} -/* -** ST_MACROS -- deal with macros received from the MTA -** -** Parameters: -** g -- generic argument structure -** -** Returns: -** continue/keep -** -** Side effects: -** set pointer in macro array to current values. -*/ - -static int -st_macros(g) - genarg *g; -{ - int i; - char **argv; - - if (g == NULL || g->a_len < 1) - return _SMFIS_FAIL; - if ((argv = dec_argv(g->a_buf + 1, g->a_len - 1)) == NULL) - return _SMFIS_FAIL; - switch (g->a_buf[0]) - { - case SMFIC_CONNECT: - i = CI_CONN; - break; - case SMFIC_HELO: - i = CI_HELO; - break; - case SMFIC_MAIL: - i = CI_MAIL; - break; - case SMFIC_RCPT: - i = CI_RCPT; - break; - default: - free(argv); - return _SMFIS_FAIL; - } - if (g->a_ctx->ctx_mac_ptr[i] != NULL) - free(g->a_ctx->ctx_mac_ptr[i]); - if (g->a_ctx->ctx_mac_buf[i] != NULL) - free(g->a_ctx->ctx_mac_buf[i]); - g->a_ctx->ctx_mac_ptr[i] = argv; - g->a_ctx->ctx_mac_buf[i] = g->a_buf; - return _SMFIS_KEEP; -} -/* -** ST_QUIT -- quit command -** -** Parameters: -** g -- generic argument structure -** -** Returns: -** noreply -*/ - -static int -st_quit(g) - genarg *g; -{ - return _SMFIS_NOREPLY; -} -/* -** ST_BODYCHUNK -- deal with a piece of the mail body -** -** Parameters: -** g -- generic argument structure -** -** Returns: -** continue or filter-specified value -*/ - -static int -st_bodychunk(g) - genarg *g; -{ - sfsistat (*fi_body) __P((SMFICTX *, unsigned char *, size_t)); - - if (g == NULL) - return _SMFIS_ABORT; - if (g->a_ctx->ctx_smfi != NULL && - (fi_body = g->a_ctx->ctx_smfi->xxfi_body) != NULL) - return (*fi_body)(g->a_ctx, (unsigned char *)g->a_buf, - g->a_len); - return SMFIS_CONTINUE; -} -/* -** ST_BODYEND -- deal with the last piece of the mail body -** -** Parameters: -** g -- generic argument structure -** -** Returns: -** continue or filter-specified value -** -** Side effects: -** sends a reply for the body part (if non-empty). -*/ - -static int -st_bodyend(g) - genarg *g; -{ - sfsistat r; - sfsistat (*fi_body) __P((SMFICTX *, unsigned char *, size_t)); - sfsistat (*fi_eom) __P((SMFICTX *)); - - if (g == NULL) - return _SMFIS_ABORT; - r = SMFIS_CONTINUE; - if (g->a_ctx->ctx_smfi != NULL) - { - if ((fi_body = g->a_ctx->ctx_smfi->xxfi_body) != NULL && - g->a_len > 0) - { - socket_t sd; - struct timeval timeout; - - timeout.tv_sec = g->a_ctx->ctx_timeout; - timeout.tv_usec = 0; - sd = g->a_ctx->ctx_sd; - r = (*fi_body)(g->a_ctx, (unsigned char *)g->a_buf, - g->a_len); - if (r != SMFIS_CONTINUE && - sendreply(r, sd, &timeout, g->a_ctx) != MI_SUCCESS) - return _SMFIS_ABORT; - } - } - if (r == SMFIS_CONTINUE && - (fi_eom = g->a_ctx->ctx_smfi->xxfi_eom) != NULL) - return (*fi_eom)(g->a_ctx); - return r; -} -/* -** ST_ABORTFCT -- deal with aborts -** -** Parameters: -** g -- generic argument structure -** -** Returns: -** abort or filter-specified value -*/ - -static int -st_abortfct(g) - genarg *g; -{ - sfsistat (*fi_abort) __P((SMFICTX *)); - - if (g == NULL) - return _SMFIS_ABORT; - if (g != NULL && g->a_ctx->ctx_smfi != NULL && - (fi_abort = g->a_ctx->ctx_smfi->xxfi_abort) != NULL) - (void) (*fi_abort)(g->a_ctx); - return _SMFIS_NOREPLY; -} -/* -** TRANS_OK -- is the state transition ok? -** -** Parameters: -** old -- old state -** new -- new state -** -** Returns: -** state transition ok -*/ - -static bool -trans_ok(old, new) - int old, new; -{ - int s, n; - - s = old; - do - { - /* is this state transition allowed? */ - if ((MI_MASK(new) & next_states[s]) != 0) - return true; - - /* - ** no: try next state; - ** this works since the relevant states are ordered - ** strict sequentially - */ - - n = s + 1; - - /* - ** can we actually "skip" this state? - ** see fix_stm() which sets this bit for those - ** states which the filter program is not interested in - */ - - if (bitset(NX_SKIP, next_states[n])) - s = n; - else - return false; - } while (s <= ST_LAST); - return false; -} -/* -** FIX_STM -- add "skip" bits to the state transition table -** -** Parameters: -** ctx -- context structure -** -** Returns: -** None. -** -** Side effects: -** may change state transition table. -*/ - -static void -fix_stm(ctx) - SMFICTX_PTR ctx; -{ - unsigned long fl; - - if (ctx == NULL || ctx->ctx_smfi == NULL) - return; - fl = ctx->ctx_pflags; - if (bitset(SMFIP_NOCONNECT, fl)) - next_states[ST_CONN] |= NX_SKIP; - if (bitset(SMFIP_NOHELO, fl)) - next_states[ST_HELO] |= NX_SKIP; - if (bitset(SMFIP_NOMAIL, fl)) - next_states[ST_MAIL] |= NX_SKIP; - if (bitset(SMFIP_NORCPT, fl)) - next_states[ST_RCPT] |= NX_SKIP; - if (bitset(SMFIP_NOHDRS, fl)) - next_states[ST_HDRS] |= NX_SKIP; - if (bitset(SMFIP_NOEOH, fl)) - next_states[ST_EOHS] |= NX_SKIP; - if (bitset(SMFIP_NOBODY, fl)) - next_states[ST_BODY] |= NX_SKIP; -} -/* -** DEC_ARGV -- split a buffer into a list of strings, NULL terminated -** -** Parameters: -** buf -- buffer with several strings -** len -- length of buffer -** -** Returns: -** array of pointers to the individual strings -*/ - -static char ** -dec_argv(buf, len) - char *buf; - size_t len; -{ - char **s; - size_t i; - int elem, nelem; - - nelem = 0; - for (i = 0; i < len; i++) - { - if (buf[i] == '\0') - ++nelem; - } - if (nelem == 0) - return NULL; - - /* last entry is only for the name */ - s = (char **)malloc((nelem + 1) * (sizeof *s)); - if (s == NULL) - return NULL; - s[0] = buf; - for (i = 0, elem = 0; i < len && elem < nelem; i++) - { - if (buf[i] == '\0') - s[++elem] = &(buf[i + 1]); - } - - /* overwrite last entry */ - s[elem] = NULL; - return s; -} -/* -** DEC_ARG2 -- split a buffer into two strings -** -** Parameters: -** buf -- buffer with two strings -** len -- length of buffer -** s1,s2 -- pointer to result strings -** -** Returns: -** MI_FAILURE/MI_SUCCESS -*/ - -static int -dec_arg2(buf, len, s1, s2) - char *buf; - size_t len; - char **s1; - char **s2; -{ - size_t i; - - *s1 = buf; - for (i = 1; i < len && buf[i] != '\0'; i++) - continue; - if (i >= len - 1) - return MI_FAILURE; - *s2 = buf + i + 1; - return MI_SUCCESS; -} -/* -** SENDOK -- is it ok for the filter to send stuff to the MTA? -** -** Parameters: -** ctx -- context structure -** flag -- flag to check -** -** Returns: -** sending allowed (in current state) -*/ - -bool -mi_sendok(ctx, flag) - SMFICTX_PTR ctx; - int flag; -{ - if (ctx == NULL || ctx->ctx_smfi == NULL) - return false; - - /* did the milter request this operation? */ - if (flag != 0 && !bitset(flag, ctx->ctx_smfi->xxfi_flags)) - return false; - - /* are we in the correct state? It must be "End of Message". */ - return ctx->ctx_state == ST_ENDM; -} diff --git a/contrib/sendmail/libmilter/handler.c b/contrib/sendmail/libmilter/handler.c deleted file mode 100644 index db3cc4645d8d..000000000000 --- a/contrib/sendmail/libmilter/handler.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 1999-2003 Sendmail, Inc. and its suppliers. - * All rights reserved. - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the sendmail distribution. - * - */ - -#include <sm/gen.h> -SM_RCSID("@(#)$Id: handler.c,v 8.30.2.4 2003/01/23 22:28:36 ca Exp $") - -#include "libmilter.h" - - -/* -** HANDLE_SESSION -- Handle a connected session in its own context -** -** Parameters: -** ctx -- context structure -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -int -mi_handle_session(ctx) - SMFICTX_PTR ctx; -{ - int ret; - - if (ctx == NULL) - return MI_FAILURE; - ctx->ctx_id = (sthread_t) sthread_get_id(); - - /* - ** Detach so resources are free when the thread returns. - ** If we ever "wait" for threads, this call must be removed. - */ - - if (pthread_detach(ctx->ctx_id) != 0) - ret = MI_FAILURE; - else - ret = mi_engine(ctx); - if (ValidSocket(ctx->ctx_sd)) - { - (void) closesocket(ctx->ctx_sd); - ctx->ctx_sd = INVALID_SOCKET; - } - if (ctx->ctx_reply != NULL) - { - free(ctx->ctx_reply); - ctx->ctx_reply = NULL; - } - if (ctx->ctx_privdata != NULL) - { - smi_log(SMI_LOG_WARN, - "%s: private data not NULL", - ctx->ctx_smfi->xxfi_name); - } - mi_clr_macros(ctx, 0); - free(ctx); - ctx = NULL; - return ret; -} diff --git a/contrib/sendmail/libmilter/libmilter.h b/contrib/sendmail/libmilter/libmilter.h deleted file mode 100644 index 7ae5bcd1ce0d..000000000000 --- a/contrib/sendmail/libmilter/libmilter.h +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 1999-2003 Sendmail, Inc. and its suppliers. - * All rights reserved. - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the sendmail distribution. - */ - -/* -** LIBMILTER.H -- include file for mail filter library functions -*/ - -#ifndef _LIBMILTER_H -# define _LIBMILTER_H 1 - -#include <sm/gen.h> - -#ifdef _DEFINE -# define EXTERN -# define INIT(x) = x -SM_IDSTR(MilterlId, "@(#)$Id: libmilter.h,v 8.33.2.9 2003/01/03 22:14:40 ca Exp $") -#else /* _DEFINE */ -# define EXTERN extern -# define INIT(x) -#endif /* _DEFINE */ - - -#define NOT_SENDMAIL 1 -#define _SOCK_ADDR union bigsockaddr -#include "sendmail.h" - -#include "libmilter/milter.h" - -# define ValidSocket(sd) ((sd) >= 0) -# define INVALID_SOCKET (-1) -# define closesocket close -# define MI_SOCK_READ(s, b, l) read(s, b, l) -# define MI_SOCK_READ_FAIL(x) ((x) < 0) -# define MI_SOCK_WRITE(s, b, l) write(s, b, l) - -# define thread_create(ptid,wr,arg) pthread_create(ptid, NULL, wr, arg) -# define sthread_get_id() pthread_self() - -typedef pthread_mutex_t smutex_t; -# define smutex_init(mp) (pthread_mutex_init(mp, NULL) == 0) -# define smutex_destroy(mp) (pthread_mutex_destroy(mp) == 0) -# define smutex_lock(mp) (pthread_mutex_lock(mp) == 0) -# define smutex_unlock(mp) (pthread_mutex_unlock(mp) == 0) -# define smutex_trylock(mp) (pthread_mutex_trylock(mp) == 0) - -#if _FFR_USE_POLL - -# include <poll.h> -# define MI_POLLSELECT "poll" - -# define MI_POLL_RD_FLAGS (POLLIN | POLLPRI) -# define MI_POLL_WR_FLAGS (POLLOUT) -# define MI_MS(timeout) (((timeout)->tv_sec * 1000) + (timeout)->tv_usec) - -# define FD_RD_VAR(rds, excs) struct pollfd rds -# define FD_WR_VAR(wrs) struct pollfd wrs - -# define FD_RD_INIT(sd, rds, excs) \ - (rds).fd = (sd); \ - (rds).events = MI_POLL_RD_FLAGS; \ - (rds).revents = 0 - -# define FD_WR_INIT(sd, wrs) \ - (wrs).fd = (sd); \ - (wrs).events = MI_POLL_WR_FLAGS; \ - (wrs).revents = 0 - -# define FD_IS_RD_EXC(sd, rds, excs) \ - (((rds).revents & (POLLERR | POLLHUP | POLLNVAL)) != 0) - -# define FD_IS_WR_RDY(sd, wrs) \ - (((wrs).revents & MI_POLL_WR_FLAGS) != 0) - -# define FD_IS_RD_RDY(sd, rds, excs) \ - (((rds).revents & MI_POLL_RD_FLAGS) != 0) - -# define FD_WR_READY(sd, excs, timeout) \ - poll(&(wrs), 1, MI_MS(timeout)) - -# define FD_RD_READY(sd, rds, excs, timeout) \ - poll(&(rds), 1, MI_MS(timeout)) - -#else /* _FFR_USE_POLL */ - -# include <sm/fdset.h> -# define MI_POLLSELECT "select" - -# define FD_RD_VAR(rds, excs) fd_set rds, excs -# define FD_WR_VAR(wrs) fd_set wrs - -# define FD_RD_INIT(sd, rds, excs) \ - FD_ZERO(&(rds)); \ - FD_SET((unsigned int) (sd), &(rds)); \ - FD_ZERO(&(excs)); \ - FD_SET((unsigned int) (sd), &(excs)) - -# define FD_WR_INIT(sd, wrs) \ - FD_ZERO(&(wrs)); \ - FD_SET((unsigned int) (sd), &(wrs)); \ - -# define FD_IS_RD_EXC(sd, rds, excs) FD_ISSET(sd, &(excs)) -# define FD_IS_WR_RDY(sd, wrs) FD_ISSET((sd), &(wrs)) -# define FD_IS_RD_RDY(sd, rds, excs) FD_ISSET((sd), &(rds)) - -# define FD_WR_READY(sd, wrs, timeout) \ - select((sd) + 1, NULL, &(wrs), NULL, (timeout)) -# define FD_RD_READY(sd, rds, excs, timeout) \ - select((sd) + 1, &(rds), NULL, &(excs), (timeout)) - -#endif /* _FFR_USE_POLL */ - -#include <sys/time.h> - -/* version info */ -#define MILTER_PRODUCT_NAME "libmilter" -#define MILTER_VERSION 100 - -/* some defaults */ -#define MI_TIMEOUT 7210 /* default timeout for read/write */ -#define MI_CHK_TIME 5 /* checking whether to terminate */ - -#ifndef MI_SOMAXCONN -# if SOMAXCONN > 20 -# define MI_SOMAXCONN SOMAXCONN -# else /* SOMAXCONN */ -# define MI_SOMAXCONN 20 -# endif /* SOMAXCONN */ -#endif /* ! MI_SOMAXCONN */ - -/* maximum number of repeated failures in mi_listener() */ -#define MAX_FAILS_M 16 /* malloc() */ -#define MAX_FAILS_T 16 /* thread creation */ -#define MAX_FAILS_A 16 /* accept() */ -#define MAX_FAILS_S 16 /* select() */ - -/* internal "commands", i.e., error codes */ -#define SMFIC_TIMEOUT ((char) 1) /* timeout */ -#define SMFIC_SELECT ((char) 2) /* select error */ -#define SMFIC_MALLOC ((char) 3) /* malloc error */ -#define SMFIC_RECVERR ((char) 4) /* recv() error */ -#define SMFIC_EOF ((char) 5) /* eof */ -#define SMFIC_UNKNERR ((char) 6) /* unknown error */ -#define SMFIC_TOOBIG ((char) 7) /* body chunk too big */ -#define SMFIC_VALIDCMD ' ' /* first valid command */ - -/* hack */ -#define smi_log syslog -#define sm_dprintf printf -#define milter_ret int -#define SMI_LOG_ERR LOG_ERR -#define SMI_LOG_FATAL LOG_ERR -#define SMI_LOG_WARN LOG_WARNING -#define SMI_LOG_INFO LOG_INFO -#define SMI_LOG_DEBUG LOG_DEBUG - -/* stop? */ -#define MILTER_CONT 0 -#define MILTER_STOP 1 -#define MILTER_ABRT 2 - -/* functions */ -extern int mi_handle_session __P((SMFICTX_PTR)); -extern int mi_engine __P((SMFICTX_PTR)); -extern int mi_listener __P((char *, int, smfiDesc_ptr, time_t, int)); -extern void mi_clr_macros __P((SMFICTX_PTR, int)); -extern int mi_stop __P((void)); -extern int mi_control_startup __P((char *)); -extern void mi_stop_milters __P((int)); -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)); - -/* communication functions */ -extern char *mi_rd_cmd __P((socket_t, struct timeval *, char *, size_t *, char *)); -extern int mi_wr_cmd __P((socket_t, struct timeval *, int, char *, size_t)); -extern bool mi_sendok __P((SMFICTX_PTR, int)); - - -#endif /* ! _LIBMILTER_H */ diff --git a/contrib/sendmail/libmilter/listener.c b/contrib/sendmail/libmilter/listener.c deleted file mode 100644 index 06087b6ae5fd..000000000000 --- a/contrib/sendmail/libmilter/listener.c +++ /dev/null @@ -1,860 +0,0 @@ -/* - * Copyright (c) 1999-2003 Sendmail, Inc. and its suppliers. - * All rights reserved. - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the sendmail distribution. - * - */ - -#include <sm/gen.h> -SM_RCSID("@(#)$Id: listener.c,v 8.85.2.9 2003/01/03 22:14:40 ca Exp $") - -/* -** listener.c -- threaded network listener -*/ - -#include "libmilter.h" -#include <sm/errstring.h> - - -# if NETINET || NETINET6 -# include <arpa/inet.h> -# endif /* NETINET || NETINET6 */ - -static smutex_t L_Mutex; -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 *)); - -/* -** MI_OPENSOCKET -- create the socket where this filter and the MTA will meet -** -** Parameters: -** conn -- connection description -** backlog -- listen backlog -** dbg -- debug level -** smfi -- filter structure to use -** -** Return value: -** MI_SUCCESS/MI_FAILURE -*/ - -int -mi_opensocket(conn, backlog, dbg, smfi) - char *conn; - int backlog; - int dbg; - smfiDesc_ptr smfi; -{ - if (smfi == NULL || conn == NULL) - return MI_FAILURE; - - if (ValidSocket(listenfd)) - return MI_SUCCESS; - - if (dbg > 0) - { - smi_log(SMI_LOG_DEBUG, - "%s: Opening listen socket on conn %s", - smfi->xxfi_name, conn); - } - (void) smutex_init(&L_Mutex); - (void) smutex_lock(&L_Mutex); - listenfd = mi_milteropen(conn, backlog, smfi->xxfi_name); - if (!ValidSocket(listenfd)) - { - smi_log(SMI_LOG_FATAL, - "%s: Unable to create listening socket on conn %s", - smfi->xxfi_name, conn); - (void) smutex_unlock(&L_Mutex); - return MI_FAILURE; - } -#if !_FFR_USE_POLL - if (!SM_FD_OK_SELECT(listenfd)) - { - smi_log(SMI_LOG_ERR, "%s: fd %d is larger than FD_SETSIZE %d", - smfi->xxfi_name, listenfd, FD_SETSIZE); - (void) smutex_unlock(&L_Mutex); - return MI_FAILURE; - } -#endif /* !_FFR_USE_POLL */ - return MI_SUCCESS; -} - -/* -** MI_MILTEROPEN -- setup socket to listen on -** -** Parameters: -** conn -- connection description -** backlog -- listen backlog -** name -- name for logging -** -** Returns: -** socket upon success, error code otherwise. -** -** Side effect: -** sets sockpath if UNIX socket. -*/ - -#if NETUNIX -static char *sockpath = NULL; -#endif /* NETUNIX */ - -static socket_t -mi_milteropen(conn, backlog, name) - char *conn; - int backlog; - char *name; -{ - socket_t sock; - int sockopt = 1; - int fdflags; - size_t len = 0; - char *p; - char *colon; - char *at; - SOCKADDR addr; - - if (conn == NULL || conn[0] == '\0') - { - smi_log(SMI_LOG_ERR, "%s: empty or missing socket information", - name); - return INVALID_SOCKET; - } - (void) memset(&addr, '\0', sizeof addr); - - /* protocol:filename or protocol:port@host */ - p = conn; - colon = strchr(p, ':'); - if (colon != NULL) - { - *colon = '\0'; - - if (*p == '\0') - { -#if NETUNIX - /* default to AF_UNIX */ - addr.sa.sa_family = AF_UNIX; - L_socksize = sizeof (struct sockaddr_un); -#else /* NETUNIX */ -# if NETINET - /* default to AF_INET */ - addr.sa.sa_family = AF_INET; - L_socksize = sizeof addr.sin; -# else /* NETINET */ -# if NETINET6 - /* default to AF_INET6 */ - addr.sa.sa_family = AF_INET6; - L_socksize = sizeof addr.sin6; -# else /* NETINET6 */ - /* no protocols available */ - smi_log(SMI_LOG_ERR, - "%s: no valid socket protocols available", - name); - return INVALID_SOCKET; -# endif /* NETINET6 */ -# endif /* NETINET */ -#endif /* NETUNIX */ - } -#if NETUNIX - else if (strcasecmp(p, "unix") == 0 || - strcasecmp(p, "local") == 0) - { - addr.sa.sa_family = AF_UNIX; - L_socksize = sizeof (struct sockaddr_un); - } -#endif /* NETUNIX */ -#if NETINET - else if (strcasecmp(p, "inet") == 0) - { - addr.sa.sa_family = AF_INET; - L_socksize = sizeof addr.sin; - } -#endif /* NETINET */ -#if NETINET6 - else if (strcasecmp(p, "inet6") == 0) - { - addr.sa.sa_family = AF_INET6; - L_socksize = sizeof addr.sin6; - } -#endif /* NETINET6 */ - else - { - smi_log(SMI_LOG_ERR, "%s: unknown socket type %s", - name, p); - return INVALID_SOCKET; - } - *colon++ = ':'; - } - else - { - colon = p; -#if NETUNIX - /* default to AF_UNIX */ - addr.sa.sa_family = AF_UNIX; - L_socksize = sizeof (struct sockaddr_un); -#else /* NETUNIX */ -# if NETINET - /* default to AF_INET */ - addr.sa.sa_family = AF_INET; - L_socksize = sizeof addr.sin; -# else /* NETINET */ -# if NETINET6 - /* default to AF_INET6 */ - addr.sa.sa_family = AF_INET6; - L_socksize = sizeof addr.sin6; -# else /* NETINET6 */ - smi_log(SMI_LOG_ERR, "%s: unknown socket type %s", - name, p); - return INVALID_SOCKET; -# endif /* NETINET6 */ -# endif /* NETINET */ -#endif /* NETUNIX */ - } - -#if NETUNIX - if (addr.sa.sa_family == AF_UNIX) - { -# if 0 - long sff = SFF_SAFEDIRPATH|SFF_OPENASROOT|SFF_NOLINK|SFF_CREAT|SFF_MUSTOWN; -# endif /* 0 */ - - at = colon; - len = strlen(colon) + 1; - if (len >= sizeof addr.sunix.sun_path) - { - errno = EINVAL; - smi_log(SMI_LOG_ERR, "%s: UNIX socket name %s too long", - name, colon); - return INVALID_SOCKET; - } - (void) sm_strlcpy(addr.sunix.sun_path, colon, - sizeof addr.sunix.sun_path); -# if 0 - errno = safefile(colon, RunAsUid, RunAsGid, RunAsUserName, sff, - S_IRUSR|S_IWUSR, NULL); - - /* if not safe, don't create */ - if (errno != 0) - { - smi_log(SMI_LOG_ERR, - "%s: UNIX socket name %s unsafe", - name, colon); - return INVALID_SOCKET; - } -# endif /* 0 */ - } -#endif /* NETUNIX */ - -#if NETINET || NETINET6 - if ( -# if NETINET - addr.sa.sa_family == AF_INET -# endif /* NETINET */ -# if NETINET && NETINET6 - || -# endif /* NETINET && NETINET6 */ -# if NETINET6 - addr.sa.sa_family == AF_INET6 -# endif /* NETINET6 */ - ) - { - unsigned short port; - - /* Parse port@host */ - at = strchr(colon, '@'); - if (at == NULL) - { - switch (addr.sa.sa_family) - { -# if NETINET - case AF_INET: - addr.sin.sin_addr.s_addr = INADDR_ANY; - break; -# endif /* NETINET */ - -# if NETINET6 - case AF_INET6: - addr.sin6.sin6_addr = in6addr_any; - break; -# endif /* NETINET6 */ - } - } - else - *at = '\0'; - - if (isascii(*colon) && isdigit(*colon)) - port = htons((unsigned short) atoi(colon)); - else - { -# ifdef NO_GETSERVBYNAME - smi_log(SMI_LOG_ERR, "%s: invalid port number %s", - name, colon); - return INVALID_SOCKET; -# else /* NO_GETSERVBYNAME */ - register struct servent *sp; - - sp = getservbyname(colon, "tcp"); - if (sp == NULL) - { - smi_log(SMI_LOG_ERR, - "%s: unknown port name %s", - name, colon); - return INVALID_SOCKET; - } - port = sp->s_port; -# endif /* NO_GETSERVBYNAME */ - } - if (at != NULL) - { - *at++ = '@'; - if (*at == '[') - { - char *end; - - end = strchr(at, ']'); - if (end != NULL) - { - bool found = false; -# if NETINET - unsigned long hid = INADDR_NONE; -# endif /* NETINET */ -# if NETINET6 - struct sockaddr_in6 hid6; -# endif /* NETINET6 */ - - *end = '\0'; -# if NETINET - if (addr.sa.sa_family == AF_INET && - (hid = inet_addr(&at[1])) != INADDR_NONE) - { - addr.sin.sin_addr.s_addr = hid; - addr.sin.sin_port = port; - found = true; - } -# endif /* NETINET */ -# if NETINET6 - (void) memset(&hid6, '\0', sizeof hid6); - if (addr.sa.sa_family == AF_INET6 && - mi_inet_pton(AF_INET6, &at[1], - &hid6.sin6_addr) == 1) - { - addr.sin6.sin6_addr = hid6.sin6_addr; - addr.sin6.sin6_port = port; - found = true; - } -# endif /* NETINET6 */ - *end = ']'; - if (!found) - { - smi_log(SMI_LOG_ERR, - "%s: Invalid numeric domain spec \"%s\"", - name, at); - return INVALID_SOCKET; - } - } - else - { - smi_log(SMI_LOG_ERR, - "%s: Invalid numeric domain spec \"%s\"", - name, at); - return INVALID_SOCKET; - } - } - else - { - struct hostent *hp = NULL; - - hp = mi_gethostbyname(at, addr.sa.sa_family); - if (hp == NULL) - { - smi_log(SMI_LOG_ERR, - "%s: Unknown host name %s", - name, at); - return INVALID_SOCKET; - } - addr.sa.sa_family = hp->h_addrtype; - switch (hp->h_addrtype) - { -# if NETINET - case AF_INET: - memmove(&addr.sin.sin_addr, - hp->h_addr, - INADDRSZ); - addr.sin.sin_port = port; - break; -# endif /* NETINET */ - -# if NETINET6 - case AF_INET6: - memmove(&addr.sin6.sin6_addr, - hp->h_addr, - IN6ADDRSZ); - addr.sin6.sin6_port = port; - break; -# endif /* NETINET6 */ - - default: - smi_log(SMI_LOG_ERR, - "%s: Unknown protocol for %s (%d)", - name, at, hp->h_addrtype); - return INVALID_SOCKET; - } -# if NETINET6 - freehostent(hp); -# endif /* NETINET6 */ - } - } - else - { - switch (addr.sa.sa_family) - { -# if NETINET - case AF_INET: - addr.sin.sin_port = port; - break; -# endif /* NETINET */ -# if NETINET6 - case AF_INET6: - addr.sin6.sin6_port = port; - break; -# endif /* NETINET6 */ - } - } - } -#endif /* NETINET || NETINET6 */ - - sock = socket(addr.sa.sa_family, SOCK_STREAM, 0); - if (!ValidSocket(sock)) - { - smi_log(SMI_LOG_ERR, - "%s: Unable to create new socket: %s", - name, sm_errstring(errno)); - return INVALID_SOCKET; - } - - if ((fdflags = fcntl(sock, F_GETFD, 0)) == -1 || - fcntl(sock, F_SETFD, fdflags | FD_CLOEXEC) == -1) - { - smi_log(SMI_LOG_ERR, - "%s: Unable to set close-on-exec: %s", name, - sm_errstring(errno)); - (void) closesocket(sock); - return INVALID_SOCKET; - } - - if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &sockopt, - sizeof(sockopt)) == -1) - { - smi_log(SMI_LOG_ERR, - "%s: Unable to setsockopt: %s", name, - sm_errstring(errno)); - (void) closesocket(sock); - return INVALID_SOCKET; - } - - if (bind(sock, &addr.sa, L_socksize) < 0) - { - smi_log(SMI_LOG_ERR, - "%s: Unable to bind to port %s: %s", - name, conn, sm_errstring(errno)); - (void) closesocket(sock); - return INVALID_SOCKET; - } - - if (listen(sock, backlog) < 0) - { - smi_log(SMI_LOG_ERR, - "%s: listen call failed: %s", name, - sm_errstring(errno)); - (void) closesocket(sock); - return INVALID_SOCKET; - } - -#if NETUNIX - if (addr.sa.sa_family == AF_UNIX && len > 0) - { - /* - ** Set global variable sockpath so the UNIX socket can be - ** unlink()ed at exit. - */ - - sockpath = (char *) malloc(len); - if (sockpath != NULL) - (void) sm_strlcpy(sockpath, colon, len); - else - { - smi_log(SMI_LOG_ERR, - "%s: can't malloc(%d) for sockpath: %s", - name, (int) len, sm_errstring(errno)); - (void) closesocket(sock); - return INVALID_SOCKET; - } - } -#endif /* NETUNIX */ - L_family = addr.sa.sa_family; - return sock; -} -/* -** MI_THREAD_HANDLE_WRAPPER -- small wrapper to handle session -** -** Parameters: -** arg -- argument to pass to mi_handle_session() -** -** Returns: -** results from mi_handle_session() -*/ - -void * -mi_thread_handle_wrapper(arg) - void *arg; -{ - return (void *) mi_handle_session(arg); -} - -/* -** MI_CLOSENER -- close listen socket -** -** NOTE: It is assumed that this function is called from a -** function that has a mutex lock (currently mi_stop_milters()). -** -** Parameters: -** none. -** -** Returns: -** none. -*/ - -void -mi_closener() -{ - (void) smutex_lock(&L_Mutex); - if (ValidSocket(listenfd)) - { -#if NETUNIX - bool removable; - struct stat sockinfo; - struct stat fileinfo; - - removable = sockpath != NULL && -#if _FFR_MILTER_ROOT_UNSAFE - geteuid() != 0 && -#endif /* _FFR_MILTER_ROOT_UNSAFE */ - fstat(listenfd, &sockinfo) == 0 && - (S_ISFIFO(sockinfo.st_mode) -# ifdef S_ISSOCK - || S_ISSOCK(sockinfo.st_mode) -# endif /* S_ISSOCK */ - ); -#endif /* NETUNIX */ - - (void) closesocket(listenfd); - listenfd = INVALID_SOCKET; - -#if NETUNIX - /* XXX sleep() some time before doing this? */ - if (sockpath != NULL) - { - if (removable && - stat(sockpath, &fileinfo) == 0 && - ((fileinfo.st_dev == sockinfo.st_dev && - fileinfo.st_ino == sockinfo.st_ino) -# ifdef S_ISSOCK - || S_ISSOCK(fileinfo.st_mode) -# endif /* S_ISSOCK */ - ) - && - (S_ISFIFO(fileinfo.st_mode) -# ifdef S_ISSOCK - || S_ISSOCK(fileinfo.st_mode) -# endif /* S_ISSOCK */ - )) - (void) unlink(sockpath); - free(sockpath); - sockpath = NULL; - } -#endif /* NETUNIX */ - } - (void) smutex_unlock(&L_Mutex); -} - -/* -** MI_LISTENER -- Generic listener harness -** -** Open up listen port -** Wait for connections -** -** Parameters: -** conn -- connection description -** dbg -- debug level -** smfi -- filter structure to use -** timeout -- timeout for reads/writes -** backlog -- listen queue backlog size -** -** Returns: -** MI_SUCCESS -- Exited normally -** (session finished or we were told to exit) -** MI_FAILURE -- Network initialization failed. -*/ - -#if BROKEN_PTHREAD_SLEEP - -/* -** Solaris 2.6, perhaps others, gets an internal threads library panic -** when sleep() is used: -** -** thread_create() failed, returned 11 (EINVAL) -** co_enable, thr_create() returned error = 24 -** libthread panic: co_enable failed (PID: 17793 LWP 1) -** stacktrace: -** ef526b10 -** ef52646c -** ef534cbc -** 156a4 -** 14644 -** 1413c -** 135e0 -** 0 -*/ - -# define MI_SLEEP(s) \ -{ \ - int rs = 0; \ - struct timeval st; \ - \ - st.tv_sec = (s); \ - st.tv_usec = 0; \ - if (st.tv_sec > 0) \ - { \ - for (;;) \ - { \ - rs = select(0, NULL, NULL, NULL, &st); \ - if (rs < 0 && errno == EINTR) \ - continue; \ - if (rs != 0) \ - { \ - smi_log(SMI_LOG_ERR, \ - "MI_SLEEP(): select() returned non-zero result %d, errno = %d", \ - rs, errno); \ - } \ - break; \ - } \ - } \ -} -#else /* BROKEN_PTHREAD_SLEEP */ -# define MI_SLEEP(s) sleep((s)) -#endif /* BROKEN_PTHREAD_SLEEP */ - -int -mi_listener(conn, dbg, smfi, timeout, backlog) - char *conn; - int dbg; - smfiDesc_ptr smfi; - time_t timeout; - int backlog; -{ - socket_t connfd = INVALID_SOCKET; - int sockopt = 1; - int r; - int ret = MI_SUCCESS; - int mcnt = 0; /* error count for malloc() failures */ - int tcnt = 0; /* error count for thread_create() failures */ - int acnt = 0; /* error count for accept() failures */ - int scnt = 0; /* error count for select() failures */ - int save_errno = 0; - sthread_t thread_id; - _SOCK_ADDR cliaddr; - SOCKADDR_LEN_T clilen; - SMFICTX_PTR ctx; - FD_RD_VAR(rds, excs); - struct timeval chktime; - - if (mi_opensocket(conn, backlog, dbg, smfi) == MI_FAILURE) - return MI_FAILURE; - - clilen = L_socksize; - (void) smutex_unlock(&L_Mutex); - while (mi_stop() == MILTER_CONT) - { - (void) smutex_lock(&L_Mutex); - if (!ValidSocket(listenfd)) - { - (void) smutex_unlock(&L_Mutex); - break; - } - - /* select on interface ports */ - FD_RD_INIT(listenfd, rds, excs); - chktime.tv_sec = MI_CHK_TIME; - chktime.tv_usec = 0; - r = FD_RD_READY(listenfd, rds, excs, &chktime); - if (r == 0) /* timeout */ - { - (void) smutex_unlock(&L_Mutex); - continue; /* just check mi_stop() */ - } - if (r < 0) - { - save_errno = errno; - (void) smutex_unlock(&L_Mutex); - if (save_errno == EINTR) - continue; - scnt++; - smi_log(SMI_LOG_ERR, - "%s: select() failed (%s), %s", - smfi->xxfi_name, sm_errstring(save_errno), - scnt >= MAX_FAILS_S ? "abort" : "try again"); - MI_SLEEP(scnt); - if (scnt >= MAX_FAILS_S) - { - ret = MI_FAILURE; - break; - } - continue; - } - if (!FD_IS_RD_RDY(listenfd, rds, excs)) - { - /* some error: just stop for now... */ - ret = MI_FAILURE; - (void) smutex_unlock(&L_Mutex); - smi_log(SMI_LOG_ERR, - "%s: %s() returned exception for socket, abort", - smfi->xxfi_name, MI_POLLSELECT); - break; - } - scnt = 0; /* reset error counter for select() */ - - memset(&cliaddr, '\0', sizeof cliaddr); - connfd = accept(listenfd, (struct sockaddr *) &cliaddr, - &clilen); - save_errno = errno; - (void) smutex_unlock(&L_Mutex); - - /* - ** If remote side closes before - ** accept() finishes, sockaddr - ** might not be fully filled in. - */ - - if (ValidSocket(connfd) && - (clilen == 0 || -# ifdef BSD4_4_SOCKADDR - cliaddr.sa.sa_len == 0 || -# endif /* BSD4_4_SOCKADDR */ - cliaddr.sa.sa_family != L_family)) - { - (void) closesocket(connfd); - connfd = INVALID_SOCKET; - save_errno = EINVAL; - } - -#if !_FFR_USE_POLL - /* check if acceptable for select() */ - if (ValidSocket(connfd) && !SM_FD_OK_SELECT(connfd)) - { - (void) closesocket(connfd); - connfd = INVALID_SOCKET; - save_errno = ERANGE; - } -#endif /* !_FFR_USE_POLL */ - - if (!ValidSocket(connfd)) - { - if (save_errno == EINTR) - continue; - acnt++; - smi_log(SMI_LOG_ERR, - "%s: accept() returned invalid socket (%s), %s", - smfi->xxfi_name, sm_errstring(save_errno), - acnt >= MAX_FAILS_A ? "abort" : "try again"); - MI_SLEEP(acnt); - if (acnt >= MAX_FAILS_A) - { - ret = MI_FAILURE; - break; - } - continue; - } - acnt = 0; /* reset error counter for accept() */ - - if (setsockopt(connfd, SOL_SOCKET, SO_KEEPALIVE, - (void *) &sockopt, sizeof sockopt) < 0) - { - smi_log(SMI_LOG_WARN, "%s: setsockopt() failed (%s)", - smfi->xxfi_name, sm_errstring(errno)); - /* XXX: continue? */ - } - if ((ctx = (SMFICTX_PTR) malloc(sizeof *ctx)) == NULL) - { - (void) closesocket(connfd); - mcnt++; - smi_log(SMI_LOG_ERR, "%s: malloc(ctx) failed (%s), %s", - smfi->xxfi_name, sm_errstring(save_errno), - mcnt >= MAX_FAILS_M ? "abort" : "try again"); - MI_SLEEP(mcnt); - if (mcnt >= MAX_FAILS_M) - { - ret = MI_FAILURE; - break; - } - continue; - } - mcnt = 0; /* reset error counter for malloc() */ - memset(ctx, '\0', sizeof *ctx); - ctx->ctx_sd = connfd; - ctx->ctx_dbg = dbg; - ctx->ctx_timeout = timeout; - ctx->ctx_smfi = smfi; -#if 0 - if (smfi->xxfi_eoh == NULL) - if (smfi->xxfi_eom == NULL) - if (smfi->xxfi_abort == NULL) - if (smfi->xxfi_close == NULL) -#endif /* 0 */ - if (smfi->xxfi_connect == NULL) - ctx->ctx_pflags |= SMFIP_NOCONNECT; - if (smfi->xxfi_helo == NULL) - ctx->ctx_pflags |= SMFIP_NOHELO; - if (smfi->xxfi_envfrom == NULL) - ctx->ctx_pflags |= SMFIP_NOMAIL; - if (smfi->xxfi_envrcpt == NULL) - ctx->ctx_pflags |= SMFIP_NORCPT; - if (smfi->xxfi_header == NULL) - ctx->ctx_pflags |= SMFIP_NOHDRS; - if (smfi->xxfi_eoh == NULL) - ctx->ctx_pflags |= SMFIP_NOEOH; - if (smfi->xxfi_body == NULL) - ctx->ctx_pflags |= SMFIP_NOBODY; - - if ((r = thread_create(&thread_id, - mi_thread_handle_wrapper, - (void *) ctx)) != 0) - { - tcnt++; - smi_log(SMI_LOG_ERR, - "%s: thread_create() failed: %d, %s", - smfi->xxfi_name, r, - tcnt >= MAX_FAILS_T ? "abort" : "try again"); - MI_SLEEP(tcnt); - (void) closesocket(connfd); - free(ctx); - if (tcnt >= MAX_FAILS_T) - { - ret = MI_FAILURE; - break; - } - continue; - } - tcnt = 0; - } - if (ret != MI_SUCCESS) - mi_stop_milters(MILTER_ABRT); - else - mi_closener(); - (void) smutex_destroy(&L_Mutex); - return ret; -} diff --git a/contrib/sendmail/libmilter/main.c b/contrib/sendmail/libmilter/main.c deleted file mode 100644 index 4e62c45fb144..000000000000 --- a/contrib/sendmail/libmilter/main.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (c) 1999-2003 Sendmail, Inc. and its suppliers. - * All rights reserved. - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the sendmail distribution. - * - */ - -#include <sm/gen.h> -SM_RCSID("@(#)$Id: main.c,v 8.64.2.10 2003/01/23 22:34:24 ca Exp $") - -#define _DEFINE 1 -#include "libmilter.h" -#include <fcntl.h> -#include <sys/stat.h> - - -static smfiDesc_ptr smfi = NULL; - -/* -** SMFI_REGISTER -- register a filter description -** -** Parameters: -** smfilter -- description of filter to register -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -int -smfi_register(smfilter) - smfiDesc_str smfilter; -{ - size_t len; - - if (smfi == NULL) - { - smfi = (smfiDesc_ptr) malloc(sizeof *smfi); - if (smfi == NULL) - return MI_FAILURE; - } - (void) memcpy(smfi, &smfilter, sizeof *smfi); - if (smfilter.xxfi_name == NULL) - smfilter.xxfi_name = "Unknown"; - - len = strlen(smfilter.xxfi_name) + 1; - smfi->xxfi_name = (char *) malloc(len); - if (smfi->xxfi_name == NULL) - return MI_FAILURE; - (void) sm_strlcpy(smfi->xxfi_name, smfilter.xxfi_name, len); - - /* compare milter version with hard coded version */ - if (smfi->xxfi_version != SMFI_VERSION) - { - /* hard failure for now! */ - smi_log(SMI_LOG_ERR, - "%s: smfi_register: version mismatch application: %d != milter: %d", - smfi->xxfi_name, smfi->xxfi_version, - (int) SMFI_VERSION); - - /* XXX how about smfi? */ - free(smfi->xxfi_name); - return MI_FAILURE; - } - - return MI_SUCCESS; -} - -/* -** SMFI_STOP -- stop milter -** -** Parameters: -** none. -** -** Returns: -** success. -*/ - -int -smfi_stop() -{ - mi_stop_milters(MILTER_STOP); - return MI_SUCCESS; -} - -/* -** default values for some variables. -** Most of these can be changed with the functions below. -*/ - -static int dbg = 0; -static char *conn = NULL; -static int timeout = MI_TIMEOUT; -static int backlog = MI_SOMAXCONN; - -#if _FFR_SMFI_OPENSOCKET -/* -** SMFI_OPENSOCKET -- try the socket setup to make sure we'll be -** able to start up -** -** Parameters: -** None. -** -** Return: -** MI_SUCCESS/MI_FAILURE -*/ - -int -smfi_opensocket() -{ - if (smfi == NULL || conn == NULL) - return MI_FAILURE; - - return mi_opensocket(conn, backlog, dbg, smfi); -} -#endif /* _FFR_SMFI_OPENSOCKET */ - -/* -** SMFI_SETDBG -- set debug level. -** -** Parameters: -** odbg -- new debug level. -** -** Returns: -** MI_SUCCESS -*/ - -int -smfi_setdbg(odbg) - int odbg; -{ - dbg = odbg; - return MI_SUCCESS; -} - -/* -** SMFI_SETTIMEOUT -- set timeout (for read/write). -** -** Parameters: -** otimeout -- new timeout. -** -** Returns: -** MI_SUCCESS -*/ - -int -smfi_settimeout(otimeout) - int otimeout; -{ - timeout = otimeout; - return MI_SUCCESS; -} - -/* -** SMFI_SETCONN -- set connection information (socket description) -** -** Parameters: -** oconn -- new connection information. -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -int -smfi_setconn(oconn) - char *oconn; -{ - size_t l; - - if (oconn == NULL || *oconn == '\0') - return MI_FAILURE; - l = strlen(oconn) + 1; - if ((conn = (char *) malloc(l)) == NULL) - return MI_FAILURE; - if (sm_strlcpy(conn, oconn, l) >= l) - return MI_FAILURE; - return MI_SUCCESS; -} - -/* -** SMFI_SETBACKLOG -- set backlog -** -** Parameters: -** obacklog -- new backlog. -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -int -smfi_setbacklog(obacklog) - int obacklog; -{ - if (obacklog <= 0) - return MI_FAILURE; - backlog = obacklog; - return MI_SUCCESS; -} - - -/* -** SMFI_MAIN -- setup milter connnection and start listener. -** -** Parameters: -** none. -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -int -smfi_main() -{ - int r; - - (void) signal(SIGPIPE, SIG_IGN); - if (conn == NULL) - { - smi_log(SMI_LOG_FATAL, "%s: missing connection information", - smfi->xxfi_name); - return MI_FAILURE; - } - - (void) atexit(mi_clean_signals); - if (mi_control_startup(smfi->xxfi_name) != MI_SUCCESS) - { - smi_log(SMI_LOG_FATAL, - "%s: Couldn't start signal thread", - smfi->xxfi_name); - return MI_FAILURE; - } - r = MI_SUCCESS; - - /* Startup the listener */ - if (mi_listener(conn, dbg, smfi, timeout, backlog) != MI_SUCCESS) - r = MI_FAILURE; - return r; -} - diff --git a/contrib/sendmail/libmilter/signal.c b/contrib/sendmail/libmilter/signal.c deleted file mode 100644 index aeb307a687ff..000000000000 --- a/contrib/sendmail/libmilter/signal.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 1999-2002 Sendmail, Inc. and its suppliers. - * All rights reserved. - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the sendmail distribution. - * - */ - -#include <sm/gen.h> -SM_RCSID("@(#)$Id: signal.c,v 8.37.2.2 2002/10/23 16:52:00 ca Exp $") - -#include "libmilter.h" - -/* -** thread to handle signals -*/ - -static smutex_t M_Mutex; - -static int MilterStop = MILTER_CONT; - -/* -** MI_STOP -- return value of MilterStop -** -** Parameters: -** none. -** -** Returns: -** value of MilterStop -*/ - -int -mi_stop() -{ - return MilterStop; -} -/* -** MI_STOP_MILTERS -- set value of MilterStop -** -** Parameters: -** v -- new value for MilterStop. -** -** Returns: -** none. -*/ - -void -mi_stop_milters(v) - int v; -{ - (void) smutex_lock(&M_Mutex); - if (MilterStop < v) - MilterStop = v; - - /* close listen socket */ - mi_closener(); - (void) smutex_unlock(&M_Mutex); -} -/* -** MI_CLEAN_SIGNALS -- clean up signal handler thread -** -** Parameters: -** none. -** -** Returns: -** none. -*/ - -void -mi_clean_signals() -{ - (void) smutex_destroy(&M_Mutex); -} -/* -** MI_SIGNAL_THREAD -- thread to deal with signals -** -** Parameters: -** name -- name of milter -** -** Returns: -** NULL -*/ - -static void * -mi_signal_thread(name) - void *name; -{ - int sig, errs; - sigset_t set; - - sigemptyset(&set); - sigaddset(&set, SIGHUP); - sigaddset(&set, SIGTERM); - - /* Handle Ctrl-C gracefully for debugging */ - sigaddset(&set, SIGINT); - errs = 0; - - while (true) - { - sig = 0; -#if defined(SOLARIS) || defined(__svr5__) - if ((sig = sigwait(&set)) < 0) -#else /* defined(SOLARIS) || defined(__svr5__) */ - if (sigwait(&set, &sig) != 0) -#endif /* defined(SOLARIS) || defined(__svr5__) */ - { - /* this can happen on OSF/1 (at least) */ - if (errno == EINTR) - continue; - smi_log(SMI_LOG_ERR, - "%s: sigwait returned error: %d", - (char *)name, errno); - if (++errs > MAX_FAILS_T) - { - mi_stop_milters(MILTER_ABRT); - return NULL; - } - continue; - } - errs = 0; - - switch (sig) - { - case SIGHUP: - case SIGTERM: - mi_stop_milters(MILTER_STOP); - return NULL; - case SIGINT: - mi_stop_milters(MILTER_ABRT); - return NULL; - default: - smi_log(SMI_LOG_ERR, - "%s: sigwait returned unmasked signal: %d", - (char *)name, sig); - break; - } - } -} -/* -** MI_SPAWN_SIGNAL_THREAD -- spawn thread to handle signals -** -** Parameters: -** name -- name of milter -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -static int -mi_spawn_signal_thread(name) - char *name; -{ - sthread_t tid; - int r; - sigset_t set; - - /* Mask HUP and KILL signals */ - sigemptyset(&set); - sigaddset(&set, SIGHUP); - sigaddset(&set, SIGTERM); - sigaddset(&set, SIGINT); - - if (pthread_sigmask(SIG_BLOCK, &set, NULL) != 0) - { - smi_log(SMI_LOG_ERR, - "%s: Couldn't mask HUP and KILL signals", name); - return MI_FAILURE; - } - r = thread_create(&tid, mi_signal_thread, (void *)name); - if (r != 0) - { - smi_log(SMI_LOG_ERR, - "%s: Couldn't start signal thread: %d", - name, r); - return MI_FAILURE; - } - return MI_SUCCESS; -} -/* -** MI_CONTROL_STARTUP -- startup for thread to handle signals -** -** Parameters: -** name -- name of milter -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -int -mi_control_startup(name) - char *name; -{ - - if (!smutex_init(&M_Mutex)) - { - smi_log(SMI_LOG_ERR, - "%s: Couldn't initialize control pipe mutex", name); - return MI_FAILURE; - } - - /* - ** spawn_signal_thread must happen before other threads are spawned - ** off so that it can mask the right signals and other threads - ** will inherit that mask. - */ - if (mi_spawn_signal_thread(name) == MI_FAILURE) - { - smi_log(SMI_LOG_ERR, - "%s: Couldn't spawn signal thread", name); - (void) smutex_destroy(&M_Mutex); - return MI_FAILURE; - } - return MI_SUCCESS; -} diff --git a/contrib/sendmail/libmilter/sm_gethost.c b/contrib/sendmail/libmilter/sm_gethost.c deleted file mode 100644 index 171474135c8c..000000000000 --- a/contrib/sendmail/libmilter/sm_gethost.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 1999-2001 Sendmail, Inc. and its suppliers. - * All rights reserved. - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the sendmail distribution. - * - */ - -#include <sm/gen.h> -SM_RCSID("@(#)$Id: sm_gethost.c,v 8.26 2001/09/11 04:04:45 gshapiro Exp $") - -#include <sendmail.h> -#if NETINET || NETINET6 -# include <arpa/inet.h> -#endif /* NETINET || NETINET6 */ - -/* -** MI_GETHOSTBY{NAME,ADDR} -- compatibility routines for gethostbyXXX -** -** Some operating systems have wierd problems with the gethostbyXXX -** routines. For example, Solaris versions at least through 2.3 -** don't properly deliver a canonical h_name field. This tries to -** work around these problems. -** -** Support IPv6 as well as IPv4. -*/ - -#if NETINET6 && NEEDSGETIPNODE - -# ifndef AI_ADDRCONFIG -# define AI_ADDRCONFIG 0 /* dummy */ -# endif /* ! AI_ADDRCONFIG */ -# ifndef AI_ALL -# define AI_ALL 0 /* dummy */ -# endif /* ! AI_ALL */ -# ifndef AI_DEFAULT -# define AI_DEFAULT 0 /* dummy */ -# endif /* ! AI_DEFAULT */ - -static struct hostent * -getipnodebyname(name, family, flags, err) - char *name; - int family; - int flags; - int *err; -{ - bool resv6 = true; - struct hostent *h; - - if (family == AF_INET6) - { - /* From RFC2133, section 6.1 */ - resv6 = bitset(RES_USE_INET6, _res.options); - _res.options |= RES_USE_INET6; - } - SM_SET_H_ERRNO(0); - h = gethostbyname(name); - if (family == AF_INET6 && !resv6) - _res.options &= ~RES_USE_INET6; - *err = h_errno; - return h; -} - -void -freehostent(h) - struct hostent *h; -{ - /* - ** Stub routine -- if they don't have getipnodeby*(), - ** they probably don't have the free routine either. - */ - - return; -} -#endif /* NEEDSGETIPNODE && NETINET6 */ - -struct hostent * -mi_gethostbyname(name, family) - char *name; - int family; -{ - struct hostent *h = NULL; -#if (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4)) -# if SOLARIS == 20300 || SOLARIS == 203 - static struct hostent hp; - static char buf[1000]; - extern struct hostent *_switch_gethostbyname_r(); - - h = _switch_gethostbyname_r(name, &hp, buf, sizeof(buf), &h_errno); -# else /* SOLARIS == 20300 || SOLARIS == 203 */ - extern struct hostent *__switch_gethostbyname(); - - h = __switch_gethostbyname(name); -# endif /* SOLARIS == 20300 || SOLARIS == 203 */ -#else /* (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4)) */ -# if NETINET6 - int flags = AI_DEFAULT|AI_ALL; - int err; -# endif /* NETINET6 */ - -# if NETINET6 -# if ADDRCONFIG_IS_BROKEN - flags &= ~AI_ADDRCONFIG; -# endif /* ADDRCONFIG_IS_BROKEN */ - h = getipnodebyname(name, family, flags, &err); - SM_SET_H_ERRNO(err); -# else /* NETINET6 */ - h = gethostbyname(name); -# endif /* NETINET6 */ - -#endif /* (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4)) */ - return h; -} - -#if NETINET6 -/* -** MI_INET_PTON -- convert printed form to network address. -** -** Wrapper for inet_pton() which handles IPv6: labels. -** -** Parameters: -** family -- address family -** src -- string -** dst -- destination address structure -** -** Returns: -** 1 if the address was valid -** 0 if the address wasn't parseable -** -1 if error -*/ - -int -mi_inet_pton(family, src, dst) - int family; - const char *src; - void *dst; -{ - if (family == AF_INET6 && - strncasecmp(src, "IPv6:", 5) == 0) - src += 5; - return inet_pton(family, src, dst); -} -#endif /* NETINET6 */ diff --git a/contrib/sendmail/libmilter/smfi.c b/contrib/sendmail/libmilter/smfi.c deleted file mode 100644 index 032a6acb288f..000000000000 --- a/contrib/sendmail/libmilter/smfi.c +++ /dev/null @@ -1,613 +0,0 @@ -/* - * Copyright (c) 1999-2002 Sendmail, Inc. and its suppliers. - * All rights reserved. - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the sendmail distribution. - * - */ - -#include <sm/gen.h> -SM_RCSID("@(#)$Id: smfi.c,v 8.64 2002/04/30 22:22:02 msk Exp $") -#include <sm/varargs.h> -#include "libmilter.h" - -/* for smfi_set{ml}reply, let's be generous. 256/16 should be sufficient */ -#define MAXREPLYLEN 980 /* max. length of a reply string */ -#define MAXREPLIES 32 /* max. number of reply strings */ - -/* -** SMFI_ADDHEADER -- send a new header to the MTA -** -** Parameters: -** ctx -- Opaque context structure -** headerf -- Header field name -** headerv -- Header field value -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -int -smfi_addheader(ctx, headerf, headerv) - SMFICTX *ctx; - char *headerf; - char *headerv; -{ - /* do we want to copy the stuff or have a special mi_wr_cmd call? */ - size_t len, l1, l2; - int r; - char *buf; - struct timeval timeout; - - if (headerf == NULL || *headerf == '\0' || headerv == NULL) - return MI_FAILURE; - if (!mi_sendok(ctx, SMFIF_ADDHDRS)) - return MI_FAILURE; - timeout.tv_sec = ctx->ctx_timeout; - timeout.tv_usec = 0; - l1 = strlen(headerf); - l2 = strlen(headerv); - len = l1 + l2 + 2; - buf = malloc(len); - if (buf == NULL) - return MI_FAILURE; - (void) memcpy(buf, headerf, l1 + 1); - (void) memcpy(buf + l1 + 1, headerv, l2 + 1); - r = mi_wr_cmd(ctx->ctx_sd, &timeout, SMFIR_ADDHEADER, buf, len); - free(buf); - return r; -} - -/* -** SMFI_CHGHEADER -- send a changed header to the MTA -** -** Parameters: -** ctx -- Opaque context structure -** headerf -- Header field name -** hdridx -- Header index value -** headerv -- Header field value -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -int -smfi_chgheader(ctx, headerf, hdridx, headerv) - SMFICTX *ctx; - char *headerf; - mi_int32 hdridx; - char *headerv; -{ - /* do we want to copy the stuff or have a special mi_wr_cmd call? */ - size_t len, l1, l2; - int r; - mi_int32 v; - char *buf; - struct timeval timeout; - - if (headerf == NULL || *headerf == '\0') - return MI_FAILURE; - if (hdridx < 0) - return MI_FAILURE; - if (!mi_sendok(ctx, SMFIF_CHGHDRS)) - return MI_FAILURE; - timeout.tv_sec = ctx->ctx_timeout; - timeout.tv_usec = 0; - if (headerv == NULL) - headerv = ""; - l1 = strlen(headerf); - l2 = strlen(headerv); - len = l1 + l2 + 2 + MILTER_LEN_BYTES; - buf = malloc(len); - if (buf == NULL) - return MI_FAILURE; - v = htonl(hdridx); - (void) memcpy(&(buf[0]), (void *) &v, MILTER_LEN_BYTES); - (void) memcpy(buf + MILTER_LEN_BYTES, headerf, l1 + 1); - (void) memcpy(buf + MILTER_LEN_BYTES + l1 + 1, headerv, l2 + 1); - r = mi_wr_cmd(ctx->ctx_sd, &timeout, SMFIR_CHGHEADER, buf, len); - free(buf); - return r; -} - -/* -** SMFI_ADDRCPT -- send an additional recipient to the MTA -** -** Parameters: -** ctx -- Opaque context structure -** rcpt -- recipient address -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -int -smfi_addrcpt(ctx, rcpt) - SMFICTX *ctx; - char *rcpt; -{ - size_t len; - struct timeval timeout; - - if (rcpt == NULL || *rcpt == '\0') - return MI_FAILURE; - if (!mi_sendok(ctx, SMFIF_ADDRCPT)) - return MI_FAILURE; - timeout.tv_sec = ctx->ctx_timeout; - timeout.tv_usec = 0; - 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 -** -** Parameters: -** ctx -- Opaque context structure -** rcpt -- recipient address -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -int -smfi_delrcpt(ctx, rcpt) - SMFICTX *ctx; - char *rcpt; -{ - size_t len; - struct timeval timeout; - - if (rcpt == NULL || *rcpt == '\0') - return MI_FAILURE; - if (!mi_sendok(ctx, SMFIF_DELRCPT)) - return MI_FAILURE; - timeout.tv_sec = ctx->ctx_timeout; - timeout.tv_usec = 0; - 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 -** -** Parameters: -** ctx -- Opaque context structure -** bodyp -- body chunk -** bodylen -- length of body chunk -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -int -smfi_replacebody(ctx, bodyp, bodylen) - SMFICTX *ctx; - unsigned char *bodyp; - int bodylen; -{ - int len, off, r; - struct timeval timeout; - - if (bodylen < 0 || - (bodyp == NULL && bodylen > 0)) - return MI_FAILURE; - if (!mi_sendok(ctx, SMFIF_CHGBODY)) - return MI_FAILURE; - timeout.tv_sec = ctx->ctx_timeout; - timeout.tv_usec = 0; - - /* split body chunk if necessary */ - off = 0; - while (bodylen > 0) - { - len = (bodylen >= MILTER_CHUNK_SIZE) ? MILTER_CHUNK_SIZE : - bodylen; - if ((r = mi_wr_cmd(ctx->ctx_sd, &timeout, SMFIR_REPLBODY, - (char *) (bodyp + off), len)) != MI_SUCCESS) - return r; - off += len; - bodylen -= len; - } - return MI_SUCCESS; -} - -#if _FFR_QUARANTINE -/* -** SMFI_QUARANTINE -- quarantine an envelope -** -** Parameters: -** ctx -- Opaque context structure -** reason -- why? -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -int -smfi_quarantine(ctx, reason) - SMFICTX *ctx; - char *reason; -{ - size_t len; - int r; - char *buf; - struct timeval timeout; - - if (reason == NULL || *reason == '\0') - return MI_FAILURE; - if (!mi_sendok(ctx, SMFIF_QUARANTINE)) - return MI_FAILURE; - timeout.tv_sec = ctx->ctx_timeout; - timeout.tv_usec = 0; - len = strlen(reason) + 1; - buf = malloc(len); - if (buf == NULL) - return MI_FAILURE; - (void) memcpy(buf, reason, len); - r = mi_wr_cmd(ctx->ctx_sd, &timeout, SMFIR_QUARANTINE, buf, len); - free(buf); - return r; -} -#endif /* _FFR_QUARANTINE */ - -/* -** MYISENHSC -- check whether a string contains an enhanced status code -** -** Parameters: -** s -- string with possible enhanced status code. -** delim -- delim for enhanced status code. -** -** Returns: -** 0 -- no enhanced status code. -** >4 -- length of enhanced status code. -** -** Side Effects: -** none. -*/ - -static int -myisenhsc(s, delim) - const char *s; - int delim; -{ - int l, h; - - if (s == NULL) - return 0; - if (!((*s == '2' || *s == '4' || *s == '5') && s[1] == '.')) - return 0; - h = 0; - l = 2; - while (h < 3 && isascii(s[l + h]) && isdigit(s[l + h])) - ++h; - if (h == 0 || s[l + h] != '.') - return 0; - l += h + 1; - h = 0; - while (h < 3 && isascii(s[l + h]) && isdigit(s[l + h])) - ++h; - if (h == 0 || s[l + h] != delim) - return 0; - return l + h; -} - -/* -** SMFI_SETREPLY -- set the reply code for the next reply to the MTA -** -** Parameters: -** ctx -- Opaque context structure -** rcode -- The three-digit (RFC 821) SMTP reply code. -** xcode -- The extended (RFC 2034) reply code. -** message -- The text part of the SMTP reply. -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -int -smfi_setreply(ctx, rcode, xcode, message) - SMFICTX *ctx; - char *rcode; - char *xcode; - char *message; -{ - size_t len; - char *buf; - - if (rcode == NULL || ctx == NULL) - return MI_FAILURE; - - /* ### <sp> \0 */ - len = strlen(rcode) + 2; - if (len != 5) - return MI_FAILURE; - if ((rcode[0] != '4' && rcode[0] != '5') || - !isascii(rcode[1]) || !isdigit(rcode[1]) || - !isascii(rcode[2]) || !isdigit(rcode[2])) - return MI_FAILURE; - if (xcode != NULL) - { - if (!myisenhsc(xcode, '\0')) - return MI_FAILURE; - len += strlen(xcode) + 1; - } - if (message != NULL) - { - size_t ml; - - /* XXX check also for unprintable chars? */ - if (strpbrk(message, "\r\n") != NULL) - return MI_FAILURE; - ml = strlen(message); - if (ml > MAXREPLYLEN) - return MI_FAILURE; - len += ml + 1; - } - buf = malloc(len); - if (buf == NULL) - return MI_FAILURE; /* oops */ - (void) sm_strlcpy(buf, rcode, len); - (void) sm_strlcat(buf, " ", len); - if (xcode != NULL) - (void) sm_strlcat(buf, xcode, len); - if (message != NULL) - { - if (xcode != NULL) - (void) sm_strlcat(buf, " ", len); - (void) sm_strlcat(buf, message, len); - } - if (ctx->ctx_reply != NULL) - free(ctx->ctx_reply); - ctx->ctx_reply = buf; - return MI_SUCCESS; -} - -#if _FFR_MULTILINE -/* -** SMFI_SETMLREPLY -- set multiline reply code for the next reply to the MTA -** -** Parameters: -** ctx -- Opaque context structure -** rcode -- The three-digit (RFC 821) SMTP reply code. -** xcode -- The extended (RFC 2034) reply code. -** txt, ... -- The text part of the SMTP reply, -** MUST be terminated with NULL. -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -int -#if SM_VA_STD -smfi_setmlreply(SMFICTX *ctx, const char *rcode, const char *xcode, ...) -#else /* SM_VA_STD */ -smfi_setmlreply(ctx, rcode, xcode, va_alist) - SMFICTX *ctx; - const char *rcode; - const char *xcode; - va_dcl -#endif /* SM_VA_STD */ -{ - size_t len; - size_t rlen; - int args; - char *buf, *txt; - const char *xc; - char repl[16]; - SM_VA_LOCAL_DECL - - if (rcode == NULL || ctx == NULL) - return MI_FAILURE; - - /* ### <sp> */ - len = strlen(rcode) + 1; - if (len != 4) - return MI_FAILURE; - if ((rcode[0] != '4' && rcode[0] != '5') || - !isascii(rcode[1]) || !isdigit(rcode[1]) || - !isascii(rcode[2]) || !isdigit(rcode[2])) - return MI_FAILURE; - if (xcode != NULL) - { - if (!myisenhsc(xcode, '\0')) - return MI_FAILURE; - xc = xcode; - } - else - { - if (rcode[0] == '4') - xc = "4.0.0"; - else - xc = "5.0.0"; - } - - /* add trailing space */ - len += strlen(xc) + 1; - rlen = len; - args = 0; - SM_VA_START(ap, xcode); - while ((txt = SM_VA_ARG(ap, char *)) != NULL) - { - size_t tl; - - tl = strlen(txt); - if (tl > MAXREPLYLEN) - break; - - /* this text, reply codes, \r\n */ - len += tl + 2 + rlen; - if (++args > MAXREPLIES) - break; - - /* XXX check also for unprintable chars? */ - if (strpbrk(txt, "\r\n") != NULL) - break; - } - SM_VA_END(ap); - if (txt != NULL) - return MI_FAILURE; - - /* trailing '\0' */ - ++len; - buf = malloc(len); - if (buf == NULL) - return MI_FAILURE; /* oops */ - (void) sm_strlcpyn(buf, len, 3, rcode, args == 1 ? " " : "-", xc); - (void) sm_strlcpyn(repl, sizeof repl, 4, rcode, args == 1 ? " " : "-", - xc, " "); - SM_VA_START(ap, xcode); - txt = SM_VA_ARG(ap, char *); - if (txt != NULL) - { - (void) sm_strlcat2(buf, " ", txt, len); - while ((txt = SM_VA_ARG(ap, char *)) != NULL) - { - if (--args <= 1) - repl[3] = ' '; - (void) sm_strlcat2(buf, "\r\n", repl, len); - (void) sm_strlcat(buf, txt, len); - } - } - if (ctx->ctx_reply != NULL) - free(ctx->ctx_reply); - ctx->ctx_reply = buf; - SM_VA_END(ap); - return MI_SUCCESS; -} -#endif /* _FFR_MULTILINE */ - -/* -** SMFI_SETPRIV -- set private data -** -** Parameters: -** ctx -- Opaque context structure -** privatedata -- pointer to private data -** -** Returns: -** MI_SUCCESS/MI_FAILURE -*/ - -int -smfi_setpriv(ctx, privatedata) - SMFICTX *ctx; - void *privatedata; -{ - if (ctx == NULL) - return MI_FAILURE; - ctx->ctx_privdata = privatedata; - return MI_SUCCESS; -} - -/* -** SMFI_GETPRIV -- get private data -** -** Parameters: -** ctx -- Opaque context structure -** -** Returns: -** pointer to private data -*/ - -void * -smfi_getpriv(ctx) - SMFICTX *ctx; -{ - if (ctx == NULL) - return NULL; - return ctx->ctx_privdata; -} - -/* -** SMFI_GETSYMVAL -- get the value of a macro -** -** See explanation in mfapi.h about layout of the structures. -** -** Parameters: -** ctx -- Opaque context structure -** symname -- name of macro -** -** Returns: -** value of macro (NULL in case of failure) -*/ - -char * -smfi_getsymval(ctx, symname) - SMFICTX *ctx; - char *symname; -{ - int i; - char **s; - char one[2]; - char braces[4]; - - if (ctx == NULL || symname == NULL || *symname == '\0') - return NULL; - - if (strlen(symname) == 3 && symname[0] == '{' && symname[2] == '}') - { - one[0] = symname[1]; - one[1] = '\0'; - } - else - one[0] = '\0'; - if (strlen(symname) == 1) - { - braces[0] = '{'; - braces[1] = *symname; - braces[2] = '}'; - braces[3] = '\0'; - } - else - braces[0] = '\0'; - - /* search backwards through the macro array */ - for (i = MAX_MACROS_ENTRIES - 1 ; i >= 0; --i) - { - if ((s = ctx->ctx_mac_ptr[i]) == NULL || - ctx->ctx_mac_buf[i] == NULL) - continue; - while (s != NULL && *s != NULL) - { - if (strcmp(*s, symname) == 0) - return *++s; - if (one[0] != '\0' && strcmp(*s, one) == 0) - return *++s; - if (braces[0] != '\0' && strcmp(*s, braces) == 0) - return *++s; - ++s; /* skip over macro value */ - ++s; /* points to next macro name */ - } - } - 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 */ |