diff --git a/postfix/HISTORY b/postfix/HISTORY index 08dc03abf..d8d34834f 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -8001,6 +8001,14 @@ Apologies for any names omitted. from outside of Postfix. Files: cleanup/cleanup_addr.c. cleanup/cleanup_envelope.c cleanup/cleanup_extracted.c. +20030417 + + Feature: the SMTP client now falls back to native name + service lookups (including /etc/hosts) when a host cannot + be found in the DNS. This is controlled by a new parameter + smtp_host_lookup (default: dns, native). Files: smtp/smtp.c, + smtp/smtp_addr.c. + Open problems: Low: smtp-source may block when sending large test messages. diff --git a/postfix/RELEASE_NOTES b/postfix/RELEASE_NOTES index 2ea6bc9f4..e5f168aa0 100644 --- a/postfix/RELEASE_NOTES +++ b/postfix/RELEASE_NOTES @@ -22,18 +22,24 @@ snapshot release). Patches change the patchlevel and the release date. Snapshots change only the release date, unless they include the same bugfixes as a patch release. -Incompatible changes with Postfix snapshot 2.0.8-2004XXXX +Incompatible changes with Postfix snapshot 2.0.8-20030417 ========================================================= "sendmail -t" no longer complains when recipients are given on the command line. Instead, it now adds recipients from headers to the -command-line recipients. +recipients from the command-line. -Major changes with Postfix snapshot 2.0.8-2004XXXX +Major changes with Postfix snapshot 2.0.8-20030417 ================================================== -sender_bcc_maps and recipient_bcc_maps, after a reorganization -of how auto-bcc recipients are added. +Automatic BCC recipients depending on sender or recipient address. +The configuration parameters in question are "sender_bcc_maps" and +"recipient_bcc_maps". See conf/sample-misc.cf for details. + +Support for sending mail to hosts not in the DNS, without having +to turn off DNS lookups. The "smtp_host_lookup" parameter controls +how the Postfix SMTP client looks up hosts. The default is to use +DNS and then the native mechanism. See conf/sample-smtp.cf. Incompatible changes with Postfix snapshot 2.0.8-20040415 ========================================================= diff --git a/postfix/conf/sample-misc.cf b/postfix/conf/sample-misc.cf index 1ec322d20..b97e9ee62 100644 --- a/postfix/conf/sample-misc.cf +++ b/postfix/conf/sample-misc.cf @@ -15,6 +15,9 @@ allow_min_user = no # receives a copy of each message that enters the Postfix system, # not including bounces that are generated locally. # +# NOTE: if mail to the BCC address bounces it will be returned to +# the sender. +# always_bcc = # The daemon_timeout parameter specifies how much time a daemon may @@ -416,6 +419,9 @@ recipient_delimiter = # Specify the types and names of databases to use. After change, # run "postmap /etc/postfix/relocated", then "postfix reload". # +# NOTE: if mail to the BCC address bounces it will be returned to +# the sender. +# #recipient_bcc_maps = hash:/etc/postfix/recipient_bcc recipient_bcc_maps = @@ -476,6 +482,9 @@ resolve_dequoted_address = no # Specify the types and names of databases to use. After change, # run "postmap /etc/postfix/relocated", then "postfix reload". # +# NOTE: if mail to the BCC address bounces it will be returned to +# the sender. +# #sender_bcc_maps = hash:/etc/postfix/sender_bcc sender_bcc_maps = diff --git a/postfix/conf/sample-smtp.cf b/postfix/conf/sample-smtp.cf index 1ab352468..19b76893b 100644 --- a/postfix/conf/sample-smtp.cf +++ b/postfix/conf/sample-smtp.cf @@ -155,6 +155,20 @@ smtp_destination_concurrency_limit = 20 # smtp_destination_recipient_limit = $default_destination_recipient_limit +# The smtp_host_lookup parameter specifies what mechanism(s) to use +# when the SMTP client looks up a host. This parameter is ignored +# when DNS lookups are disabled. +# +# The default is to use both DNS and the native naming service which +# (also) uses /etc/hosts. +# +# Specify "dns" if hosts can be found in the DNS (preferred). +# Specify "dns, native" if some hosts are not in the DNS. +# Specify "native" to use the native naming service only. +# +#smtp_host_lookup = dns +smtp_host_lookup = dns, native + # # TIMEOUT CONTROLS # diff --git a/postfix/html/sendmail.1.html b/postfix/html/sendmail.1.html index a5804b223..cbdf2d5c6 100644 --- a/postfix/html/sendmail.1.html +++ b/postfix/html/sendmail.1.html @@ -138,10 +138,10 @@ SENDMAIL(1) SENDMAIL(1) This mode of operation is implemented by running the smtpd(8) daemon. - -bv Send an email report after verifying each recipient - address. Verification always happens in the back- - ground. This is useful for testing address rewrit- - ing and routing configurations. + -bv Do not collect or deliver a message. Instead, send + an email report after verifying each recipient + address. This is useful for testing address + rewriting and routing configurations. -f sender Set the envelope sender address. This is the diff --git a/postfix/html/smtp.8.html b/postfix/html/smtp.8.html index d33b3af53..be7b18649 100644 --- a/postfix/html/smtp.8.html +++ b/postfix/html/smtp.8.html @@ -89,6 +89,13 @@ SMTP(8) SMTP(8) Disable DNS lookups. This means that mail must be forwarded via a smart relay host. + smtp_host_lookup + What host lookup mechanism the SMTP client should + use. Specify dns (use DNS lookup) and/or native + (use the native naming service which also uses + /etc/hosts). This setting is ignored when DNS + lookups are disabled. + error_notice_recipient Recipient of protocol/policy/resource/software error notices. diff --git a/postfix/man/man1/sendmail.1 b/postfix/man/man1/sendmail.1 index e7453eb8d..5f453991a 100644 --- a/postfix/man/man1/sendmail.1 +++ b/postfix/man/man1/sendmail.1 @@ -121,8 +121,8 @@ run the process as the \fBmail_owner\fR user. This mode of operation is implemented by running the \fBsmtpd\fR(8) daemon. .IP \fB-bv\fR -Send an email report after verifying each recipient address. -Verification always happens in the background. This is useful +Do not collect or deliver a message. Instead, send an email +report after verifying each recipient address. This is useful for testing address rewriting and routing configurations. .IP "\fB-f \fIsender\fR" Set the envelope sender address. This is the address where diff --git a/postfix/man/man8/smtp.8 b/postfix/man/man8/smtp.8 index 64fa7fae7..1ca75585d 100644 --- a/postfix/man/man8/smtp.8 +++ b/postfix/man/man8/smtp.8 @@ -95,6 +95,11 @@ specified in the \fBdebug_peer_level\fR parameter. .IP \fBdisable_dns_lookups\fR Disable DNS lookups. This means that mail must be forwarded via a smart relay host. +.IP \fBsmtp_host_lookup\fR +What host lookup mechanism the SMTP client should use. +Specify \fBdns\fR (use DNS lookup) and/or \fBnative\fR +(use the native naming service which also uses /etc/hosts). +This setting is ignored when DNS lookups are disabled. .IP \fBerror_notice_recipient\fR Recipient of protocol/policy/resource/software error notices. .IP \fBfallback_relay\fR diff --git a/postfix/src/cleanup/Makefile.in b/postfix/src/cleanup/Makefile.in index d3d8832db..6ad1ee0ac 100644 --- a/postfix/src/cleanup/Makefile.in +++ b/postfix/src/cleanup/Makefile.in @@ -129,12 +129,13 @@ cleanup_addr.o: ../../include/mail_params.h cleanup_addr.o: ../../include/ext_prop.h cleanup_addr.o: ../../include/mail_addr.h cleanup_addr.o: ../../include/canon_addr.h -cleanup_addr.o: cleanup.h -cleanup_addr.o: ../../include/argv.h -cleanup_addr.o: ../../include/nvtable.h -cleanup_addr.o: ../../include/htable.h +cleanup_addr.o: ../../include/mail_addr_find.h cleanup_addr.o: ../../include/maps.h cleanup_addr.o: ../../include/dict.h +cleanup_addr.o: ../../include/argv.h +cleanup_addr.o: cleanup.h +cleanup_addr.o: ../../include/nvtable.h +cleanup_addr.o: ../../include/htable.h cleanup_addr.o: ../../include/tok822.h cleanup_addr.o: ../../include/resolve_clnt.h cleanup_addr.o: ../../include/been_here.h diff --git a/postfix/src/cleanup/cleanup_addr.c b/postfix/src/cleanup/cleanup_addr.c index b52a27a18..8c7f2f892 100644 --- a/postfix/src/cleanup/cleanup_addr.c +++ b/postfix/src/cleanup/cleanup_addr.c @@ -75,12 +75,14 @@ #include #include #include +#include /* Application-specific. */ #include "cleanup.h" -#define STR vstring_str +#define STR vstring_str +#define IGNORE_EXTENSION (char **) 0 /* cleanup_addr_sender - process envelope sender record */ @@ -111,7 +113,8 @@ void cleanup_addr_sender(CLEANUP_STATE *state, const char *buf) if ((state->flags & CLEANUP_FLAG_BCC_OK) && *STR(clean_addr) && cleanup_send_bcc_maps - && (bcc = maps_find(cleanup_send_bcc_maps, STR(clean_addr), 0)) != 0) + && (bcc = mail_addr_find(cleanup_send_bcc_maps, STR(clean_addr), + IGNORE_EXTENSION)) != 0) cleanup_addr_bcc(state, bcc); vstring_free(clean_addr); } @@ -139,7 +142,8 @@ void cleanup_addr_recipient(CLEANUP_STATE *state, const char *buf) if ((state->flags & CLEANUP_FLAG_BCC_OK) && *STR(clean_addr) && cleanup_rcpt_bcc_maps - && (bcc = maps_find(cleanup_rcpt_bcc_maps, STR(clean_addr), 0)) != 0) + && (bcc = mail_addr_find(cleanup_rcpt_bcc_maps, STR(clean_addr), + IGNORE_EXTENSION)) != 0) cleanup_addr_bcc(state, bcc); vstring_free(clean_addr); } diff --git a/postfix/src/global/mail_params.h b/postfix/src/global/mail_params.h index 67cc4ea05..3c8021d5d 100644 --- a/postfix/src/global/mail_params.h +++ b/postfix/src/global/mail_params.h @@ -173,6 +173,13 @@ extern char *var_fallback_relay; #define DEF_DISABLE_DNS 0 extern bool var_disable_dns; +#define SMTP_HOST_LOOKUP_DNS "dns" +#define SMTP_HOST_LOOKUP_NATIVE "native" + +#define VAR_SMTP_HOST_LOOKUP "smtp_host_lookup" +#define DEF_SMTP_HOST_LOOKUP SMTP_HOST_LOOKUP_DNS "," SMTP_HOST_LOOKUP_NATIVE +extern int var_smtp_dns_lookup; + /* * Location of the mail queue directory tree. */ diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index cff3dd02c..d31e34b0b 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,7 +20,7 @@ * Patches change the patchlevel and the release date. Snapshots change the * release date only, unless they include the same bugfix as a patch release. */ -#define MAIL_RELEASE_DATE "20030416" +#define MAIL_RELEASE_DATE "20030417" #define VAR_MAIL_VERSION "mail_version" #define DEF_MAIL_VERSION "2.0.8-" MAIL_RELEASE_DATE diff --git a/postfix/src/sendmail/Makefile.in b/postfix/src/sendmail/Makefile.in index 50d16cca4..7fdaae232 100644 --- a/postfix/src/sendmail/Makefile.in +++ b/postfix/src/sendmail/Makefile.in @@ -73,6 +73,7 @@ sendmail.o: ../../include/iostuff.h sendmail.o: ../../include/stringops.h sendmail.o: ../../include/set_ugid.h sendmail.o: ../../include/connect.h +sendmail.o: ../../include/split_at.h sendmail.o: ../../include/mail_queue.h sendmail.o: ../../include/mail_proto.h sendmail.o: ../../include/attr.h @@ -92,3 +93,5 @@ sendmail.o: ../../include/mail_stream.h sendmail.o: ../../include/verp_sender.h sendmail.o: ../../include/deliver_request.h sendmail.o: ../../include/recipient_list.h +sendmail.o: ../../include/mime_state.h +sendmail.o: ../../include/header_opts.h diff --git a/postfix/src/sendmail/sendmail.c b/postfix/src/sendmail/sendmail.c index 38e604c16..26989db70 100644 --- a/postfix/src/sendmail/sendmail.c +++ b/postfix/src/sendmail/sendmail.c @@ -115,8 +115,8 @@ /* This mode of operation is implemented by running the /* \fBsmtpd\fR(8) daemon. /* .IP \fB-bv\fR -/* Send an email report after verifying each recipient address. -/* Verification always happens in the background. This is useful +/* Do not collect or deliver a message. Instead, send an email +/* report after verifying each recipient address. This is useful /* for testing address rewriting and routing configurations. /* .IP "\fB-f \fIsender\fR" /* Set the envelope sender address. This is the address where @@ -353,7 +353,7 @@ char *verp_delims; /* - * Context for extracting recipients. + * Callback context for extracting recipients. */ typedef struct SM_STATE { VSTREAM *dst; /* output stream */ diff --git a/postfix/src/smtp/smtp.c b/postfix/src/smtp/smtp.c index 8e8e9519b..f6c0a4c24 100644 --- a/postfix/src/smtp/smtp.c +++ b/postfix/src/smtp/smtp.c @@ -79,6 +79,11 @@ /* .IP \fBdisable_dns_lookups\fR /* Disable DNS lookups. This means that mail must be forwarded /* via a smart relay host. +/* .IP \fBsmtp_host_lookup\fR +/* What host lookup mechanism the SMTP client should use. +/* Specify \fBdns\fR (use DNS lookup) and/or \fBnative\fR +/* (use the native naming service which also uses /etc/hosts). +/* This setting is ignored when DNS lookups are disabled. /* .IP \fBerror_notice_recipient\fR /* Recipient of protocol/policy/resource/software error notices. /* .IP \fBfallback_relay\fR @@ -292,12 +297,14 @@ int var_smtp_pix_thresh; int var_smtp_pix_delay; int var_smtp_line_limit; char *var_smtp_helo_name; +char *var_smtp_host_lookup; /* * Global variables. smtp_errno is set by the address lookup routines and by * the connection management routines. */ int smtp_errno; +int smtp_host_lookup_mask; /* deliver_message - deliver message with extreme prejudice */ @@ -401,8 +408,33 @@ static void smtp_service(VSTREAM *client_stream, char *unused_service, char **ar static void pre_init(char *unused_name, char **unused_argv) { + static NAME_MASK lookup_masks[] = { + SMTP_HOST_LOOKUP_DNS, SMTP_MASK_DNS, + SMTP_HOST_LOOKUP_NATIVE, SMTP_MASK_NATIVE, + 0, + }; + + /* + * Turn on per-peer debugging. + */ debug_peer_init(); + /* + * Select hostname lookup mechanisms. + */ + if (var_disable_dns) + smtp_host_lookup_mask = SMTP_MASK_NATIVE; + else + smtp_host_lookup_mask = name_mask(VAR_SMTP_HOST_LOOKUP, lookup_masks, + var_smtp_host_lookup); + if (msg_verbose) + msg_info("host name lookup methods: %s", + str_name_mask(VAR_SMTP_HOST_LOOKUP, lookup_masks, + smtp_host_lookup_mask)); + + /* + * SASL initialization. + */ if (var_smtp_sasl_enable) #ifdef USE_SASL_AUTH smtp_sasl_initialize(); @@ -417,7 +449,7 @@ static void pre_init(char *unused_name, char **unused_argv) static void pre_accept(char *unused_name, char **unused_argv) { const char *table; - + if ((table = dict_changed_name()) != 0) { msg_info("table %s has changed -- restarting", table); exit(0); @@ -447,6 +479,7 @@ int main(int argc, char **argv) VAR_SMTP_SASL_OPTS, DEF_SMTP_SASL_OPTS, &var_smtp_sasl_opts, 0, 0, VAR_SMTP_BIND_ADDR, DEF_SMTP_BIND_ADDR, &var_smtp_bind_addr, 0, 0, VAR_SMTP_HELO_NAME, DEF_SMTP_HELO_NAME, &var_smtp_helo_name, 1, 0, + VAR_SMTP_HOST_LOOKUP, DEF_SMTP_HOST_LOOKUP, &var_smtp_host_lookup, 1, 0, 0, }; static CONFIG_TIME_TABLE time_table[] = { diff --git a/postfix/src/smtp/smtp.h b/postfix/src/smtp/smtp.h index a3baeba6c..c4500d1d1 100644 --- a/postfix/src/smtp/smtp.h +++ b/postfix/src/smtp/smtp.h @@ -69,6 +69,10 @@ typedef struct SMTP_STATE { * smtp.c */ extern int smtp_errno; /* XXX can we get rid of this? */ +extern int smtp_host_lookup_mask; /* host lookup methods to use */ + +#define SMTP_MASK_DNS (1<<0) +#define SMTP_MASK_NATIVE (1<<1) /* * smtp_session.c diff --git a/postfix/src/smtp/smtp_addr.c b/postfix/src/smtp/smtp_addr.c index 9235fe502..021496b3e 100644 --- a/postfix/src/smtp/smtp_addr.c +++ b/postfix/src/smtp/smtp_addr.c @@ -175,9 +175,32 @@ static DNS_RR *smtp_addr_one(DNS_RR *addr_list, char *host, unsigned pref, VSTRI } /* - * Use gethostbyname() when DNS is disabled. + * Use DNS lookup, but keep the option open to use native name service. */ - if (var_disable_dns) { + if (smtp_host_lookup_mask & SMTP_MASK_DNS) { + switch (dns_lookup(host, T_A, RES_DEFNAMES, &addr, (VSTRING *) 0, why)) { + case DNS_OK: + for (rr = addr; rr; rr = rr->next) + rr->pref = pref; + addr_list = dns_rr_append(addr_list, addr); + return (addr_list); + default: + smtp_errno = SMTP_RETRY; + return (addr_list); + case DNS_FAIL: + smtp_errno = SMTP_FAIL; + return (addr_list); + case DNS_NOTFOUND: + smtp_errno = SMTP_FAIL; + /* maybe gethostbyname() will succeed */ + break; + } + } + + /* + * Use the native name service which also looks in /etc/hosts. + */ + if (smtp_host_lookup_mask & SMTP_MASK_NATIVE) { memset((char *) &fixed, 0, sizeof(fixed)); if ((hp = gethostbyname(host)) == 0) { vstring_sprintf(why, "%s: %s", host, HSTRERROR(h_errno)); @@ -200,22 +223,8 @@ static DNS_RR *smtp_addr_one(DNS_RR *addr_list, char *host, unsigned pref, VSTRI } /* - * Append the addresses for this host to the address list. + * No further alternatives for host lookup. */ - switch (dns_lookup(host, T_A, RES_DEFNAMES, &addr, (VSTRING *) 0, why)) { - case DNS_OK: - for (rr = addr; rr; rr = rr->next) - rr->pref = pref; - addr_list = dns_rr_append(addr_list, addr); - break; - default: - smtp_errno = SMTP_RETRY; - break; - case DNS_NOTFOUND: - case DNS_FAIL: - smtp_errno = SMTP_FAIL; - break; - } return (addr_list); }