summaryrefslogtreecommitdiffstats
path: root/src/postconf
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 08:41:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 08:41:51 +0000
commit3e160e27e4686620d16477a9ea9cf00141e52ce7 (patch)
tree884561d26afa36d7653aa4dc43410e1ae479d43e /src/postconf
parentAdding upstream version 3.8.6. (diff)
downloadpostfix-88041ab92eed134a20655cccac118a666f236db5.tar.xz
postfix-88041ab92eed134a20655cccac118a666f236db5.zip
Adding upstream version 3.9.0.upstream/3.9.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/postconf')
-rw-r--r--src/postconf/Makefile.in85
-rw-r--r--src/postconf/postconf.c40
-rw-r--r--src/postconf/postconf.h7
-rw-r--r--src/postconf/postconf_dbms.c49
-rw-r--r--src/postconf/postconf_unused.c112
-rw-r--r--src/postconf/postconf_user.c16
-rw-r--r--src/postconf/test29.ref3
-rw-r--r--src/postconf/test72.ref3
-rw-r--r--src/postconf/test73.ref3
-rw-r--r--src/postconf/test74.ref3
-rw-r--r--src/postconf/test75.ref3
-rw-r--r--src/postconf/test76.ref9
12 files changed, 282 insertions, 51 deletions
diff --git a/src/postconf/Makefile.in b/src/postconf/Makefile.in
index 6aff794..6df6dfa 100644
--- a/src/postconf/Makefile.in
+++ b/src/postconf/Makefile.in
@@ -17,7 +17,7 @@ MAKES = bool_table.h bool_vars.h int_table.h int_vars.h str_table.h \
nint_table.h nint_vars.h nbool_table.h nbool_vars.h long_table.h \
long_vars.h str_fn_table.h str_fn_vars.h
DB_MAKES= pcf_ldap_suffixes.h pcf_memcache_suffixes.h pcf_mysql_suffixes.h \
- pcf_pgsql_suffixes.h pcf_sqlite_suffixes.h
+ pcf_pgsql_suffixes.h pcf_sqlite_suffixes.h pcf_mongodb_suffixes.h
TEST_TMP= main.cf master.cf test*.tmp
DUMMIES = makes_dummy # for "make -j"
PROG = postconf
@@ -55,7 +55,8 @@ tests: test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 \
test31 test32 test33 test34 test35 test36 test37 test39 test40 test41 \
test42 test43 test44 test45 test46 test47 test48 test49 test50 test51 \
test52 test53 test54 test55 test56 test57 test58 test59 test60 test61 \
- test62 test63 test64 test65 test66 test67 test68 test69 test70 test71
+ test62 test63 test64 test65 test66 test67 test68 test69 test70 test71 \
+ test72 test73 test74 test75 test76
root_tests:
@@ -78,6 +79,9 @@ pcf_ldap_suffixes.h: ../global/dict_ldap.c
pcf_memcache_suffixes.h: ../global/dict_memcache.c
sh extract_cfg.sh -d ../global/dict_memcache.c > $@
+pcf_mongodb_suffixes.h: ../global/dict_mongodb.c
+ sh extract_cfg.sh -d ../global/dict_mongodb.c > $@
+
pcf_mysql_suffixes.h: ../global/dict_mysql.c
sh extract_cfg.sh -d -s ../global/dict_mysql.c > $@
@@ -465,6 +469,9 @@ test29: $(PROG) test29.ref
echo 'memcachexx = proxy:memcache:memcachefoo' >> main.cf
echo 'memcachefoo_domain = bar' >> main.cf
echo 'memcachefoo_domainx = bar' >> main.cf
+ echo 'mongodbxx = proxy:mongodb:mongodbfoo' >> main.cf
+ echo 'mongodbfoo_domain = bar' >> main.cf
+ echo 'mongodbfoo_domainx = bar' >> main.cf
touch -t 197101010000 main.cf
$(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -nc . >test29.tmp 2>&1
diff test29.ref test29.tmp
@@ -807,7 +814,7 @@ test58: $(PROG) test58.ref
echo 'yy_backup = bbb' >> main.cf
echo 'yy_bogus = bbb' >> main.cf
touch -t 197101010000 main.cf
- $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./postconf -nc. >test58.tmp 2>&1 || true
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -nc. >test58.tmp 2>&1 || true
diff test58.ref test58.tmp
rm -f main.cf master.cf test58.tmp
@@ -989,6 +996,75 @@ test71: $(PROG) test71.ref
diff test71.ref test71.tmp
rm -f main.cf master.cf test71.tmp
+# Different requests to add lines to master.cf.
+test72: $(PROG) test72.ref
+ rm -f main.cf master.cf
+ touch main.cf master.cf
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -Mc. smtp/unix='smtp unix - n n - 0 other'
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -Mc. smtp/abcd='smtp fifo - n n - 0 other'
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -Mc. smtp/abcd='smtp inet - n n - 0 other'
+ touch -t 197201010000 main.cf
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -Mc. >test72.tmp 2>&1
+ diff test72.ref test72.tmp
+ rm -f main.cf master.cf test72.tmp
+
+# Replace one entry based on the name+type in the request's service entry.
+test73: $(PROG) test73.ref
+ rm -f main.cf master.cf
+ touch main.cf master.cf
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -Mc. smtp/unix='smtp unix - n n - 0 other'
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -Mc. smtp/abcd='smtp fifo - n n - 0 other'
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -Mc. smtp/abcd='smtp inet - n n - 0 other'
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -Mc. smtp/abcd='smtp unix - n n - 0 otherx'
+ touch -t 197301010000 main.cf
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -Mc. >test73.tmp 2>&1
+ diff test73.ref test73.tmp
+ rm -f main.cf master.cf test73.tmp
+
+# Replace one entry based on the name+type in the request's service pattern.
+test74: $(PROG) test74.ref
+ rm -f main.cf master.cf
+ touch main.cf master.cf
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -Mc. smtp/unix='smtp unix - n n - 0 other'
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -Mc. smtp/abcd='smtp fifo - n n - 0 other'
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -Mc. smtp/abcd='smtp inet - n n - 0 other'
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -Mc. smtp/fifo='lmtp unix - n n - 0 otherx'
+ touch -t 197401010000 main.cf
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -Mc. >test74.tmp 2>&1
+ diff test74.ref test74.tmp
+ rm -f main.cf master.cf test74.tmp
+
+# Warn about skipping redundant name=value update.
+test75: $(PROG) test75.ref
+ rm -f main.cf master.cf
+ touch main.cf master.cf
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -c. mail_version=x mail_version=y >test75.tmp 2>&1
+ touch -t 197501010000 main.cf
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -nc. >>test75.tmp 2>&1
+ diff test75.ref test75.tmp
+ rm -f main.cf master.cf test75.tmp
+
+# Warn about unused, deprecated, or deleted parameters.
+test76: $(PROG) test76.ref
+ rm -f main.cf master.cf
+ touch main.cf master.cf
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -c. \
+ config_directory=. \
+ deleted-test-only=whatever \
+ disable_dns_lookups=no \
+ lmtp_use_tls=no \
+ smtpd_tls_dh1024_param_file=auto >test76.tmp 2>&1
+ touch -t 197601010000 main.cf
+ echo foo unix - n n - 0 other >> master.cf
+ echo ' -o alias_maps=foo' >> master.cf
+ echo ' -o smtp_enforce_tls=yes' >> master.cf
+ touch -t 197601010000 master.cf
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -nc. >>test76.tmp 2>&1
+ diff test76.ref test76.tmp
+ $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -qnc. >/dev/null 2>test76.tmp
+ diff /dev/null test76.tmp
+ rm -f main.cf master.cf test76.tmp
+
printfck: $(OBJS) $(PROG)
rm -rf printfck
mkdir printfck
@@ -1094,6 +1170,7 @@ postconf_dbms.o: ../../include/dict.h
postconf_dbms.o: ../../include/dict_ht.h
postconf_dbms.o: ../../include/dict_ldap.h
postconf_dbms.o: ../../include/dict_memcache.h
+postconf_dbms.o: ../../include/dict_mongodb.h
postconf_dbms.o: ../../include/dict_mysql.h
postconf_dbms.o: ../../include/dict_pcre.h
postconf_dbms.o: ../../include/dict_pgsql.h
@@ -1118,6 +1195,7 @@ postconf_dbms.o: ../../include/vstream.h
postconf_dbms.o: ../../include/vstring.h
postconf_dbms.o: pcf_ldap_suffixes.h
postconf_dbms.o: pcf_memcache_suffixes.h
+postconf_dbms.o: pcf_mongodb_suffixes.h
postconf_dbms.o: pcf_mysql_suffixes.h
postconf_dbms.o: pcf_pgsql_suffixes.h
postconf_dbms.o: pcf_sqlite_suffixes.h
@@ -1184,6 +1262,7 @@ postconf_main.o: postconf_main.c
postconf_master.o: ../../include/argv.h
postconf_master.o: ../../include/check_arg.h
postconf_master.o: ../../include/dict.h
+postconf_master.o: ../../include/dict_ht.h
postconf_master.o: ../../include/htable.h
postconf_master.o: ../../include/mail_params.h
postconf_master.o: ../../include/master_proto.h
diff --git a/src/postconf/postconf.c b/src/postconf/postconf.c
index f598a5b..74f13b2 100644
--- a/src/postconf/postconf.c
+++ b/src/postconf/postconf.c
@@ -8,7 +8,7 @@
/* .ti -4
/* \fBManaging main.cf:\fR
/*
-/* \fBpostconf\fR [\fB-dfhHnopvx\fR] [\fB-c \fIconfig_dir\fR]
+/* \fBpostconf\fR [\fB-dfhHnopqvx\fR] [\fB-c \fIconfig_dir\fR]
/* [\fB-C \fIclass,...\fR] [\fIparameter ...\fR]
/*
/* \fBpostconf\fR [\fB-epv\fR] [\fB-c \fIconfig_dir\fR]
@@ -23,7 +23,7 @@
/* .ti -4
/* \fBManaging master.cf service entries:\fR
/*
-/* \fBpostconf\fR \fB-M\fR [\fB-fovx\fR] [\fB-c \fIconfig_dir\fR]
+/* \fBpostconf\fR \fB-M\fR [\fB-foqvx\fR] [\fB-c \fIconfig_dir\fR]
/* [\fIservice\fR[\fB/\fItype\fR]\fI ...\fR]
/*
/* \fBpostconf\fR \fB-M\fR [\fB-ev\fR] [\fB-c \fIconfig_dir\fR]
@@ -38,7 +38,7 @@
/* .ti -4
/* \fBManaging master.cf service fields:\fR
/*
-/* \fBpostconf\fR \fB-F\fR [\fB-fhHovx\fR] [\fB-c \fIconfig_dir\fR]
+/* \fBpostconf\fR \fB-F\fR [\fB-fhHoqvx\fR] [\fB-c \fIconfig_dir\fR]
/* [\fIservice\fR[\fB/\fItype\fR[\fB/\fIfield\fR]]\fI ...\fR]
/*
/* \fBpostconf\fR \fB-F\fR [\fB-ev\fR] [\fB-c \fIconfig_dir\fR]
@@ -47,7 +47,7 @@
/* .ti -4
/* \fBManaging master.cf service parameters:\fR
/*
-/* \fBpostconf\fR \fB-P\fR [\fB-fhHovx\fR] [\fB-c \fIconfig_dir\fR]
+/* \fBpostconf\fR \fB-P\fR [\fB-fhHoqvx\fR] [\fB-c \fIconfig_dir\fR]
/* [\fIservice\fR[\fB/\fItype\fR[\fB/\fIparameter\fR]]\fI ...\fR]
/*
/* \fBpostconf\fR \fB-P\fR [\fB-ev\fR] [\fB-c \fIconfig_dir\fR]
@@ -293,6 +293,11 @@
/* \fBmemcache_table\fR(5).
/*
/* This feature is available with Postfix 2.9 and later.
+/* .IP "\fBmongodb\fR"
+/* MongoDB database client. This is described in
+/* \fBmongodb_table\fR(5).
+/*
+/* This feature is available with Postfix 3.9 and later.
/* .IP "\fBmysql\fR (read-only)"
/* MySQL database client. Available on systems with support
/* for MySQL databases. This is described in \fBmysql_table\fR(5).
@@ -452,6 +457,10 @@
/* wildcard fields.
/*
/* This feature is available with Postfix 2.11 and later.
+/* .IP \fB-q\fR
+/* Do not log warnings for deprecated or unused parameters.
+/*
+/* This feature is available with Postfix 3.9 and later.
/* .IP "\fB-t\fR [\fItemplate_file\fR]"
/* Display the templates for text that appears at the beginning
/* of delivery status notification (DSN) messages, without
@@ -779,6 +788,8 @@ static void pcf_check_compat_options(int optval)
const int (*op)[2];
int excess;
+ optval &= ~PCF_DEF_MODE;
+
for (op = pcf_compat_options; op[0][0] != 0; op++) {
if ((optval & *op[0]) != 0
&& (excess = (optval & ~((*op)[0] | (*op)[1]))) != 0)
@@ -844,7 +855,7 @@ int main(int argc, char **argv)
/*
* Parse JCL.
*/
- while ((ch = GETOPT(argc, argv, "aAbc:C:deEfFhHlmMno:pPtT:vxX#")) > 0) {
+ while ((ch = GETOPT(argc, argv, "aAbc:C:deEfFhHlmMno:pPqtT:vxX#")) > 0) {
switch (ch) {
case 'a':
pcf_cmd_mode |= PCF_SHOW_SASL_SERV;
@@ -912,6 +923,9 @@ int main(int argc, char **argv)
case 'P':
pcf_cmd_mode |= PCF_MASTER_PARAM;
break;
+ case 'q':
+ pcf_cmd_mode &= ~(PCF_WARN_UNUSED_DEPRECATED);
+ break;
case 't':
pcf_cmd_mode |= PCF_DUMP_DSN_TEMPL;
if (ext_argv)
@@ -1028,7 +1042,7 @@ int main(int argc, char **argv)
pcf_set_parameters(override_params->argv);
pcf_register_builtin_parameters(basename(argv[0]), getpid());
pcf_register_service_parameters();
- pcf_register_user_parameters();
+ pcf_register_user_parameters(pcf_cmd_mode);
if (pcf_cmd_mode & PCF_MASTER_FLD)
pcf_show_master_fields(VSTREAM_OUT, pcf_cmd_mode, argc - optind,
argv + optind);
@@ -1038,7 +1052,8 @@ int main(int argc, char **argv)
else
pcf_show_master_entries(VSTREAM_OUT, pcf_cmd_mode, argc - optind,
argv + optind);
- pcf_flag_unused_master_parameters();
+ if (pcf_cmd_mode & PCF_WARN_UNUSED_DEPRECATED)
+ pcf_flag_unused_master_parameters();
}
/*
@@ -1090,7 +1105,7 @@ int main(int argc, char **argv)
pcf_read_master(PCF_WARN_ON_OPEN_ERROR);
pcf_register_service_parameters();
if ((pcf_cmd_mode & PCF_SHOW_DEFS) == 0)
- pcf_register_user_parameters();
+ pcf_register_user_parameters(pcf_cmd_mode);
/*
* Show the requested values.
@@ -1099,11 +1114,12 @@ int main(int argc, char **argv)
argv + optind);
/*
- * Flag unused parameters. This makes no sense with "postconf -d",
- * because that ignores all the user-specified parameters and
- * user-specified macro expansions in main.cf.
+ * Flag unused or deprecated parameters. This makes no sense with
+ * "postconf -d", because that ignores all the user-specified
+ * parameters and user-specified macro expansions in main.cf.
*/
- if ((pcf_cmd_mode & PCF_SHOW_DEFS) == 0) {
+ if ((pcf_cmd_mode & PCF_SHOW_DEFS) == 0
+ && (pcf_cmd_mode & PCF_WARN_UNUSED_DEPRECATED) != 0) {
pcf_flag_unused_main_parameters();
pcf_flag_unused_master_parameters();
}
diff --git a/src/postconf/postconf.h b/src/postconf/postconf.h
index 24a1ed7..b42245c 100644
--- a/src/postconf/postconf.h
+++ b/src/postconf/postconf.h
@@ -46,8 +46,9 @@
#define PCF_MASTER_PARAM (1<<19) /* manage master.cf -o name=value */
#define PCF_HIDE_VALUE (1<<20) /* hide main.cf/master.cf =value */
#define PCF_SHOW_TLS (1<<21) /* TLS support introspection */
+#define PCF_WARN_UNUSED_DEPRECATED (1<<22) /* As the name says */
-#define PCF_DEF_MODE 0
+#define PCF_DEF_MODE (PCF_WARN_UNUSED_DEPRECATED)
/*
* Structure for one "valid parameter" (built-in, service-defined or valid
@@ -274,12 +275,12 @@ typedef struct {
/*
* postconf_user.c.
*/
-extern void pcf_register_user_parameters(void);
+extern void pcf_register_user_parameters(int);
/*
* postconf_dbms.c
*/
-extern void pcf_register_dbms_parameters(const char *,
+extern void pcf_register_dbms_parameters(int, const char *,
const char *(*) (const char *, int, PCF_MASTER_ENT *),
PCF_MASTER_ENT *);
diff --git a/src/postconf/postconf_dbms.c b/src/postconf/postconf_dbms.c
index 0ed5b53..105ae85 100644
--- a/src/postconf/postconf_dbms.c
+++ b/src/postconf/postconf_dbms.c
@@ -6,8 +6,9 @@
/* SYNOPSIS
/* #include <postconf.h>
/*
-/* void pcf_register_dbms_parameters(param_value, flag_parameter,
+/* void pcf_register_dbms_parameters(mode, param_value, flag_parameter,
/* local_scope)
+/* int mode;
/* const char *param_value;
/* const char *(flag_parameter) (const char *, int, PCF_MASTER_ENT *);
/* PCF_MASTER_ENT *local_scope;
@@ -17,6 +18,9 @@
/* the database name to a database-defined suffix.
/*
/* Arguments:
+/* .IP mode
+/* If PCF_WARN_UNUSED_DEPRECATED is set, warn about unused
+/* database settings.
/* .IP param_value
/* A parameter value to be searched for "type:table" strings.
/* When a database type is found that supports legacy-style
@@ -77,6 +81,7 @@
#include <dict_pgsql.h>
#include <dict_sqlite.h>
#include <dict_memcache.h>
+#include <dict_mongodb.h>
#include <dict_regexp.h>
#include <dict_pcre.h>
@@ -131,6 +136,13 @@ static const char *pcf_memcache_suffixes[] = {
0,
};
+/* See mongodb_table(5). */
+
+static const char *pcf_mongodb_suffixes[] = {
+#include "pcf_mongodb_suffixes.h"
+ 0,
+};
+
/*
* Bundle up the database types and their suffix lists.
*/
@@ -149,6 +161,7 @@ static const PCF_DBMS_INFO pcf_dbms_info[] = {
{DICT_TYPE_PGSQL, PCF_DBMS_CLASS_CLIENT, pcf_pgsql_suffixes},
{DICT_TYPE_SQLITE, PCF_DBMS_CLASS_CLIENT, pcf_sqlite_suffixes},
{DICT_TYPE_MEMCACHE, PCF_DBMS_CLASS_CLIENT, pcf_memcache_suffixes},
+ {DICT_TYPE_MONGODB, PCF_DBMS_CLASS_CLIENT, pcf_mongodb_suffixes},
{DICT_TYPE_REGEXP, PCF_DBMS_CLASS_REGEX},
{DICT_TYPE_PCRE, PCF_DBMS_CLASS_REGEX},
{0},
@@ -163,7 +176,8 @@ static const PCF_DBMS_INFO pcf_dbms_info[] = {
/* pcf_check_dbms_client - look for unused names in client configuration */
-static void pcf_check_dbms_client(const PCF_DBMS_INFO *dp, const char *cf_file)
+static void pcf_check_dbms_client(int mode, const PCF_DBMS_INFO *dp,
+ const char *cf_file)
{
DICT *dict;
VSTREAM *fp;
@@ -217,19 +231,21 @@ static void pcf_check_dbms_client(const PCF_DBMS_INFO *dp, const char *cf_file)
* code, because a database client parameter namespace is unlike the
* parameter namespaces in main.cf or master.cf.
*/
- for (cpp = dp->db_suffixes; *cpp; cpp++)
- (void) dict_del(dict, *cpp);
- for (dir = DICT_SEQ_FUN_FIRST;
- dict->sequence(dict, dir, &name, &value) == DICT_STAT_SUCCESS;
- dir = DICT_SEQ_FUN_NEXT)
- msg_warn("%s: unused parameter: %s=%s", dict_spec, name, value);
+ if (mode & PCF_WARN_UNUSED_DEPRECATED) {
+ for (cpp = dp->db_suffixes; *cpp; cpp++)
+ (void) dict_del(dict, *cpp);
+ for (dir = DICT_SEQ_FUN_FIRST;
+ dict->sequence(dict, dir, &name, &value) == DICT_STAT_SUCCESS;
+ dir = DICT_SEQ_FUN_NEXT)
+ msg_warn("%s: unused parameter: %s=%s", dict_spec, name, value);
+ }
}
myfree(dict_spec);
}
/* pcf_register_dbms_helper - parse one possible database type:name */
-static void pcf_register_dbms_helper(char *str_value,
+static void pcf_register_dbms_helper(int mode, char *str_value,
const char *(flag_parameter) (const char *, int, PCF_MASTER_ENT *),
PCF_MASTER_ENT *local_scope,
int recurse)
@@ -258,8 +274,8 @@ static void pcf_register_dbms_helper(char *str_value,
myfree(err);
}
if (recurse)
- pcf_register_dbms_helper(db_type, flag_parameter, local_scope,
- recurse);
+ pcf_register_dbms_helper(mode, db_type, flag_parameter,
+ local_scope, recurse);
continue;
}
@@ -287,7 +303,7 @@ static void pcf_register_dbms_helper(char *str_value,
for (dp = pcf_dbms_info; dp->db_type != 0; dp++) {
if (strcmp(db_type, dp->db_type) == 0) {
if (dp->db_class == PCF_DBMS_CLASS_CLIENT)
- pcf_check_dbms_client(dp, prefix);
+ pcf_check_dbms_client(mode, dp, prefix);
break;
}
}
@@ -321,8 +337,8 @@ static void pcf_register_dbms_helper(char *str_value,
break;
}
}
- pcf_register_dbms_helper(prefix, flag_parameter, local_scope,
- next_recurse);
+ pcf_register_dbms_helper(mode, prefix, flag_parameter,
+ local_scope, next_recurse);
continue;
} else {
for (dp = pcf_dbms_info; dp->db_type != 0; dp++) {
@@ -347,7 +363,7 @@ static void pcf_register_dbms_helper(char *str_value,
/* pcf_register_dbms_parameters - look for database_type:prefix_name */
-void pcf_register_dbms_parameters(const char *param_value,
+void pcf_register_dbms_parameters(int mode, const char *param_value,
const char *(flag_parameter) (const char *, int, PCF_MASTER_ENT *),
PCF_MASTER_ENT *local_scope)
{
@@ -363,7 +379,8 @@ void pcf_register_dbms_parameters(const char *param_value,
buffer = vstring_alloc(100);
bufp = pcf_expand_parameter_value(buffer, PCF_SHOW_EVAL, param_value,
local_scope);
- pcf_register_dbms_helper(bufp, flag_parameter, local_scope, PCF_DBMS_RECURSE);
+ pcf_register_dbms_helper(mode, bufp, flag_parameter, local_scope,
+ PCF_DBMS_RECURSE);
}
#endif
diff --git a/src/postconf/postconf_unused.c b/src/postconf/postconf_unused.c
index d4416f8..717d1a5 100644
--- a/src/postconf/postconf_unused.c
+++ b/src/postconf/postconf_unused.c
@@ -2,7 +2,7 @@
/* NAME
/* postconf_unused 3
/* SUMMARY
-/* report unused parameters
+/* report unused or deprecated parameters
/* SYNOPSIS
/* #include <postconf.h>
/*
@@ -15,11 +15,11 @@
/* In other words, don't call these functions with "postconf
/* -d" which ignores user-defined main.cf settings.
/*
-/* pcf_flag_unused_main_parameters() reports unused "name=value"
-/* entries in main.cf.
+/* pcf_flag_unused_main_parameters() reports unused or deprecated
+/* "name=value" entries in main.cf.
/*
-/* pcf_flag_unused_master_parameters() reports unused "-o
-/* name=value" entries in master.cf.
+/* pcf_flag_unused_master_parameters() reports unused or
+/* deprecated "-o name=value" entries in master.cf.
/* DIAGNOSTICS
/* Problems are reported to the standard error stream.
/* LICENSE
@@ -31,6 +31,10 @@
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
+/*
+/* Wietse Venema
+/* porcupine.org
+/* Amawalk, NY 10501, USA
/*--*/
/* System library. */
@@ -52,12 +56,66 @@
#include <postconf.h>
+ /*
+ * Deprecated parameter names and suggested alternatives. If we keep deleted
+ * parameter names in the table, a warning can still suggest alternatives.
+ * The downside of keeping deleted names in the table is that we may falsely
+ * warn about a user-defined parameter whose name matches that of a deleted
+ * parameter.
+ */
+typedef struct {
+ char *name;
+ char *alternative;
+} PCF_DEPR_PARAM_INFO;
+
+static const PCF_DEPR_PARAM_INFO pcf_depr_param_info[] = {
+
+ /*
+ * Parameters with deprecation warnings as of Postfix 3.9. The
+ * disable_dns_lookups parameter was documented as deprecated since
+ * Postfix 2.11 but nothing was logged.
+ */
+ "disable_dns_lookups", "specify \"smtp_dns_support_level\"",
+ "lmtp_use_tls", "specify \"lmtp_tls_security_level\"",
+ "postscreen_use_tls", "specify \"postscreen_tls_security_level\"",
+ "smtp_use_tls", "specify \"smtp_tls_security_level\"",
+ "smtpd_use_tls", "specify \"smtpd_tls_security_level\"",
+ "tlsproxy_client_use_tls", "specify \"tlsproxy_client_security_level\"",
+ "tlsproxy_use_tls", "specify \"tlsproxy_tls_security_level\"",
+ "lmtp_enforce_tls", "lmtp_tls_security_level",
+ "postscreen_enforce_tls", "specify \"postscreen_tls_security_level\"",
+ "smtp_enforce_tls", "specify \"smtp_tls_security_level\"",
+ "smtpd_enforce_tls", "specify \"smtpd_tls_security_level\"",
+ "tlsproxy_client_enforce_tls", "specify \"tlsproxy_client_security_level\"",
+ "tlsproxy_enforce_tls", "specify \"tlsproxy_tls_security_level\"",
+ "lmtp_tls_per_site", "specify \"lmtp_tls_policy_maps\"",
+ "smtp_tls_per_site", "specify \"smtp_tls_policy_maps\"",
+ "tlsproxy_client_per_site", "specify \"tlsproxy_client_policy_maps\"",
+ "smtpd_tls_dh1024_param_file", "do not specify (leave at default)",
+ "smtpd_tls_eecdh_grade", "do not specify (leave at default)",
+ "deleted-test-only", "do not specify", /* For testing */
+ 0,
+};
+static HTABLE *pcf_depr_param_table;
+
+/* pcf_init_depr_params - initialize lookup table */
+
+static void pcf_init_depr_params(void)
+{
+ const PCF_DEPR_PARAM_INFO *dp;
+
+ pcf_depr_param_table = htable_create(30);
+ for (dp = pcf_depr_param_info; dp->name; dp++)
+ (void) htable_enter(pcf_depr_param_table, dp->name, (void *) dp);
+}
+
/* pcf_flag_unused_parameters - warn about unused parameters */
static void pcf_flag_unused_parameters(DICT *dict, const char *conf_name,
PCF_MASTER_ENT *local_scope)
{
const char *myname = "pcf_flag_unused_parameters";
+ const PCF_DEPR_PARAM_INFO *dp;
const char *param_name;
const char *param_value;
int how;
@@ -67,23 +125,55 @@ static void pcf_flag_unused_parameters(DICT *dict, const char *conf_name,
*/
if (pcf_param_table == 0)
msg_panic("%s: global parameter table is not initialized", myname);
+ if (dict->sequence == 0)
+ msg_panic("%s: parameter dictionary %s has no iterator",
+ myname, conf_name);
+
+ /*
+ * One-time initialization.
+ */
+ if (pcf_depr_param_table == 0)
+ pcf_init_depr_params();
/*
* Iterate over all entries, and flag parameter names that aren't used
- * anywhere. Show the warning message at the end of the output.
+ * anywhere, or that are deprecated. Show the warning message(s) after
+ * the end of the stdout output.
*/
- if (dict->sequence == 0)
- msg_panic("%s: parameter dictionary %s has no iterator",
- myname, conf_name);
for (how = DICT_SEQ_FUN_FIRST;
dict->sequence(dict, how, &param_name, &param_value) == 0;
how = DICT_SEQ_FUN_NEXT) {
+
+ /*
+ * Flag a parameter that is not used (deleted name, or incorrect
+ * name).
+ */
if (PCF_PARAM_TABLE_LOCATE(pcf_param_table, param_name) == 0
&& (local_scope == 0
|| PCF_PARAM_TABLE_LOCATE(local_scope->valid_names, param_name) == 0)) {
vstream_fflush(VSTREAM_OUT);
- msg_warn("%s/%s: unused parameter: %s=%s",
- var_config_dir, conf_name, param_name, param_value);
+ if ((dp = (const PCF_DEPR_PARAM_INFO *)
+ htable_find(pcf_depr_param_table, param_name)) != 0) {
+ msg_warn("%s/%s: support for parameter %s has been removed;"
+ " instead, %s", var_config_dir, conf_name,
+ param_name, dp->alternative);
+ } else {
+ msg_warn("%s/%s: unused parameter: %s=%s",
+ var_config_dir, conf_name, param_name, param_value);
+ }
+ }
+
+ /*
+ * Flag a parameter that is used but deprecated. Note that this may
+ * falsely complain about a user-defined parameter whose name matches
+ * that of a deleted parameter.
+ */
+ else if ((dp = (const PCF_DEPR_PARAM_INFO *)
+ htable_find(pcf_depr_param_table, param_name)) != 0) {
+ vstream_fflush(VSTREAM_OUT);
+ msg_warn("%s/%s: support for parameter \"%s\" will be removed;"
+ " instead, %s", var_config_dir, conf_name,
+ param_name, dp->alternative);
}
}
}
diff --git a/src/postconf/postconf_user.c b/src/postconf/postconf_user.c
index 5942ec0..46f4d61 100644
--- a/src/postconf/postconf_user.c
+++ b/src/postconf/postconf_user.c
@@ -6,7 +6,7 @@
/* SYNOPSIS
/* #include <postconf.h>
/*
-/* void pcf_register_user_parameters()
+/* void pcf_register_user_parameters(int mode)
/* DESCRIPTION
/* Postfix has multiple parameter name spaces: the global
/* main.cf parameter name space, and the local parameter name
@@ -40,6 +40,10 @@
/* to instantiate legacy per-dbms parameters, and to examine
/* per-dbms configuration files. This is limited to the content
/* of global and local, built-in and per-service, parameters.
+/*
+/* Arguments:
+/* .IP mode
+/* Passed on to pcf_register_dbms_parameters().
/* DIAGNOSTICS
/* Problems are reported to the standard error stream.
/* LICENSE
@@ -224,7 +228,7 @@ static const char *pcf_lookup_eval(const char *dict_name, const char *name)
/* pcf_scan_user_parameter_namespace - scan parameters in name space */
-static void pcf_scan_user_parameter_namespace(const char *dict_name,
+static void pcf_scan_user_parameter_namespace(int mode, const char *dict_name,
PCF_MASTER_ENT *local_scope)
{
const char *myname = "pcf_scan_user_parameter_namespace";
@@ -308,7 +312,7 @@ static void pcf_scan_user_parameter_namespace(const char *dict_name,
*/
if (node != 0
&& (PCF_BUILTIN_PARAMETER(node) || PCF_SERVICE_PARAMETER(node)))
- pcf_register_dbms_parameters(cparam_value, pcf_flag_user_parameter,
+ pcf_register_dbms_parameters(mode, cparam_value, pcf_flag_user_parameter,
local_scope);
#endif
}
@@ -345,7 +349,7 @@ static void pcf_scan_default_parameter_values(HTABLE *valid_params,
/* pcf_register_user_parameters - add parameters with user-defined names */
-void pcf_register_user_parameters(void)
+void pcf_register_user_parameters(int mode)
{
const char *myname = "pcf_register_user_parameters";
PCF_MASTER_ENT *masterp;
@@ -403,7 +407,7 @@ void pcf_register_user_parameters(void)
*/
for (masterp = pcf_master_table; masterp->argv != 0; masterp++)
if (masterp->all_params != 0)
- pcf_scan_user_parameter_namespace(masterp->name_space, masterp);
+ pcf_scan_user_parameter_namespace(mode, masterp->name_space, masterp);
/*
* Scan parameter values that are left at their defaults in the global
@@ -418,5 +422,5 @@ void pcf_register_user_parameters(void)
/*
* Scan the explicit name=value entries in the global name space.
*/
- pcf_scan_user_parameter_namespace(CONFIG_DICT, (PCF_MASTER_ENT *) 0);
+ pcf_scan_user_parameter_namespace(mode, CONFIG_DICT, (PCF_MASTER_ENT *) 0);
}
diff --git a/src/postconf/test29.ref b/src/postconf/test29.ref
index 646890a..c3bbaec 100644
--- a/src/postconf/test29.ref
+++ b/src/postconf/test29.ref
@@ -2,15 +2,18 @@ config_directory = .
./postconf: warning: ./main.cf: unused parameter: pgsqlfoo_domain=bar
./postconf: warning: ./main.cf: unused parameter: sqlitefoo_domain=bar
./postconf: warning: ./main.cf: unused parameter: ldapxx=proxy:ldap:ldapfoo
+./postconf: warning: ./main.cf: unused parameter: mongodbfoo_domain=bar
./postconf: warning: ./main.cf: unused parameter: sqlitexx=proxy:sqlite:sqlitefoo
./postconf: warning: ./main.cf: unused parameter: mysqlfoo_domain=bar
./postconf: warning: ./main.cf: unused parameter: sqlitefoo_domainx=bar
./postconf: warning: ./main.cf: unused parameter: memcachefoo_domain=bar
./postconf: warning: ./main.cf: unused parameter: pgsqlfoo_domainx=bar
+./postconf: warning: ./main.cf: unused parameter: mongodbfoo_domainx=bar
./postconf: warning: ./main.cf: unused parameter: ldapfoo_domainx=bar
./postconf: warning: ./main.cf: unused parameter: ldapfoo_domain=bar
./postconf: warning: ./main.cf: unused parameter: memcachexx=proxy:memcache:memcachefoo
./postconf: warning: ./main.cf: unused parameter: memcachefoo_domainx=bar
./postconf: warning: ./main.cf: unused parameter: mysqlfoo_domainx=bar
./postconf: warning: ./main.cf: unused parameter: mysqlxx=proxy:mysql:mysqlfoo
+./postconf: warning: ./main.cf: unused parameter: mongodbxx=proxy:mongodb:mongodbfoo
./postconf: warning: ./main.cf: unused parameter: pgsqlxx=proxy:pgsql:pgsqlfoo
diff --git a/src/postconf/test72.ref b/src/postconf/test72.ref
new file mode 100644
index 0000000..6b13cdc
--- /dev/null
+++ b/src/postconf/test72.ref
@@ -0,0 +1,3 @@
+smtp unix - n n - 0 other
+smtp fifo - n n - 0 other
+smtp inet - n n - 0 other
diff --git a/src/postconf/test73.ref b/src/postconf/test73.ref
new file mode 100644
index 0000000..9554cc0
--- /dev/null
+++ b/src/postconf/test73.ref
@@ -0,0 +1,3 @@
+smtp unix - n n - 0 otherx
+smtp fifo - n n - 0 other
+smtp inet - n n - 0 other
diff --git a/src/postconf/test74.ref b/src/postconf/test74.ref
new file mode 100644
index 0000000..2886334
--- /dev/null
+++ b/src/postconf/test74.ref
@@ -0,0 +1,3 @@
+smtp unix - n n - 0 other
+lmtp unix - n n - 0 otherx
+smtp inet - n n - 0 other
diff --git a/src/postconf/test75.ref b/src/postconf/test75.ref
new file mode 100644
index 0000000..b8c54ab
--- /dev/null
+++ b/src/postconf/test75.ref
@@ -0,0 +1,3 @@
+./postconf: warning: ignoring earlier request: 'mail_version = x'
+config_directory = .
+mail_version = y
diff --git a/src/postconf/test76.ref b/src/postconf/test76.ref
new file mode 100644
index 0000000..3e4cd26
--- /dev/null
+++ b/src/postconf/test76.ref
@@ -0,0 +1,9 @@
+config_directory = .
+disable_dns_lookups = no
+lmtp_use_tls = no
+smtpd_tls_dh1024_param_file = auto
+./postconf: warning: ./main.cf: support for parameter "disable_dns_lookups" will be removed; instead, specify "smtp_dns_support_level"
+./postconf: warning: ./main.cf: support for parameter "lmtp_use_tls" will be removed; instead, specify "lmtp_tls_security_level"
+./postconf: warning: ./main.cf: support for parameter "smtpd_tls_dh1024_param_file" will be removed; instead, do not specify (leave at default)
+./postconf: warning: ./main.cf: support for parameter deleted-test-only has been removed; instead, do not specify
+./postconf: warning: ./master.cf: support for parameter "smtp_enforce_tls" will be removed; instead, specify "smtp_tls_security_level"