diff --git a/postfix/HISTORY b/postfix/HISTORY index c57b542c8..50729f18c 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -28780,3 +28780,80 @@ Apologies for any names omitted. Cleanup: the netstring client sets or clears errno to improve error messages from its callers. File: util/netstring.c. + +20250109 + + Bugfix (defect introduced: Postfix 2.6): fixed the parsing + of multiple commas in a multi_instance_directories parameter + value. Michael Tokarev. Files: conf/postfix-script, + conf/post-install, conf/postfix-wrapper, proto/postfix-wrapper. + + Cleanup: replace static result buffer with per-instance buffer. + Michael Tokarev. File: util/dict_cdb.c. + + Feature: first/next iterator support for cdb: tables, if + built with tinycdb. Michael Tokarev. Wietse added a test + and documentation. Files: util/dict_cdb.c proto/CDB_README.html, + postmap/Makefile.in. + +20241111 + + Zero code change baseline for new features. Code base is + 20241027. + + This renames symbols that are part of the Postfix SMTPUTF8 + implementation. The result still uses the same bitflags, + but the unused bitflags can now officially be used to + implement other Postfix features. The only change is that + in three debug messages, "smtputf8" becomes "sendopts". + Otherwise, the compiler output is bit-for-bit identical. + + This change makes it possible to propagate new bitflags + from Postfix mail receiving programs through queue files + into delivery agents without having to rip up internal APIs + like when we implemented SMTPUTF8 support. + + There is some SMTPUTF8-related code that will need to be + updated to read only specific bitflags instead of testing + an entire integer for (non)zero. Older Postfix implementations + will not do evil things when they encounter queue file with + new flags from a newer Postfix version. They will correctly + handle SMTPUTF8 messages and ignore the new flags. Some + programs may falsely claim that a non-SMTPUTF8 message with + a non-ASCII envelope address has an UTF8 envelope address. + Although such messages violate SMTP, Postfix will do no + harm. + +20250109 + + No intentional behavior change. + + Code cleanup: in SMTPUTF8 support, set and read the sender + options flags more selectively, instead of assuming that + all bits are used exclusively for SMTPUTF8 support. Files: + bounce/bounce_notify_util.c, cleanup/cleanup_api.c, + cleanup/cleanup_envelope.c, smtp/smtp_proto.c. + + TODO: in smtp_proto.c, add valid_utf8_stringz() check when + sending a DSN ORCPT address. Better: reuse IS_UTF8_ADDRESS() + (it's currently defined in bounce_notify_util.c). + + TODO: take a cue from Arnt Gulbrandsen's qmail patch. In the SMTP + client, enforce SMTPUTF8 if the message headers or envelope + require SMTPUTF8, or if the sender requested it. Ditto for + bounces. The qmail patch does not look for UTF8 text in headers, + but Exim will reject UTF8 headers unless the client requests + SMTPUTF8. + + TODO: If we don't auto-generate the "SMTPUTF8 requested" + flag we may need to update the bounce daemon. Maybe it can + use similar logic as the SMTP client. + + TODO: in the bounce daemon consider replacing + (bounce_info->smtputf8 & SMTPUTF8_FLAG_REQUESTED) with + (bounce_info->smtputf8 & SMTPUTF8_FLAG_ALL): message/global + should be selected if a message has 8bit header or envelope. + + TODO: in stable releases in the queue managers "and" the + queue file's smtputf8 value with SMTPUTF8_FLAG_ALL, for + forward compatibility. diff --git a/postfix/README_FILES/CDB_README b/postfix/README_FILES/CDB_README index 0dbb5cbe2..6ccf26807 100644 --- a/postfix/README_FILES/CDB_README +++ b/postfix/README_FILES/CDB_README @@ -17,8 +17,25 @@ temporarily while a CDB file is under construction). CDB databases are maintained with the postmap(1) or postalias(1) command. The DATABASE_README document has general information about Postfix databases. -CDB support is available with Postfix 2.2 and later releases. This document -describes how to build Postfix with CDB support. +You can use "cdb:" tables wherever you can use read-only "hash", "btree" or +"lmdb" tables with the following limitations: + + * CDB databases cannot be larger than 4GB on LP64 and ILP32 systems, because + the CDB library API uses unsigned integers for file offsets. + + * The "ppoossttmmaapp --ii" (incremental record insertion) and "ppoossttmmaapp --dd" + (incremental record deletion) command-line options are not available. For + the same reason the "cdb:" map type cannot be used to for persistent + caches, such as the address verification cache for the verify(8) service, + the TLS session cache for the tlsmgr(8) service, or the dynamic allowlist + for postscreen(8). + + * The "sequence" operation ("ppoossttmmaapp --ss" or "ppoossttaalliiaass --ss") is available only + wen Postfix is built with tinycdb by Michael Tokarev, not with the original + cdb library by Daniel Bernstein. + +CDB support is available with Postfix 2.2 and later releases. The remainder of +this document describes how to build Postfix with CDB support. BBuuiillddiinngg PPoossttffiixx wwiitthh CCDDBB ssuuppppoorrtt @@ -64,11 +81,3 @@ building a dynamically-loaded or statically-loaded CDB database client. database library dependencies. And that was exactly what dynamic database client loading was meant to avoid. -After Postfix has been built with cdb support, you can use "cdb" tables -wherever you can use read-only "hash", "btree" or "dbm" tables. However, the -"ppoossttmmaapp --ii" (incremental record insertion) and "ppoossttmmaapp --dd" (incremental -record deletion) command-line options are not available. For the same reason -the "cdb" map type cannot be used to store the persistent address verification -cache for the verify(8) service, or to store TLS session information for the -tlsmgr(8) service. - diff --git a/postfix/WISHLIST b/postfix/WISHLIST index 64e2ad51f..50f56fd10 100644 --- a/postfix/WISHLIST +++ b/postfix/WISHLIST @@ -19,6 +19,9 @@ Wish list: relay_recipient_maps empty should default to 'no valid recipients'. Subject to compatibility level. + Replace static result buffers with per-instance buffers in + dict_unix.c, dict_ni*c. + The Milter 'quarantine' action should be reported with a call-back function, instead of setting the Milter default reply. However, we still need the existing 'reply' based diff --git a/postfix/conf/post-install b/postfix/conf/post-install index cceef6770..cd5f14678 100644 --- a/postfix/conf/post-install +++ b/postfix/conf/post-install @@ -296,7 +296,7 @@ test -d "$config_directory" || { instances=`test ! -f $def_config_directory/main.cf || $POSTCONF -qc $def_config_directory -h multi_instance_directories | - sed 's/,/ /'` || exit 1 + sed 'y/,/ /'` || exit 1 update_shared_files=1 for name in $instances diff --git a/postfix/conf/postfix-script b/postfix/conf/postfix-script index c43d764fb..de86d382b 100755 --- a/postfix/conf/postfix-script +++ b/postfix/conf/postfix-script @@ -97,7 +97,7 @@ def_config_directory=`$command_directory/postconf -dh config_directory` || { instances=`test ! -f $def_config_directory/main.cf || $command_directory/postconf -qc $def_config_directory \ - -h multi_instance_directories | sed 's/,/ /'` || { + -h multi_instance_directories | sed 'y/,/ /'` || { $FATAL cannot execute $command_directory/postconf! exit 1 } diff --git a/postfix/conf/postfix-wrapper b/postfix/conf/postfix-wrapper index dd0a51762..cb9dc10d8 100644 --- a/postfix/conf/postfix-wrapper +++ b/postfix/conf/postfix-wrapper @@ -188,7 +188,7 @@ POSTFIX=$command_directory/postfix # Canonicalize the instance directory list. The list is specified # in startup order. -instance_dirs=`$POSTCONF -h multi_instance_directories | sed 's/,/ /'` || +instance_dirs=`$POSTCONF -h multi_instance_directories | sed 'y/,/ /'` || exit 1 case "$1" in diff --git a/postfix/html/CDB_README.html b/postfix/html/CDB_README.html index e58ccc818..e6952eed5 100644 --- a/postfix/html/CDB_README.html +++ b/postfix/html/CDB_README.html @@ -35,8 +35,33 @@ under construction). CDB databases are maintained with the postalias(1) command. The DATABASE_README document has general information about Postfix databases.

+

You can use "cdb:" tables wherever you can use read-only "hash", +"btree" or "lmdb" tables with the following limitations:

+ + +

CDB support is available with Postfix 2.2 and later releases. -This document describes how to build Postfix with CDB support.

+The remainder of this document describes how to build Postfix with +CDB support.

Building Postfix with CDB support

@@ -99,12 +124,3 @@ will have CDB database library dependencies. And that was exactly what dynamic database client loading was meant to avoid.

- -

After Postfix has been built with cdb support, you can use -"cdb" tables wherever you can use read-only "hash", "btree" or -"dbm" tables. However, the "postmap -i" (incremental record -insertion) and "postmap -d" (incremental record deletion) -command-line options are not available. For the same reason the -"cdb" map type cannot be used to store the persistent address -verification cache for the verify(8) service, or to store -TLS session information for the tlsmgr(8) service.

diff --git a/postfix/html/bounce.8.html b/postfix/html/bounce.8.html index 603ca0f53..212ec8f6b 100644 --- a/postfix/html/bounce.8.html +++ b/postfix/html/bounce.8.html @@ -194,5 +194,8 @@ BOUNCE(8) BOUNCE(8) 111 8th Avenue New York, NY 10011, USA + Wietse Venema + porcupine.org + BOUNCE(8) diff --git a/postfix/html/defer.8.html b/postfix/html/defer.8.html index 603ca0f53..212ec8f6b 100644 --- a/postfix/html/defer.8.html +++ b/postfix/html/defer.8.html @@ -194,5 +194,8 @@ BOUNCE(8) BOUNCE(8) 111 8th Avenue New York, NY 10011, USA + Wietse Venema + porcupine.org + BOUNCE(8) diff --git a/postfix/html/local.8.html b/postfix/html/local.8.html index 2a7945801..915540c23 100644 --- a/postfix/html/local.8.html +++ b/postfix/html/local.8.html @@ -524,7 +524,7 @@ LOCAL(8) LOCAL(8) delay_logging_resolution_limit (2) The maximal number of digits after the decimal point when log- - ging sub-second delay values. + ging delay values. export_environment (see 'postconf -d' output) The list of environment variables that a Postfix process will @@ -632,5 +632,8 @@ LOCAL(8) LOCAL(8) 111 8th Avenue New York, NY 10011, USA + Wietse Venema + porcupine.org + LOCAL(8) diff --git a/postfix/html/postfix-wrapper.5.html b/postfix/html/postfix-wrapper.5.html index 88884eece..845e23126 100644 --- a/postfix/html/postfix-wrapper.5.html +++ b/postfix/html/postfix-wrapper.5.html @@ -106,7 +106,7 @@ POSTFIX-WRAPPER(5) POSTFIX-WRAPPER(5) POSTCONF=$command_directory/postconf POSTFIX=$command_directory/postfix instance_dirs=`$POSTCONF -h multi_instance_directories | - sed 's/,/ /'` || exit 1 + sed 'y/,/ /'` || exit 1 err=0 for dir in $config_directory $instance_dirs diff --git a/postfix/html/trace.8.html b/postfix/html/trace.8.html index 603ca0f53..212ec8f6b 100644 --- a/postfix/html/trace.8.html +++ b/postfix/html/trace.8.html @@ -194,5 +194,8 @@ BOUNCE(8) BOUNCE(8) 111 8th Avenue New York, NY 10011, USA + Wietse Venema + porcupine.org + BOUNCE(8) diff --git a/postfix/makedefs b/postfix/makedefs index 9bd730281..5d2a25571 100644 --- a/postfix/makedefs +++ b/postfix/makedefs @@ -979,7 +979,7 @@ CCARGS="$CCARGS -DSNAPSHOT" # Non-production: needs thorough testing, or major changes are still # needed before the code stabilizes. -#CCARGS="$CCARGS -DNONPROD" +CCARGS="$CCARGS -DNONPROD" # Workaround: prepend Postfix include files before other include files. CCARGS="-I. -I../../include $CCARGS" diff --git a/postfix/man/man5/postfix-wrapper.5 b/postfix/man/man5/postfix-wrapper.5 index 3f4ee9cd0..d6e66910c 100644 --- a/postfix/man/man5/postfix-wrapper.5 +++ b/postfix/man/man5/postfix-wrapper.5 @@ -123,7 +123,7 @@ manager implementation: POSTCONF=$command_directory/postconf POSTFIX=$command_directory/postfix instance_dirs=\`$POSTCONF \-h multi_instance_directories | - sed 's/,/ /'\` || exit 1 + sed 'y/,/ /'\` || exit 1 err=0 for dir in $config_directory $instance_dirs diff --git a/postfix/man/man8/bounce.8 b/postfix/man/man8/bounce.8 index 007ffdc0d..8581c3c1e 100644 --- a/postfix/man/man8/bounce.8 +++ b/postfix/man/man8/bounce.8 @@ -180,3 +180,6 @@ Wietse Venema Google, Inc. 111 8th Avenue New York, NY 10011, USA + +Wietse Venema +porcupine.org diff --git a/postfix/man/man8/local.8 b/postfix/man/man8/local.8 index af11a607d..9eff04c6a 100644 --- a/postfix/man/man8/local.8 +++ b/postfix/man/man8/local.8 @@ -574,7 +574,7 @@ How much time a Postfix daemon process may take to handle a request before it is terminated by a built\-in watchdog timer. .IP "\fBdelay_logging_resolution_limit (2)\fR" The maximal number of digits after the decimal point when logging -sub\-second delay values. +delay values. .IP "\fBexport_environment (see 'postconf -d' output)\fR" The list of environment variables that a Postfix process will export to non\-Postfix processes. @@ -673,3 +673,6 @@ Wietse Venema Google, Inc. 111 8th Avenue New York, NY 10011, USA + +Wietse Venema +porcupine.org diff --git a/postfix/proto/CDB_README.html b/postfix/proto/CDB_README.html index 0654551d3..cb25a8a74 100644 --- a/postfix/proto/CDB_README.html +++ b/postfix/proto/CDB_README.html @@ -35,8 +35,33 @@ under construction). CDB databases are maintained with the postmap(1) or postalias(1) command. The DATABASE_README document has general information about Postfix databases.

+

You can use "cdb:" tables wherever you can use read-only "hash", +"btree" or "lmdb" tables with the following limitations:

+ + +

CDB support is available with Postfix 2.2 and later releases. -This document describes how to build Postfix with CDB support.

+The remainder of this document describes how to build Postfix with +CDB support.

Building Postfix with CDB support

@@ -99,12 +124,3 @@ will have CDB database library dependencies. And that was exactly what dynamic database client loading was meant to avoid.

- -

After Postfix has been built with cdb support, you can use -"cdb" tables wherever you can use read-only "hash", "btree" or -"dbm" tables. However, the "postmap -i" (incremental record -insertion) and "postmap -d" (incremental record deletion) -command-line options are not available. For the same reason the -"cdb" map type cannot be used to store the persistent address -verification cache for the verify(8) service, or to store -TLS session information for the tlsmgr(8) service.

diff --git a/postfix/proto/postfix-wrapper b/postfix/proto/postfix-wrapper index 177282ef7..aaf6a53c6 100644 --- a/postfix/proto/postfix-wrapper +++ b/postfix/proto/postfix-wrapper @@ -113,7 +113,7 @@ # POSTCONF=$command_directory/postconf # POSTFIX=$command_directory/postfix # instance_dirs=\`$POSTCONF -h multi_instance_directories | -# sed 's/,/ /'\` || exit 1 +# sed 'y/,/ /'\` || exit 1 # # err=0 # for dir in $config_directory $instance_dirs diff --git a/postfix/proto/stop b/postfix/proto/stop index 22af8cf39..c1a080d87 100644 --- a/postfix/proto/stop +++ b/postfix/proto/stop @@ -1659,3 +1659,8 @@ GECOS iso ORCPT RET +ILP +REQUIRETLS +RequireTLS +requiretls +sendopts diff --git a/postfix/proto/stop.spell-cc b/postfix/proto/stop.spell-cc index 97b670546..7ecd9ce84 100644 --- a/postfix/proto/stop.spell-cc +++ b/postfix/proto/stop.spell-cc @@ -1854,3 +1854,6 @@ Charset atext qp cntrl +TINYCDB +getdata +XXXSENDOPTS diff --git a/postfix/proto/stop.spell-history b/postfix/proto/stop.spell-history index 29ba11fe1..8a8540985 100644 --- a/postfix/proto/stop.spell-history +++ b/postfix/proto/stop.spell-history @@ -97,3 +97,4 @@ roff diffs CLOSEFROM Roessner +bitflags diff --git a/postfix/src/bounce/Makefile.in b/postfix/src/bounce/Makefile.in index c0b4c383c..469db866a 100644 --- a/postfix/src/bounce/Makefile.in +++ b/postfix/src/bounce/Makefile.in @@ -279,6 +279,7 @@ bounce_notify_service.o: ../../include/post_mail.h bounce_notify_service.o: ../../include/rcpt_buf.h bounce_notify_service.o: ../../include/rec_type.h bounce_notify_service.o: ../../include/recipient_list.h +bounce_notify_service.o: ../../include/sendopts.h bounce_notify_service.o: ../../include/smtputf8.h bounce_notify_service.o: ../../include/stringops.h bounce_notify_service.o: ../../include/sys_defs.h @@ -322,6 +323,7 @@ bounce_notify_util.o: ../../include/rcpt_buf.h bounce_notify_util.o: ../../include/rec_type.h bounce_notify_util.o: ../../include/recipient_list.h bounce_notify_util.o: ../../include/record.h +bounce_notify_util.o: ../../include/sendopts.h bounce_notify_util.o: ../../include/smtputf8.h bounce_notify_util.o: ../../include/stringops.h bounce_notify_util.o: ../../include/sys_defs.h @@ -382,6 +384,7 @@ bounce_notify_verp.o: ../../include/post_mail.h bounce_notify_verp.o: ../../include/rcpt_buf.h bounce_notify_verp.o: ../../include/rec_type.h bounce_notify_verp.o: ../../include/recipient_list.h +bounce_notify_verp.o: ../../include/sendopts.h bounce_notify_verp.o: ../../include/smtputf8.h bounce_notify_verp.o: ../../include/stringops.h bounce_notify_verp.o: ../../include/sys_defs.h @@ -417,6 +420,7 @@ bounce_one_service.o: ../../include/post_mail.h bounce_one_service.o: ../../include/rcpt_buf.h bounce_one_service.o: ../../include/rec_type.h bounce_one_service.o: ../../include/recipient_list.h +bounce_one_service.o: ../../include/sendopts.h bounce_one_service.o: ../../include/smtputf8.h bounce_one_service.o: ../../include/stringops.h bounce_one_service.o: ../../include/sys_defs.h @@ -497,6 +501,7 @@ bounce_trace_service.o: ../../include/post_mail.h bounce_trace_service.o: ../../include/rcpt_buf.h bounce_trace_service.o: ../../include/rec_type.h bounce_trace_service.o: ../../include/recipient_list.h +bounce_trace_service.o: ../../include/sendopts.h bounce_trace_service.o: ../../include/smtputf8.h bounce_trace_service.o: ../../include/stringops.h bounce_trace_service.o: ../../include/sys_defs.h @@ -529,6 +534,7 @@ bounce_warn_service.o: ../../include/post_mail.h bounce_warn_service.o: ../../include/rcpt_buf.h bounce_warn_service.o: ../../include/rec_type.h bounce_warn_service.o: ../../include/recipient_list.h +bounce_warn_service.o: ../../include/sendopts.h bounce_warn_service.o: ../../include/smtputf8.h bounce_warn_service.o: ../../include/stringops.h bounce_warn_service.o: ../../include/sys_defs.h diff --git a/postfix/src/bounce/bounce.c b/postfix/src/bounce/bounce.c index 23939299b..1567bada0 100644 --- a/postfix/src/bounce/bounce.c +++ b/postfix/src/bounce/bounce.c @@ -160,6 +160,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -313,7 +316,7 @@ static int bounce_notify_proto(char *service_name, VSTREAM *client, { const char *myname = "bounce_notify_proto"; int flags; - int smtputf8; + int sendopts; int dsn_ret; /* @@ -324,7 +327,7 @@ static int bounce_notify_proto(char *service_name, VSTREAM *client, RECV_ATTR_STR(MAIL_ATTR_QUEUE, queue_name), RECV_ATTR_STR(MAIL_ATTR_QUEUEID, queue_id), RECV_ATTR_STR(MAIL_ATTR_ENCODING, encoding), - RECV_ATTR_INT(MAIL_ATTR_SMTPUTF8, &smtputf8), + RECV_ATTR_INT(MAIL_ATTR_SENDOPTS, &sendopts), RECV_ATTR_STR(MAIL_ATTR_SENDER, sender), RECV_ATTR_STR(MAIL_ATTR_DSN_ENVID, dsn_envid), RECV_ATTR_INT(MAIL_ATTR_DSN_RET, &dsn_ret), @@ -348,9 +351,9 @@ static int bounce_notify_proto(char *service_name, VSTREAM *client, VS_NEUTER(sender); VS_NEUTER(dsn_envid); if (msg_verbose) - msg_info("%s: flags=0x%x service=%s queue=%s id=%s encoding=%s smtputf8=%d sender=%s envid=%s ret=0x%x", + msg_info("%s: flags=0x%x service=%s queue=%s id=%s encoding=%s sendopts=%d sender=%s envid=%s ret=0x%x", myname, flags, service_name, STR(queue_name), STR(queue_id), - STR(encoding), smtputf8, STR(sender), STR(dsn_envid), + STR(encoding), sendopts, STR(sender), STR(dsn_envid), dsn_ret); /* @@ -364,7 +367,7 @@ static int bounce_notify_proto(char *service_name, VSTREAM *client, * Execute the request. */ return (service(flags, service_name, STR(queue_name), - STR(queue_id), STR(encoding), smtputf8, + STR(queue_id), STR(encoding), sendopts, STR(sender), STR(dsn_envid), dsn_ret, bounce_templates)); } @@ -375,7 +378,7 @@ static int bounce_verp_proto(char *service_name, VSTREAM *client) { const char *myname = "bounce_verp_proto"; int flags; - int smtputf8; + int sendopts; int dsn_ret; /* @@ -386,7 +389,7 @@ static int bounce_verp_proto(char *service_name, VSTREAM *client) RECV_ATTR_STR(MAIL_ATTR_QUEUE, queue_name), RECV_ATTR_STR(MAIL_ATTR_QUEUEID, queue_id), RECV_ATTR_STR(MAIL_ATTR_ENCODING, encoding), - RECV_ATTR_INT(MAIL_ATTR_SMTPUTF8, &smtputf8), + RECV_ATTR_INT(MAIL_ATTR_SENDOPTS, &sendopts), RECV_ATTR_STR(MAIL_ATTR_SENDER, sender), RECV_ATTR_STR(MAIL_ATTR_DSN_ENVID, dsn_envid), RECV_ATTR_INT(MAIL_ATTR_DSN_RET, &dsn_ret), @@ -416,9 +419,9 @@ static int bounce_verp_proto(char *service_name, VSTREAM *client) return (-1); } if (msg_verbose) - msg_info("%s: flags=0x%x service=%s queue=%s id=%s encoding=%s smtputf8=%d sender=%s envid=%s ret=0x%x delim=%s", + msg_info("%s: flags=0x%x service=%s queue=%s id=%s encoding=%s sendopts=%d sender=%s envid=%s ret=0x%x delim=%s", myname, flags, service_name, STR(queue_name), - STR(queue_id), STR(encoding), smtputf8, STR(sender), + STR(queue_id), STR(encoding), sendopts, STR(sender), STR(dsn_envid), dsn_ret, STR(verp_delims)); /* @@ -436,12 +439,12 @@ static int bounce_verp_proto(char *service_name, VSTREAM *client) mail_addr_double_bounce())) { msg_warn("request to send VERP-style notification of bounced mail"); return (bounce_notify_service(flags, service_name, STR(queue_name), - STR(queue_id), STR(encoding), smtputf8, + STR(queue_id), STR(encoding), sendopts, STR(sender), STR(dsn_envid), dsn_ret, bounce_templates)); } else return (bounce_notify_verp(flags, service_name, STR(queue_name), - STR(queue_id), STR(encoding), smtputf8, + STR(queue_id), STR(encoding), sendopts, STR(sender), STR(dsn_envid), dsn_ret, STR(verp_delims), bounce_templates)); } @@ -452,7 +455,7 @@ static int bounce_one_proto(char *service_name, VSTREAM *client) { const char *myname = "bounce_one_proto"; int flags; - int smtputf8; + int sendopts; int dsn_ret; /* @@ -463,7 +466,7 @@ static int bounce_one_proto(char *service_name, VSTREAM *client) RECV_ATTR_STR(MAIL_ATTR_QUEUE, queue_name), RECV_ATTR_STR(MAIL_ATTR_QUEUEID, queue_id), RECV_ATTR_STR(MAIL_ATTR_ENCODING, encoding), - RECV_ATTR_INT(MAIL_ATTR_SMTPUTF8, &smtputf8), + RECV_ATTR_INT(MAIL_ATTR_SENDOPTS, &sendopts), RECV_ATTR_STR(MAIL_ATTR_SENDER, sender), RECV_ATTR_STR(MAIL_ATTR_DSN_ENVID, dsn_envid), RECV_ATTR_INT(MAIL_ATTR_DSN_RET, &dsn_ret), @@ -512,9 +515,9 @@ static int bounce_one_proto(char *service_name, VSTREAM *client) * RECIPIENT_FROM_RCPT_BUF(). */ if (msg_verbose) - msg_info("%s: flags=0x%x queue=%s id=%s encoding=%s smtputf8=%d sender=%s envid=%s dsn_ret=0x%x orig_to=%s to=%s off=%ld dsn_orig=%s notif=0x%x stat=%s act=%s why=%s", + msg_info("%s: flags=0x%x queue=%s id=%s encoding=%s sendopts=%d sender=%s envid=%s dsn_ret=0x%x orig_to=%s to=%s off=%ld dsn_orig=%s notif=0x%x stat=%s act=%s why=%s", myname, flags, STR(queue_name), STR(queue_id), - STR(encoding), smtputf8, STR(sender), STR(dsn_envid), + STR(encoding), sendopts, STR(sender), STR(dsn_envid), dsn_ret, STR(rcpt_buf->orig_addr), STR(rcpt_buf->address), rcpt_buf->offset, STR(rcpt_buf->dsn_orcpt), rcpt_buf->dsn_notify, STR(dsn_buf->status), @@ -524,7 +527,7 @@ static int bounce_one_proto(char *service_name, VSTREAM *client) * Execute the request. */ return (bounce_one_service(flags, STR(queue_name), STR(queue_id), - STR(encoding), smtputf8, STR(sender), + STR(encoding), sendopts, STR(sender), STR(dsn_envid), dsn_ret, rcpt_buf, dsn_buf, bounce_templates)); } diff --git a/postfix/src/bounce/bounce_notify_service.c b/postfix/src/bounce/bounce_notify_service.c index d6c751f50..b8068f176 100644 --- a/postfix/src/bounce/bounce_notify_service.c +++ b/postfix/src/bounce/bounce_notify_service.c @@ -7,14 +7,14 @@ /* #include "bounce_service.h" /* /* int bounce_notify_service(flags, service, queue_name, queue_id, -/* encoding, smtputf8, sender, dsn_envid, +/* encoding, sendopts, sender, dsn_envid, /* dsn_ret, templates) /* int flags; /* char *service; /* char *queue_name; /* char *queue_id; /* char *encoding; -/* int smtputf8; +/* int sendopts; /* char *sender; /* char *dsn_envid; /* int dsn_ret; @@ -84,7 +84,7 @@ int bounce_notify_service(int flags, char *service, char *queue_name, char *queue_id, char *encoding, - int smtputf8, char *recipient, + int sendopts, char *recipient, char *dsn_envid, int dsn_ret, BOUNCE_TEMPLATES *ts) { @@ -131,7 +131,7 @@ int bounce_notify_service(int flags, char *service, char *queue_name, * notification is enabled. */ bounce_info = bounce_mail_init(service, queue_name, queue_id, - encoding, smtputf8, dsn_envid, + encoding, sendopts, dsn_envid, ts->failure); #define NULL_SENDER MAIL_ADDR_EMPTY /* special address */ @@ -179,7 +179,7 @@ int bounce_notify_service(int flags, char *service, char *queue_name, postmaster, MAIL_SRC_MASK_BOUNCE, NULL_TRACE_FLAGS, - smtputf8, + sendopts, new_id)) != 0) { /* @@ -219,7 +219,7 @@ int bounce_notify_service(int flags, char *service, char *queue_name, if ((bounce = post_mail_fopen_nowait(NULL_SENDER, recipient, MAIL_SRC_MASK_BOUNCE, NULL_TRACE_FLAGS, - smtputf8, + sendopts, new_id)) != 0) { /* @@ -274,7 +274,7 @@ int bounce_notify_service(int flags, char *service, char *queue_name, postmaster, MAIL_SRC_MASK_BOUNCE, NULL_TRACE_FLAGS, - smtputf8, + sendopts, new_id)) != 0) { count = -1; if (bounce_header(bounce, bounce_info, postmaster, diff --git a/postfix/src/bounce/bounce_notify_util.c b/postfix/src/bounce/bounce_notify_util.c index bfc92c567..9c2bb86cc 100644 --- a/postfix/src/bounce/bounce_notify_util.c +++ b/postfix/src/bounce/bounce_notify_util.c @@ -13,22 +13,22 @@ /* } BOUNCE_INFO; /* /* BOUNCE_INFO *bounce_mail_init(service, queue_name, queue_id, encoding, -/* smtputf8, dsn_envid, template) +/* sendopts, dsn_envid, template) /* const char *service; /* const char *queue_name; /* const char *queue_id; /* const char *encoding; -/* int smtputf8; +/* int sendopts; /* const char *dsn_envid; /* const BOUNCE_TEMPLATE *template; /* /* BOUNCE_INFO *bounce_mail_one_init(queue_name, queue_id, encoding, -/* smtputf8, dsn_envid, dsn_notify, +/* sendopts, dsn_envid, dsn_notify, /* rcpt_buf, dsn_buf, template) /* const char *queue_name; /* const char *queue_id; /* const char *encoding; -/* int smtputf8; +/* int sendopts; /* int dsn_notify; /* const char *dsn_envid; /* RCPT_BUF *rcpt_buf; @@ -160,6 +160,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -221,7 +224,7 @@ static BOUNCE_INFO *bounce_mail_alloc(const char *service, const char *queue_name, const char *queue_id, const char *encoding, - int smtputf8, + int sendopts, const char *dsn_envid, RCPT_BUF *rcpt_buf, DSN_BUF *dsn_buf, @@ -244,7 +247,7 @@ static BOUNCE_INFO *bounce_mail_alloc(const char *service, bounce_info->service = service; bounce_info->queue_name = queue_name; bounce_info->queue_id = queue_id; - bounce_info->smtputf8 = smtputf8; + bounce_info->sendopts = sendopts; /* Fix 20140708: override MIME encoding: addresses may be 8bit. */ /* Fix 20140718: override MIME encoding: 8bit $myhostname expansion. */ if (var_smtputf8_enable /* was: bounce_info->smtputf8 */ ) { @@ -422,7 +425,7 @@ BOUNCE_INFO *bounce_mail_init(const char *service, const char *queue_name, const char *queue_id, const char *encoding, - int smtputf8, + int sendopts, const char *dsn_envid, BOUNCE_TEMPLATE *template) { @@ -449,7 +452,7 @@ BOUNCE_INFO *bounce_mail_init(const char *service, dsn_buf = dsb_create(); } bounce_info = bounce_mail_alloc(service, queue_name, queue_id, encoding, - smtputf8, dsn_envid, rcpt_buf, dsn_buf, + sendopts, dsn_envid, rcpt_buf, dsn_buf, template, log_handle); return (bounce_info); } @@ -459,7 +462,7 @@ BOUNCE_INFO *bounce_mail_init(const char *service, BOUNCE_INFO *bounce_mail_one_init(const char *queue_name, const char *queue_id, const char *encoding, - int smtputf8, + int sendopts, const char *dsn_envid, RCPT_BUF *rcpt_buf, DSN_BUF *dsn_buf, @@ -471,7 +474,7 @@ BOUNCE_INFO *bounce_mail_one_init(const char *queue_name, * Initialize the bounce_info structure for just one recipient. */ bounce_info = bounce_mail_alloc("none", queue_name, queue_id, encoding, - smtputf8, dsn_envid, rcpt_buf, dsn_buf, + sendopts, dsn_envid, rcpt_buf, dsn_buf, template, (BOUNCE_LOG *) 0); return (bounce_info); } @@ -694,12 +697,12 @@ int bounce_header_dsn(VSTREAM *bounce, BOUNCE_INFO *bounce_info) "Delivery report"); /* Generate *global* only if the original requested SMTPUTF8 support. */ post_mail_fprintf(bounce, "Content-Type: message/%sdelivery-status", - (bounce_info->smtputf8 & SMTPUTF8_FLAG_REQUESTED) ? + (bounce_info->sendopts & SMTPUTF8_FLAG_REQUESTED) ? "global-" : ""); /* Fix 20140709: addresses may be 8bit. */ if (NOT_7BIT_MIME(bounce_info) /* BC Fix 20170610: prevent MIME downgrade of message/delivery-status. */ - && (bounce_info->smtputf8 & SMTPUTF8_FLAG_REQUESTED)) + && (bounce_info->sendopts & SMTPUTF8_FLAG_REQUESTED)) post_mail_fprintf(bounce, "Content-Transfer-Encoding: %s", bounce_info->mime_encoding); @@ -727,7 +730,8 @@ int bounce_header_dsn(VSTREAM *bounce, BOUNCE_INFO *bounce_info) /* Fix 20140708: use "utf-8" or "rfc822" as appropriate. */ if (VSTRING_LEN(bounce_info->sender) > 0) post_mail_fprintf(bounce, "X-%s-Sender: %s; %s", - bounce_info->mail_name, bounce_info->smtputf8 + bounce_info->mail_name, + (bounce_info->sendopts & SMTPUTF8_FLAG_ALL) && IS_UTF8_ADDRESS(STR(bounce_info->sender)) ? "utf-8" : "rfc822", STR(bounce_info->sender)); if (bounce_info->arrival_time > 0) @@ -746,7 +750,7 @@ int bounce_recipient_dsn(VSTREAM *bounce, BOUNCE_INFO *bounce_info) post_mail_fputs(bounce, ""); /* Fix 20140708: Don't send "utf-8" type with non-UTF8 address. */ post_mail_fprintf(bounce, "Final-Recipient: %s; %s", - bounce_info->smtputf8 + (bounce_info->sendopts & SMTPUTF8_FLAG_ALL) && IS_UTF8_ADDRESS(rcpt->address) ? "utf-8" : "rfc822", rcpt->address); @@ -774,7 +778,7 @@ int bounce_recipient_dsn(VSTREAM *bounce, BOUNCE_INFO *bounce_info) } else if (NON_NULL_EMPTY(rcpt->orig_addr)) { /* Fix 20140708: Don't send "utf-8" type with non-UTF8 address. */ post_mail_fprintf(bounce, "Original-Recipient: %s; %s", - bounce_info->smtputf8 + (bounce_info->sendopts & SMTPUTF8_FLAG_ALL) && IS_UTF8_ADDRESS(rcpt->orig_addr) ? "utf-8" : "rfc822", rcpt->orig_addr); } @@ -869,7 +873,7 @@ int bounce_original(VSTREAM *bounce, BOUNCE_INFO *bounce_info, headers_only == DSN_RET_HDRS ? "Message Headers" : "Message"); /* Generate *global* only if the original requested SMTPUTF8 support. */ - if (bounce_info->smtputf8 & SMTPUTF8_FLAG_REQUESTED) + if (bounce_info->sendopts & SMTPUTF8_FLAG_REQUESTED) post_mail_fprintf(bounce, "Content-Type: message/%s", headers_only == DSN_RET_HDRS ? "global-headers" : "global"); diff --git a/postfix/src/bounce/bounce_notify_verp.c b/postfix/src/bounce/bounce_notify_verp.c index 8bfd71b82..84e20b8e2 100644 --- a/postfix/src/bounce/bounce_notify_verp.c +++ b/postfix/src/bounce/bounce_notify_verp.c @@ -7,7 +7,7 @@ /* #include "bounce_service.h" /* /* int bounce_notify_verp(flags, service, queue_name, queue_id, -/* encoding, smtputf8, sender, +/* encoding, sendopts, sender, /* dsn_envid, dsn_ret, verp_delims, /* templates) /* int flags; @@ -15,7 +15,7 @@ /* char *queue_name; /* char *queue_id; /* char *encoding; -/* int smtputf8; +/* int sendopts; /* char *sender; /* char *dsn_envid; /* int dsn_ret; @@ -87,7 +87,7 @@ int bounce_notify_verp(int flags, char *service, char *queue_name, char *queue_id, char *encoding, - int smtputf8, char *recipient, + int sendopts, char *recipient, char *dsn_envid, int dsn_ret, char *verp_delims, BOUNCE_TEMPLATES *ts) { @@ -115,7 +115,7 @@ int bounce_notify_verp(int flags, char *service, char *queue_name, * Initialize. Open queue file, bounce log, etc. */ bounce_info = bounce_mail_init(service, queue_name, queue_id, - encoding, smtputf8, dsn_envid, + encoding, sendopts, dsn_envid, ts->failure); /* @@ -131,7 +131,7 @@ int bounce_notify_verp(int flags, char *service, char *queue_name, vstring_strcpy(rcpt_buf->address, "(recipient address unavailable)"); (void) RECIPIENT_FROM_RCPT_BUF(rcpt_buf); bounce_status = bounce_one_service(flags, queue_name, queue_id, - encoding, smtputf8, recipient, + encoding, sendopts, recipient, dsn_envid, dsn_ret, rcpt_buf, dsn_buf, ts); rcpb_free(rcpt_buf); @@ -166,7 +166,7 @@ int bounce_notify_verp(int flags, char *service, char *queue_name, if ((bounce = post_mail_fopen_nowait(NULL_SENDER, STR(verp_buf), MAIL_SRC_MASK_BOUNCE, NULL_TRACE_FLAGS, - smtputf8, + sendopts, new_id)) != 0) { /* @@ -226,7 +226,7 @@ int bounce_notify_verp(int flags, char *service, char *queue_name, postmaster, MAIL_SRC_MASK_BOUNCE, NULL_TRACE_FLAGS, - smtputf8, + sendopts, new_id)) != 0) { if (bounce_header(bounce, bounce_info, postmaster, POSTMASTER_COPY) == 0 diff --git a/postfix/src/bounce/bounce_one_service.c b/postfix/src/bounce/bounce_one_service.c index 18092e6e5..ab6cac829 100644 --- a/postfix/src/bounce/bounce_one_service.c +++ b/postfix/src/bounce/bounce_one_service.c @@ -7,13 +7,13 @@ /* #include "bounce_service.h" /* /* int bounce_one_service(flags, queue_name, queue_id, encoding, -/* smtputf8, orig_sender, envid, ret, +/* sendopts, orig_sender, envid, ret, /* rcpt_buf, dsn_buf, templates) /* int flags; /* char *queue_name; /* char *queue_id; /* char *encoding; -/* int smtputf8; +/* int sendopts; /* char *orig_sender; /* char *envid; /* int ret; @@ -83,7 +83,7 @@ /* bounce_one_service - send a bounce for one recipient */ int bounce_one_service(int flags, char *queue_name, char *queue_id, - char *encoding, int smtputf8, + char *encoding, int sendopts, char *orig_sender, char *dsn_envid, int dsn_ret, RCPT_BUF *rcpt_buf, DSN_BUF *dsn_buf, BOUNCE_TEMPLATES *ts) @@ -100,7 +100,7 @@ int bounce_one_service(int flags, char *queue_name, char *queue_id, * Initialize. Open queue file, bounce log, etc. */ bounce_info = bounce_mail_one_init(queue_name, queue_id, encoding, - smtputf8, dsn_envid, rcpt_buf, + sendopts, dsn_envid, rcpt_buf, dsn_buf, ts->failure); #define NULL_SENDER MAIL_ADDR_EMPTY /* special address */ @@ -148,7 +148,7 @@ int bounce_one_service(int flags, char *queue_name, char *queue_id, var_2bounce_rcpt, MAIL_SRC_MASK_BOUNCE, NULL_TRACE_FLAGS, - smtputf8, + sendopts, new_id)) != 0) { /* @@ -185,7 +185,7 @@ int bounce_one_service(int flags, char *queue_name, char *queue_id, if ((bounce = post_mail_fopen_nowait(NULL_SENDER, orig_sender, MAIL_SRC_MASK_BOUNCE, NULL_TRACE_FLAGS, - smtputf8, + sendopts, new_id)) != 0) { /* @@ -231,7 +231,7 @@ int bounce_one_service(int flags, char *queue_name, char *queue_id, var_bounce_rcpt, MAIL_SRC_MASK_BOUNCE, NULL_TRACE_FLAGS, - smtputf8, + sendopts, new_id)) != 0) { if (bounce_header(bounce, bounce_info, var_bounce_rcpt, POSTMASTER_COPY) == 0 diff --git a/postfix/src/bounce/bounce_service.h b/postfix/src/bounce/bounce_service.h index b79542fc9..21e323c69 100644 --- a/postfix/src/bounce/bounce_service.h +++ b/postfix/src/bounce/bounce_service.h @@ -90,7 +90,7 @@ typedef struct { DSN_BUF *dsn_buf; /* delivery status info */ BOUNCE_LOG *log_handle; /* open logfile */ char *mail_name; /* $mail_name, cooked */ - int smtputf8; /* SMTPUTF8 requested */ + int sendopts; /* smtputf8, requiretls, etc. */ } BOUNCE_INFO; /* */ diff --git a/postfix/src/bounce/bounce_trace_service.c b/postfix/src/bounce/bounce_trace_service.c index 8a62305fc..cb29bbb26 100644 --- a/postfix/src/bounce/bounce_trace_service.c +++ b/postfix/src/bounce/bounce_trace_service.c @@ -7,14 +7,14 @@ /* #include "bounce_service.h" /* /* int bounce_trace_service(flags, service, queue_name, queue_id, -/* encoding, smtputf8, sender, envid, +/* encoding, sendopts, sender, envid, /* ret, templates) /* int flags; /* char *service; /* char *queue_name; /* char *queue_id; /* char *encoding; -/* int smtputf8; +/* int sendopts; /* char *sender; /* char *envid; /* int ret; @@ -81,7 +81,7 @@ int bounce_trace_service(int flags, char *service, char *queue_name, char *queue_id, char *encoding, - int smtputf8, + int sendopts, char *recipient, char *dsn_envid, int unused_dsn_ret, BOUNCE_TEMPLATES *ts) @@ -140,7 +140,7 @@ int bounce_trace_service(int flags, char *service, char *queue_name, #define NON_DSN_FLAGS (DEL_REQ_FLAG_USR_VRFY | DEL_REQ_FLAG_RECORD) bounce_info = bounce_mail_init(service, queue_name, queue_id, - encoding, smtputf8, dsn_envid, + encoding, sendopts, dsn_envid, flags & NON_DSN_FLAGS ? ts->verify : ts->success); @@ -179,7 +179,7 @@ int bounce_trace_service(int flags, char *service, char *queue_name, if ((bounce = post_mail_fopen_nowait(sender, recipient, MAIL_SRC_MASK_BOUNCE, NULL_TRACE_FLAGS, - smtputf8, + sendopts, new_id)) != 0) { count = -1; if (bounce_header(bounce, bounce_info, recipient, diff --git a/postfix/src/bounce/bounce_warn_service.c b/postfix/src/bounce/bounce_warn_service.c index bbb805d8e..f9fc7641b 100644 --- a/postfix/src/bounce/bounce_warn_service.c +++ b/postfix/src/bounce/bounce_warn_service.c @@ -7,14 +7,14 @@ /* #include "bounce_service.h" /* /* int bounce_warn_service(flags, service, queue_name, queue_id, -/* encoding, smtputf8, sender, envid, +/* encoding, sendopts, sender, envid, /* dsn_ret, templates) /* int flags; /* char *service; /* char *queue_name; /* char *queue_id; /* char *encoding; -/* int smtputf8; +/* int sendopts; /* char *sender; /* char *envid; /* int dsn_ret; @@ -84,7 +84,7 @@ int bounce_warn_service(int unused_flags, char *service, char *queue_name, char *queue_id, char *encoding, - int smtputf8, char *recipient, + int sendopts, char *recipient, char *dsn_envid, int dsn_ret, BOUNCE_TEMPLATES *ts) { @@ -121,7 +121,7 @@ int bounce_warn_service(int unused_flags, char *service, char *queue_name, * notify_classes restrictions. */ bounce_info = bounce_mail_init(service, queue_name, queue_id, - encoding, smtputf8, dsn_envid, ts->delay); + encoding, sendopts, dsn_envid, ts->delay); #define NULL_SENDER MAIL_ADDR_EMPTY /* special address */ #define NULL_TRACE_FLAGS 0 @@ -168,7 +168,7 @@ int bounce_warn_service(int unused_flags, char *service, char *queue_name, postmaster, MAIL_SRC_MASK_BOUNCE, NULL_TRACE_FLAGS, - smtputf8, + sendopts, new_id)) != 0) { /* @@ -207,7 +207,7 @@ int bounce_warn_service(int unused_flags, char *service, char *queue_name, if ((bounce = post_mail_fopen_nowait(NULL_SENDER, recipient, MAIL_SRC_MASK_BOUNCE, NULL_TRACE_FLAGS, - smtputf8, + sendopts, new_id)) != 0) { /* @@ -258,7 +258,7 @@ int bounce_warn_service(int unused_flags, char *service, char *queue_name, postmaster, MAIL_SRC_MASK_BOUNCE, NULL_TRACE_FLAGS, - smtputf8, + sendopts, new_id)) != 0) { count = -1; if (bounce_header(bounce, bounce_info, postmaster, diff --git a/postfix/src/cleanup/Makefile.in b/postfix/src/cleanup/Makefile.in index 0cc020e5b..f60e36c1d 100644 --- a/postfix/src/cleanup/Makefile.in +++ b/postfix/src/cleanup/Makefile.in @@ -778,6 +778,7 @@ cleanup_addr.o: ../../include/nvtable.h cleanup_addr.o: ../../include/rec_type.h cleanup_addr.o: ../../include/record.h cleanup_addr.o: ../../include/resolve_clnt.h +cleanup_addr.o: ../../include/sendopts.h cleanup_addr.o: ../../include/smtputf8.h cleanup_addr.o: ../../include/string_list.h cleanup_addr.o: ../../include/stringops.h @@ -821,6 +822,7 @@ cleanup_api.o: ../../include/nvtable.h cleanup_api.o: ../../include/rec_type.h cleanup_api.o: ../../include/recipient_list.h cleanup_api.o: ../../include/resolve_clnt.h +cleanup_api.o: ../../include/sendopts.h cleanup_api.o: ../../include/smtputf8.h cleanup_api.o: ../../include/string_list.h cleanup_api.o: ../../include/sys_defs.h @@ -937,6 +939,7 @@ cleanup_envelope.o: ../../include/rec_type.h cleanup_envelope.o: ../../include/recipient_list.h cleanup_envelope.o: ../../include/record.h cleanup_envelope.o: ../../include/resolve_clnt.h +cleanup_envelope.o: ../../include/sendopts.h cleanup_envelope.o: ../../include/smtputf8.h cleanup_envelope.o: ../../include/string_list.h cleanup_envelope.o: ../../include/stringops.h @@ -1276,6 +1279,7 @@ cleanup_out.o: ../../include/nvtable.h cleanup_out.o: ../../include/rec_type.h cleanup_out.o: ../../include/record.h cleanup_out.o: ../../include/resolve_clnt.h +cleanup_out.o: ../../include/sendopts.h cleanup_out.o: ../../include/smtputf8.h cleanup_out.o: ../../include/split_at.h cleanup_out.o: ../../include/string_list.h diff --git a/postfix/src/cleanup/cleanup.h b/postfix/src/cleanup/cleanup.h index 09b1b8286..3565b6f16 100644 --- a/postfix/src/cleanup/cleanup.h +++ b/postfix/src/cleanup/cleanup.h @@ -129,9 +129,9 @@ typedef struct CLEANUP_STATE { struct CLEANUP_REGION *curr_body_region; /* - * Internationalization. + * Internationalization, RequireTLS, etc. */ - int smtputf8; /* what support is desired */ + int sendopts; /* what support is desired */ } CLEANUP_STATE; /* @@ -369,4 +369,7 @@ extern int cleanup_hfrom_format; /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ diff --git a/postfix/src/cleanup/cleanup_addr.c b/postfix/src/cleanup/cleanup_addr.c index f5e7d914c..ec3bc6170 100644 --- a/postfix/src/cleanup/cleanup_addr.c +++ b/postfix/src/cleanup/cleanup_addr.c @@ -68,6 +68,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -149,10 +152,10 @@ off_t cleanup_addr_sender(CLEANUP_STATE *state, const char *buf) /* Fix 20140711: Auto-detect an UTF8 sender. */ if (var_smtputf8_enable && *STR(clean_addr) && !allascii(STR(clean_addr)) && valid_utf8_stringz(STR(clean_addr))) { - state->smtputf8 |= SMTPUTF8_FLAG_SENDER; + state->sendopts |= SMTPUTF8_FLAG_SENDER; /* Fix 20140713: request SMTPUTF8 support selectively. */ if (state->flags & CLEANUP_FLAG_AUTOUTF8) - state->smtputf8 |= SMTPUTF8_FLAG_REQUESTED; + state->sendopts |= SMTPUTF8_FLAG_REQUESTED; } CLEANUP_OUT_BUF(state, REC_TYPE_FROM, clean_addr); if (state->sender) /* XXX Can't happen */ @@ -219,12 +222,12 @@ void cleanup_addr_recipient(CLEANUP_STATE *state, const char *buf) && valid_utf8_stringz(STR(clean_addr))) { /* Fix 20140713: request SMTPUTF8 support selectively. */ if (state->flags & CLEANUP_FLAG_AUTOUTF8) - state->smtputf8 |= SMTPUTF8_FLAG_REQUESTED; + state->sendopts |= SMTPUTF8_FLAG_REQUESTED; } /* Fix 20141024: Don't fake up a "bare" DSN original rcpt in smtp(8). */ if (state->dsn_orcpt == 0 && *STR(clean_addr) != 0) state->dsn_orcpt = concatenate((!allascii(STR(clean_addr)) - && (state->smtputf8 & SMTPUTF8_FLAG_REQUESTED)) ? + && (state->sendopts & SMTPUTF8_FLAG_REQUESTED)) ? "utf-8" : "rfc822", ";", STR(clean_addr), (char *) 0); cleanup_out_recipient(state, state->dsn_orcpt, state->dsn_notify, state->orig_rcpt, STR(clean_addr)); @@ -278,7 +281,7 @@ void cleanup_addr_bcc_dsn(CLEANUP_STATE *state, const char *bcc, && valid_utf8_stringz(STR(clean_addr))) { /* Fix 20140713: request SMTPUTF8 support selectively. */ if (state->flags & CLEANUP_FLAG_AUTOUTF8) - state->smtputf8 |= SMTPUTF8_FLAG_REQUESTED; + state->sendopts |= SMTPUTF8_FLAG_REQUESTED; } cleanup_out_recipient(state, dsn_orcpt, dsn_notify, STR(clean_addr), STR(clean_addr)); diff --git a/postfix/src/cleanup/cleanup_api.c b/postfix/src/cleanup/cleanup_api.c index 83ef0f084..a51269735 100644 --- a/postfix/src/cleanup/cleanup_api.c +++ b/postfix/src/cleanup/cleanup_api.c @@ -100,6 +100,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -206,7 +209,8 @@ void cleanup_control(CLEANUP_STATE *state, int flags) state->err_mask = ~0; } if (state->flags & CLEANUP_FLAG_SMTPUTF8) - state->smtputf8 = SMTPUTF8_FLAG_REQUESTED; + state->sendopts |= SMTPUTF8_FLAG_REQUESTED; + /* TODO: REQUIRETLS */ } /* cleanup_flush - finish queue file */ diff --git a/postfix/src/cleanup/cleanup_bounce.c b/postfix/src/cleanup/cleanup_bounce.c index 361875ec7..8358d1227 100644 --- a/postfix/src/cleanup/cleanup_bounce.c +++ b/postfix/src/cleanup/cleanup_bounce.c @@ -229,13 +229,13 @@ int cleanup_bounce(CLEANUP_STATE *state) bounce_err = bounce_flush(BOUNCE_FLAG_CLEAN, state->queue_name, state->queue_id, - encoding, state->smtputf8, state->sender, + encoding, state->sendopts, state->sender, dsn_envid, dsn_ret); } else { bounce_err = bounce_flush_verp(BOUNCE_FLAG_CLEAN, state->queue_name, state->queue_id, - encoding, state->smtputf8, state->sender, + encoding, state->sendopts, state->sender, dsn_envid, dsn_ret, state->verp_delims); } if (bounce_err != 0) { diff --git a/postfix/src/cleanup/cleanup_envelope.c b/postfix/src/cleanup/cleanup_envelope.c index 6c1a32b4f..097eeabd2 100644 --- a/postfix/src/cleanup/cleanup_envelope.c +++ b/postfix/src/cleanup/cleanup_envelope.c @@ -42,6 +42,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -350,16 +353,17 @@ static void cleanup_envelope_process(CLEANUP_STATE *state, int type, /* * Initial envelope non-recipient record processing. * - * If the message was requeued with "postsuper -r" use their - * SMTPUTF8_REQUESTED flag. + * If this message was requeued with "postsuper -r", use their sender + * options flags, excluding flags derived from headers or envelopes. + * Those flags may be derived again, depending on Postfix configuration. */ if (state->flags & CLEANUP_FLAG_INRCPT) /* Tell qmgr that recipient records are mixed with other information. */ state->qmgr_opts |= QMGR_READ_FLAG_MIXED_RCPT_OTHER; if (type == REC_TYPE_SIZE) { - /* Use our own SIZE record, except for the SMTPUTF8_REQUESTED flag. */ - (void) sscanf(buf, "%*s $*s %*s %*s %*s %d", &state->smtputf8); - state->smtputf8 &= SMTPUTF8_FLAG_REQUESTED; + /* Ignore their SIZE record, but keep the non-derived sender options. */ + (void) sscanf(buf, "%*s $*s %*s %*s %*s %d", &state->sendopts); + state->sendopts &= ~SOPT_FLAG_DERIVED; return; } if (mapped_type == REC_TYPE_CTIME) diff --git a/postfix/src/cleanup/cleanup_final.c b/postfix/src/cleanup/cleanup_final.c index db77fc741..c20c8a71c 100644 --- a/postfix/src/cleanup/cleanup_final.c +++ b/postfix/src/cleanup/cleanup_final.c @@ -74,5 +74,5 @@ void cleanup_final(CLEANUP_STATE *state) (REC_TYPE_SIZE_CAST3) state->rcpt_count, (REC_TYPE_SIZE_CAST4) state->qmgr_opts, (REC_TYPE_SIZE_CAST5) state->cont_length, - (REC_TYPE_SIZE_CAST6) state->smtputf8); + (REC_TYPE_SIZE_CAST6) state->sendopts); } diff --git a/postfix/src/cleanup/cleanup_out.c b/postfix/src/cleanup/cleanup_out.c index 5f8ed0a8c..23e254fa3 100644 --- a/postfix/src/cleanup/cleanup_out.c +++ b/postfix/src/cleanup/cleanup_out.c @@ -69,6 +69,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -186,10 +189,10 @@ void cleanup_out_header(CLEANUP_STATE *state, VSTRING *header_buf) * Fix 20140711: Auto-detect the presence of a non-ASCII header. */ if (var_smtputf8_enable && *STR(header_buf) && !allascii(STR(header_buf))) { - state->smtputf8 |= SMTPUTF8_FLAG_HEADER; + state->sendopts |= SMTPUTF8_FLAG_HEADER; /* Fix 20140713: request SMTPUTF8 support selectively. */ if (state->flags & CLEANUP_FLAG_AUTOUTF8) - state->smtputf8 |= SMTPUTF8_FLAG_REQUESTED; + state->sendopts |= SMTPUTF8_FLAG_REQUESTED; } /* diff --git a/postfix/src/cleanup/cleanup_state.c b/postfix/src/cleanup/cleanup_state.c index 4899dd468..51f7786e3 100644 --- a/postfix/src/cleanup/cleanup_state.c +++ b/postfix/src/cleanup/cleanup_state.c @@ -140,7 +140,7 @@ CLEANUP_STATE *cleanup_state_alloc(VSTREAM *src) state->milter_err_text = 0; state->milter_dsn_buf = 0; state->free_regions = state->body_regions = state->curr_body_region = 0; - state->smtputf8 = 0; + state->sendopts = 0; return (state); } diff --git a/postfix/src/global/Makefile.in b/postfix/src/global/Makefile.in index 47c291ffa..84f10c40b 100644 --- a/postfix/src/global/Makefile.in +++ b/postfix/src/global/Makefile.in @@ -37,7 +37,7 @@ SRCS = abounce.c anvil_clnt.c been_here.c bounce.c bounce_log.c \ normalize_mailhost_addr.c map_search.c reject_deliver_request.c \ info_log_addr_form.c sasl_mech_filter.c login_sender_match.c \ test_main.c compat_level.c config_known_tcp_ports.c \ - hfrom_format.c rfc2047_code.c ascii_header_text.c + hfrom_format.c rfc2047_code.c ascii_header_text.c sendopts.c OBJS = abounce.o anvil_clnt.o been_here.o bounce.o bounce_log.o \ canon_addr.o cfg_parser.o cleanup_strerror.o cleanup_strflags.o \ clnt_stream.o conv_time.o db_common.o debug_peer.o debug_process.o \ @@ -76,7 +76,7 @@ OBJS = abounce.o anvil_clnt.o been_here.o bounce.o bounce_log.o \ normalize_mailhost_addr.o map_search.o reject_deliver_request.o \ info_log_addr_form.o sasl_mech_filter.o login_sender_match.o \ test_main.o compat_level.o config_known_tcp_ports.o \ - hfrom_format.o rfc2047_code.o ascii_header_text.o + hfrom_format.o rfc2047_code.o ascii_header_text.o sendopts.o # MAP_OBJ is for maps that may be dynamically loaded with dynamicmaps.cf. # When hard-linking these maps, makedefs sets NON_PLUGIN_MAP_OBJ=$(MAP_OBJ), # otherwise it sets the PLUGIN_* macros. @@ -113,7 +113,7 @@ HDRS = abounce.h anvil_clnt.h been_here.h bounce.h bounce_log.h \ maillog_client.h normalize_mailhost_addr.h map_search.h \ info_log_addr_form.h sasl_mech_filter.h login_sender_match.h \ test_main.h compat_level.h config_known_tcp_ports.h \ - hfrom_format.h rfc2047_code.h ascii_header_text.h + hfrom_format.h rfc2047_code.h ascii_header_text.h sendopts.h TESTSRC = rec2stream.c stream2rec.c recdump.c DEFS = -I. -I$(INC_DIR) -D$(SYSTYPE) CFLAGS = $(DEBUG) $(OPT) $(DEFS) @@ -131,7 +131,7 @@ TESTPROG= domain_list dot_lockfile mail_addr_crunch mail_addr_find \ fold_addr smtp_reply_footer mail_addr_map normalize_mailhost_addr \ haproxy_srvr map_search delivered_hdr login_sender_match \ compat_level config_known_tcp_ports hfrom_format rfc2047_code \ - ascii_header_text + ascii_header_text sendopts LIBS = ../../lib/lib$(LIB_PREFIX)util$(LIB_SUFFIX) LIB_DIR = ../../lib @@ -405,6 +405,9 @@ rfc2047_code: rfc2047_code.c $(LIB) $(LIBS) ascii_header_text: ascii_header_text.c $(LIB) $(LIBS) $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS) +sendopts: sendopts.c $(LIB) $(LIBS) + $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS) + config_known_tcp_ports: config_known_tcp_ports.c $(LIB) $(LIBS) $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS) @@ -418,7 +421,7 @@ tests: tok822_test mime_tests strip_addr_test tok822_limit_test \ normalize_mailhost_addr_test haproxy_srvr_test map_search_test \ delivered_hdr_test login_sender_match_test compat_level_test \ config_known_tcp_ports_test hfrom_format_test rfc2047_code_test \ - ascii_header_text_test + ascii_header_text_test sendopts_test mime_tests: mime_test mime_nest mime_8bit mime_dom mime_trunc mime_cvt \ mime_cvt2 mime_cvt3 mime_garb1 mime_garb2 mime_garb3 mime_garb4 @@ -790,6 +793,9 @@ rfc2047_code_test: update rfc2047_code ascii_header_text_test: update ascii_header_text $(SHLIB_ENV) $(VALGRIND) ./ascii_header_text +sendopts_test: update sendopts + -$(SHLIB_ENV) $(VALGRIND) ./sendopts + clean: rm -f *.o $(LIB) *core $(TESTPROG) junk $(MAPS) @@ -2399,6 +2405,7 @@ post_mail.o: post_mail.c post_mail.o: post_mail.h post_mail.o: rec_type.h post_mail.o: record.h +post_mail.o: sendopts.h post_mail.o: smtputf8.h quote_821_local.o: ../../include/check_arg.h quote_821_local.o: ../../include/sys_defs.h @@ -2752,6 +2759,7 @@ smtputf8.o: ../../include/vstring.h smtputf8.o: cleanup_user.h smtputf8.o: mail_params.h smtputf8.o: mail_proto.h +smtputf8.o: sendopts.h smtputf8.o: smtputf8.c smtputf8.o: smtputf8.h split_addr.o: ../../include/check_arg.h diff --git a/postfix/src/global/abounce.c b/postfix/src/global/abounce.c index 5522f602e..fc16af7d5 100644 --- a/postfix/src/global/abounce.c +++ b/postfix/src/global/abounce.c @@ -6,26 +6,26 @@ /* SYNOPSIS /* #include /* -/* void abounce_flush(flags, queue, id, encoding, smtputf8, sender, +/* void abounce_flush(flags, queue, id, encoding, sendopts, sender, /* dsn_envid, dsn_ret, callback, context) /* int flags; /* const char *queue; /* const char *id; /* const char *encoding; -/* int smtputf8; +/* int sendopts; /* const char *sender; /* const char *dsn_envid; /* int dsn_ret; /* void (*callback)(int status, void *context); /* void *context; /* -/* void abounce_flush_verp(flags, queue, id, encoding, smtputf8, sender, +/* void abounce_flush_verp(flags, queue, id, encoding, sendopts, sender, /* dsn_envid, dsn_ret, verp, callback, context) /* int flags; /* const char *queue; /* const char *id; /* const char *encoding; -/* int smtputf8; +/* int sendopts; /* const char *sender; /* const char *dsn_envid; /* int dsn_ret; @@ -33,26 +33,26 @@ /* void (*callback)(int status, void *context); /* void *context; /* -/* void adefer_flush(flags, queue, id, encoding, smtputf8, sender, +/* void adefer_flush(flags, queue, id, encoding, sendopts, sender, /* dsn_envid, dsn_ret, callback, context) /* int flags; /* const char *queue; /* const char *id; /* const char *encoding; -/* int smtputf8; +/* int sendopts; /* const char *sender; /* const char *dsn_envid; /* int dsn_ret; /* void (*callback)(int status, void *context); /* void *context; /* -/* void adefer_flush_verp(flags, queue, id, encoding, smtputf8, sender, +/* void adefer_flush_verp(flags, queue, id, encoding, sendopts, sender, /* dsn_envid, dsn_ret, verp, callback, context) /* int flags; /* const char *queue; /* const char *id; /* const char *encoding; -/* int smtputf8; +/* int sendopts; /* const char *sender; /* const char *dsn_envid; /* int dsn_ret; @@ -60,26 +60,26 @@ /* void (*callback)(int status, void *context); /* void *context; /* -/* void adefer_warn(flags, queue, id, encoding, smtputf8, sender, +/* void adefer_warn(flags, queue, id, encoding, sendopts, sender, /* dsn_envid, dsn_ret, callback, context) /* int flags; /* const char *queue; /* const char *id; /* const char *encoding; -/* int smtputf8; +/* int sendopts; /* const char *sender; /* const char *dsn_envid; /* int dsn_ret; /* void (*callback)(int status, void *context); /* void *context; /* -/* void atrace_flush(flags, queue, id, encoding, smtputf8, sender, +/* void atrace_flush(flags, queue, id, encoding, sendopts, sender, /* dsn_envid, dsn_ret, callback, context) /* int flags; /* const char *queue; /* const char *id; /* const char *encoding; -/* int smtputf8; +/* int sendopts; /* const char *sender; /* const char *dsn_envid; /* int dsn_ret; @@ -138,8 +138,8 @@ /* file has the same name as the original message file. /* .IP encoding /* The body content encoding: MAIL_ATTR_ENC_{7BIT,8BIT,NONE}. -/* .IP smtputf8 -/* The level of SMTPUTF8 support (to be defined). +/* .IP sendopts +/* Sender-requested SMTPUTF8 or RequireTLS support. /* .IP sender /* The sender envelope address. /* .IP dsn_envid @@ -174,6 +174,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -320,7 +323,7 @@ static void abounce_send(int event, void *context) static void abounce_connect(const char *class, const char *service, int command, int flags, const char *queue, const char *id, - const char *encoding, int smtputf8, + const char *encoding, int sendopts, const char *sender, const char *dsn_envid, int dsn_ret, const char *verp, ABOUNCE_FN callback, @@ -363,7 +366,7 @@ static void abounce_connect(const char *class, const char *service, SEND_ATTR_STR(MAIL_ATTR_QUEUE, queue), SEND_ATTR_STR(MAIL_ATTR_QUEUEID, id), SEND_ATTR_STR(MAIL_ATTR_ENCODING, encoding), - SEND_ATTR_INT(MAIL_ATTR_SMTPUTF8, smtputf8), + SEND_ATTR_INT(MAIL_ATTR_SENDOPTS, sendopts), SEND_ATTR_STR(MAIL_ATTR_SENDER, sender), SEND_ATTR_STR(MAIL_ATTR_DSN_ENVID, dsn_envid), SEND_ATTR_INT(MAIL_ATTR_DSN_RET, dsn_ret), @@ -390,77 +393,77 @@ static void abounce_connect(const char *class, const char *service, /* abounce_flush_verp - asynchronous bounce flush */ void abounce_flush_verp(int flags, const char *queue, const char *id, - const char *encoding, int smtputf8, + const char *encoding, int sendopts, const char *sender, const char *dsn_envid, int dsn_ret, const char *verp, ABOUNCE_FN callback, void *context) { abounce_connect(MAIL_CLASS_PRIVATE, var_bounce_service, - BOUNCE_CMD_VERP, flags, queue, id, encoding, smtputf8, + BOUNCE_CMD_VERP, flags, queue, id, encoding, sendopts, sender, dsn_envid, dsn_ret, verp, callback, context); } /* adefer_flush_verp - asynchronous defer flush */ void adefer_flush_verp(int flags, const char *queue, const char *id, - const char *encoding, int smtputf8, + const char *encoding, int sendopts, const char *sender, const char *dsn_envid, int dsn_ret, const char *verp, ABOUNCE_FN callback, void *context) { flags |= BOUNCE_FLAG_DELRCPT; abounce_connect(MAIL_CLASS_PRIVATE, var_defer_service, - BOUNCE_CMD_VERP, flags, queue, id, encoding, smtputf8, + BOUNCE_CMD_VERP, flags, queue, id, encoding, sendopts, sender, dsn_envid, dsn_ret, verp, callback, context); } /* abounce_flush - asynchronous bounce flush */ void abounce_flush(int flags, const char *queue, const char *id, - const char *encoding, int smtputf8, + const char *encoding, int sendopts, const char *sender, const char *dsn_envid, int dsn_ret, ABOUNCE_FN callback, void *context) { abounce_connect(MAIL_CLASS_PRIVATE, var_bounce_service, BOUNCE_CMD_FLUSH, - flags, queue, id, encoding, smtputf8, sender, dsn_envid, + flags, queue, id, encoding, sendopts, sender, dsn_envid, dsn_ret, ABOUNCE_NO_VERP, callback, context); } /* adefer_flush - asynchronous defer flush */ void adefer_flush(int flags, const char *queue, const char *id, - const char *encoding, int smtputf8, + const char *encoding, int sendopts, const char *sender, const char *dsn_envid, int dsn_ret, ABOUNCE_FN callback, void *context) { flags |= BOUNCE_FLAG_DELRCPT; abounce_connect(MAIL_CLASS_PRIVATE, var_defer_service, BOUNCE_CMD_FLUSH, - flags, queue, id, encoding, smtputf8, sender, dsn_envid, + flags, queue, id, encoding, sendopts, sender, dsn_envid, dsn_ret, ABOUNCE_NO_VERP, callback, context); } /* adefer_warn - send copy of defer log to sender as warning bounce */ void adefer_warn(int flags, const char *queue, const char *id, - const char *encoding, int smtputf8, + const char *encoding, int sendopts, const char *sender, const char *dsn_envid, int dsn_ret, ABOUNCE_FN callback, void *context) { abounce_connect(MAIL_CLASS_PRIVATE, var_defer_service, BOUNCE_CMD_WARN, - flags, queue, id, encoding, smtputf8, sender, dsn_envid, + flags, queue, id, encoding, sendopts, sender, dsn_envid, dsn_ret, ABOUNCE_NO_VERP, callback, context); } /* atrace_flush - asynchronous trace flush */ void atrace_flush(int flags, const char *queue, const char *id, - const char *encoding, int smtputf8, + const char *encoding, int sendopts, const char *sender, const char *dsn_envid, int dsn_ret, ABOUNCE_FN callback, void *context) { abounce_connect(MAIL_CLASS_PRIVATE, var_trace_service, BOUNCE_CMD_TRACE, - flags, queue, id, encoding, smtputf8, sender, dsn_envid, + flags, queue, id, encoding, sendopts, sender, dsn_envid, dsn_ret, ABOUNCE_NO_VERP, callback, context); } diff --git a/postfix/src/global/bounce.c b/postfix/src/global/bounce.c index 072a7a73b..a11ee7da8 100644 --- a/postfix/src/global/bounce.c +++ b/postfix/src/global/bounce.c @@ -14,36 +14,36 @@ /* const char *relay; /* DSN *dsn; /* -/* int bounce_flush(flags, queue, id, encoding, smtputf8, sender, +/* int bounce_flush(flags, queue, id, encoding, sendopts, sender, /* dsn_envid, dsn_ret) /* int flags; /* const char *queue; /* const char *id; /* const char *encoding; -/* int smtputf8; +/* int sendopts; /* const char *sender; /* const char *dsn_envid; /* int dsn_ret; /* -/* int bounce_flush_verp(flags, queue, id, encoding, smtputf8, +/* int bounce_flush_verp(flags, queue, id, encoding, sendopts, /* sender, dsn_envid, dsn_ret, verp_delims) /* int flags; /* const char *queue; /* const char *id; /* const char *encoding; -/* int smtputf8; +/* int sendopts; /* const char *sender; /* const char *dsn_envid; /* int dsn_ret; /* const char *verp_delims; /* -/* int bounce_one(flags, queue, id, encoding, smtputf8, sender, +/* int bounce_one(flags, queue, id, encoding, sendopts, sender, /* dsn_envid, ret, stats, recipient, relay, dsn) /* int flags; /* const char *queue; /* const char *id; /* const char *encoding; -/* int smtputf8; +/* int sendopts; /* const char *sender; /* const char *dsn_envid; /* int dsn_ret; @@ -65,13 +65,13 @@ /* RECIPIENT *rcpt; /* const char *relay; /* -/* int bounce_one_intern(flags, queue, id, encoding, smtputf8, sender, +/* int bounce_one_intern(flags, queue, id, encoding, sendopts, sender, /* dsn_envid, ret, stats, recipient, relay, dsn) /* int flags; /* const char *queue; /* const char *id; /* const char *encoding; -/* int smtputf8; +/* int sendopts; /* const char *sender; /* const char *dsn_envid; /* int dsn_ret; @@ -151,8 +151,8 @@ /* This information is used for syslogging only. /* .IP encoding /* The body content encoding: MAIL_ATTR_ENC_{7BIT,8BIT,NONE}. -/* .IP smtputf8 -/* The level of SMTPUTF8 support (to be defined). +/* .IP sendopts +/* Sender-requested SMTPUTF8 or RequireTLS support. /* .IP sender /* The sender envelope address. /* .IP dsn_envid @@ -191,6 +191,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -347,7 +350,7 @@ int bounce_append_intern(int flags, const char *id, MSG_STATS *stats, /* bounce_flush - flush the bounce log and deliver to the sender */ int bounce_flush(int flags, const char *queue, const char *id, - const char *encoding, int smtputf8, + const char *encoding, int sendopts, const char *sender, const char *dsn_envid, int dsn_ret) { @@ -365,7 +368,7 @@ int bounce_flush(int flags, const char *queue, const char *id, SEND_ATTR_STR(MAIL_ATTR_QUEUE, queue), SEND_ATTR_STR(MAIL_ATTR_QUEUEID, id), SEND_ATTR_STR(MAIL_ATTR_ENCODING, encoding), - SEND_ATTR_INT(MAIL_ATTR_SMTPUTF8, smtputf8), + SEND_ATTR_INT(MAIL_ATTR_SENDOPTS, sendopts), SEND_ATTR_STR(MAIL_ATTR_SENDER, sender), SEND_ATTR_STR(MAIL_ATTR_DSN_ENVID, dsn_envid), SEND_ATTR_INT(MAIL_ATTR_DSN_RET, dsn_ret), @@ -382,7 +385,7 @@ int bounce_flush(int flags, const char *queue, const char *id, /* bounce_flush_verp - verpified notification */ int bounce_flush_verp(int flags, const char *queue, const char *id, - const char *encoding, int smtputf8, + const char *encoding, int sendopts, const char *sender, const char *dsn_envid, int dsn_ret, const char *verp_delims) { @@ -400,7 +403,7 @@ int bounce_flush_verp(int flags, const char *queue, const char *id, SEND_ATTR_STR(MAIL_ATTR_QUEUE, queue), SEND_ATTR_STR(MAIL_ATTR_QUEUEID, id), SEND_ATTR_STR(MAIL_ATTR_ENCODING, encoding), - SEND_ATTR_INT(MAIL_ATTR_SMTPUTF8, smtputf8), + SEND_ATTR_INT(MAIL_ATTR_SENDOPTS, sendopts), SEND_ATTR_STR(MAIL_ATTR_SENDER, sender), SEND_ATTR_STR(MAIL_ATTR_DSN_ENVID, dsn_envid), SEND_ATTR_INT(MAIL_ATTR_DSN_RET, dsn_ret), @@ -418,7 +421,7 @@ int bounce_flush_verp(int flags, const char *queue, const char *id, /* bounce_one - send notice for one recipient */ int bounce_one(int flags, const char *queue, const char *id, - const char *encoding, int smtputf8, + const char *encoding, int sendopts, const char *sender, const char *dsn_envid, int dsn_ret, MSG_STATS *stats, RECIPIENT *rcpt, const char *relay, DSN *dsn) @@ -443,14 +446,14 @@ int bounce_one(int flags, const char *queue, const char *id, return (defer_append_intern(flags, id, stats, rcpt, relay, dsn_res)); my_dsn = *dsn_res; } - return (bounce_one_intern(flags, queue, id, encoding, smtputf8, sender, + return (bounce_one_intern(flags, queue, id, encoding, sendopts, sender, dsn_envid, dsn_ret, stats, rcpt, relay, &my_dsn)); } /* bounce_one_intern - send notice for one recipient */ int bounce_one_intern(int flags, const char *queue, const char *id, - const char *encoding, int smtputf8, + const char *encoding, int sendopts, const char *sender, const char *dsn_envid, int dsn_ret, MSG_STATS *stats, RECIPIENT *rcpt, const char *relay, @@ -508,7 +511,7 @@ int bounce_one_intern(int flags, const char *queue, const char *id, SEND_ATTR_STR(MAIL_ATTR_QUEUE, queue), SEND_ATTR_STR(MAIL_ATTR_QUEUEID, id), SEND_ATTR_STR(MAIL_ATTR_ENCODING, encoding), - SEND_ATTR_INT(MAIL_ATTR_SMTPUTF8, smtputf8), + SEND_ATTR_INT(MAIL_ATTR_SENDOPTS, sendopts), SEND_ATTR_STR(MAIL_ATTR_SENDER, sender), SEND_ATTR_STR(MAIL_ATTR_DSN_ENVID, dsn_envid), SEND_ATTR_INT(MAIL_ATTR_DSN_RET, dsn_ret), diff --git a/postfix/src/global/defer.c b/postfix/src/global/defer.c index 8eaf082c2..919484d63 100644 --- a/postfix/src/global/defer.c +++ b/postfix/src/global/defer.c @@ -14,35 +14,35 @@ /* const char *relay; /* DSN *dsn; /* -/* int defer_flush(flags, queue, id, encoding, smtputf8, sender, +/* int defer_flush(flags, queue, id, encoding, sendopts, sender, /* dsn_envid, dsn_ret) /* int flags; /* const char *queue; /* const char *id; /* const char *encoding; -/* int smtputf8; +/* int sendopts; /* const char *sender; /* const char *dsn_envid; /* int dsn_ret; /* -/* int defer_warn(flags, queue, id, encoding, smtputf8, sender, +/* int defer_warn(flags, queue, id, encoding, sendopts, sender, dsn_envid, dsn_ret) /* int flags; /* const char *queue; /* const char *id; /* const char *encoding; -/* int smtputf8; +/* int sendopts; /* const char *sender; /* const char *dsn_envid; /* int dsn_ret; /* -/* int defer_one(flags, queue, id, encoding, smtputf8, sender, +/* int defer_one(flags, queue, id, encoding, sendopts, sender, /* dsn_envid, ret, stats, recipient, relay, dsn) /* int flags; /* const char *queue; /* const char *id; /* const char *encoding; -/* int smtputf8; +/* int sendopts; /* const char *sender; /* const char *dsn_envid; /* int dsn_ret; @@ -128,8 +128,8 @@ /* Delivery status. See dsn(3). The specified action is ignored. /* .IP encoding /* The body content encoding: MAIL_ATTR_ENC_{7BIT,8BIT,NONE}. -/* .IP smtputf8 -/* The level of SMTPUTF8 support (to be defined). +/* .IP sendopts +/* Sender-requested SMTPUTF8 or RequireTLS support. /* .IP sender /* The sender envelope address. /* .IP dsn_envid @@ -158,6 +158,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -300,7 +303,7 @@ int defer_append_intern(int flags, const char *id, MSG_STATS *stats, /* defer_flush - flush the defer log and deliver to the sender */ int defer_flush(int flags, const char *queue, const char *id, - const char *encoding, int smtputf8, + const char *encoding, int sendopts, const char *sender, const char *dsn_envid, int dsn_ret) { @@ -313,7 +316,7 @@ int defer_flush(int flags, const char *queue, const char *id, SEND_ATTR_STR(MAIL_ATTR_QUEUE, queue), SEND_ATTR_STR(MAIL_ATTR_QUEUEID, id), SEND_ATTR_STR(MAIL_ATTR_ENCODING, encoding), - SEND_ATTR_INT(MAIL_ATTR_SMTPUTF8, smtputf8), + SEND_ATTR_INT(MAIL_ATTR_SENDOPTS, sendopts), SEND_ATTR_STR(MAIL_ATTR_SENDER, sender), SEND_ATTR_STR(MAIL_ATTR_DSN_ENVID, dsn_envid), SEND_ATTR_INT(MAIL_ATTR_DSN_RET, dsn_ret), @@ -328,7 +331,7 @@ int defer_flush(int flags, const char *queue, const char *id, * do not flush the log */ int defer_warn(int flags, const char *queue, const char *id, - const char *encoding, int smtputf8, + const char *encoding, int sendopts, const char *sender, const char *envid, int dsn_ret) { if (mail_command_client(MAIL_CLASS_PRIVATE, var_defer_service, @@ -338,7 +341,7 @@ int defer_warn(int flags, const char *queue, const char *id, SEND_ATTR_STR(MAIL_ATTR_QUEUE, queue), SEND_ATTR_STR(MAIL_ATTR_QUEUEID, id), SEND_ATTR_STR(MAIL_ATTR_ENCODING, encoding), - SEND_ATTR_INT(MAIL_ATTR_SMTPUTF8, smtputf8), + SEND_ATTR_INT(MAIL_ATTR_SENDOPTS, sendopts), SEND_ATTR_STR(MAIL_ATTR_SENDER, sender), SEND_ATTR_STR(MAIL_ATTR_DSN_ENVID, envid), SEND_ATTR_INT(MAIL_ATTR_DSN_RET, dsn_ret), @@ -352,7 +355,7 @@ int defer_warn(int flags, const char *queue, const char *id, /* defer_one - defer mail for one recipient */ int defer_one(int flags, const char *queue, const char *id, - const char *encoding, int smtputf8, + const char *encoding, int sendopts, const char *sender, const char *dsn_envid, int dsn_ret, MSG_STATS *stats, RECIPIENT *rcpt, const char *relay, DSN *dsn) @@ -374,7 +377,7 @@ int defer_one(int flags, const char *queue, const char *id, if (delivery_status_filter != 0 && (dsn_res = dsn_filter_lookup(delivery_status_filter, &my_dsn)) != 0) { if (dsn_res->status[0] == '5') - return (bounce_one_intern(flags, queue, id, encoding, smtputf8, + return (bounce_one_intern(flags, queue, id, encoding, sendopts, sender, dsn_envid, dsn_ret, stats, rcpt, relay, dsn_res)); my_dsn = *dsn_res; diff --git a/postfix/src/global/deliver_pass.c b/postfix/src/global/deliver_pass.c index 231b07000..545282945 100644 --- a/postfix/src/global/deliver_pass.c +++ b/postfix/src/global/deliver_pass.c @@ -54,6 +54,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -109,7 +112,7 @@ static int deliver_pass_send_request(VSTREAM *stream, DELIVER_REQUEST *request, SEND_ATTR_LONG(MAIL_ATTR_SIZE, request->data_size), SEND_ATTR_STR(MAIL_ATTR_NEXTHOP, nexthop), SEND_ATTR_STR(MAIL_ATTR_ENCODING, request->encoding), - SEND_ATTR_INT(MAIL_ATTR_SMTPUTF8, request->smtputf8), + SEND_ATTR_INT(MAIL_ATTR_SENDOPTS, request->sendopts), SEND_ATTR_STR(MAIL_ATTR_SENDER, request->sender), SEND_ATTR_STR(MAIL_ATTR_DSN_ENVID, request->dsn_envid), SEND_ATTR_INT(MAIL_ATTR_DSN_RET, request->dsn_ret), diff --git a/postfix/src/global/deliver_request.c b/postfix/src/global/deliver_request.c index 7bc5553d0..196dcbfa1 100644 --- a/postfix/src/global/deliver_request.c +++ b/postfix/src/global/deliver_request.c @@ -16,6 +16,7 @@ /* long data_size; /* char *nexthop; /* char *encoding; +/* int sendopts; /* char *sender; /* MSG_STATS msg_stats; /* RECIPIENT_LIST rcpt_list; @@ -97,6 +98,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -213,7 +217,7 @@ static int deliver_request_get(VSTREAM *stream, DELIVER_REQUEST *request) static VSTRING *dsn_envid; static RCPT_BUF *rcpt_buf; int rcpt_count; - int smtputf8; + int sendopts; int dsn_ret; /* @@ -253,7 +257,7 @@ static int deliver_request_get(VSTREAM *stream, DELIVER_REQUEST *request) RECV_ATTR_LONG(MAIL_ATTR_SIZE, &request->data_size), RECV_ATTR_STR(MAIL_ATTR_NEXTHOP, nexthop), RECV_ATTR_STR(MAIL_ATTR_ENCODING, encoding), - RECV_ATTR_INT(MAIL_ATTR_SMTPUTF8, &smtputf8), + RECV_ATTR_INT(MAIL_ATTR_SENDOPTS, &sendopts), RECV_ATTR_STR(MAIL_ATTR_SENDER, address), RECV_ATTR_STR(MAIL_ATTR_DSN_ENVID, dsn_envid), RECV_ATTR_INT(MAIL_ATTR_DSN_RET, &dsn_ret), @@ -288,8 +292,8 @@ static int deliver_request_get(VSTREAM *stream, DELIVER_REQUEST *request) request->queue_id = mystrdup(vstring_str(queue_id)); request->nexthop = mystrdup(vstring_str(nexthop)); request->encoding = mystrdup(vstring_str(encoding)); - /* Fix 20140708: dedicated smtputf8 attribute with its own flags. */ - request->smtputf8 = smtputf8; + /* Fix 20140708: dedicated sendopts attribute with its own flags. */ + request->sendopts = sendopts; request->sender = mystrdup(vstring_str(address)); request->client_name = mystrdup(vstring_str(client_name)); request->client_addr = mystrdup(vstring_str(client_addr)); diff --git a/postfix/src/global/deliver_request.h b/postfix/src/global/deliver_request.h index c1c5b1dd0..7cf8b294c 100644 --- a/postfix/src/global/deliver_request.h +++ b/postfix/src/global/deliver_request.h @@ -42,7 +42,7 @@ typedef struct DELIVER_REQUEST { long data_size; /* message size */ char *nexthop; /* next hop name */ char *encoding; /* content encoding */ - int smtputf8; /* SMTPUTF8 level */ + int sendopts; /* smtputf8, requiretls, etc. */ char *sender; /* envelope sender */ MSG_STATS msg_stats; /* time profile */ RECIPIENT_LIST rcpt_list; /* envelope recipients */ @@ -151,6 +151,9 @@ extern int PRINTFLIKE(4, 5) reject_deliver_request(const char *, /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ #endif diff --git a/postfix/src/global/mail_proto.h b/postfix/src/global/mail_proto.h index e3c0c4750..798de6694 100644 --- a/postfix/src/global/mail_proto.h +++ b/postfix/src/global/mail_proto.h @@ -308,7 +308,7 @@ extern char *mail_pathname(const char *, const char *); #define MAIL_ATTR_DSN_RET "ret_flags" /* dsn full/headers */ #define MAIL_ATTR_DSN_NOTIFY "notify_flags" /* dsn notify flags */ #define MAIL_ATTR_DSN_ORCPT "dsn_orig_rcpt" /* dsn original recipient */ -#define MAIL_ATTR_SMTPUTF8 "smtputf8" /* RFC6531 support */ +#define MAIL_ATTR_SENDOPTS "sendopts" /* RFC6531 etc. support */ /* * SMTP reply footer support. @@ -329,6 +329,9 @@ extern char *mail_pathname(const char *, const char *); /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ #endif diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index dbd0f0afd..08d6ed264 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,7 +20,7 @@ * Patches change both the patchlevel and the release date. Snapshots have no * patchlevel; they change the release date only. */ -#define MAIL_RELEASE_DATE "20250107" +#define MAIL_RELEASE_DATE "20250109" #define MAIL_VERSION_NUMBER "3.10" #ifdef SNAPSHOT diff --git a/postfix/src/global/sendopts.c b/postfix/src/global/sendopts.c new file mode 100644 index 000000000..0dc3ddc15 --- /dev/null +++ b/postfix/src/global/sendopts.c @@ -0,0 +1,161 @@ +/*++ +/* NAME +/* sendopts 3 +/* SUMMARY +/* Support for SMTPUTF8, REQUIRETLS, etc. +/* SYNOPSIS +/* #include +/* +/* const char *sendopts_strflags(code) +/* int code; +/* DESCRIPTION +/* Postfix queue files and IPC messages contain a sendopts field +/* with flags that control SMTPUTF8, REQUIRETLS, etc. support. The +/* flags are documented in sendopts(3h), and are based on information +/* received with ESMTP requests or with message content. +/* +/* The SMTPUTF8 flags life cycle is documented in smtputf8(3h). +/* +/* sendopts_strflags() maps a sendopts flag value to printable +/* string. The result is overwritten upon each call. +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* porcupine.org +/*--*/ + +/* System library. */ + +#include + + /* + * Utility library. + */ +#include +#include +#include + + /* + * Global library. + */ +#include + + /* + * Mapping from flags code to printable string. + */ +static NAME_MASK sendopts_flag_map[] = { + "smtputf8_requested", SOPT_SMTPUTF8_REQUESTED, + "smtputf8_header", SOPT_SMTPUTF8_HEADER, + "smtputf8_sender", SOPT_SMTPUTF8_SENDER, + "smtputf8_recipient", SOPT_SMTPUTF8_RECIPIENT, + "requiretls_header", SOPT_REQUIRETLS_HEADER, + "requiretls_esmtp", SOPT_REQUIRETLS_ESMTP, + 0, +}; + +/* sendopts_strflags - map flags code to printable string */ + +const char *sendopts_strflags(unsigned flags) +{ + static VSTRING *result; + + if (flags == 0) + return ("none"); + + if (result == 0) + result = vstring_alloc(20); + else + VSTRING_RESET(result); + + return (str_name_mask_opt(result, "sendopts_strflags", sendopts_flag_map, + flags, NAME_MASK_FATAL)); +} + +#ifdef TEST +#include +#include +#include +#include + + /* + * Tests and test cases. + */ +typedef struct TEST_CASE { + const char *label; /* identifies test case */ + int mask; + const char *want; +} TEST_CASE; + +static const TEST_CASE test_cases[] = { + {"SOPT_SMTPUTF8_ALL", + SOPT_SMTPUTF8_ALL, + "smtputf8_requested smtputf8_header smtputf8_sender smtputf8_recipient" + }, + {"SOPT_SMTPUTF8_DERIVED", + SOPT_SMTPUTF8_DERIVED, + "smtputf8_header smtputf8_sender smtputf8_recipient" + }, + {"SOPT_SMTPUTF8_REQUESTED", + SOPT_SMTPUTF8_REQUESTED, + "smtputf8_requested" + }, + {"SOPT_SMTPUTF8_HEADER", + SOPT_SMTPUTF8_HEADER, + "smtputf8_header" + }, + {"SOPT_SMTPUTF8_SENDER", + SOPT_SMTPUTF8_SENDER, + "smtputf8_sender" + }, + {"SOPT_SMTPUTF8_RECIPIENT", + SOPT_SMTPUTF8_RECIPIENT, + "smtputf8_recipient" + }, + {"SOPT_REQUIRETLS_ALL", + SOPT_REQUIRETLS_ALL, + "requiretls_header requiretls_esmtp" + }, + {"SOPT_REQUIRETLS_DERIVED", + SOPT_REQUIRETLS_DERIVED, + "requiretls_header" + }, + {"SOPT_REQUIRETLS_HEADER", + SOPT_REQUIRETLS_HEADER, + "requiretls_header" + }, + {"SOPT_REQUIRETLS_ESMTP", + SOPT_REQUIRETLS_ESMTP, + "requiretls_esmtp" + }, + {0}, +}; + +int main(int argc, char **argv) +{ + const TEST_CASE *tp; + int pass = 0; + int fail = 0; + const char *got; + + msg_vstream_init(sane_basename((VSTRING *) 0, argv[0]), VSTREAM_ERR); + + for (tp = test_cases; tp->label != 0; tp++) { + msg_info("RUN %s", tp->label); + got = sendopts_strflags(tp->mask); + if (strcmp(got, tp->want) != 0) { + msg_warn("got result '%s', want: '%s'", got, tp->want); + fail++; + msg_info("FAIL %s", tp->label); + } else { + msg_info("PASS %s", tp->label); + pass++; + } + } + msg_info("PASS=%d FAIL=%d", pass, fail); + exit(fail != 0); +} + +#endif diff --git a/postfix/src/global/sendopts.h b/postfix/src/global/sendopts.h new file mode 100644 index 000000000..c80ea5a33 --- /dev/null +++ b/postfix/src/global/sendopts.h @@ -0,0 +1,63 @@ +#ifndef _SENDOPTS_H_INCLUDED_ +#define _SENDOPTS_H_INCLUDED_ + +/*++ +/* NAME +/* sendopts 3h +/* SUMMARY +/* Support for SMTPUTF8, REQUIRETLS, etc. +/* SYNOPSIS +/* #include +/* DESCRIPTION +/* .nf + + /* + * Support for SMTPUTF8 (RFC 6531, RFC 6532, RFC 6533). These flags were + * migrated from and MUST NOT be changed, to maintain queue + * file compatibility. + */ +#define SOPT_SMTPUTF8_NONE (0) +#define SOPT_SMTPUTF8_REQUESTED (1<<0) /* queue file/delivery/bounce request */ +#define SOPT_SMTPUTF8_HEADER (1<<1) /* queue file/delivery/bounce request */ +#define SOPT_SMTPUTF8_SENDER (1<<2) /* queue file/delivery/bounce request */ +#define SOPT_SMTPUTF8_RECIPIENT (1<<3) /* delivery request only */ +#define SOPT_SMTPUTF8_ALL (SOPT_SMTPUTF8_REQUESTED | \ + SOPT_SMTPUTF8_HEADER | \ + SOPT_SMTPUTF8_SENDER | \ + SOPT_SMTPUTF8_RECIPIENT) +#define SOPT_SMTPUTF8_DERIVED \ + (SOPT_SMTPUTF8_ALL & ~SOPT_SMTPUTF8_REQUESTED) + + /* + * Support for REQUIRETLS (RFC 8689). At this time only the TLS-Required: + * header is implemented, but we reserve the flag that would support it. + */ +#define SOPT_REQUIRETLS_HEADER (1<<4) /* TLS-Required: no */ +#define SOPT_REQUIRETLS_ESMTP (1<<5) /* MAIL FROM ... REQUIRETLS */ +#define SOPT_REQUIRETLS_ALL (SOPT_REQUIRETLS_HEADER | \ + SOPT_REQUIRETLS_ESMTP) +#define SOPT_REQUIRETLS_DERIVED SOPT_REQUIRETLS_HEADER + +#define SOPT_FLAG_ALL (SOPT_SMTPUTF8_ALL | SOPT_REQUIRETLS_ALL) +#define SOPT_FLAG_DERIVED (SOPT_SMTPUTF8_DERIVED | SOPT_REQUIRETLS_DERIVED) + + /* + * Debug helper. + */ +extern const char *sendopts_strflags(unsigned flags); + +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema +/* porcupine.org +/*--*/ + +#endif diff --git a/postfix/src/global/smtputf8.h b/postfix/src/global/smtputf8.h index 5d72fb49d..4aa721ba9 100644 --- a/postfix/src/global/smtputf8.h +++ b/postfix/src/global/smtputf8.h @@ -11,24 +11,29 @@ /* DESCRIPTION /* .nf + /* + * Global library. + */ +#include + /* * Avoiding chicken-and-egg problems during the initial SMTPUTF8 roll-out in * environments with pre-existing mail flows that contain UTF8. - * + * * Prior to SMTPUTF8, mail flows that contain UTF8 worked because the vast * majority of MTAs is perfectly capable of handling UTF8 in address * localparts (and in headers), even if pre-SMTPUTF8 standards do not * support this practice. - * + * * When turning on Postfix SMTPUTF8 support for the first time, we don't want * to suddenly break pre-existing mail flows that contain UTF8 because 1) a * client does not request SMTPUTF8 support, and because 2) a down-stream * MTA does not announce SMTPUTF8 support. - * + * * While 1) is easy enough to avoid (keep accepting UTF8 in address localparts * just like Postfix has always done), 2) presents a thornier problem. The * root cause of that problem is the need for SMTPUTF8 autodetection. - * + * * What is SMTPUTF8 autodetection? Postfix cannot rely solely on the sender's * declaration that a message requires SMTPUTF8 support, because UTF8 may be * introduced during local processing (for example, the client hostname in @@ -36,21 +41,21 @@ * incomplete address, address rewriting, alias expansion, automatic BCC * recipients, local forwarding, and changes made by header checks or Milter * applications). - * + * * In summary, after local processing has happened, Postfix may decide that a * message requires SMTPUTF8 support, even when that message initially did * not require SMTPUTF8 support. This could make the message undeliverable * to destinations that do not support SMTPUTF8. In an environment with * pre-existing mail flows that contain UTF8, we want to avoid disrupting * those mail flows when rolling out SMTPUTF8 support. - * + * * For the vast majority of sites, the simplest solution is to autodetect * SMTPUTF8 support only for Postfix sendmail command-line submissions, at * least as long as SMTPUTF8 support has not yet achieved wold domination. - * + * * However, sites that add UTF8 content via local processing (see above) should * autodetect SMTPUTF8 support for all email. - * + * * smtputf8_autodetect() uses the setting of the smtputf8_autodetect_classes * parameter, and the mail source classes defined in mail_params.h. */ @@ -58,31 +63,39 @@ extern int smtputf8_autodetect(int); /* * The flag SMTPUTF8_FLAG_REQUESTED is raised on request by the sender, or - * when a queue file contains at least one UTF8 envelope recipient. One this - * flag is raised it is preserved when mail is forwarded or bounced. + * when SMTPUTF8 auto-detection is enabled and a queue file contains at + * least one UTF8 envelope sender, envelope recipient, or message header. + * Once this flag is raised, it is preserved when mail is forwarded or + * bounced. * * The flag SMTPUTF8_FLAG_HEADER is raised when a queue file contains at least - * one UTF8 message header. + * one UTF8 message header even if SMTPUTF8_FLAG_REQUESTED is disabled. * * The flag SMTPUTF8_FLAG_SENDER is raised when a queue file contains an UTF8 - * envelope sender. + * envelope sender, even if SMTPUTF8_FLAG_REQUESTED is disabled. * * The three flags SMTPUTF8_FLAG_REQUESTED/HEADER/SENDER are stored in the * queue file, are sent with delivery requests to Postfix delivery agents, * and are sent with "flush" requests to the bounce daemon to ensure that * the resulting notification message will have a content-transfer-encoding - * of 8bit. + * of 8bit. The derived flags SMTPUTF8_FLAG_HEADER/SENDER are ignored when a + * message is re-queued with "postsuper -r". They may be regenerated by the + * cleanup daemon. * * In the future, mailing lists will have a mix of UTF8 and non-UTF8 * subscribers. With the following flag, Postfix can avoid requiring * SMTPUTF8 delivery when it isn't really needed. * - * The flag SMTPUTF8_FLAG_RECIPIENT is raised when a delivery request (NOT: - * message) contains at least one UTF8 envelope recipient. The flag is NOT - * stored in the queue file. The flag sent in requests to the bounce daemon - * ONLY when bouncing a single recipient. The flag is used ONLY in requests - * to Postfix delivery agents, to give Postfix flexibility when delivering - * messages to non-SMTPUTF8 servers. + * The fourth flag, SMTPUTF8_FLAG_RECIPIENT, is raised when a delivery request + * (NOT: message) contains at least one UTF8 envelope recipient. This flag + * is NOT stored in the queue file. The flag is used ONLY in requests to + * Postfix delivery agents, to give delivery agents flexibility when + * delivering messages to non-SMTPUTF8 servers. Delivery agents may then + * pass the flag to the bounce daemon. + * + * XXXSENDOPTS Verify that the flag is sent for only one recipient. What + * problem would that solve? The recipient becomes message content in the + * delivery status notification; it is just data. * * If a delivery request has none of the flags SMTPUTF8_FLAG_RECIPIENT, * SMTPUTF8_FLAG_SENDER, or SMTPUTF8_FLAG_HEADER, then the message can @@ -94,10 +107,15 @@ extern int smtputf8_autodetect(int); * the SMTP client protocol engine. */ #define SMTPUTF8_FLAG_NONE (0) -#define SMTPUTF8_FLAG_REQUESTED (1<<0) /* queue file/delivery/bounce request */ -#define SMTPUTF8_FLAG_HEADER (1<<1) /* queue file/delivery/bounce request */ -#define SMTPUTF8_FLAG_SENDER (1<<2) /* queue file/delivery/bounce request */ -#define SMTPUTF8_FLAG_RECIPIENT (1<<3) /* delivery request only */ + /* In queue file, delivery request, or bounce request. */ +#define SMTPUTF8_FLAG_REQUESTED SOPT_SMTPUTF8_REQUESTED +#define SMTPUTF8_FLAG_HEADER SOPT_SMTPUTF8_HEADER +#define SMTPUTF8_FLAG_SENDER SOPT_SMTPUTF8_SENDER + /* In delivery or bounce request only. */ +#define SMTPUTF8_FLAG_RECIPIENT SOPT_SMTPUTF8_RECIPIENT + +#define SMTPUTF8_FLAG_ALL SOPT_SMTPUTF8_ALL +#define SMTPUTF8_FLAG_DERIVED SOPT_SMTPUTF8_DERIVED /* LICENSE /* .ad @@ -108,6 +126,9 @@ extern int smtputf8_autodetect(int); /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ #endif diff --git a/postfix/src/local/Makefile.in b/postfix/src/local/Makefile.in index 7bd27db21..a600a267e 100644 --- a/postfix/src/local/Makefile.in +++ b/postfix/src/local/Makefile.in @@ -302,6 +302,7 @@ forward.o: ../../include/rec_type.h forward.o: ../../include/recipient_list.h forward.o: ../../include/record.h forward.o: ../../include/resolve_clnt.h +forward.o: ../../include/sendopts.h forward.o: ../../include/sent.h forward.o: ../../include/smtputf8.h forward.o: ../../include/stringops.h diff --git a/postfix/src/local/forward.c b/postfix/src/local/forward.c index 722dcf712..3d5c316cb 100644 --- a/postfix/src/local/forward.c +++ b/postfix/src/local/forward.c @@ -53,6 +53,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -160,7 +163,7 @@ static FORWARD_INFO *forward_open(DELIVER_REQUEST *request, const char *sender) #define FORWARD_CLEANUP_FLAGS \ (CLEANUP_FLAG_BOUNCE | CLEANUP_FLAG_MASK_INTERNAL \ | smtputf8_autodetect(MAIL_SRC_MASK_FORWARD) \ - | ((request->smtputf8 & SMTPUTF8_FLAG_REQUESTED) ? \ + | ((request->sendopts & SMTPUTF8_FLAG_REQUESTED) ? \ CLEANUP_FLAG_SMTPUTF8 : 0)) attr_print(cleanup, ATTR_FLAG_NONE, diff --git a/postfix/src/local/local.c b/postfix/src/local/local.c index d9587cae4..f77c1a543 100644 --- a/postfix/src/local/local.c +++ b/postfix/src/local/local.c @@ -530,7 +530,7 @@ /* request before it is terminated by a built-in watchdog timer. /* .IP "\fBdelay_logging_resolution_limit (2)\fR" /* The maximal number of digits after the decimal point when logging -/* sub-second delay values. +/* delay values. /* .IP "\fBexport_environment (see 'postconf -d' output)\fR" /* The list of environment variables that a Postfix process will export /* to non-Postfix processes. @@ -619,6 +619,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -747,7 +750,7 @@ static int local_deliver(DELIVER_REQUEST *rqst, char *service) state.msg_attr.fp = rqst->fp; state.msg_attr.offset = rqst->data_offset; state.msg_attr.encoding = rqst->encoding; - state.msg_attr.smtputf8 = rqst->smtputf8; + state.msg_attr.sendopts = rqst->sendopts; state.msg_attr.sender = rqst->sender; state.msg_attr.dsn_envid = rqst->dsn_envid; state.msg_attr.dsn_ret = rqst->dsn_ret; diff --git a/postfix/src/local/local.h b/postfix/src/local/local.h index 4052000c9..13d0dc79e 100644 --- a/postfix/src/local/local.h +++ b/postfix/src/local/local.h @@ -72,7 +72,7 @@ typedef struct DELIVER_ATTR { char *queue_id; /* mail queue id */ long offset; /* data offset */ char *encoding; /* MIME encoding */ - int smtputf8; /* from delivery request */ + int sendopts; /* from delivery request */ const char *sender; /* taken from envelope */ char *dsn_envid; /* DSN envelope ID */ int dsn_ret; /* DSN headers/full */ @@ -135,7 +135,7 @@ typedef struct LOCAL_STATE { attr.queue_id, &attr.msg_stats, &attr.rcpt, attr.relay, \ DSN_FROM_DSN_BUF(attr.why) #define BOUNCE_ONE_ATTR(attr) \ - attr.queue_name, attr.queue_id, attr.encoding, attr.smtputf8, \ + attr.queue_name, attr.queue_id, attr.encoding, attr.sendopts, \ attr.sender, attr.dsn_envid, attr.dsn_ret, \ &attr.msg_stats, &attr.rcpt, attr.relay, \ DSN_FROM_DSN_BUF(attr.why) diff --git a/postfix/src/oqmgr/Makefile.in b/postfix/src/oqmgr/Makefile.in index 151737bcc..fc48077d7 100644 --- a/postfix/src/oqmgr/Makefile.in +++ b/postfix/src/oqmgr/Makefile.in @@ -175,6 +175,7 @@ qmgr_deliver.o: ../../include/nvtable.h qmgr_deliver.o: ../../include/rcpt_print.h qmgr_deliver.o: ../../include/recipient_list.h qmgr_deliver.o: ../../include/scan_dir.h +qmgr_deliver.o: ../../include/sendopts.h qmgr_deliver.o: ../../include/smtputf8.h qmgr_deliver.o: ../../include/stringops.h qmgr_deliver.o: ../../include/sys_defs.h @@ -272,6 +273,7 @@ qmgr_message.o: ../../include/record.h qmgr_message.o: ../../include/resolve_clnt.h qmgr_message.o: ../../include/rewrite_clnt.h qmgr_message.o: ../../include/scan_dir.h +qmgr_message.o: ../../include/sendopts.h qmgr_message.o: ../../include/sent.h qmgr_message.o: ../../include/split_addr.h qmgr_message.o: ../../include/split_at.h diff --git a/postfix/src/oqmgr/qmgr.h b/postfix/src/oqmgr/qmgr.h index cc22ca51d..1c4dbf2bf 100644 --- a/postfix/src/oqmgr/qmgr.h +++ b/postfix/src/oqmgr/qmgr.h @@ -300,7 +300,7 @@ struct QMGR_MESSAGE { char *sender; /* complete address */ char *dsn_envid; /* DSN envelope ID */ int dsn_ret; /* DSN headers/full */ - int smtputf8; /* requires unicode */ + int sendopts; /* smtputf8, requiretls, etc. */ char *verp_delims; /* VERP delimiters */ char *filter_xport; /* filtering transport */ char *inspect_xport; /* inspecting transport */ @@ -429,4 +429,7 @@ extern char *qmgr_error_nexthop(DSN *); /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ diff --git a/postfix/src/oqmgr/qmgr_active.c b/postfix/src/oqmgr/qmgr_active.c index fb5954276..ada8c648b 100644 --- a/postfix/src/oqmgr/qmgr_active.c +++ b/postfix/src/oqmgr/qmgr_active.c @@ -75,6 +75,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -307,7 +310,7 @@ void qmgr_active_done(QMGR_MESSAGE *message) message->queue_name, message->queue_id, message->encoding, - message->smtputf8, + message->sendopts, message->sender, message->dsn_envid, message->dsn_ret, @@ -318,7 +321,7 @@ void qmgr_active_done(QMGR_MESSAGE *message) message->queue_name, message->queue_id, message->encoding, - message->smtputf8, + message->sendopts, message->sender, message->dsn_envid, message->dsn_ret, @@ -403,7 +406,7 @@ static void qmgr_active_done_2_generic(QMGR_MESSAGE *message) message->queue_name, message->queue_id, message->encoding, - message->smtputf8, + message->sendopts, message->sender, message->dsn_envid, message->dsn_ret, @@ -465,7 +468,7 @@ static void qmgr_active_done_25_generic(QMGR_MESSAGE *message) message->queue_name, message->queue_id, message->encoding, - message->smtputf8, + message->sendopts, message->sender, message->dsn_envid, message->dsn_ret, @@ -476,7 +479,7 @@ static void qmgr_active_done_25_generic(QMGR_MESSAGE *message) message->queue_name, message->queue_id, message->encoding, - message->smtputf8, + message->sendopts, message->sender, message->dsn_envid, message->dsn_ret, @@ -492,7 +495,7 @@ static void qmgr_active_done_25_generic(QMGR_MESSAGE *message) message->queue_name, message->queue_id, message->encoding, - message->smtputf8, + message->sendopts, message->sender, message->dsn_envid, message->dsn_ret, diff --git a/postfix/src/oqmgr/qmgr_deliver.c b/postfix/src/oqmgr/qmgr_deliver.c index 6c093506b..4e11ed027 100644 --- a/postfix/src/oqmgr/qmgr_deliver.c +++ b/postfix/src/oqmgr/qmgr_deliver.c @@ -45,6 +45,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -147,7 +150,7 @@ static int qmgr_deliver_send_request(QMGR_ENTRY *entry, VSTREAM *stream) MSG_STATS stats; char *sender; int flags; - int smtputf8 = message->smtputf8; + int sendopts = message->sendopts; const char *addr; /* @@ -156,9 +159,9 @@ static int qmgr_deliver_send_request(QMGR_ENTRY *entry, VSTREAM *stream) for (recipient = list.info; recipient < list.info + list.len; recipient++) if (var_smtputf8_enable && (addr = recipient->address)[0] && !allascii(addr) && valid_utf8_stringz(addr)) { - smtputf8 |= SMTPUTF8_FLAG_RECIPIENT; + sendopts |= SMTPUTF8_FLAG_RECIPIENT; if (message->verp_delims) - smtputf8 |= SMTPUTF8_FLAG_SENDER; + sendopts |= SMTPUTF8_FLAG_SENDER; } /* @@ -187,7 +190,7 @@ static int qmgr_deliver_send_request(QMGR_ENTRY *entry, VSTREAM *stream) SEND_ATTR_LONG(MAIL_ATTR_SIZE, message->cont_length), SEND_ATTR_STR(MAIL_ATTR_NEXTHOP, entry->queue->nexthop), SEND_ATTR_STR(MAIL_ATTR_ENCODING, message->encoding), - SEND_ATTR_INT(MAIL_ATTR_SMTPUTF8, smtputf8), + SEND_ATTR_INT(MAIL_ATTR_SENDOPTS, sendopts), SEND_ATTR_STR(MAIL_ATTR_SENDER, sender), SEND_ATTR_STR(MAIL_ATTR_DSN_ENVID, message->dsn_envid), SEND_ATTR_INT(MAIL_ATTR_DSN_RET, message->dsn_ret), diff --git a/postfix/src/oqmgr/qmgr_message.c b/postfix/src/oqmgr/qmgr_message.c index b885264a2..a88c8e5e7 100644 --- a/postfix/src/oqmgr/qmgr_message.c +++ b/postfix/src/oqmgr/qmgr_message.c @@ -94,6 +94,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -137,6 +140,7 @@ #include #include #include +#include /* Client stubs. */ @@ -178,7 +182,7 @@ static QMGR_MESSAGE *qmgr_message_create(const char *queue_name, message->sender = 0; message->dsn_envid = 0; message->dsn_ret = 0; - message->smtputf8 = 0; + message->sendopts = 0; message->filter_xport = 0; message->inspect_xport = 0; message->redirect_addr = 0; @@ -548,7 +552,7 @@ static int qmgr_message_read(QMGR_MESSAGE *message) &message->data_size, &message->data_offset, &nrcpt, &message->rflags, &message->cont_length, - &message->smtputf8)) >= 3) { + &message->sendopts)) >= 3) { /* Postfix >= 1.0 (a.k.a. 20010228). */ if (message->data_offset <= 0 || message->data_size <= 0) { msg_warn("%s: invalid size record: %.100s", @@ -562,6 +566,8 @@ static int qmgr_message_read(QMGR_MESSAGE *message) rec_type = REC_TYPE_ERROR; break; } + /* Forward compatibility. */ + message->sendopts &= SOPT_FLAG_ALL; } else if (count == 1) { /* Postfix < 1.0 (a.k.a. 20010228). */ qmgr_message_oldstyle_scan(message); diff --git a/postfix/src/pickup/Makefile.in b/postfix/src/pickup/Makefile.in index 9279cad00..c42a73e20 100644 --- a/postfix/src/pickup/Makefile.in +++ b/postfix/src/pickup/Makefile.in @@ -72,6 +72,7 @@ pickup.o: ../../include/rec_type.h pickup.o: ../../include/record.h pickup.o: ../../include/safe_open.h pickup.o: ../../include/scan_dir.h +pickup.o: ../../include/sendopts.h pickup.o: ../../include/set_ugid.h pickup.o: ../../include/smtputf8.h pickup.o: ../../include/stringops.h diff --git a/postfix/src/postmap/Makefile.in b/postfix/src/postmap/Makefile.in index 9175767e7..4f114f504 100644 --- a/postfix/src/postmap/Makefile.in +++ b/postfix/src/postmap/Makefile.in @@ -27,7 +27,7 @@ update: ../../bin/$(PROG) cp $(PROG) ../../bin tests: test1 test2 fail_test quote_test file_test lmdb_abb_test \ - lmdb_bulk_test lmdb_incr_test + lmdb_bulk_test lmdb_incr_test cdb_bulk_test root_tests: @@ -74,6 +74,17 @@ file_test: $(PROG) file_test.in file_test.ref diff file_test.ref file_test.tmp rm -f file_test.tmp file_test_map.* postmap-file-1 postmap-file-2 +cdb_bulk_test: $(PROG) + rm -f cdb_bulk.cdb main.cf + tr A-Z a-z < /usr/share/dict/words| \ + sed -e 's/.*/& &/' -e 10000q| LANG=C sort -u >cdb_bulk + touch -t 197101010000 main.cf + ($(SHLIB_ENV) $(VALGRIND) ./postmap -c . cdb:cdb_bulk; \ + $(SHLIB_ENV) $(VALGRIND) ./postmap -s cdb:cdb_bulk | \ + LANG=C sort > cdb_bulk.tmp) + cmp cdb_bulk cdb_bulk.tmp + rm -f cdb_bulk cdb_bulk.tmp cdb_bulk.cdb main.cf + lmdb_abb_test: $(PROG) lmdb_abb lmdb_abb.ref rm -f lmdb_abb.lmdb ($(SHLIB_ENV) $(VALGRIND) ./postmap lmdb:lmdb_abb; \ @@ -86,6 +97,7 @@ lmdb_bulk_test: $(PROG) tr A-Z a-z < /usr/share/dict/words| \ sed -e 's/.*/& &/' -e 10000q| LANG=C sort -u >lmdb_retry echo lmdb_map_size=10240 >main.cf + touch -t 197101010000 main.cf ($(SHLIB_ENV) $(VALGRIND) ./postmap -c . lmdb:lmdb_retry; \ $(SHLIB_ENV) $(VALGRIND) ./postmap -s lmdb:lmdb_retry | \ LANG=C sort > lmdb_retry.tmp) @@ -97,6 +109,7 @@ lmdb_incr_test: $(PROG) tr A-Z a-z < /usr/share/dict/words| \ sed -e 's/.*/& &/' -e 1000q| LANG=C sort -u >lmdb_retry echo lmdb_map_size=10240 >main.cf + touch -t 197101010000 main.cf ($(SHLIB_ENV) $(VALGRIND) ./postmap -ic . lmdb:lmdb_retry lmdb_retry.tmp) diff --git a/postfix/src/qmgr/Makefile.in b/postfix/src/qmgr/Makefile.in index d5448b32c..573b5c7f4 100644 --- a/postfix/src/qmgr/Makefile.in +++ b/postfix/src/qmgr/Makefile.in @@ -177,6 +177,7 @@ qmgr_deliver.o: ../../include/nvtable.h qmgr_deliver.o: ../../include/rcpt_print.h qmgr_deliver.o: ../../include/recipient_list.h qmgr_deliver.o: ../../include/scan_dir.h +qmgr_deliver.o: ../../include/sendopts.h qmgr_deliver.o: ../../include/smtputf8.h qmgr_deliver.o: ../../include/stringops.h qmgr_deliver.o: ../../include/sys_defs.h @@ -288,6 +289,7 @@ qmgr_message.o: ../../include/resolve_clnt.h qmgr_message.o: ../../include/rewrite_clnt.h qmgr_message.o: ../../include/sane_time.h qmgr_message.o: ../../include/scan_dir.h +qmgr_message.o: ../../include/sendopts.h qmgr_message.o: ../../include/sent.h qmgr_message.o: ../../include/split_addr.h qmgr_message.o: ../../include/split_at.h diff --git a/postfix/src/qmgr/qmgr.h b/postfix/src/qmgr/qmgr.h index 4a205b48e..cf04ed9e4 100644 --- a/postfix/src/qmgr/qmgr.h +++ b/postfix/src/qmgr/qmgr.h @@ -345,7 +345,7 @@ struct QMGR_MESSAGE { char *sender; /* complete address */ char *dsn_envid; /* DSN envelope ID */ int dsn_ret; /* DSN headers/full */ - int smtputf8; /* requires unicode */ + int sendopts; /* smtputf8, requiretls, etc. */ char *verp_delims; /* VERP delimiters */ char *filter_xport; /* filtering transport */ char *inspect_xport; /* inspecting transport */ @@ -539,6 +539,9 @@ extern char *qmgr_error_nexthop(DSN *); /* 111 8th Avenue /* New York, NY 10011, USA /* +/* Wietse Venema +/* porcupine.org +/* /* Preemptive scheduler enhancements: /* Patrik Rak /* Modra 6 diff --git a/postfix/src/qmgr/qmgr_active.c b/postfix/src/qmgr/qmgr_active.c index fb5954276..ada8c648b 100644 --- a/postfix/src/qmgr/qmgr_active.c +++ b/postfix/src/qmgr/qmgr_active.c @@ -75,6 +75,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -307,7 +310,7 @@ void qmgr_active_done(QMGR_MESSAGE *message) message->queue_name, message->queue_id, message->encoding, - message->smtputf8, + message->sendopts, message->sender, message->dsn_envid, message->dsn_ret, @@ -318,7 +321,7 @@ void qmgr_active_done(QMGR_MESSAGE *message) message->queue_name, message->queue_id, message->encoding, - message->smtputf8, + message->sendopts, message->sender, message->dsn_envid, message->dsn_ret, @@ -403,7 +406,7 @@ static void qmgr_active_done_2_generic(QMGR_MESSAGE *message) message->queue_name, message->queue_id, message->encoding, - message->smtputf8, + message->sendopts, message->sender, message->dsn_envid, message->dsn_ret, @@ -465,7 +468,7 @@ static void qmgr_active_done_25_generic(QMGR_MESSAGE *message) message->queue_name, message->queue_id, message->encoding, - message->smtputf8, + message->sendopts, message->sender, message->dsn_envid, message->dsn_ret, @@ -476,7 +479,7 @@ static void qmgr_active_done_25_generic(QMGR_MESSAGE *message) message->queue_name, message->queue_id, message->encoding, - message->smtputf8, + message->sendopts, message->sender, message->dsn_envid, message->dsn_ret, @@ -492,7 +495,7 @@ static void qmgr_active_done_25_generic(QMGR_MESSAGE *message) message->queue_name, message->queue_id, message->encoding, - message->smtputf8, + message->sendopts, message->sender, message->dsn_envid, message->dsn_ret, diff --git a/postfix/src/qmgr/qmgr_deliver.c b/postfix/src/qmgr/qmgr_deliver.c index 6c880ce74..258f051e8 100644 --- a/postfix/src/qmgr/qmgr_deliver.c +++ b/postfix/src/qmgr/qmgr_deliver.c @@ -50,6 +50,9 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema +/* porcupine.org /*--*/ /* System library. */ @@ -152,7 +155,7 @@ static int qmgr_deliver_send_request(QMGR_ENTRY *entry, VSTREAM *stream) MSG_STATS stats; char *sender; int flags; - int smtputf8 = message->smtputf8; + int sendopts = message->sendopts; const char *addr; /* @@ -161,9 +164,9 @@ static int qmgr_deliver_send_request(QMGR_ENTRY *entry, VSTREAM *stream) for (recipient = list.info; recipient < list.info + list.len; recipient++) if (var_smtputf8_enable && (addr = recipient->address)[0] && !allascii(addr) && valid_utf8_stringz(addr)) { - smtputf8 |= SMTPUTF8_FLAG_RECIPIENT; + sendopts |= SMTPUTF8_FLAG_RECIPIENT; if (message->verp_delims) - smtputf8 |= SMTPUTF8_FLAG_SENDER; + sendopts |= SMTPUTF8_FLAG_SENDER; } /* @@ -192,7 +195,7 @@ static int qmgr_deliver_send_request(QMGR_ENTRY *entry, VSTREAM *stream) SEND_ATTR_LONG(MAIL_ATTR_SIZE, message->cont_length), SEND_ATTR_STR(MAIL_ATTR_NEXTHOP, entry->queue->nexthop), SEND_ATTR_STR(MAIL_ATTR_ENCODING, message->encoding), - SEND_ATTR_INT(MAIL_ATTR_SMTPUTF8, smtputf8), + SEND_ATTR_INT(MAIL_ATTR_SENDOPTS, sendopts), SEND_ATTR_STR(MAIL_ATTR_SENDER, sender), SEND_ATTR_STR(MAIL_ATTR_DSN_ENVID, message->dsn_envid), SEND_ATTR_INT(MAIL_ATTR_DSN_RET, message->dsn_ret), diff --git a/postfix/src/qmgr/qmgr_message.c b/postfix/src/qmgr/qmgr_message.c index 79143f3d3..2e44c1d22 100644 --- a/postfix/src/qmgr/qmgr_message.c +++ b/postfix/src/qmgr/qmgr_message.c @@ -98,6 +98,9 @@ /* 111 8th Avenue /* New York, NY 10011, USA /* +/* Wietse Venema +/* porcupine.org +/* /* Preemptive scheduler enhancements: /* Patrik Rak /* Modra 6 @@ -146,6 +149,7 @@ #include #include #include +#include /* Client stubs. */ @@ -189,7 +193,7 @@ static QMGR_MESSAGE *qmgr_message_create(const char *queue_name, message->sender = 0; message->dsn_envid = 0; message->dsn_ret = 0; - message->smtputf8 = 0; + message->sendopts = 0; message->filter_xport = 0; message->inspect_xport = 0; message->redirect_addr = 0; @@ -589,7 +593,7 @@ static int qmgr_message_read(QMGR_MESSAGE *message) &message->data_size, &message->data_offset, &message->rcpt_unread, &message->rflags, &message->cont_length, - &message->smtputf8)) >= 3) { + &message->sendopts)) >= 3) { /* Postfix >= 1.0 (a.k.a. 20010228). */ if (message->data_offset <= 0 || message->data_size <= 0) { msg_warn("%s: invalid size record: %.100s", @@ -603,6 +607,8 @@ static int qmgr_message_read(QMGR_MESSAGE *message) rec_type = REC_TYPE_ERROR; break; } + /* Forward compatibility. */ + message->sendopts &= SOPT_FLAG_ALL; } else if (count == 1) { /* Postfix < 1.0 (a.k.a. 20010228). */ qmgr_message_oldstyle_scan(message); diff --git a/postfix/src/qmqpd/Makefile.in b/postfix/src/qmqpd/Makefile.in index 54ab932c4..86fa308b9 100644 --- a/postfix/src/qmqpd/Makefile.in +++ b/postfix/src/qmqpd/Makefile.in @@ -79,6 +79,7 @@ qmqpd.o: ../../include/quote_flags.h qmqpd.o: ../../include/rec_type.h qmqpd.o: ../../include/recipient_list.h qmqpd.o: ../../include/record.h +qmqpd.o: ../../include/sendopts.h qmqpd.o: ../../include/smtputf8.h qmqpd.o: ../../include/sys_defs.h qmqpd.o: ../../include/vbuf.h diff --git a/postfix/src/smtp/Makefile.in b/postfix/src/smtp/Makefile.in index 685a72b67..f416b071a 100644 --- a/postfix/src/smtp/Makefile.in +++ b/postfix/src/smtp/Makefile.in @@ -207,6 +207,7 @@ smtp_chat.o: ../../include/post_mail.h smtp_chat.o: ../../include/recipient_list.h smtp_chat.o: ../../include/resolve_clnt.h smtp_chat.o: ../../include/scache.h +smtp_chat.o: ../../include/sendopts.h smtp_chat.o: ../../include/smtp_stream.h smtp_chat.o: ../../include/smtputf8.h smtp_chat.o: ../../include/sock_addr.h @@ -439,6 +440,7 @@ smtp_proto.o: ../../include/recipient_list.h smtp_proto.o: ../../include/record.h smtp_proto.o: ../../include/resolve_clnt.h smtp_proto.o: ../../include/scache.h +smtp_proto.o: ../../include/sendopts.h smtp_proto.o: ../../include/smtp_stream.h smtp_proto.o: ../../include/smtputf8.h smtp_proto.o: ../../include/sock_addr.h diff --git a/postfix/src/smtp/smtp_proto.c b/postfix/src/smtp/smtp_proto.c index 1b0222c17..847d0cc35 100644 --- a/postfix/src/smtp/smtp_proto.c +++ b/postfix/src/smtp/smtp_proto.c @@ -650,8 +650,8 @@ int smtp_helo(SMTP_STATE *state) * non-SMTPUTF8 server? That could make life easier for mailing lists. */ #define DELIVERY_REQUIRES_SMTPUTF8 \ - ((request->smtputf8 & SMTPUTF8_FLAG_REQUESTED) \ - && (request->smtputf8 & ~SMTPUTF8_FLAG_REQUESTED)) + ((request->sendopts & SMTPUTF8_FLAG_REQUESTED) \ + && (request->sendopts & SMTPUTF8_FLAG_DERIVED)) /* * Require that the server supports SMTPUTF8 when delivery requires @@ -1776,7 +1776,7 @@ static int smtp_loop(SMTP_STATE *state, NOCLOBBER int send_state, * the SMTPUTF8 promise that was made to the sender. */ if ((session->features & SMTP_FEATURE_SMTPUTF8) != 0 - && (request->smtputf8 & SMTPUTF8_FLAG_REQUESTED) != 0) + && (request->sendopts & SMTPUTF8_FLAG_REQUESTED) != 0) vstring_strcat(next_command, " SMTPUTF8"); /* @@ -1841,7 +1841,7 @@ static int smtp_loop(SMTP_STATE *state, NOCLOBBER int send_state, quote_822_local(session->scratch, rcpt->orig_addr); vstring_sprintf(session->scratch2, "%s;%s", /* Fix 20140707: sender must request SMTPUTF8. */ - (request->smtputf8 != 0 + ((request->sendopts & SMTPUTF8_FLAG_ALL) && !allascii(vstring_str(session->scratch))) ? "utf-8" : "rfc822", vstring_str(session->scratch)); diff --git a/postfix/src/smtpd/Makefile.in b/postfix/src/smtpd/Makefile.in index c9607d1c2..139918f41 100644 --- a/postfix/src/smtpd/Makefile.in +++ b/postfix/src/smtpd/Makefile.in @@ -227,6 +227,7 @@ smtpd.o: ../../include/rec_type.h smtpd.o: ../../include/recipient_list.h smtpd.o: ../../include/record.h smtpd.o: ../../include/resolve_clnt.h +smtpd.o: ../../include/sendopts.h smtpd.o: ../../include/smtp_stream.h smtpd.o: ../../include/smtputf8.h smtpd.o: ../../include/sock_addr.h @@ -288,6 +289,7 @@ smtpd_chat.o: ../../include/nvtable.h smtpd_chat.o: ../../include/post_mail.h smtpd_chat.o: ../../include/rec_type.h smtpd_chat.o: ../../include/record.h +smtpd_chat.o: ../../include/sendopts.h smtpd_chat.o: ../../include/smtp_reply_footer.h smtpd_chat.o: ../../include/smtp_stream.h smtpd_chat.o: ../../include/smtputf8.h diff --git a/postfix/src/util/dict_cdb.c b/postfix/src/util/dict_cdb.c index a9133cc35..ea98363ff 100644 --- a/postfix/src/util/dict_cdb.c +++ b/postfix/src/util/dict_cdb.c @@ -84,6 +84,11 @@ typedef struct { DICT dict; /* generic members */ struct cdb cdb; /* cdb structure */ + VSTRING *val_buf; /* value result */ +#ifdef TINYCDB_VERSION + VSTRING *key_buf; /* key result */ + unsigned seq_cptr; /* current sequence pointer */ +#endif } DICT_CDBQ; /* query interface */ typedef struct { @@ -93,15 +98,31 @@ typedef struct { char *tmp_path; /* temporary pathname (.tmp) */ } DICT_CDBM; /* rebuild interface */ +/* dict_cdbq_getdata - get data out of the cdb using given buffer */ + +static const char *dict_cdbq_get_data(DICT_CDBQ *dict_cdbq, + VSTRING **bufp, unsigned len, unsigned pos) +{ + VSTRING *buf = *bufp; + + if (!buf) + buf = *bufp = vstring_alloc(len < 20 ? 20 : len); + VSTRING_RESET(buf); + VSTRING_SPACE(buf, len); + + if (cdb_read(&dict_cdbq->cdb, vstring_str(buf), len, pos) < 0) + msg_fatal("error reading %s: %m", dict_cdbq->dict.name); + vstring_set_payload_size(buf, len); + VSTRING_TERMINATE(buf); + return vstring_str(buf); +} + /* dict_cdbq_lookup - find database entry, query mode */ static const char *dict_cdbq_lookup(DICT *dict, const char *name) { DICT_CDBQ *dict_cdbq = (DICT_CDBQ *) dict; - unsigned vlen; int status = 0; - static char *buf; - static unsigned len; const char *result = 0; dict->error = 0; @@ -141,25 +162,56 @@ static const char *dict_cdbq_lookup(DICT *dict, const char *name) msg_fatal("error reading %s: %m", dict->name); if (status) { - vlen = cdb_datalen(&dict_cdbq->cdb); - if (len < vlen) { - if (buf == 0) - buf = mymalloc(vlen + 1); - else - buf = myrealloc(buf, vlen + 1); - len = vlen; - } - if (cdb_read(&dict_cdbq->cdb, buf, vlen, - cdb_datapos(&dict_cdbq->cdb)) < 0) - msg_fatal("error reading %s: %m", dict->name); - buf[vlen] = '\0'; - result = buf; + result = dict_cdbq_get_data(dict_cdbq, &dict_cdbq->val_buf, + cdb_datalen(&dict_cdbq->cdb), cdb_datapos(&dict_cdbq->cdb)); } /* No locking so not release the lock. */ return (result); } +#ifdef TINYCDB_VERSION + +/* dict_cdbq_sequence - traverse the dictionary */ + +static int dict_cdbq_sequence(DICT *dict, int function, + const char **key, const char **value) +{ + const char *myname = "dict_cdbq_sequence"; + DICT_CDBQ *dict_cdbq = (DICT_CDBQ *) dict; + int status; + + switch (function) { + case DICT_SEQ_FUN_FIRST: + cdb_seqinit(&dict_cdbq->seq_cptr, &dict_cdbq->cdb); + break; + case DICT_SEQ_FUN_NEXT: + if (!dict_cdbq->seq_cptr) + msg_panic("%s: %s: no cursor", myname, dict_cdbq->dict.name); + break; + default: + msg_panic("%s: invalid function %d", myname, function); + } + + status = cdb_seqnext(&dict_cdbq->seq_cptr, &dict_cdbq->cdb); + + if (status < 0) + msg_fatal("error seeking %s: %m", dict_cdbq->dict.name); + + if (!status) { + dict_cdbq->seq_cptr = 0; + return -1; /* not found */ + } + *key = dict_cdbq_get_data(dict_cdbq, &dict_cdbq->key_buf, + cdb_keylen(&dict_cdbq->cdb), cdb_keypos(&dict_cdbq->cdb)); + *value = dict_cdbq_get_data(dict_cdbq, &dict_cdbq->val_buf, + cdb_datalen(&dict_cdbq->cdb), cdb_datapos(&dict_cdbq->cdb)); + + return 0; +} + +#endif /* TINYCDB_VERSION */ + /* dict_cdbq_close - close data base, query mode */ static void dict_cdbq_close(DICT *dict) @@ -170,6 +222,12 @@ static void dict_cdbq_close(DICT *dict) close(dict->stat_fd); if (dict->fold_buf) vstring_free(dict->fold_buf); + if (dict_cdbq->val_buf) + vstring_free(dict_cdbq->val_buf); +#ifdef TINYCDB_VERSION + if (dict_cdbq->key_buf) + vstring_free(dict_cdbq->key_buf); +#endif dict_free(dict); } @@ -200,9 +258,13 @@ static DICT *dict_cdbq_open(const char *path, int dict_flags) dict_cdbq = (DICT_CDBQ *) dict_alloc(DICT_TYPE_CDB, cdb_path, sizeof(*dict_cdbq)); + dict_cdbq->val_buf = 0; #if defined(TINYCDB_VERSION) + dict_cdbq->key_buf = 0; + dict_cdbq->seq_cptr = 0; if (cdb_init(&(dict_cdbq->cdb), fd) != 0) msg_fatal("dict_cdbq_open: unable to init %s: %m", cdb_path); + dict_cdbq->dict.sequence = dict_cdbq_sequence; #else cdb_init(&(dict_cdbq->cdb), fd); #endif diff --git a/postfix/src/verify/Makefile.in b/postfix/src/verify/Makefile.in index c0668a95b..879f32c2a 100644 --- a/postfix/src/verify/Makefile.in +++ b/postfix/src/verify/Makefile.in @@ -74,6 +74,7 @@ verify.o: ../../include/mymalloc.h verify.o: ../../include/nvtable.h verify.o: ../../include/post_mail.h verify.o: ../../include/recipient_list.h +verify.o: ../../include/sendopts.h verify.o: ../../include/set_eugid.h verify.o: ../../include/smtputf8.h verify.o: ../../include/split_at.h