From: Wietse Venema Date: Wed, 14 Apr 1999 05:00:00 +0000 (-0500) Subject: snapshot-19990414 X-Git-Tag: v20010228~116 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c606018c41265be6280958e011bedb6af574292d;p=thirdparty%2Fpostfix.git snapshot-19990414 --- diff --git a/postfix/HISTORY b/postfix/HISTORY index 48a8751dd..c9e68603d 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -2601,6 +2601,23 @@ Apologies for any names omitted. Bugfix: auto-detection of changes to DB or DBM lookup tables wan't done for TCP connections. +19990410 + + Feature: $recipient expansion in forward_path. Philip A. + Prindeville, Mirapoint, Inc., USA. File: local/dotforward.c + + Feature: the smtp client consistently treats a numerical + hostname as an address. File: smtp/smtp_addr.c. + +19990414 + + Compatibility: support comment lines starting with # in + $mydestination include files. This makes Postfix more + compatible with sendmail.cw files. File: util/match_list.c. + + Feature: specify "mydomain = domain.name" to have the local + domain name automagically appended to $myhostname. Files: + global/mail_params.c, postconf/postconf.c. Future: diff --git a/postfix/conf/main.cf.default b/postfix/conf/main.cf.default index e1dd69fa6..eb67f4ea0 100644 --- a/postfix/conf/main.cf.default +++ b/postfix/conf/main.cf.default @@ -61,7 +61,7 @@ luser_relay = mail_name = Postfix mail_owner = postfix mail_spool_directory = /var/mail -mail_version = Snapshot-19990410 +mail_version = Snapshot-19990414 mailbox_command = mailbox_transport = maps_rbl_domains = rbl.maps.vix.com diff --git a/postfix/global/mail_params.c b/postfix/global/mail_params.c index 856156a92..5731a1c97 100644 --- a/postfix/global/mail_params.c +++ b/postfix/global/mail_params.c @@ -98,6 +98,7 @@ #include #include #include +#include /* Global library. */ @@ -167,11 +168,20 @@ static const char *check_myhostname(void) { const char *name; const char *dot; + const char *domain; + /* + * If the local machine name is not in FQDN form, try to append the + * contents of $mydomain. + */ name = get_hostname(); - if ((dot = strchr(name, '.')) == 0) - msg_fatal("My hostname %s is not a FQDN. Set %s in %s/main.cf", - name, VAR_MYHOSTNAME, var_config_dir); + if ((dot = strchr(name, '.')) == 0) { + if ((domain = config_lookup_eval(VAR_MYDOMAIN)) == 0) + msg_fatal("My hostname %s is not a fully qualified name - " + "set %s or %s in %s/main.cf", + name, VAR_MYHOSTNAME, VAR_MYDOMAIN, var_config_dir); + name = concatenate(name, ".", domain, (char *) 0); + } return (name); } diff --git a/postfix/global/mail_version.h b/postfix/global/mail_version.h index 67394bfd5..81a91b856 100644 --- a/postfix/global/mail_version.h +++ b/postfix/global/mail_version.h @@ -15,7 +15,7 @@ * Version of this program. */ #define VAR_MAIL_VERSION "mail_version" -#define DEF_MAIL_VERSION "Snapshot-19990410" +#define DEF_MAIL_VERSION "Snapshot-19990414" extern char *var_mail_version; /* LICENSE diff --git a/postfix/local/dotforward.c b/postfix/local/dotforward.c index d3e5b614c..1f49e7671 100644 --- a/postfix/local/dotforward.c +++ b/postfix/local/dotforward.c @@ -92,6 +92,7 @@ typedef struct { struct mypasswd *pwd; /* recipient */ char *extension; /* address extension */ char *domain; /* recipient's domain */ + char *recipient; /* recipient */ VSTRING *path; /* result */ } FW_CONTEXT; @@ -101,7 +102,8 @@ typedef struct { #define FW_FLAG_EXTENSION (1<<3) /* expanded $extension */ #define FW_FLAG_DELIMITER (1<<4) /* expanded $recipient_delimiter */ #define FW_FLAG_DOMAIN (1<<5) /* expanded $domain */ -#define FW_FLAG_OTHER (1<<5) /* expanded text */ +#define FW_FLAG_RECIPIENT (1<<6) /* expanded $recipient */ +#define FW_FLAG_OTHER (1<<7) /* expanded text */ /* dotforward_parse_callback - callback for mac_parse */ @@ -134,6 +136,9 @@ static void dotforward_parse_callback(int type, VSTRING *buf, char *context) } else if (strcmp(vstring_str(buf), "domain") == 0) { flg = FW_FLAG_DOMAIN; ptr = fw_context->domain; + } else if (strcmp(vstring_str(buf), "recipient") == 0) { + flg = FW_FLAG_RECIPIENT; + ptr = fw_context->recipient; } else msg_fatal("unknown macro $%s in %s", vstring_str(buf), VAR_FORWARD_PATH); @@ -277,6 +282,7 @@ int deliver_dotforward(LOCAL_STATE state, USER_ATTR usr_attr, int *statusp) fw_context.extension = state.msg_attr.extension; fw_context.path = path; fw_context.domain = domain; + fw_context.recipient = state.msg_attr.recipient; lookup_status = -1; diff --git a/postfix/postconf/postconf.c b/postfix/postconf/postconf.c index 9cee72ab8..d6ec2e3cc 100644 --- a/postfix/postconf/postconf.c +++ b/postfix/postconf/postconf.c @@ -146,11 +146,34 @@ static CONFIG_STR_FN_TABLE str_fn_table_2[] = { 0, }; + /* + * XXX Global so that call-backs can see it. + */ +static int mode = SHOW_NAME; + /* check_myhostname - lookup hostname and validate */ static const char *check_myhostname(void) { - return (get_hostname()); + const char *name; + const char *dot; + const char *domain; + + /* + * If the local machine name is not in FQDN form, try to append the + * contents of $mydomain. + * + * XXX Do not complain when running as "postconf -d". + */ + name = get_hostname(); + if ((mode & SHOW_DEFS) == 0 && (dot = strchr(name, '.')) == 0) { + if ((domain = config_lookup_eval(VAR_MYDOMAIN)) == 0) + msg_fatal("My hostname %s is not a fully qualified name - " + "set %s or %s in %s/main.cf", + name, VAR_MYHOSTNAME, VAR_MYDOMAIN, var_config_dir); + name = concatenate(name, ".", domain, (char *) 0); + } + return (name); } /* get_myhostname - look up and store my hostname */ @@ -444,7 +467,6 @@ static void show_parameters(int mode, char **names) int main(int argc, char **argv) { int ch; - int mode = SHOW_NAME; int fd; struct stat st; diff --git a/postfix/smtp/smtp_addr.c b/postfix/smtp/smtp_addr.c index 380d37cbd..2ecd77868 100644 --- a/postfix/smtp/smtp_addr.c +++ b/postfix/smtp/smtp_addr.c @@ -120,12 +120,19 @@ static void smtp_print_addr(char *what, DNS_RR *addr_list) static DNS_RR *smtp_addr_one(DNS_RR *addr_list, char *host, unsigned pref, VSTRING *why) { char *myname = "smtp_addr_one"; + struct in_addr inaddr; + DNS_FIXED fixed; DNS_RR *addr = 0; DNS_RR *rr; if (msg_verbose) msg_info("%s: host %s", myname, host); + if (ISDIGIT(host[0]) && (inaddr.s_addr = inet_addr(host)) != INADDR_NONE) { + memset((char *) &fixed, 0, sizeof(fixed)); + return (dns_rr_create(host, &fixed, pref, (char *) &inaddr, sizeof(inaddr))); + } + /* * Append the addresses for this host to the address list. */ @@ -366,24 +373,16 @@ DNS_RR *smtp_domain_addr(char *name, VSTRING *why) DNS_RR *smtp_host_addr(char *host, VSTRING *why) { - DNS_FIXED fixed; DNS_RR *addr_list; - struct in_addr addr; /* * If the host is specified by numerical address, just convert the * address to internal form. Otherwise, the host is specified by name. */ #define PREF0 0 - if (ISDIGIT(host[0]) && (addr.s_addr = inet_addr(host)) != INADDR_NONE) { - fixed.type = fixed.class = fixed.ttl = fixed.length = 0; - addr_list = dns_rr_create(host, &fixed, PREF0, - (char *) &addr, sizeof(addr)); - } else { - addr_list = smtp_addr_one((DNS_RR *) 0, host, PREF0, why); - if (*var_fallback_relay) - addr_list = smtp_addr_fallback(addr_list); - } + addr_list = smtp_addr_one((DNS_RR *) 0, host, PREF0, why); + if (*var_fallback_relay) + addr_list = smtp_addr_fallback(addr_list); if (msg_verbose) smtp_print_addr(host, addr_list); return (addr_list); diff --git a/postfix/util/match_list.c b/postfix/util/match_list.c index 4f406458a..7ae42d6d5 100644 --- a/postfix/util/match_list.c +++ b/postfix/util/match_list.c @@ -103,7 +103,8 @@ static ARGV *match_list_parse(ARGV *list, char *string) if ((fp = vstream_fopen(pattern, O_RDONLY, 0)) == 0) msg_fatal("%s: open file %s: %m", myname, pattern); while (vstring_fgets(buf, fp)) - list = match_list_parse(list, vstring_str(buf)); + if (vstring_str(buf)[0] != '#') + list = match_list_parse(list, vstring_str(buf)); if (vstream_fclose(fp)) msg_fatal("%s: read file %s: %m", myname, pattern); } else if (strchr(pattern, ':') != 0) { /* type:table */