From: Wietse Venema Date: Sun, 10 Dec 2000 05:00:00 +0000 (-0500) Subject: snapshot-20001210 X-Git-Tag: v20010228~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ad8f0f553e428ca4dbce1b0e69c1ac62933a4d4;p=thirdparty%2Fpostfix.git snapshot-20001210 --- diff --git a/postfix/HISTORY b/postfix/HISTORY index aa742df65..bdfbb6022 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -4528,16 +4528,24 @@ Apologies for any names omitted. Feature: mailbox locking is now configurable. The configuration parameter name is "mailbox_delivery_lock". Depending on the operating system one can specify one or more of "flock", - "fcntl" and "dotlock". The default setting is system - dependent. All mailbox file opens are now done by the - mbox_open() routine. This affects the operation of the - postlock command, and of local delivery to mailbox or - /file/name. Files: util/safe_open.c, util/myflock.c, + "fcntl" and "dotlock". Use "postconf -l" to find out what + locking methods Postfix supports. The default setting is + system dependent. All mailbox file opens are now done by + one central mbox_open() routine. This affects the operation + of the postlock command, and of local delivery to mailbox + or /file/name. Files: util/safe_open.c, util/myflock.c, global/deliver_flock.c, global/mbox_conf.c, global/mbox_open.c. - local/mailbox.c, local/file.c, postlock/postlock.c. The - old sun_mailtool_compatibility parameter is being phased - out (it just turns off flock/fcntl locks). It still works, - but a warning is logged as a reminder that it goes away. + local/mailbox.c, local/file.c, postlock/postlock.c. + + Compatibility: the old sun_mailtool_compatibility parameter + is being phased out. It still works (by turning off + flock/fcntl locks), but logs a warning as a reminder that + it will go away. + + Compatibility: when delivering to /file/name, the local + delivery agent now logs a warning when it is unable to + create a /file/name.lock file, and then delivers the mail + (older Postfix versions would silently deliver). 20001202 @@ -4545,11 +4553,10 @@ Apologies for any names omitted. ESMTP. Someone asked for this long ago. Files: smtp/smtp.c, smtp/smtp_proto.c. - Feature? Bugfix? The smtp client will now ignore server - replies that do not start with "CODE SPACE" or with "CODE - HYPHEN". Which means that "CODE TEXT" is now treated as - "CODE HYPHEN TEXT", instead of being treated as "CODE SPACE - TEXT", the way it was before. File: smtp/smtp_chat.c. + Feature? Bugfix? The smtp client now skips server replies + that do not start with "CODE SPACE" or with "CODE HYPHEN", + and flags them as protocol errors. Older versions silently + treat "CODE TEXT" as "CODE SPACE TEXT". File: smtp/smtp_chat.c. 20001203 @@ -4558,14 +4565,14 @@ Apologies for any names omitted. 20001204 - Bugfix: master no longer imported MAIL_CONF and other - necessary environmental parameters. Postfix now has - explicit "import_environment" and "export_environment" - configuration parameters that control what environment - parameters are imported from or exported to the external - environment. Files: util/clean_env.c, util/spawn_command.c, + Bugfix: the Postfix master daemon no longer imported + MAIL_CONF and some other necessary environment parameters. + Postfix now has explicit "import_environment" and + "export_environment" configuration parameters that control + what environment parameters are shared with non-Postfix + processes. Files: util/clean_env.c, util/spawn_command.c, util/vstream_popen.c, global/pipe_command.c, and everything - that uses this code. + that invokes this code. 20001208 @@ -4586,9 +4593,18 @@ Apologies for any names omitted. example, "mailbox_transport = lmtp:unix:/file/name". File: global/deliver_pass.c. - Bugfix: local_destination_concurrency_limit no longer works - as per-user concurrency limit but as per-domain limit, so - the limit of "2" in the sample main.cf files would result - in poor local delivery performance. The Postfix install - procedure repairs this. Problem reported by David Schweikert - (ee.ethz.ch) and Dallas Wisehaupt (cynicism.com). +20001210 + + Bugfix: the local_destination_concurrency_limit paramater + no longer worked as per-user concurrency limit but instead + worked as per-domain limit, so that the limit of "2" in + the default main.cf files resulted in poor local delivery + performance. Files: qmgr/qmgr_message.c, qmgr/qmgr_deliver.c. + Problem reported by David Schweikert (ee.ethz.ch) and Dallas + Wisehaupt (cynicism.com). + +20001210 + + Feature: support for MYSQL connections over UNIX-domain + sockets by Piotr Klaban. Files: util/dict_mysql.c, + MYSQL_README. diff --git a/postfix/INSTALL.sh b/postfix/INSTALL.sh index c2e8e79a8..df4f74351 100644 --- a/postfix/INSTALL.sh +++ b/postfix/INSTALL.sh @@ -285,7 +285,6 @@ bin/postconf -c $CONFIG_DIRECTORY -e \ "command_directory = $command_directory" \ "queue_directory = $queue_directory" \ "mail_owner = $mail_owner" \ - "local_destination_concurrency_limit = 0" \ || exit 1 (echo "# This file was generated by $0" diff --git a/postfix/MYSQL_README b/postfix/MYSQL_README index 7fb79e108..31cdcdc55 100644 --- a/postfix/MYSQL_README +++ b/postfix/MYSQL_README @@ -60,7 +60,8 @@ additional_conditions = and status = 'paid' # # the hosts that postfix will try to connect to # and query from (in the order listed) -hosts = host1.some.domain host2.some.domain +# specify unix: for unix-domain sockets, inet: for TCP connections (default) +hosts = host1.some.domain host2.some.domain unix:/file/name # end mysql config file diff --git a/postfix/RELEASE_NOTES b/postfix/RELEASE_NOTES index 4b481b439..5a312ef28 100644 --- a/postfix/RELEASE_NOTES +++ b/postfix/RELEASE_NOTES @@ -1,27 +1,76 @@ -Incompatible changes with snapshot-2000XXXX +Incompatible changes with snapshot-20001210 =========================================== -The "sun_mailtool_compatibility" is going away (a compatibility mode -that turns off kernel locks on mailbox files). It still works, but -a warning is logged. Instead, specify the mailbox locking strategy -via the new "mailbox_delivery_lock" parameter. +If this release does not work for you, you can go back to a previous +Postfix version without losing your mail, subject to the "incompatible +changes" listed for previous Postfix releases below. -Major changes with snapshot-2000XXXX +When delivering to /file/name (as directed in an alias or .forward +file), the local delivery agent now logs a warning when it is unable +to create a /file/name.lock file. Mail is still delivered as before. + +The "sun_mailtool_compatibility" feature is going away (a compatibility +mode that turns off kernel locks on mailbox files). It still works, +but a warning is logged. Instead of using "sun_mailtool_compatibility", +specify the mailbox locking strategy as "mailbox_delivery_lock = +dotlock". + +The Postfix SMTP client now skips SMTP server replies that do not +start with "CODE SPACE" or with "CODE HYPHEN" and flags them as +protocol errors. Older Postfix SMTP clients silently treated "CODE +TEXT" as "CODE SPACE TEXT", i.e. as a valid SMTP reply. + +This snapshot does not yet change default relay settings. That +change alone affects a dozen files, most of which documentation. +This may be an incompatibility with some people's expectations, +but such are my rules - between code freeze and release no major +functionality changes are allowed. + +Several interfaces of libutil and libglobal routines have changed. +This may break third-party code written for Postfix. In particular, +the safe_open() routine has changed, the way the preferred locking +method is specified in the sys_defs.h file, as well as all routines +that perform file locking. When compiling third-party code written +for Postfix, the incompatibilities will be detected by the compiler +provided that #include file dependencies are properly maintained. + +Major changes with snapshot-20001210 ==================================== +This snapshot includes bugfixes that were already released as +patches 12 and 13 for the 19991231 "stable" release: + + - The queue manager could deadlock for 10 seconds when bouncing + mail under extreme load from one-to-one mass mailings. + + - Local delivery performance was substandard, because the per-user + concurrency limit accidentally applied to the entire local + domain. + The mailbox locking style is now fully configurable at runtime. -The new configuration parameter is "mailbox_delivery_lock". +The new configuration parameter is called "mailbox_delivery_lock". Depending on the operating system type, mailboxes can be locked -with one or more of "flock", "fcntl" or "dotlock". This also applies -to "/file/name" deliveries by the Postfix local delivery agent. -The default setting of "mailbox_delivery_lock" is system dependent. -The command "postconf -l" shows the available locking styles. - -The "import_environment" and "export_environment" configuration -parameters now control what environment variables Postfix will -import from its parent and what it variables Postfix will pass on -to a non-Postfix process. It is not safe to import or export -everything, and different sites may have different needs. +with one or more of "flock", "fcntl" or "dotlock". The command +"postconf -l" shows the available locking styles. The default +mailbox locking style is system dependent. This change affects +all mailbox and all "/file/name" deliveries by the Postfix local +delivery agent. + +The new "import_environment" and "export_environment" configuration +parameters now provide explicit control over what environment +variables Postfix will import, and what environment variables +Postfix will pass on to a non-Postfix process. This is better than +hard-coding my debugging environment into public releases. + +The "mailbox_transport" and "fallback_transport" parameters now +understand the form "transport:nexthop", with suitable defaults +when either transport or nexthop are omitted, just like in the +Postfix transport map. This allows you to specify for example, +"mailbox_transport = lmtp:unix:/file/name". + +The MYSQL client now supports server connections over UNIX-domain +sockets. Code provided by Piotr Klaban. See the file MYSQL_README +for examples of "host" syntax. Incompatible changes with snapshot-20001121 =========================================== diff --git a/postfix/conf/main.cf b/postfix/conf/main.cf index 52334767f..a2a81298b 100644 --- a/postfix/conf/main.cf +++ b/postfix/conf/main.cf @@ -5,6 +5,17 @@ # that begin with whitespace continue the previous line. A value can # contain references to other $names or ${name}s. +# SOFT BOUNCE +# +# The soft_bounce parameter provides a limited safety net for +# testing. When soft_bounce is enabled, mail will remain queued that +# would otherwise bounce. This parameter disables locally-generated +# bounces, and prevents the SMTP server from rejecting mail permanently +# (by changing 5xx replies into 4xx replies). However, soft_bounce +# is no cure for address rewriting mistakes or mail routing mistakes. +# +#soft_bounce = no + # LOCAL PATHNAME INFORMATION # # The queue_directory specifies the location of the Postfix queue. @@ -388,11 +399,8 @@ mail_owner = postfix # # Each message delivery transport has its XXX_destination_concurrency_limit # parameter. The default is $default_destination_concurrency_limit. -# The limit is per destination domain, so the destination concurrency -# limit for local delivery must be set to zero otherwise performance -# will suffer. -local_destination_concurrency_limit = 0 +local_destination_concurrency_limit = 2 default_destination_concurrency_limit = 10 # DEBUGGING CONTROL diff --git a/postfix/conf/sample-local.cf b/postfix/conf/sample-local.cf index ab2214468..183e524ff 100644 --- a/postfix/conf/sample-local.cf +++ b/postfix/conf/sample-local.cf @@ -18,6 +18,14 @@ # biff = no biff = yes +# The require_home_directory parameter controls whether a local +# recipient's home directory must exist before mail delivery is +# attempted. By default this test is disabled. It can be useful for +# environments that import home directories to the file server (NOT +# RECOMMENDED). +# +require_home_directory = no + # # OVERRIDE LOCAL TRANSPORT # @@ -177,15 +185,14 @@ fallback_transport = # # The local_destination_concurrency_limit parameter limits the number -# of parallel deliveries to the local domain. It should therefore be -# set to zero, in order to prevent poor local delivery performance. -# In old Postfix versions this parameter implemented a per-user -# limit. That is no longer the case. +# of parallel deliveries to the same local recipient. # # The default limit is taken from the default_destination_concurrency_limit -# parameter. +# parameter. I recommend a low limit of 2, just in case someone has +# an expensive shell command in a .forward file or in an alias (e.g., +# a mailing list manager). You don't want to run lots of those. # -local_destination_concurrency_limit = 0 +local_destination_concurrency_limit = 2 # The local_destination_recipient_limit parameter limits the number # of recipients per local message delivery. The default limit is diff --git a/postfix/conf/sample-misc.cf b/postfix/conf/sample-misc.cf index 0741e0e20..436767b3c 100644 --- a/postfix/conf/sample-misc.cf +++ b/postfix/conf/sample-misc.cf @@ -260,6 +260,25 @@ queue_directory = /var/spool/postfix # recipient_delimiter = + recipient_delimiter = +# The propagate_unmatched_extensions parameter specifies what lookup +# tables should copy the address extension from the lookup key to +# the lookup result. +# +# For example, with a virtual table entry "joe@domain joe.user", +# the address joe+foo@domain would be rewritten to joe.user+foo. +# Address extensions can be propagated with canonical, virtual, +# and alias maps, as well as with .forward and :include: files, +# including mailing lists!! +# +# By default, only canonical and virtual maps propagate address +# extensions to lookup results. Enabling this feature for other +# types of lookups usually causes problems when mail is forwarded +# to other sites, especially with mail that is sent to a mailing +# list exploder address. +# +#propagate_unmatched_extensions = canonical, virtual, alias, forward, include +#propagate_unmatched_extensions = canonical, virtual + # The relayhost parameter specifies the default host to send mail to # when no entry is matched in the optional transport(5) table. When # no relayhost is given, mail is routed directly to the destination. @@ -293,15 +312,6 @@ relayhost = # relocated_maps = hash:/etc/postfix/relocated relocated_maps = -# The sun_mailtool_compatibility parameter disables kernel file locks -# on mailboxes. This is needed on SUN workstations because the mailtool -# program keeps an exclusive kernel lock while its window is open. -# SUN software uses user.lock files only. Unless you remove all SUN -# mail software, kernel locks just give a false sense of security. -# -#sun_mailtool_compatibility = yes -sun_mailtool_compatibility = no - # The syslog_facility parameter controls where Postfix logging is # sent by the syslog daemon. Specify a logging facility as defined # in syslog.conf(5). The default logging facility is "mail". diff --git a/postfix/conf/sample-smtp.cf b/postfix/conf/sample-smtp.cf index 2359377f8..680c714bd 100644 --- a/postfix/conf/sample-smtp.cf +++ b/postfix/conf/sample-smtp.cf @@ -38,6 +38,24 @@ fallback_relay = # ignore_mx_lookup_error = no +# The smtp_always_send_ehlo parameter specifies that the SMTP client +# should always send EHLO at the start of an SMTP session. +# +# By default, Postfix sends EHLO only when the word "ESMTP" appears +# in the server greeting banner (example: 220 spike.porcupine.org +# ESMTP Postfix). +# +smtp_always_send_ehlo = no + +# The smtp_never_send_ehlo parameter specifies that the SMTP client +# should never send EHLO at the start of an SMTP session. +# +# By default, Postfix sends EHLO whenever the word "ESMTP" appears +# in the server greeting banner (example: 220 spike.porcupine.org +# ESMTP Postfix). +# +smtp_never_send_ehlo = no + # The smtp_bind_address parameter specifies a numerical network # address that the client should bind to when making a connection. # This can be used in the main.cf file, or in the master.cf file, diff --git a/postfix/src/global/Makefile.in b/postfix/src/global/Makefile.in index c19cd75ae..fac2db938 100644 --- a/postfix/src/global/Makefile.in +++ b/postfix/src/global/Makefile.in @@ -243,6 +243,17 @@ depend: $(MAKES) @$(EXPORT) make -f Makefile.in Makefile 1>&2 # do not edit below this line - it is generated by 'make depend' +abounce.o: abounce.c +abounce.o: ../../include/sys_defs.h +abounce.o: ../../include/msg.h +abounce.o: ../../include/mymalloc.h +abounce.o: ../../include/events.h +abounce.o: ../../include/vstream.h +abounce.o: ../../include/vbuf.h +abounce.o: mail_proto.h +abounce.o: ../../include/iostuff.h +abounce.o: abounce.h +abounce.o: bounce.h been_here.o: been_here.c been_here.o: ../../include/sys_defs.h been_here.o: ../../include/msg.h @@ -343,6 +354,9 @@ deliver_pass.o: ../../include/msg.h deliver_pass.o: ../../include/vstring.h deliver_pass.o: ../../include/vbuf.h deliver_pass.o: ../../include/vstream.h +deliver_pass.o: ../../include/split_at.h +deliver_pass.o: ../../include/mymalloc.h +deliver_pass.o: mail_params.h deliver_pass.o: deliver_pass.h deliver_pass.o: deliver_request.h deliver_pass.o: recipient_list.h @@ -595,6 +609,9 @@ mail_params.o: ../../include/vbuf.h mail_params.o: mynetworks.h mail_params.o: mail_conf.h mail_params.o: mail_version.h +mail_params.o: mail_proto.h +mail_params.o: ../../include/vstream.h +mail_params.o: ../../include/iostuff.h mail_params.o: mail_params.h mail_pathname.o: mail_pathname.c mail_pathname.o: ../../include/sys_defs.h @@ -659,11 +676,13 @@ mail_stream.o: ../../include/vstring.h mail_stream.o: ../../include/vbuf.h mail_stream.o: ../../include/vstream.h mail_stream.o: ../../include/stringops.h +mail_stream.o: ../../include/argv.h mail_stream.o: cleanup_user.h mail_stream.o: mail_proto.h mail_stream.o: ../../include/iostuff.h mail_stream.o: mail_queue.h mail_stream.o: opened.h +mail_stream.o: mail_params.h mail_stream.o: mail_stream.h mail_task.o: mail_task.c mail_task.o: ../../include/sys_defs.h diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 7588e001e..6600e0d3b 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -15,7 +15,7 @@ * Version of this program. */ #define VAR_MAIL_VERSION "mail_version" -#define DEF_MAIL_VERSION "Snapshot-20001209" +#define DEF_MAIL_VERSION "Snapshot-20001210" extern char *var_mail_version; /* LICENSE diff --git a/postfix/src/global/mbox_open.c b/postfix/src/global/mbox_open.c index e53373b91..d533dd86f 100644 --- a/postfix/src/global/mbox_open.c +++ b/postfix/src/global/mbox_open.c @@ -102,7 +102,7 @@ MBOX *mbox_open(const char *path, int flags, int mode, struct stat * st, */ if (st == 0) st = &local_statbuf; - if ((fp = safe_open(path, flags, mode | O_NONBLOCK, st, + if ((fp = safe_open(path, flags | O_NONBLOCK, mode, st, chown_uid, chown_gid, why)) == 0) { return (0); } diff --git a/postfix/src/master/Makefile.in b/postfix/src/master/Makefile.in index 3acb84e40..83d6200cc 100644 --- a/postfix/src/master/Makefile.in +++ b/postfix/src/master/Makefile.in @@ -92,6 +92,7 @@ master.o: ../../include/stringops.h master.o: ../../include/myflock.h master.o: ../../include/watchdog.h master.o: ../../include/clean_env.h +master.o: ../../include/argv.h master.o: ../../include/mail_params.h master.o: ../../include/debug_process.h master.o: ../../include/mail_task.h diff --git a/postfix/src/nqmgr/Makefile.in b/postfix/src/nqmgr/Makefile.in index 608f7faa8..eea19d355 100644 --- a/postfix/src/nqmgr/Makefile.in +++ b/postfix/src/nqmgr/Makefile.in @@ -94,6 +94,7 @@ qmgr_active.o: ../../include/vstring.h qmgr_active.o: ../../include/recipient_list.h qmgr_active.o: ../../include/bounce.h qmgr_active.o: ../../include/defer.h +qmgr_active.o: ../../include/abounce.h qmgr_active.o: ../../include/rec_type.h qmgr_active.o: qmgr.h qmgr_active.o: ../../include/scan_dir.h diff --git a/postfix/src/nqmgr/qmgr_deliver.c b/postfix/src/nqmgr/qmgr_deliver.c index aacb8efa5..3c479746f 100644 --- a/postfix/src/nqmgr/qmgr_deliver.c +++ b/postfix/src/nqmgr/qmgr_deliver.c @@ -50,6 +50,7 @@ #include #include +#include /* Utility library. */ @@ -122,11 +123,18 @@ static int qmgr_deliver_send_request(QMGR_ENTRY *entry, VSTREAM *stream) QMGR_RCPT_LIST list = entry->rcpt_list; QMGR_RCPT *recipient; QMGR_MESSAGE *message = entry->message; + char *cp; + /* + * With local delivery, the queue name is user@nexthop, so that we can + * implement per-recipient concurrency limits. The delivery agent + * protocol expects nexthop only. + */ mail_print(stream, "%d %s %s %ld %ld %s %s %s %s %ld", message->inspect_xport ? DEL_REQ_FLAG_BOUNCE : DEL_REQ_FLAG_DEFLT, message->queue_name, message->queue_id, message->data_offset, message->data_size, + (cp = strrchr(entry->queue->name, '@')) != 0 && cp[1] ? cp + 1 : entry->queue->name, message->sender, message->errors_to, message->return_receipt, message->arrival_time); diff --git a/postfix/src/nqmgr/qmgr_message.c b/postfix/src/nqmgr/qmgr_message.c index 91b261354..aa2ad1157 100644 --- a/postfix/src/nqmgr/qmgr_message.c +++ b/postfix/src/nqmgr/qmgr_message.c @@ -678,8 +678,9 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message) */ if ((at = strrchr(STR(reply.recipient), '@')) == 0 || resolve_local(at + 1)) { -#if 0 vstring_strcpy(reply.nexthop, STR(reply.recipient)); + lowercase(STR(reply.nexthop)); +#if 0 (void) split_at_right(STR(reply.nexthop), '@'); #endif #if 0 diff --git a/postfix/src/postdrop/Makefile.in b/postfix/src/postdrop/Makefile.in index 8a1a5983c..2d893c3ac 100644 --- a/postfix/src/postdrop/Makefile.in +++ b/postfix/src/postdrop/Makefile.in @@ -62,6 +62,7 @@ postdrop.o: ../../include/vbuf.h postdrop.o: ../../include/vstring.h postdrop.o: ../../include/msg_vstream.h postdrop.o: ../../include/msg_syslog.h +postdrop.o: ../../include/argv.h postdrop.o: ../../include/mail_proto.h postdrop.o: ../../include/iostuff.h postdrop.o: ../../include/mail_queue.h diff --git a/postfix/src/qmgr/Makefile.in b/postfix/src/qmgr/Makefile.in index 91f57e21f..c37f1d78f 100644 --- a/postfix/src/qmgr/Makefile.in +++ b/postfix/src/qmgr/Makefile.in @@ -92,6 +92,7 @@ qmgr_active.o: ../../include/vstring.h qmgr_active.o: ../../include/recipient_list.h qmgr_active.o: ../../include/bounce.h qmgr_active.o: ../../include/defer.h +qmgr_active.o: ../../include/abounce.h qmgr_active.o: ../../include/rec_type.h qmgr_active.o: qmgr.h qmgr_active.o: ../../include/scan_dir.h diff --git a/postfix/src/qmgr/qmgr_deliver.c b/postfix/src/qmgr/qmgr_deliver.c index cfc49de73..003c4373e 100644 --- a/postfix/src/qmgr/qmgr_deliver.c +++ b/postfix/src/qmgr/qmgr_deliver.c @@ -45,6 +45,7 @@ #include #include +#include /* Utility library. */ @@ -117,11 +118,18 @@ static int qmgr_deliver_send_request(QMGR_ENTRY *entry, VSTREAM *stream) QMGR_RCPT_LIST list = entry->rcpt_list; QMGR_RCPT *recipient; QMGR_MESSAGE *message = entry->message; + char *cp; + /* + * With local delivery, the queue name is user@nexthop, so that we can + * implement per-recipient concurrency limits. The delivery agent + * protocol expects nexthop only. + */ mail_print(stream, "%d %s %s %ld %ld %s %s %s %s %ld", message->inspect_xport ? DEL_REQ_FLAG_BOUNCE : DEL_REQ_FLAG_DEFLT, message->queue_name, message->queue_id, message->data_offset, message->data_size, + (cp = strrchr(entry->queue->name, '@')) != 0 && cp[1] ? cp + 1 : entry->queue->name, message->sender, message->errors_to, message->return_receipt, message->arrival_time); diff --git a/postfix/src/qmgr/qmgr_message.c b/postfix/src/qmgr/qmgr_message.c index 6e532a5b9..cc02674bc 100644 --- a/postfix/src/qmgr/qmgr_message.c +++ b/postfix/src/qmgr/qmgr_message.c @@ -556,8 +556,9 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message) */ if ((at = strrchr(STR(reply.recipient), '@')) == 0 || resolve_local(at + 1)) { -#if 0 vstring_strcpy(reply.nexthop, STR(reply.recipient)); + lowercase(STR(reply.nexthop)); +#if 0 (void) split_at_right(STR(reply.nexthop), '@'); #endif #if 0 diff --git a/postfix/src/util/dict_mysql.c b/postfix/src/util/dict_mysql.c index ba1c0658e..135917b83 100644 --- a/postfix/src/util/dict_mysql.c +++ b/postfix/src/util/dict_mysql.c @@ -64,6 +64,10 @@ #include "sys_defs.h" #ifdef HAS_MYSQL +#include +#include +#include +#include #include #include #include @@ -77,6 +81,8 @@ #include "dict_mysql.h" #include "argv.h" #include "vstring.h" +#include "split_at.h" +#include "find_inet.h" /* external declarations */ extern int dict_errno; @@ -230,9 +236,7 @@ static MYSQL_RES *plmysql_query(PLMYSQL *PLDB, /* answer already found */ if (res != 0 && host->stat == STATACTIVE) { msg_info("dict_mysql: closing unnessary connection to %s", host->hostname); - mysql_close(&(host->db)); /* also frees memory, have to - * reallocate it */ - host->db = *((MYSQL *) mymalloc(sizeof(MYSQL))); + mysql_close(&(host->db)); plmysql_down_host(host); } /* try to connect for the first time if we don't have a result yet */ @@ -279,18 +283,36 @@ static MYSQL_RES *plmysql_query(PLMYSQL *PLDB, */ static void plmysql_connect_single(HOST *host, char *dbname, char *username, char *password) { - if (mysql_connect(&(host->db), host->hostname, username, password)) { - if (mysql_select_db(&(host->db), dbname) == 0) { - msg_info("dict_mysql: successful connection to host %s", host->hostname); - host->stat = STATACTIVE; - } else { - plmysql_down_host(host); - msg_warn("%s", mysql_error(&(host->db))); - } + char *destination = host->hostname; + char *unix_socket = 0; + char *hostname = 0; + char *service; + unsigned port = 0; + + /* + * Ad-hoc parsing code. Expect "unix:pathname" or "inet:host:port", where + * both "inet:" and ":port" are optional. + */ + if (strncmp(destination, "unix:", 5) == 0) { + unix_socket = destination + 5; + } else { + if (strncmp(destination, "inet:", 5) == 0) + destination += 5; + hostname = mystrdup(destination); + if ((service = split_at(hostname, ':')) != 0) + port = ntohs(find_inet_port(service, "tcp")); + } + + host->db = *((MYSQL *) mysql_init(NULL)); + if (mysql_real_connect(&(host->db), hostname, username, password, dbname, port, unix_socket, 0)) { + msg_info("dict_mysql: successful connection to host %s", host->hostname); + host->stat = STATACTIVE; } else { plmysql_down_host(host); msg_warn("%s", mysql_error(&(host->db))); } + if (hostname) + myfree(hostname); } /* diff --git a/postfix/src/util/name_mask.c b/postfix/src/util/name_mask.c index 52e9cf769..0ed7a7558 100644 --- a/postfix/src/util/name_mask.c +++ b/postfix/src/util/name_mask.c @@ -139,9 +139,9 @@ int main(int argc, char **argv) VSTRING *buf = vstring_alloc(1); while (--argc && *++argv) { - mask = name_mask(table, *argv); + mask = name_mask("test", table, *argv); vstream_printf("%s -> 0x%x -> %s\n", - *argv, mask, str_name_mask(buf, table, mask)); + *argv, mask, str_name_mask("mask_test", table, mask)); vstream_fflush(VSTREAM_OUT); } vstring_free(buf); diff --git a/postfix/src/util/safe_open.c b/postfix/src/util/safe_open.c index 4183a1b8c..f582cc1f0 100644 --- a/postfix/src/util/safe_open.c +++ b/postfix/src/util/safe_open.c @@ -87,7 +87,7 @@ /* safe_open_exist - open existing file */ static VSTREAM *safe_open_exist(const char *path, int flags, - struct stat * fstat_st, VSTRING *why) + struct stat * fstat_st, VSTRING * why) { struct stat local_statbuf; struct stat lstat_st; @@ -97,7 +97,7 @@ static VSTREAM *safe_open_exist(const char *path, int flags, * Open an existing file. */ if ((fp = vstream_fopen(path, flags & ~(O_CREAT | O_EXCL), 0)) == 0) { - vstring_sprintf(why, "cannot open existing file: %m"); + vstring_sprintf(why, "cannot open file: %m"); return (0); } @@ -110,8 +110,9 @@ static VSTREAM *safe_open_exist(const char *path, int flags, fstat_st = &local_statbuf; if (fstat(vstream_fileno(fp), fstat_st) < 0) { msg_fatal("%s: bad open file status: %m", path); - } else if (fstat_st->st_nlink > 1) { - vstring_sprintf(why, "file has multiple hard links"); + } else if (fstat_st->st_nlink != 1) { + vstring_sprintf(why, "file has %d hard links", + (int) fstat_st->st_nlink); } else if (S_ISDIR(fstat_st->st_mode)) { vstring_sprintf(why, "file is a directory"); } @@ -158,7 +159,7 @@ static VSTREAM *safe_open_exist(const char *path, int flags, /* safe_open_create - create new file */ static VSTREAM *safe_open_create(const char *path, int flags, int mode, - struct stat * st, uid_t user, uid_t group, VSTRING *why) + struct stat * st, uid_t user, uid_t group, VSTRING * why) { VSTREAM *fp; @@ -206,7 +207,7 @@ static VSTREAM *safe_open_create(const char *path, int flags, int mode, /* safe_open - safely open or create file */ VSTREAM *safe_open(const char *path, int flags, int mode, - struct stat * st, uid_t user, gid_t group, VSTRING *why) + struct stat * st, uid_t user, gid_t group, VSTRING * why) { VSTREAM *fp; diff --git a/postfix/src/util/sys_defs.h b/postfix/src/util/sys_defs.h index cf315c46b..f7c118624 100644 --- a/postfix/src/util/sys_defs.h +++ b/postfix/src/util/sys_defs.h @@ -437,7 +437,7 @@ extern int initgroups(const char *, int); #define HAS_DBM #define HAS_FCNTL_LOCK #define INTERNAL_LOCK MYFLOCK_STYLE_FCNTL -#define DEF_MAILBOX_LOCK "fcntl, dotlock" +#define DEF_MAILBOX_LOCK "fcntl" #define HAS_FSYNC #define DEF_DB_TYPE "dbm" #define ALIAS_DB_MAP "dbm:/etc/mail/aliases" @@ -467,7 +467,7 @@ extern int h_errno; /* imports too much stuff */ #define HAS_DBM #define HAS_FCNTL_LOCK #define INTERNAL_LOCK MYFLOCK_STYLE_FCNTL -#define DEF_MAILBOX_LOCK "fcntl, dotlock" +#define DEF_MAILBOX_LOCK "fcntl" #define HAS_FSYNC #define DEF_DB_TYPE "dbm" #define ALIAS_DB_MAP "dbm:/etc/mail/aliases" @@ -497,7 +497,7 @@ extern int h_errno; /* imports too much stuff */ #define HAS_DBM #define HAS_FCNTL_LOCK #define INTERNAL_LOCK MYFLOCK_STYLE_FCNTL -#define DEF_MAILBOX_LOCK "fcntl, dotlock" +#define DEF_MAILBOX_LOCK "fcntl" #define HAS_FSYNC #define HAS_NIS #define MISSING_SETENV @@ -531,7 +531,7 @@ extern int h_errno; #define HAS_DBM #define HAS_FLOCK_LOCK #define INTERNAL_LOCK MYFLOCK_STYLE_FLOCK -#define DEF_MAILBOX_LOCK "flock, dotlock" +#define DEF_MAILBOX_LOCK "flock" #define USE_STATFS #define HAVE_SYS_DIR_H #define STATFS_IN_SYS_VFS_H @@ -581,7 +581,7 @@ extern int opterr; #define HAS_DBM #define HAS_FLOCK_LOCK #define INTERNAL_LOCK MYFLOCK_STYLE_FLOCK -#define DEF_MAILBOX_LOCK "flock, dotlock" +#define DEF_MAILBOX_LOCK "flock" #define USE_STATFS #define HAVE_SYS_DIR_H #define STATFS_IN_SYS_VFS_H diff --git a/postfix/src/util/vstream_popen.c b/postfix/src/util/vstream_popen.c index dad7b3062..b31a76bf8 100644 --- a/postfix/src/util/vstream_popen.c +++ b/postfix/src/util/vstream_popen.c @@ -319,13 +319,15 @@ int main(int argc, char **argv) /* * Sanity check. */ - if (argc != 2) + if (argc < 2) msg_fatal("usage: %s 'command'", argv[0]); /* * Open stream to child process. */ - if ((stream = vstream_popen(argv[1], O_RDWR)) == 0) + if ((stream = vstream_popen(O_RDWR, + VSTREAM_POPEN_ARGV, argv + 1, + VSTREAM_POPEN_END)) == 0) msg_fatal("vstream_popen: %m"); /*