Mail addresses (PLEASE send questions to the mailing list)
- postfix-XXX@postfix.org Postfix mailing lists
+ postfix-users@postfix.org Postfix users mailing list
wietse@porcupine.org the original author
-In order to subscribe to a mailing list, see http://www.postfix.org/.
+In order to subscribe to the mailing list, see http://www.postfix.org/.
Acknowledgments
===============
mailq yes
majordomo yes (edit approve script to delete /^delivered-to:/i)
mime yes (including 8bit to quoted-printable conversion)
-mime conversion not yet; postfix uses just-send-eight
mysql tables yes (contributed)
netinfo tables yes (contributed)
newaliases yes (main alias database only)
reorganization of the way queue scans were done. The queue
manager socket now has become public.
-10091002
+19981002
SMTPD now logs "lost connection after end-of-message" instead
of "lost connection after DATA".
-10091005
+19981005
More bullet proofing: timeouts on all triggers.
Richard Stockton, Gramma Software. Files:
cleanup/cleanup_envelope.c, cleanup/cleanup_extracted.c
+20030528
+
+ Compatibility: "sendmail -q<time>" without -bd option now
+ exits immediately, instead of waiting for input on the
+ standard input stream and screwing up system boot sequences.
+ File: sendmail/sendmail.c.
+
+ Bugfix: the Postfix LMTP client used the wrong service
+ name, causing trouble with SASL 2.1.13. Daniel Schales,
+ Louisiana Tech. File: lmtp/lmtp_sasl_glue.c.
+
+ Workaround: IRIX select() reports that a non-blocking file
+ descriptor is writable while write() transfers zero bytes.
+ File: global/pipe_command.c.
+
+ Feature: "postcat -q" (search the queue for the named file)
+ support copied from snapshot release because I can't see
+ people suffer. File: postcat/postcat.c.
+
+20030530
+
+ Bugfix: client access denied with smtpd_delay_reject=no
+ broke "sendmail -bs". Fix by Victor Duchovni, Morgan Stanley.
+ File: smtpd/smtpd.c.
+
+20030531
+
+ Compatibility: allow <@site,@site:address> route addresses
+ in SMTP commands. File: smtpd/smtpd.c.
+
+20030605
+
+ Bugfix: the "dead host" backoff timer in the MySQL client
+ didn't work. Fix by Leandro Santi. File: util/dict_mysql.c.
+
+ Safety: stricter checks on what queue file records the
+ postdrop submission command accepts (idea copied from
+ snapshot). File: postdrop/postdrop.c.
+
+ Workaround: turned off non-blocking write to pipe because
+ too many systems give a weird write() result. File:
+ global/pipe_command.c.
+
+20030609
+
+ Workaround: Solaris non-blocking socket read() may hang.
+ Leandro Santi. File: smtpd/smtpd.c.
+
Open problems:
Low: smtp-source may block when sending large test messages.
precedence over filters specified with the main.cf content_filter
parameter.
-- Only the last FILTER action from smtpd access maps or in
+- Only the last FILTER action from smtpd access maps or from
header/body_checks takes effect.
- The same content filter is applied to all the recipients of a
postcat - show Postfix queue file contents
<b>SYNOPSIS</b>
- <b>postcat</b> [<b>-v</b>] [<i>files</i>...]
+ <b>postcat</b> [<b>-vq</b>] [<b>-c</b> <i>config_dir</i>] [<i>files</i>...]
<b>DESCRIPTION</b>
- The <b>postcat</b> command prints the contents of the named Post-
- fix queue <i>files</i> in human-readable form. If no <i>files</i> are
- specified on the command line, the program reads from
- standard input.
+ The <b>postcat</b> command prints the contents of the named <i>files</i>
+ in human-readable form. The files are expected to be in
+ Postfix queue file format. If no <i>files</i> are specified on
+ the command line, the program reads from standard input.
Options:
+ <b>-c</b> <i>config_dir</i>
+ The <b>main.cf</b> configuration file is in the named
+ directory instead of the default configuration
+ directory.
+
+ <b>-q</b> Search the Postfix queue for <i>files</i>. By default,
+ file names are taken literally.
+
<b>-v</b> Enable verbose logging for debugging purposes. Mul-
- tiple <b>-v</b> options make the software increasingly
+ tiple <b>-v</b> options make the software increasingly
verbose.
<b>DIAGNOSTICS</b>
Problems are reported to the standard error stream.
+<b>ENVIRONMENT</b>
+ <b>MAIL</b><i>_</i><b>CONFIG</b>
+ Directory with Postfix configuration files.
+
+<b>CONFIGURATION</b> <b>PARAMETERS</b>
+ See the Postfix <b>main.cf</b> file for syntax details and for
+ default values. Use the <b>postfix</b> <b>reload</b> command after a
+ configuration change.
+
+ <b>queue</b><i>_</i><b>directory</b>
+ Top-level directory of the Postfix queue. This is
+ also the root directory of Postfix daemons that run
+ chrooted.
+
<b>LICENSE</b>
- The Secure Mailer license must be distributed with this
+ The Secure Mailer license must be distributed with this
software.
<b>AUTHOR(S)</b>
<b>virtual</b><i>_</i><b>minimum</b><i>_</i><b>uid</b>
Specifies a minimum uid that will be accepted as a
- return from a <b>virtual</b><i>_</i><b>owner</b><i>_</i><b>maps</b> or <b>vir-</b>
- <b>tual</b><i>_</i><b>uid</b><i>_</i><b>maps</b> lookup. Returned values less than
- this will be rejected, and the message will be
- deferred.
+ return from a <b>virtual</b><i>_</i><b>uid</b><i>_</i><b>maps</b> lookup. Returned
+ values less than this will be rejected, and the
+ message will be deferred.
<b>virtual</b><i>_</i><b>uid</b><i>_</i><b>maps</b>
Recipients are looked up in these maps to determine
- the user ID to be used when writing to the target
+ the user ID to be used when writing to the target
mailbox.
- While searching a lookup table, an address exten-
+ While searching a lookup table, an address exten-
sion (<i>user+foo@domain.tld</i>) is ignored.
- In a lookup table, specify a left-hand side of
- <i>@domain.tld</i> to match any user in the specified
- domain that does not have a specific
+ In a lookup table, specify a left-hand side of
+ <i>@domain.tld</i> to match any user in the specified
+ domain that does not have a specific
<i>user@domain.tld</i> entry.
- For security reasons, regular expression maps are
- allowed but regular expression substitution of $1
+ For security reasons, regular expression maps are
+ allowed but regular expression substitution of $1
etc. is disallowed, because that would open a secu-
rity hole.
- For security reasons, proxied table lookup is not
+ For security reasons, proxied table lookup is not
allowed, because that would open a security hole.
<b>virtual</b><i>_</i><b>gid</b><i>_</i><b>maps</b>
Recipients are looked up in these maps to determine
- the group ID to be used when writing to the target
+ the group ID to be used when writing to the target
mailbox.
- While searching a lookup table, an address exten-
+ While searching a lookup table, an address exten-
sion (<i>user+foo@domain.tld</i>) is ignored.
- In a lookup table, specify a left-hand side of
- <i>@domain.tld</i> to match any user in the specified
- domain that does not have a specific
+ In a lookup table, specify a left-hand side of
+ <i>@domain.tld</i> to match any user in the specified
+ domain that does not have a specific
<i>user@domain.tld</i> entry.
- For security reasons, regular expression maps are
- allowed but regular expression substitution of $1
+ For security reasons, regular expression maps are
+ allowed but regular expression substitution of $1
etc. is disallowed, because that would open a secu-
rity hole.
- For security reasons, proxied table lookup is not
+ For security reasons, proxied table lookup is not
allowed, because that would open a security hole.
<b>Locking</b> <b>controls</b>
<b>virtual</b><i>_</i><b>mailbox</b><i>_</i><b>lock</b>
- How to lock UNIX-style mailboxes: one or more of
- <b>flock</b>, <b>fcntl</b> or <b>dotlock</b>. The <b>dotlock</b> method
- requires that the recipient UID or GID has write
+ How to lock UNIX-style mailboxes: one or more of
+ <b>flock</b>, <b>fcntl</b> or <b>dotlock</b>. The <b>dotlock</b> method
+ requires that the recipient UID or GID has write
access to the parent directory of the mailbox file.
- This setting is ignored with <b>maildir</b> style deliv-
+ This setting is ignored with <b>maildir</b> style deliv-
ery, because such deliveries are safe without
explicit locks.
- Use the command <b>postconf</b> <b>-l</b> to find out what lock-
+ Use the command <b>postconf</b> <b>-l</b> to find out what lock-
ing methods are available on your system.
<b>deliver</b><i>_</i><b>lock</b><i>_</i><b>attempts</b>
- Limit the number of attempts to acquire an exclu-
+ Limit the number of attempts to acquire an exclu-
sive lock on a UNIX-style mailbox file.
<b>deliver</b><i>_</i><b>lock</b><i>_</i><b>delay</b>
Time (default: seconds) between successive attempts
- to acquire an exclusive lock on a UNIX-style mail-
- box file. The actual delay is slightly randomized.
+ to acquire an exclusive lock on a UNIX-style mail-
+ box file. The actual delay is slightly randomized.
<b>stale</b><i>_</i><b>lock</b><i>_</i><b>time</b>
- Limit the time after which a stale lockfile is
- removed (applicable to UNIX-style mailboxes only).
+ Limit the time after which a stale lockfile is
+ removed (applicable to UNIX-style mailboxes only).
<b>Resource</b> <b>controls</b>
<b>virtual</b><i>_</i><b>destination</b><i>_</i><b>concurrency</b><i>_</i><b>limit</b>
Limit the number of parallel deliveries to the same
domain via the <b>virtual</b> delivery agent. The default
limit is taken from the <b>default</b><i>_</i><b>destination</b><i>_</i><b>concur-</b>
- <b>rency</b><i>_</i><b>limit</b> parameter. The limit is enforced by
+ <b>rency</b><i>_</i><b>limit</b> parameter. The limit is enforced by
the Postfix queue manager.
<b>virtual</b><i>_</i><b>destination</b><i>_</i><b>recipient</b><i>_</i><b>limit</b>
Limit the number of recipients per message delivery
- via the <b>virtual</b> delivery agent. The default limit
- is taken from the <b>default</b><i>_</i><b>destination</b><i>_</i><b>recipi-</b>
- <b>ent</b><i>_</i><b>limit</b> parameter. The limit is enforced by the
+ via the <b>virtual</b> delivery agent. The default limit
+ is taken from the <b>default</b><i>_</i><b>destination</b><i>_</i><b>recipi-</b>
+ <b>ent</b><i>_</i><b>limit</b> parameter. The limit is enforced by the
Postfix queue manager.
<b>virtual</b><i>_</i><b>mailbox</b><i>_</i><b>limit</b>
- The maximal size in bytes of a mailbox or maildir
+ The maximal size in bytes of a mailbox or maildir
file. Set to zero to disable the limit.
<b>HISTORY</b>
- This agent was originally based on the Postfix local
+ This agent was originally based on the Postfix local
delivery agent. Modifications mainly consisted of removing
- code that either was not applicable or that was not safe
- in this context: aliases, ~user/.forward files, delivery
+ code that either was not applicable or that was not safe
+ in this context: aliases, ~user/.forward files, delivery
to "|command" or to /file/name.
- The <b>Delivered-To:</b> header appears in the <b>qmail</b> system by
+ The <b>Delivered-To:</b> header appears in the <b>qmail</b> system by
Daniel Bernstein.
- The <b>maildir</b> structure appears in the <b>qmail</b> system by
+ The <b>maildir</b> structure appears in the <b>qmail</b> system by
Daniel Bernstein.
<b>SEE</b> <b>ALSO</b>
<a href="qmgr.8.html">qmgr(8)</a> queue manager
<b>LICENSE</b>
- The Secure Mailer license must be distributed with this
+ The Secure Mailer license must be distributed with this
software.
<b>AUTHOR(S)</b>
.SH SYNOPSIS
.na
.nf
-\fBpostcat\fR [\fB-v\fR] [\fIfiles\fR...]
+\fBpostcat\fR [\fB-vq\fR] [\fB-c \fIconfig_dir\fR] [\fIfiles\fR...]
.SH DESCRIPTION
.ad
.fi
The \fBpostcat\fR command prints the contents of the named
-Postfix queue \fIfiles\fR in human-readable form. If no
+\fIfiles\fR in human-readable form. The files are expected
+to be in Postfix queue file format. If no
\fIfiles\fR are specified on the command line, the program
reads from standard input.
Options:
+.IP "\fB-c \fIconfig_dir\fR"
+The \fBmain.cf\fR configuration file is in the named directory
+instead of the default configuration directory.
+.IP \fB-q\fR
+Search the Postfix queue for \fIfiles\fR. By default,
+file names are taken literally.
.IP \fB-v\fR
Enable verbose logging for debugging purposes. Multiple \fB-v\fR
options make the software increasingly verbose.
.ad
.fi
Problems are reported to the standard error stream.
+.SH ENVIRONMENT
+.na
+.nf
+.ad
+.fi
+.IP \fBMAIL_CONFIG\fR
+Directory with Postfix configuration files.
+.SH CONFIGURATION PARAMETERS
+.na
+.nf
+.ad
+.fi
+See the Postfix \fBmain.cf\fR file for syntax details and for
+default values. Use the \fBpostfix reload\fR command after a
+configuration change.
+.IP \fBqueue_directory\fR
+Top-level directory of the Postfix queue. This is also the root
+directory of Postfix daemons that run chrooted.
.SH LICENSE
.na
.nf
configuration parameter.
.IP \fBvirtual_minimum_uid\fR
Specifies a minimum uid that will be accepted as a return from
-a \fBvirtual_owner_maps\fR or \fBvirtual_uid_maps\fR lookup.
+a \fBvirtual_uid_maps\fR lookup.
Returned values less than this will be rejected, and the message
will be deferred.
.IP \fBvirtual_uid_maps\fR
}
}
if (type == REC_TYPE_TIME) {
- state->time = atol(buf);
+ if (state->time == 0)
+ state->time = atol(buf);
cleanup_out(state, type, buf, len);
} else if (type == REC_TYPE_FULL) {
- state->fullname = mystrdup(buf);
+ if (state->fullname == 0)
+ state->fullname = mystrdup(buf);
} else if (type == REC_TYPE_FROM) {
VSTRING *clean_addr = vstring_alloc(100);
* Patches change the patchlevel and the release date. Snapshots change the
* release date only, unless they include the same bugfix as a patch release.
*/
-#define MAIL_RELEASE_DATE "20030521"
+#define MAIL_RELEASE_DATE "20030609"
#define VAR_MAIL_VERSION "mail_version"
-#define DEF_MAIL_VERSION "2.0.10"
+#define DEF_MAIL_VERSION "2.0.11"
extern char *var_mail_version;
/*
*
* Turn on non-blocking writes to the child process so that we can enforce
* timeouts after partial writes.
+ *
+ * XXX Too much trouble with different systems returning weird write()
+ * results when a pipe is writable.
*/
if (pipe(cmd_in_pipe) < 0 || pipe(cmd_out_pipe) < 0)
msg_fatal("%s: pipe: %m", myname);
non_blocking(cmd_out_pipe[1], NON_BLOCKING);
+#if 0
non_blocking(cmd_in_pipe[1], NON_BLOCKING);
+#endif
/*
* Spawn off a child process and irrevocably change privilege to the
#define REC_TYPE_CONTENT "XLN"
#define REC_TYPE_EXTRACT "EDROPreAFIL"
+ /*
+ * The subset of inputs that the postdrop command allows.
+ */
+#define REC_TYPE_POST_ENVELOPE "MFSRVA"
+#define REC_TYPE_POST_CONTENT "XLN"
+#define REC_TYPE_POST_EXTRACT "E"
+
/*
* The record at the beginning of the envelope segment specifies the message
* content size, data offset, and recipient count. These are fixed-width
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
/*--*/
-/**INDENT** Error@17: Unmatched #endif */
#endif
#define NULL_SERVER_ADDR ((char *) 0)
#define NULL_CLIENT_ADDR ((char *) 0)
- if (SASL_CLIENT_NEW("smtp", state->session->host,
+ if (SASL_CLIENT_NEW("lmtp", state->session->host,
NULL_CLIENT_ADDR, NULL_SERVER_ADDR,
state->sasl_callbacks, NULL_SECFLAGS,
(sasl_conn_t **) &state->sasl_conn) != SASL_OK)
token.o: ../../include/resolve_clnt.h
token.o: ../../include/mail_params.h
token.o: ../../include/bounce.h
+token.o: ../../include/defer.h
token.o: local.h
token.o: ../../include/been_here.h
token.o: ../../include/deliver_request.h
postcat.o: ../../include/vstring_vstream.h
postcat.o: ../../include/record.h
postcat.o: ../../include/rec_type.h
+postcat.o: ../../include/mail_queue.h
+postcat.o: ../../include/mail_conf.h
+postcat.o: ../../include/mail_params.h
/* SUMMARY
/* show Postfix queue file contents
/* SYNOPSIS
-/* \fBpostcat\fR [\fB-v\fR] [\fIfiles\fR...]
+/* \fBpostcat\fR [\fB-vq\fR] [\fB-c \fIconfig_dir\fR] [\fIfiles\fR...]
/* DESCRIPTION
/* The \fBpostcat\fR command prints the contents of the named
-/* Postfix queue \fIfiles\fR in human-readable form. If no
+/* \fIfiles\fR in human-readable form. The files are expected
+/* to be in Postfix queue file format. If no
/* \fIfiles\fR are specified on the command line, the program
/* reads from standard input.
/*
/* Options:
+/* .IP "\fB-c \fIconfig_dir\fR"
+/* The \fBmain.cf\fR configuration file is in the named directory
+/* instead of the default configuration directory.
+/* .IP \fB-q\fR
+/* Search the Postfix queue for \fIfiles\fR. By default,
+/* file names are taken literally.
/* .IP \fB-v\fR
/* Enable verbose logging for debugging purposes. Multiple \fB-v\fR
/* options make the software increasingly verbose.
/* DIAGNOSTICS
/* Problems are reported to the standard error stream.
+/* ENVIRONMENT
+/* .ad
+/* .fi
+/* .IP \fBMAIL_CONFIG\fR
+/* Directory with Postfix configuration files.
+/* CONFIGURATION PARAMETERS
+/* .ad
+/* .fi
+/* See the Postfix \fBmain.cf\fR file for syntax details and for
+/* default values. Use the \fBpostfix reload\fR command after a
+/* configuration change.
+/* .IP \fBqueue_directory\fR
+/* Top-level directory of the Postfix queue. This is also the root
+/* directory of Postfix daemons that run chrooted.
/* LICENSE
/* .ad
/* .fi
#include <record.h>
#include <rec_type.h>
+#include <mail_queue.h>
+#include <mail_conf.h>
+#include <mail_params.h>
/* Application-specific. */
+#define PC_FLAG_QUEUE (1<<0) /* search queue */
+
#define STR vstring_str
/* postcat - visualize Postfix queue file contents */
int ch;
#define TEXT_RECORD(rec_type) \
- (rec_type == REC_TYPE_CONT || rec_type == REC_TYPE_NORM)
+ (rec_type == REC_TYPE_CONT || rec_type == REC_TYPE_NORM)
/*
* See if this is a plausible file.
static NORETURN usage(char *myname)
{
- msg_fatal("usage: %s [-v] [file(s)...]", myname);
+ msg_fatal("usage: %s [-c config_dir] [-q (access queue)] [-v] [file(s)...]",
+ myname);
}
int main(int argc, char **argv)
int ch;
int fd;
struct stat st;
+ int flags = 0;
+ static char *queue_names[] = {
+ MAIL_QUEUE_MAILDROP,
+ MAIL_QUEUE_INCOMING,
+ MAIL_QUEUE_ACTIVE,
+ MAIL_QUEUE_DEFERRED,
+ MAIL_QUEUE_HOLD,
+ 0,
+ };
+ char **cpp;
+ int tries;
/*
* To minimize confusion, make sure that the standard file descriptors
/*
* Parse JCL.
*/
- while ((ch = GETOPT(argc, argv, "v")) > 0) {
+ while ((ch = GETOPT(argc, argv, "c:qv")) > 0) {
switch (ch) {
+ case 'c':
+ if (setenv(CONF_ENV_PATH, optarg, 1) < 0)
+ msg_fatal("out of memory");
+ break;
+ case 'q':
+ flags |= PC_FLAG_QUEUE;
+ break;
case 'v':
msg_verbose++;
break;
}
}
+ /*
+ * Further initialization...
+ */
+ mail_conf_read();
+
/*
* Initialize.
*/
postcat(VSTREAM_IN, buffer);
}
+ /*
+ * Copy the named queue files in the specified order.
+ */
+ else if (flags & PC_FLAG_QUEUE) {
+ if (chdir(var_queue_dir))
+ msg_fatal("chdir %s: %m", var_queue_dir);
+ while (optind < argc) {
+ if (!mail_queue_id_ok(argv[optind]))
+ msg_fatal("bad mail queue ID: %s", argv[optind]);
+ for (fp = 0, tries = 0; fp == 0 && tries < 2; tries++)
+ for (cpp = queue_names; fp == 0 && *cpp != 0; cpp++)
+ fp = mail_queue_open(*cpp, argv[optind], O_RDONLY, 0);
+ if (fp == 0)
+ msg_fatal("open queue file %s: %m", argv[optind]);
+ postcat(fp, buffer);
+ if (vstream_fclose(fp))
+ msg_warn("close %s: %m", argv[optind]);
+ optind++;
+ }
+ }
+
/*
* Copy the named files in the specified order.
*/
MAIL_STREAM *dst;
int rec_type;
static char *segment_info[] = {
- REC_TYPE_ENVELOPE, REC_TYPE_CONTENT, REC_TYPE_EXTRACT,
+ REC_TYPE_POST_ENVELOPE, REC_TYPE_POST_CONTENT, REC_TYPE_POST_EXTRACT, ""
};
char **expected;
uid_t uid = getuid();
int flags = SM_FLAG_DEFAULT;
char *site_to_flush = 0;
char *encoding = 0;
+ char *qtime = 0;
/*
* Be consistent with file permissions.
break;
case 'q':
if (ISDIGIT(optarg[0])) {
- if (mode == SM_MODE_DAEMON) {
- if (msg_verbose)
- msg_info("-%c%s option ignored", c, optarg);
-
- }
+ qtime = optarg;
} else if (optarg[0] == 'R') {
site_to_flush = optarg + 1;
if (*site_to_flush == 0)
/*
* Start processing. Everything is delegated to external commands.
*/
+ if (qtime && mode != SM_MODE_DAEMON)
+ exit(0);
switch (mode) {
default:
msg_panic("unknown operation mode: %d", mode);
int naddr;
int non_addr;
char *err = 0;
- char *junk;
+ char *junk = 0;
+ char *text;
+ char *colon;
/*
* Special case.
msg_info("%s: input: %s", myname, STR(arg->vstrval));
if (STR(arg->vstrval)[0] == '<'
&& STR(arg->vstrval)[LEN(arg->vstrval) - 1] == '>') {
- junk = mystrndup(STR(arg->vstrval) + 1, LEN(arg->vstrval) - 2);
- tree = tok822_parse(junk);
- myfree(junk);
+ junk = text = mystrndup(STR(arg->vstrval) + 1, LEN(arg->vstrval) - 2);
} else
- tree = tok822_parse(STR(arg->vstrval));
+ text = STR(arg->vstrval);
+
+ /*
+ * Truncate deprecated route address form.
+ */
+ if (*text == '@' && (colon = strchr(text, ':')) != 0)
+ text = colon + 1;
+ tree = tok822_parse(text);
+
+ if (junk)
+ myfree(junk);
/*
* Find trouble.
* Report trouble. Log a warning only if we are going to sleep+reject so
* that attackers can't flood our logfiles.
*/
- if (arg->strval[0] == 0 && !allow_empty_addr) {
+ if ((arg->strval[0] == 0 && !allow_empty_addr) || arg->strval[0] == '@') {
msg_warn("Illegal address syntax from %s in %s command: %s",
state->namaddr, state->where, STR(arg->vstrval));
err = "501 Bad address syntax";
verp_delims = arg + VERP_CMD_LEN + 1;
if (verp_delims_verify(verp_delims) != 0) {
state->error_mask |= MAIL_ERROR_PROTOCOL;
- smtpd_chat_reply(state, "501 %s needs two characters from %s",
+ smtpd_chat_reply(state, "501 Error: %s needs two characters from %s",
VERP_CMD, var_verp_filter);
return (-1);
}
}
}
if (verp_delims && argv[2].strval[0] == 0) {
- smtpd_chat_reply(state, "503 Error: XVERP requires non-null sender");
+ smtpd_chat_reply(state, "503 Error: %s requires non-null sender",
+ VERP_CMD);
return (-1);
}
state->time = time((time_t *) 0);
break;
case 0:
- if (var_smtpd_delay_reject == 0
+ if (SMTPD_STAND_ALONE(state) == 0
+ && var_smtpd_delay_reject == 0
&& (state->access_denied = smtpd_check_client(state)) != 0) {
smtpd_chat_reply(state, "%s", state->access_denied);
} else {
smtpd_state_init(&state, stream);
msg_info("connect from %s[%s]", state.name, state.addr);
+ /*
+ * XXX non_blocking() aborts upon error.
+ */
+#ifdef BROKEN_READ_SELECT_ON_BLOCKING_SOCKET
+ non_blocking(vstream_fileno(stream), NON_BLOCKING);
+#endif
+
/*
* See if we need to turn on verbose logging for this client.
*/
static PLMYSQL *plmysql_init(char *hostnames[], int);
static MYSQL_RES *plmysql_query(PLMYSQL *, const char *, char *, char *, char *);
static void plmysql_dealloc(PLMYSQL *);
+static void plmysql_close_host(HOST *);
static void plmysql_down_host(HOST *);
static void plmysql_connect_single(HOST *, char *, char *, char *);
static int plmysql_ready_reconn(HOST *);
if (msg_verbose)
msg_info("dict_mysql: closing unnessary connection to %s",
host->hostname);
- plmysql_down_host(host);
+ plmysql_close_host(host);
}
/* try to connect for the first time if we don't have a result yet */
if (res == 0 && host->stat == STATUNTRIED) {
myfree(hostname);
}
+/* plmysql_close_host - close an established MySQL connection */
+static void plmysql_close_host(HOST *host)
+{
+ mysql_close(host->db);
+ host->db = 0;
+ host->stat = STATUNTRIED;
+}
+
/*
- * plmysql_down_host - mark a HOST down update ts if marked down
- * for the first time so that we'll know when to retry the connection
+ * plmysql_down_host - close a failed connection AND set a "stay away from
+ * this host" timer
*/
static void plmysql_down_host(HOST *host)
{
- if (host->stat != STATFAIL) {
- host->ts = time((time_t *) 0) + RETRY_CONN_INTV;
- host->stat = STATFAIL;
- }
mysql_close(host->db);
host->db = 0;
+ host->ts = time((time_t *) 0) + RETRY_CONN_INTV;
+ host->stat = STATFAIL;
}
/**********************************************************************
#include "iostuff.h"
/* Backwards compatibility */
-#ifdef FNDELAY
+#ifndef O_NONBLOCK
#define PATTERN FNDELAY
#else
#define PATTERN O_NONBLOCK
#define USE_STATFS
#define STATFS_IN_SYS_MOUNT_H
#define HAS_POSIX_REGEXP
+#define BROKEN_WRITE_SELECT_ON_NON_BLOCKING_PIPE
#endif
/*
#define LOCAL_CONNECT stream_connect
#define LOCAL_TRIGGER stream_trigger
#define HAS_VOLATILE_LOCKS
+#define BROKEN_READ_SELECT_ON_BLOCKING_SOCKET
/*
* Allow build environment to override paths.
*/
#define DBM_NO_TRAILING_NULL /* XXX check */
#define USE_STATVFS
#define STATVFS_IN_SYS_STATVFS_H
+#define BROKEN_WRITE_SELECT_ON_NON_BLOCKING_PIPE
#endif
#if defined(IRIX5)
/* configuration parameter.
/* .IP \fBvirtual_minimum_uid\fR
/* Specifies a minimum uid that will be accepted as a return from
-/* a \fBvirtual_owner_maps\fR or \fBvirtual_uid_maps\fR lookup.
+/* a \fBvirtual_uid_maps\fR lookup.
/* Returned values less than this will be rejected, and the message
/* will be deferred.
/* .IP \fBvirtual_uid_maps\fR