diff --git a/postfix/HISTORY b/postfix/HISTORY index 8cabbf735..79c4f0881 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -17203,6 +17203,7 @@ Apologies for any names omitted. smtp/smtp_params.c, smtp/smtp_proto.c, smtpd/smtpd.c, tls/tls.h, tls/tls_client.c, tls/tls_misc.c, tls/tls_server.c, tlsmgr/tlsmgr.c, tlsproxy/tlsproxy.c. + 20111203 Cleanup: time-dependent sender addresses of address @@ -18181,3 +18182,12 @@ Apologies for any names omitted. Feature: "postconf -Mn" support to print only master.cf entries that have "-o name=value" parameter setttings. Files: postconf/postconf_master.c. + +20121226 + + Miscellaneous cleanups of postconf internal APIs, + identifiers and comments. No changes in behavior. + + Bugfix (omission in feature 20111203): the SMTP server + supported time-dependent address-verification sender addresses + only with RCPT TO but not with MAIL FROM. File: smtpd/smtpd.c. diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index d3bbd539a..9cd5501ee 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 "20121224" +#define MAIL_RELEASE_DATE "20121226" #define MAIL_VERSION_NUMBER "2.10" #ifdef SNAPSHOT diff --git a/postfix/src/postconf/Makefile.in b/postfix/src/postconf/Makefile.in index 6b44aa677..41423d32f 100644 --- a/postfix/src/postconf/Makefile.in +++ b/postfix/src/postconf/Makefile.in @@ -56,7 +56,7 @@ update: ../../bin/$(PROG) $(SAMPLES) $(MAKES): makes_dummy -makes_dummy: $(INC_DIR)/mail_params.h ../global/mail_params.c +makes_dummy: $(INC_DIR)/mail_params.h ../global/mail_params.c extract.awk Makefile.in $(AWK) -f extract.awk ../*/*.c | $(SHELL) touch makes_dummy diff --git a/postfix/src/postconf/postconf.h b/postfix/src/postconf/postconf.h index 0f7e5864d..363d4d48d 100644 --- a/postfix/src/postconf/postconf.h +++ b/postfix/src/postconf/postconf.h @@ -185,7 +185,7 @@ extern void register_user_parameters(void); * postconf_dbms.c */ extern void register_dbms_parameters(const char *, - const char *(*) (const char *, int, char *), + const char *(*) (const char *, int, PC_MASTER_ENT *), PC_MASTER_ENT *); /* @@ -193,7 +193,8 @@ extern void register_dbms_parameters(const char *, */ const char *lookup_parameter_value(int, const char *, PC_MASTER_ENT *, PC_PARAM_NODE *); -const char *expand_parameter_value(int, const char *, PC_MASTER_ENT *); + +char *expand_parameter_value(VSTRING *, int, const char *, PC_MASTER_ENT *); /* * postconf_unused.c. diff --git a/postfix/src/postconf/postconf_builtin.c b/postfix/src/postconf/postconf_builtin.c index 239477ed5..d845d4951 100644 --- a/postfix/src/postconf/postconf_builtin.c +++ b/postfix/src/postconf/postconf_builtin.c @@ -143,8 +143,8 @@ static const CONFIG_STR_TABLE legacy_str_table[] = { * function. We direct the calls to our own versions of those functions * because the run-time conditions are slightly different. * - * Important: if the evaluation of these parameters has any side effects, then - * those side effects must happen only once. + * Important: if the evaluation of a parameter default value has any side + * effects, then those side effects must happen only once. */ static const char *pc_check_myhostname(void); static const char *pc_check_mydomainname(void); @@ -162,8 +162,8 @@ static const CONFIG_STR_FN_TABLE str_fn_table[] = { * The AWK script cannot identify these parameters or values, so we provide * our own. * - * Important: if the evaluation of these parameters has any side effects, then - * those side effects must happen only once. + * Important: if the evaluation of a parameter default value has any side + * effects, then those side effects must happen only once. */ static CONFIG_STR_TABLE adhoc_procname = {VAR_PROCNAME}; static CONFIG_INT_TABLE adhoc_pid = {VAR_PID}; @@ -205,7 +205,7 @@ static void get_myhostname(void) if ((name = mail_conf_lookup_eval(VAR_MYHOSTNAME)) == 0) name = pc_check_myhostname(); - var_mynetworks = mystrdup(name); + var_myhostname = mystrdup(name); } /* pc_check_mydomainname - lookup domain name and validate */ @@ -225,9 +225,9 @@ static const char *pc_check_mydomainname(void) * Use the hostname when it is not a FQDN ("foo"), or when the hostname * actually is a domain name ("foo.com"). */ - if (var_mynetworks == 0) + if (var_myhostname == 0) get_myhostname(); - if ((dot = strchr(var_mynetworks, '.')) == 0 || strchr(dot + 1, '.') == 0) + if ((dot = strchr(var_myhostname, '.')) == 0 || strchr(dot + 1, '.') == 0) return (domain = DEF_MYDOMAIN); return (domain = mystrdup(dot + 1)); } @@ -373,7 +373,7 @@ void register_builtin_parameters(const char *procname, pid_t pid) /* * Initialize the global parameter table. */ - param_table = PC_PARAM_TABLE_CREATE(100); + param_table = PC_PARAM_TABLE_CREATE(1000); /* * Add the built-in parameters to the global name space. The class diff --git a/postfix/src/postconf/postconf_dbms.c b/postfix/src/postconf/postconf_dbms.c index 024c2bf5a..128a8adda 100644 --- a/postfix/src/postconf/postconf_dbms.c +++ b/postfix/src/postconf/postconf_dbms.c @@ -9,7 +9,7 @@ /* void register_dbms_parameters(param_value, flag_parameter, /* local_scope) /* const char *param_value; -/* const char *(flag_parameter) (const char *, int, char *); +/* const char *(flag_parameter) (const char *, int, PC_MASTER_ENT *); /* PC_MASTER_ENT *local_scope; /* DESCRIPTION /* This module implements legacy support for database configuration @@ -25,7 +25,7 @@ /* names for that database type. /* .IP flag_parameter /* A function that takes as arguments a candidate parameter -/* name, an unused value, and a PC_PARAM_CTX pointer. The +/* name, parameter flags, and a PC_MASTER_ENT pointer. The /* function will flag the parameter as "used" if it has a /* "name=value" entry in the local or global namespace. /* .IP local_scope @@ -145,7 +145,7 @@ static const PC_DBMS_INFO dbms_info[] = { /* register_dbms_parameters - look for database_type:prefix_name */ void register_dbms_parameters(const char *param_value, - const char *(flag_parameter) (const char *, int, char *), + const char *(flag_parameter) (const char *, int, PC_MASTER_ENT *), PC_MASTER_ENT *local_scope) { const PC_DBMS_INFO *dp; @@ -155,18 +155,15 @@ void register_dbms_parameters(const char *param_value, static VSTRING *buffer = 0; static VSTRING *candidate = 0; const char **cpp; - PC_PARAM_CTX param_ctx; - - param_ctx.local_scope = local_scope; - param_ctx.param_class = PC_PARAM_FLAG_DBMS | PC_PARAM_FLAG_USER; /* * XXX This does not examine both sides of conditional macro expansion, * and may expand the "wrong" conditional macros. This is the best we can * do for legacy database configuration support. */ - bufp = STR(vstring_strcpy(buffer ? buffer : (buffer = vstring_alloc(100)), - expand_parameter_value(SHOW_EVAL, param_value, local_scope))); + if (buffer == 0) + buffer = vstring_alloc(100); + bufp = expand_parameter_value(buffer, SHOW_EVAL, param_value, local_scope); /* * Naive parsing. We don't really know if the parameter specifies free @@ -192,7 +189,9 @@ void register_dbms_parameters(const char *param_value, vstring_sprintf(candidate ? candidate : (candidate = vstring_alloc(30)), "%s_%s", prefix, *cpp); - flag_parameter(STR(candidate), 0, (char *) ¶m_ctx); + flag_parameter(STR(candidate), + PC_PARAM_FLAG_DBMS | PC_PARAM_FLAG_USER, + local_scope); } break; } diff --git a/postfix/src/postconf/postconf_lookup.c b/postfix/src/postconf/postconf_lookup.c index 6ad1b9f8c..dc3c6964b 100644 --- a/postfix/src/postconf/postconf_lookup.c +++ b/postfix/src/postconf/postconf_lookup.c @@ -12,7 +12,8 @@ /* PC_MASTER_ENT *local_scope; /* PC_PARAM_NODE *node; /* -/* const char *expand_parameter_value(mode, value, local_scope) +/* char *expand_parameter_value(buf, mode, value, local_scope) +/* VSTRING *buf; /* int mode; /* const char *value; /* PC_MASTER_ENT *local_scope; @@ -38,6 +39,8 @@ /* each call. /* /* Arguments: +/* .IP buf +/* Null pointer, or pointer to output storage. /* .IP mode /* Bit-wise OR of zero or one of the following (other flags /* are ignored): @@ -54,9 +57,9 @@ /* The parameter value where $name should be expanded. /* .IP local_scope /* Null pointer, or pointer to master.cf entry with local -/* parameter definitions. +/* name=value settings. /* .IP node -/* Null pointer, or global default settings for the named +/* Null pointer, or global default setting for the named /* parameter. /* DIAGNOSTICS /* Problems are reported to the standard error stream. @@ -128,11 +131,11 @@ typedef struct { PC_MASTER_ENT *local_scope; } PC_EVAL_CTX; -/* expand_parameter_value_helper - macro parser call-back routine */ +/* lookup_parameter_value_wrapper - macro parser call-back routine */ -static const char *expand_parameter_value_helper(const char *key, - int unused_type, - char *context) +static const char *lookup_parameter_value_wrapper(const char *key, + int unused_type, + char *context) { PC_EVAL_CTX *cp = (PC_EVAL_CTX *) context; @@ -142,19 +145,22 @@ static const char *expand_parameter_value_helper(const char *key, /* expand_parameter_value - expand $name in parameter value */ -const char *expand_parameter_value(int mode, const char *value, - PC_MASTER_ENT *local_scope) +char *expand_parameter_value(VSTRING *buf, int mode, const char *value, + PC_MASTER_ENT *local_scope) { const char *myname = "expand_parameter_value"; - static VSTRING *buf; + static VSTRING *local_buf; int status; PC_EVAL_CTX eval_ctx; /* * Initialize. */ - if (buf == 0) - buf = vstring_alloc(10); + if (buf == 0) { + if (local_buf == 0) + local_buf = vstring_alloc(10); + buf = local_buf; + } /* * Expand macros recursively. @@ -170,7 +176,7 @@ const char *expand_parameter_value(int mode, const char *value, eval_ctx.mode = (mode & ~SHOW_NONDEF); eval_ctx.local_scope = local_scope; status = mac_expand(buf, value, MAC_EXP_FLAG_RECURSE, DONT_FILTER, - expand_parameter_value_helper, (char *) &eval_ctx); + lookup_parameter_value_wrapper, (char *) &eval_ctx); if (status & MAC_PARSE_ERROR) msg_fatal("macro processing error"); if (msg_verbose > 1) { diff --git a/postfix/src/postconf/postconf_main.c b/postfix/src/postconf/postconf_main.c index 21626cd2a..a2e2e34aa 100644 --- a/postfix/src/postconf/postconf_main.c +++ b/postfix/src/postconf/postconf_main.c @@ -177,7 +177,8 @@ static void print_parameter(int mode, const char *name, */ if (value != 0) { if ((mode & SHOW_EVAL) != 0 && PC_RAW_PARAMETER(node) == 0) - value = expand_parameter_value(mode, value, (PC_MASTER_ENT *) 0); + value = expand_parameter_value((VSTRING *) 0, mode, value, + (PC_MASTER_ENT *) 0); if (mode & SHOW_NAME) { print_line(mode, "%s = %s\n", name, value); } else { diff --git a/postfix/src/postconf/postconf_master.c b/postfix/src/postconf/postconf_master.c index 0e1ac970e..8e16a2a5c 100644 --- a/postfix/src/postconf/postconf_master.c +++ b/postfix/src/postconf/postconf_master.c @@ -245,7 +245,8 @@ static void print_master_line(int mode, PC_MASTER_ENT *masterp) if (strcmp(arg, "-o") == 0 && (aval = argv[field + 1]) != 0 && (mode & SHOW_EVAL) != 0) - aval = expand_parameter_value(mode, aval, masterp); + aval = expand_parameter_value((VSTRING *) 0, mode, + aval, masterp); /* * Keep option and value on the same line. diff --git a/postfix/src/postconf/postconf_user.c b/postfix/src/postconf/postconf_user.c index 563da5c09..195c81739 100644 --- a/postfix/src/postconf/postconf_user.c +++ b/postfix/src/postconf/postconf_user.c @@ -96,16 +96,7 @@ static HTABLE *rest_class_table; _ctx.local_scope = (scope); \ _ctx.param_class = (class); \ (void) mac_expand(NO_SCAN_RESULT, (value), MAC_EXP_FLAG_SCAN, \ - NO_SCAN_FILTER, flag_user_parameter, (char *) &_ctx); \ -} while (0) - -/* FLAG_USER_PARAMETER - flag user-defined name "valid" if it has name=value */ - -#define FLAG_USER_PARAMETER(name, class, scope) do { \ - PC_PARAM_CTX _ctx; \ - _ctx.local_scope = (scope); \ - _ctx.param_class = (class); \ - flag_user_parameter((name), NO_SCAN_MODE, (char *) &_ctx); \ + NO_SCAN_FILTER, flag_user_parameter_wrapper, (char *) &_ctx); \ } while (0) /* convert_user_parameter - get user-defined parameter string value */ @@ -118,12 +109,9 @@ static const char *convert_user_parameter(char *unused_ptr) /* flag_user_parameter - flag user-defined name "valid" if it has name=value */ static const char *flag_user_parameter(const char *mac_name, - int unused_mode, - char *context) + int param_class, + PC_MASTER_ENT *local_scope) { - PC_PARAM_CTX *param_ctx = (PC_PARAM_CTX *) context; - PC_MASTER_ENT *local_scope = param_ctx->local_scope; - int param_class = param_ctx->param_class; const char *source = local_scope ? MASTER_CONF_FILE : MAIN_CONF_FILE; int user_supplied = 0; @@ -201,6 +189,17 @@ static const char *flag_user_parameter(const char *mac_name, return (0); } +/* flag_user_parameter_wrapper - max_expand call-back helper */ + +static const char *flag_user_parameter_wrapper(const char *mac_name, + int unused_mode, + char *context) +{ + PC_PARAM_CTX *ctx = (PC_PARAM_CTX *) context; + + return (flag_user_parameter(mac_name, ctx->param_class, ctx->local_scope)); +} + /* pc_lookup_eval - generalized mail_conf_lookup_eval */ static const char *pc_lookup_eval(const char *dict_name, const char *name) @@ -243,7 +242,7 @@ static void scan_user_parameter_namespace(const char *dict_name, if (local_scope == 0 && htable_locate(rest_class_table, param_name) == 0) htable_enter(rest_class_table, param_name, ""); - FLAG_USER_PARAMETER(param_name, PC_PARAM_FLAG_USER, local_scope); + flag_user_parameter(param_name, PC_PARAM_FLAG_USER, local_scope); } myfree(saved_class_list); } diff --git a/postfix/src/smtpd/smtpd.c b/postfix/src/smtpd/smtpd.c index ce0b937bc..8cf169131 100644 --- a/postfix/src/smtpd/smtpd.c +++ b/postfix/src/smtpd/smtpd.c @@ -2352,6 +2352,21 @@ static int mail_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) VERP_CMD); return (-1); } + if (SMTPD_STAND_ALONE(state) == 0) { + const char *verify_sender; + + /* + * XXX Don't reject the address when we're probed with our own + * address verification sender address. Otherwise, some timeout or + * some UCE block may result in mutual negative caching, making it + * painful to get the mail through. Unfortunately we still have to + * send the address to the Milters otherwise they may bail out with a + * "missing recipient" protocol error. + */ + verify_sender = valid_verify_sender_addr(STR(state->addr_buf)); + if (verify_sender != 0) + vstring_strcpy(state->addr_buf, verify_sender); + } if (SMTPD_STAND_ALONE(state) == 0 && var_smtpd_delay_reject == 0 && (err = smtpd_check_mail(state, STR(state->addr_buf))) != 0) {