From 7313937cafdff90b254f160f9a30c970574b7bc5 Mon Sep 17 00:00:00 2001 From: Wietse Venema Date: Thu, 26 Apr 2012 00:00:00 -0500 Subject: [PATCH] postfix-2.10-20120426 --- postfix/HISTORY | 8 +++++ postfix/src/global/mail_version.h | 2 +- postfix/src/postconf/Makefile.in | 19 +++++++++-- postfix/src/postconf/postconf_user.c | 51 +++++++++++++++++++--------- postfix/src/postconf/test4b.ref | 5 +++ 5 files changed, 66 insertions(+), 19 deletions(-) create mode 100644 postfix/src/postconf/test4b.ref diff --git a/postfix/HISTORY b/postfix/HISTORY index bcbe233dd..d95e00ddb 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -17738,3 +17738,11 @@ Apologies for any names omitted. Workaround: bugs in 10-year old gcc versions break compilation with #ifdef inside a macro invocation (NOT: definition). Files: tls/tls.h, tls/tls_client.c, tls/tls_server.c. + +20120426 + + Bugfix (introduced Postfix 2.9): postconf flagged parameters + defined in master.cf as "unused" when they were used only + in main.cf. Problem reported by Michael Tokarev. Files: + postconf/postconf_user.c, postconf/test4b.ref, postconf + Makefile.in. diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index a57108141..1a8f59b2d 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 "20120425" +#define MAIL_RELEASE_DATE "20120426" #define MAIL_VERSION_NUMBER "2.10" #ifdef SNAPSHOT diff --git a/postfix/src/postconf/Makefile.in b/postfix/src/postconf/Makefile.in index b757205db..6fb859340 100644 --- a/postfix/src/postconf/Makefile.in +++ b/postfix/src/postconf/Makefile.in @@ -42,7 +42,7 @@ test: $(TESTPROG) tests: test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 \ test12 test13 test14 test15 test16 test17 test18 test19 test20 test21 \ - test22 test23 test24 test25 test26 test27 test28 test29 test30 + test22 test23 test24 test25 test26 test27 test28 test29 test30 test4b root_tests: @@ -80,7 +80,7 @@ test2: $(PROG) test2.ref diff test2.ref test2.tmp rm -f main.cf master.cf test2.tmp -# Define one parameter in main,cf, validate it with main.cf. +# Define one parameter in main.cf, validate it with main.cf. test3: $(PROG) test3.ref rm -f main.cf master.cf @@ -105,6 +105,21 @@ test4: $(PROG) test4.ref diff test4.ref test4.tmp rm -f main.cf master.cf test4.tmp +# Define one parameter in master.cf, validate it with main.cf. + +test4b: $(PROG) test4b.ref + rm -f main.cf master.cf + touch main.cf master.cf + echo 'always_bcc = $$foo' >> main.cf + echo 'biff = $$bar' >> main.cf + echo 'bar = aaa' >> main.cf + echo smtpd1 unix - n n - 0 smtpd >> master.cf + echo ' -o foo=xxx -o bar=yyy -o baz=zzz' >> master.cf + echo '#smtpd1 unix - n n - 0 smtpd' >> master.cf + ./$(PROG) -nc . >test4b.tmp 2>&1 + diff test4b.ref test4b.tmp + rm -f main.cf master.cf test4b.tmp + # Define one user-defined parameter with name=value in master.cf, # validate it with known_parameter=$$name in master.cf. diff --git a/postfix/src/postconf/postconf_user.c b/postfix/src/postconf/postconf_user.c index d3ff7e318..1ad955869 100644 --- a/postfix/src/postconf/postconf_user.c +++ b/postfix/src/postconf/postconf_user.c @@ -126,15 +126,28 @@ static const char *flag_user_parameter(const char *mac_name, * compatibility after a feature name change. */ if (local_scope && dict_get(local_scope->all_params, mac_name)) { + /* $name in master.cf references name=value in master.cf. */ if (PC_PARAM_TABLE_LOCATE(local_scope->valid_names, mac_name) == 0) PC_PARAM_TABLE_ENTER(local_scope->valid_names, mac_name, PC_PARAM_FLAG_USER, PC_PARAM_NO_DATA, convert_user_parameter); } else if (mail_conf_lookup(mac_name) != 0) { + /* $name in main/master.cf references name=value in main.cf. */ if (PC_PARAM_TABLE_LOCATE(param_table, mac_name) == 0) PC_PARAM_TABLE_ENTER(param_table, mac_name, PC_PARAM_FLAG_USER, PC_PARAM_NO_DATA, convert_user_parameter); } + if (local_scope == 0) { + for (local_scope = master_table; local_scope->argv; local_scope++) { + if (local_scope->all_params != 0 + && dict_get(local_scope->all_params, mac_name) != 0 + /* $name in main.cf references name=value in master.cf. */ + && PC_PARAM_TABLE_LOCATE(local_scope->valid_names, mac_name) == 0) + PC_PARAM_TABLE_ENTER(local_scope->valid_names, mac_name, + PC_PARAM_FLAG_USER, PC_PARAM_NO_DATA, + convert_user_parameter); + } + } return (0); } @@ -277,21 +290,7 @@ void register_user_parameters(void) rest_class_table = htable_create(1); /* - * Scan parameter values that are left at their defaults in the global - * name space. Some defaults contain the $name of an obsolete parameter - * for backwards compatilility purposes. We might warn that an explicit - * name=value is obsolete, but we must not warn that the parameter is - * unused. - */ - scan_default_parameter_values(param_table, CONFIG_DICT, (PC_MASTER_ENT *) 0); - - /* - * Scan the explicit name=value entries in the global name space. - */ - scan_user_parameter_namespace(CONFIG_DICT, (PC_MASTER_ENT *) 0); - - /* - * Scan the "-o parameter=value" instances in each master.cf name space. + * Initialize the per-service parameter name spaces. */ for (masterp = master_table; (argv = masterp->argv) != 0; masterp++) { for (field = PC_MASTER_MIN_FIELDS; argv->argv[field] != 0; field++) { @@ -309,7 +308,27 @@ void register_user_parameters(void) if ((dict = dict_handle(masterp->name_space)) != 0) { masterp->all_params = dict; masterp->valid_names = htable_create(1); - scan_user_parameter_namespace(masterp->name_space, masterp); } } + + /* + * Scan parameter values that are left at their defaults in the global + * name space. Some defaults contain the $name of an obsolete parameter + * for backwards compatilility purposes. We might warn that an explicit + * name=value is obsolete, but we must not warn that the parameter is + * unused. + */ + scan_default_parameter_values(param_table, CONFIG_DICT, (PC_MASTER_ENT *) 0); + + /* + * Scan the explicit name=value entries in the global name space. + */ + scan_user_parameter_namespace(CONFIG_DICT, (PC_MASTER_ENT *) 0); + + /* + * Scan the "-o parameter=value" instances in each master.cf name space. + */ + for (masterp = master_table; masterp->argv != 0; masterp++) + if (masterp->all_params != 0) + scan_user_parameter_namespace(masterp->name_space, masterp); } diff --git a/postfix/src/postconf/test4b.ref b/postfix/src/postconf/test4b.ref new file mode 100644 index 000000000..5dda033f9 --- /dev/null +++ b/postfix/src/postconf/test4b.ref @@ -0,0 +1,5 @@ +always_bcc = $foo +bar = aaa +biff = $bar +config_directory = . +./postconf: warning: ./master.cf: unused parameter: baz=zzz -- 2.47.3