From dd091f097676c94cc56ff2e4aa023d3b080877ef Mon Sep 17 00:00:00 2001 From: Wietse Venema Date: Tue, 15 Apr 2003 00:00:00 -0500 Subject: [PATCH] postfix-2.0.8-20030415 --- postfix/.indent.pro | 9 ++-- postfix/HISTORY | 11 +++-- postfix/README_FILES/PGSQL_README | 36 +++++++++------- postfix/README_FILES/SASL_README | 13 ++++++ postfix/RELEASE_NOTES | 8 ++-- postfix/src/global/mail_stream.c | 69 +++++++++++++++++-------------- postfix/src/global/mail_stream.h | 1 + postfix/src/global/mail_version.h | 2 +- postfix/src/smtpstone/smtp-sink.c | 4 +- postfix/src/util/dict_pgsql.c | 8 ++-- 10 files changed, 97 insertions(+), 64 deletions(-) diff --git a/postfix/.indent.pro b/postfix/.indent.pro index de1515131..cd42b54bb 100644 --- a/postfix/.indent.pro +++ b/postfix/.indent.pro @@ -1,7 +1,3 @@ --THOST --TPLPGSQL --TPGSQL_NAME --TDICT_PGSQL -TABOUNCE -TALIAS_TOKEN -TARGV @@ -50,6 +46,7 @@ -TDICT_PCRE_PRESCAN_CONTEXT -TDICT_PCRE_REGEXP -TDICT_PCRE_RULE +-TDICT_PGSQL -TDICT_PROXY -TDICT_REGEXP -TDICT_REGEXP_EXPAND_CONTEXT @@ -70,6 +67,7 @@ -THEADER_OPTS -THEADER_TOKEN -THOST +-THOST -THTABLE -THTABLE_INFO -TINET_ADDR_LIST @@ -87,6 +85,7 @@ -TMAC_PARSE -TMAIL_PRINT -TMAIL_SCAN +-TMAIL_STREAM -TMAPS -TMASTER_PROC -TMASTER_SERV @@ -109,10 +108,12 @@ -TNAMADR_LIST -TNAME_MASK -TPEER_NAME +-TPGSQL_NAME -TPICKUP_INFO -TPIPE_ATTR -TPIPE_PARAMS -TPLMYSQL +-TPLPGSQL -TPOST_MAIL_STATE -TQMGR_ENTRY -TQMGR_JOB diff --git a/postfix/HISTORY b/postfix/HISTORY index 8439d67f8..6f0545601 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -7959,14 +7959,19 @@ Apologies for any names omitted. now has an explicit flush operation, and the smtp-source/sink programs are updated to take advantage of this. - Cleanup: the file system clock drift detection code now runs - only once per process instance, to minimize the performance - impact. File: global/mail_stream.c. + Cleanup: the file system clock drift detection code now + runs only once per process instance, to minimize the + performance impact. File: global/mail_stream.c. Robustness: avoid TIME_WAIT state with smtp/qmqp-source client sockets. This puts less strain on local system resources. +10030415 + + Cleanup: the file system clock drift detection code now + runs only for incoming mail. File: global/mail_stream.c. + Open problems: Low: smtp-source may block when sending large test messages. diff --git a/postfix/README_FILES/PGSQL_README b/postfix/README_FILES/PGSQL_README index 78675cee6..623ca3820 100644 --- a/postfix/README_FILES/PGSQL_README +++ b/postfix/README_FILES/PGSQL_README @@ -26,9 +26,11 @@ Building Postfix with PostgreSQL support To use pgsql with Postfix on Debian GNU/Linux, you must install the postfix-pgsql package. -In order to build Postfix with pgsql map support, you will need to -add -DHAS_PGSQL and -I for the directory containing the PostgreSQL -header files and the libpq library to AUXLIBS, for example: +In order to build Postfix with pgsql map support, you specify +-DHAS_PGSQL, the directory with the PostgreSQL header files, and +the location of the libpq library file. + +For example: make tidy make -f Makefile.init makefiles \ @@ -103,17 +105,19 @@ hosts = host1.some.domain host2.some.domain unix:/file/name # end pgsql config file -Eliminating single points of failure -==================================== +Using mirrored databases +======================== -Since sites that have a need for multiple mail exchangers may enjoy -the convenience of using a networked mailer database, but do not -want to introduce a single point of failure to their system, we've -included the ability to have postfix reference multiple hosts for -access to a single pgsql map. This will work if sites set up -mirrored pgsql databases on two or more hosts. Whenever queries -fail with an error at one host, the rest of the hosts will be tried -in order. Each host that is in an error state will undergo a -reconnection attempt every so often, and if no pgsql server hosts -are reachable, then mail will be deferred until at least one of -those hosts is reachable. +Sites that have a need for multiple mail exchangers may enjoy the +convenience of using a networked mailer database, but do not want +to introduce a single point of failure to their system. + +For this reason we've included the ability to have Postfix reference +multiple hosts for access to a single pgsql map. This will work +if sites set up mirrored pgsql databases on two or more hosts. + +Whenever queries fail with an error at one host, the rest of the +hosts will be tried in order. Each host that is in an error state +will undergo a reconnection attempt every so often, and if no pgsql +server hosts are reachable, then mail will be deferred until at +least one of those hosts is reachable. diff --git a/postfix/README_FILES/SASL_README b/postfix/README_FILES/SASL_README index e2d1d39df..f5dbdcca4 100644 --- a/postfix/README_FILES/SASL_README +++ b/postfix/README_FILES/SASL_README @@ -227,6 +227,19 @@ can use one of the following commands: mmencode is part of the metamail software. MIME::Base64 is available from www.cpan.org. +Trouble shooting the SASL internals +=================================== + +[based on text by Liviu Daia] + +In the Cyrus SASL sources you'll find a subdirectory named "sample". +Run make there, then run the resulting sample server and client in +separate terminals. Strace / ktrace / truss the server to see what +makes it unhappy, fix the problem, then write the authors thanking +them for providing such useful logging. Repeat the previous step +until you can successfully authenticate with the sample client. +Only then get back to Postfix. + Enabling SASL authentication in the Postfix SMTP client ======================================================= diff --git a/postfix/RELEASE_NOTES b/postfix/RELEASE_NOTES index 72b7e1905..55fab1989 100644 --- a/postfix/RELEASE_NOTES +++ b/postfix/RELEASE_NOTES @@ -38,10 +38,10 @@ PostgreSQL table lookups. Specify "pgsql:/file/name" where "/file/name" defines the database. See the sample-pgsql-aliases.cf file for examples, and the PGSQL_README file for general information. -Workarounds for file systems whose clock runs ahead of the local -clock (this can happen with remote file systems). Postfix now logs -a warning and proceeds with reduced performance, instead of ignoring -new mail completely. +Workaround for file system clock drift that caused Postfix to ignore +new mail (this could happen with file systems mounted from a server). +Postfix now logs a warning and proceeds with only slightly reduced +performance, instead of ignoring new mail. Incompatible changes with Postfix snapshot 2.0.6-20030305 ========================================================= diff --git a/postfix/src/global/mail_stream.c b/postfix/src/global/mail_stream.c index e07e37d59..094cb00b0 100644 --- a/postfix/src/global/mail_stream.c +++ b/postfix/src/global/mail_stream.c @@ -111,9 +111,10 @@ static VSTRING *id_buf; /* mail_stream_cleanup - clean up after success or failure */ -void mail_stream_cleanup(MAIL_STREAM * info) +void mail_stream_cleanup(MAIL_STREAM *info) { FREE_AND_WIPE(info->close, info->stream); + FREE_AND_WIPE(myfree, info->queue); FREE_AND_WIPE(myfree, info->id); FREE_AND_WIPE(myfree, info->class); FREE_AND_WIPE(myfree, info->service); @@ -122,16 +123,17 @@ void mail_stream_cleanup(MAIL_STREAM * info) /* mail_stream_finish_file - finish file mail stream */ -static int mail_stream_finish_file(MAIL_STREAM * info, VSTRING *unused_why) +static int mail_stream_finish_file(MAIL_STREAM *info, VSTRING *unused_why) { int status = 0; static char wakeup[] = {TRIGGER_REQ_WAKEUP}; struct stat st; time_t now; struct utimbuf tbuf; - char *queue_file_path = 0; - static int fs_clock_ok = 0; - static int fs_clock_warned = 0; + char *path_to_reset = 0; + static int incoming_fs_clock_ok = 0; + static int incoming_clock_warned = 0; + int check_incoming_fs_clock; /* * Make sure the message makes it to file. Set the execute bit when no @@ -145,18 +147,25 @@ static int mail_stream_finish_file(MAIL_STREAM * info, VSTRING *unused_why) * must end with an explicit END record. Postfix queue files without END * record are discarded. * - * Attempt to detect file system clocks that are ahead of local time. the - * effect can be difficult to understand (mail is enqueued but Postfix - * ignores it). This clock drift detection may not work with file systems - * that work on a local copy of the file and that update the server only - * after the file is closed. + * Attempt to detect file system clocks that are ahead of local time, but + * don't check the file system clock all the time. The effect of file + * system clock drift can be difficult to understand (Postfix ignores new + * mail until the next queue run). + * + * This clock drift detection code may not work with file systems that work + * on a local copy of the file and that update the server only after the + * file is closed. */ + check_incoming_fs_clock = + (!incoming_fs_clock_ok && !strcmp(info->queue, MAIL_QUEUE_INCOMING)); + if (vstream_fflush(info->stream) || fchmod(vstream_fileno(info->stream), 0700 | info->mode) #ifdef HAS_FSYNC || fsync(vstream_fileno(info->stream)) #endif - || (fs_clock_ok == 0 && fstat(vstream_fileno(info->stream), &st) < 0) + || (check_incoming_fs_clock + && fstat(vstream_fileno(info->stream), &st) < 0) ) status = (errno == EFBIG ? CLEANUP_STAT_SIZE : CLEANUP_STAT_WRITE); @@ -164,24 +173,21 @@ static int mail_stream_finish_file(MAIL_STREAM * info, VSTRING *unused_why) st.st_mtime += 10; #endif - /* - * Don't check the file system clock all the time. - */ - if (fs_clock_ok == 0 && st.st_mtime <= time(&now)) - fs_clock_ok = 1; - /* * Work around file system clocks that are ahead of local time. */ - if (status == CLEANUP_STAT_OK && fs_clock_ok == 0) { - if (fs_clock_warned == 0) { - msg_warn("%s: file system clock is %d seconds ahead of local clock", - info->id, (int) (st.st_mtime - now)); - msg_warn("%s: resetting file time stamps - this hurts performance", - info->id); - fs_clock_warned = 1; + if (status == CLEANUP_STAT_OK && check_incoming_fs_clock) { + if (st.st_mtime <= time(&now)) { + incoming_fs_clock_ok = 1; + } else { + path_to_reset = mystrdup(VSTREAM_PATH(info->stream)); + if (incoming_clock_warned == 0) { + msg_warn("file system clock is %d seconds ahead of local clock", + (int) (st.st_mtime - now)); + msg_warn("resetting file time stamps - this hurts performance"); + incoming_clock_warned = 1; + } } - queue_file_path = mystrdup(VSTREAM_PATH(info->stream)); } /* @@ -199,11 +205,11 @@ static int mail_stream_finish_file(MAIL_STREAM * info, VSTRING *unused_why) /* * Work around file system clocks that are ahead of local time. */ - if (queue_file_path != 0) { + if (path_to_reset != 0) { tbuf.actime = tbuf.modtime = now; - if (utime(queue_file_path, &tbuf) < 0 && errno != ENOENT) + if (utime(path_to_reset, &tbuf) < 0 && errno != ENOENT) msg_fatal("%s: update file time stamps: %m", info->id); - myfree(queue_file_path); + myfree(path_to_reset); } /* @@ -222,7 +228,7 @@ static int mail_stream_finish_file(MAIL_STREAM * info, VSTRING *unused_why) /* mail_stream_finish_ipc - finish IPC mail stream */ -static int mail_stream_finish_ipc(MAIL_STREAM * info, VSTRING *why) +static int mail_stream_finish_ipc(MAIL_STREAM *info, VSTRING *why) { int status = CLEANUP_STAT_WRITE; @@ -247,7 +253,7 @@ static int mail_stream_finish_ipc(MAIL_STREAM * info, VSTRING *why) /* mail_stream_finish - finish action */ -int mail_stream_finish(MAIL_STREAM * info, VSTRING *why) +int mail_stream_finish(MAIL_STREAM *info, VSTRING *why) { return (info->finish(info, why)); } @@ -268,6 +274,7 @@ MAIL_STREAM *mail_stream_file(const char *queue, const char *class, info->stream = stream; info->finish = mail_stream_finish_file; info->close = vstream_fclose; + info->queue = mystrdup(queue); info->id = mystrdup(basename(VSTREAM_PATH(stream))); info->class = mystrdup(class); info->service = mystrdup(service); @@ -295,6 +302,7 @@ MAIL_STREAM *mail_stream_service(const char *class, const char *name) info->stream = stream; info->finish = mail_stream_finish_ipc; info->close = vstream_fclose; + info->queue = 0; info->id = mystrdup(vstring_str(id_buf)); info->class = 0; info->service = 0; @@ -345,6 +353,7 @@ MAIL_STREAM *mail_stream_command(const char *command) info->stream = stream; info->finish = mail_stream_finish_ipc; info->close = vstream_pclose; + info->queue = 0; info->id = mystrdup(vstring_str(id_buf)); info->class = 0; info->service = 0; diff --git a/postfix/src/global/mail_stream.h b/postfix/src/global/mail_stream.h index c9fbfd97a..a1e64f13e 100644 --- a/postfix/src/global/mail_stream.h +++ b/postfix/src/global/mail_stream.h @@ -27,6 +27,7 @@ typedef int (*MAIL_STREAM_CLOSE_FN) (VSTREAM *); struct MAIL_STREAM { VSTREAM *stream; /* file or pipe or socket */ + char *queue; /* (initial) queue name */ char *id; /* queue id */ MAIL_STREAM_FINISH_FN finish; /* finish code */ MAIL_STREAM_CLOSE_FN close; /* close stream */ diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 4a74a4f8b..f6665ddc1 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,7 +20,7 @@ * 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 "20030414" +#define MAIL_RELEASE_DATE "20030415" #define VAR_MAIL_VERSION "mail_version" #define DEF_MAIL_VERSION "2.0.8-" MAIL_RELEASE_DATE diff --git a/postfix/src/smtpstone/smtp-sink.c b/postfix/src/smtpstone/smtp-sink.c index cdcd1cd05..2f3f7af04 100644 --- a/postfix/src/smtpstone/smtp-sink.c +++ b/postfix/src/smtpstone/smtp-sink.c @@ -205,8 +205,8 @@ static void data_event(int unused_event, char *context) static void dot_response(SINK_STATE *state) { if (enable_lmtp) { - while (state->rcpts-- > 0) /* XXX this could block */ - ok_response(state); + while (state->rcpts-- > 0) /* XXX this could block */ + ok_response(state); /* XXX this flushes too often */ } else { ok_response(state); } diff --git a/postfix/src/util/dict_pgsql.c b/postfix/src/util/dict_pgsql.c index 0fc350f67..7968168e1 100644 --- a/postfix/src/util/dict_pgsql.c +++ b/postfix/src/util/dict_pgsql.c @@ -6,9 +6,9 @@ /* SYNOPSIS /* #include /* -/* DICT *dict_pgsql_open(name, dummy, unused_dict_flags) +/* DICT *dict_pgsql_open(name, unused_open_flags, unused_dict_flags) /* const char *name; -/* int dummy; +/* int unused_open_flags; /* int unused_dict_flags; /* DESCRIPTION /* dict_pgsql_open() creates a dictionary of type 'pgsql'. This @@ -17,8 +17,8 @@ /* or a null pointer in case of problems. /* /* The pgsql dictionary can manage multiple connections to -/* different sql servers on different hosts. It assumes that -/* the underlying data on each host is identical (mirrored) and +/* different sql servers for the same database. It assumes that +/* the underlying data on each server is identical (mirrored) and /* maintains one connection at any given time. If any connection /* fails, any other available ones will be opened and used. /* The intent of this feature is to eliminate a single point of