summaryrefslogtreecommitdiffstats
path: root/src/postconf/postconf_dbms.c
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/postconf_dbms.c
parentAdding upstream version 3.8.6. (diff)
downloadpostfix-3e160e27e4686620d16477a9ea9cf00141e52ce7.tar.xz
postfix-3e160e27e4686620d16477a9ea9cf00141e52ce7.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/postconf_dbms.c')
-rw-r--r--src/postconf/postconf_dbms.c49
1 files changed, 33 insertions, 16 deletions
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