summaryrefslogtreecommitdiff
path: root/res/res_config_ldap.c
diff options
context:
space:
mode:
authorSean Bright <sean.bright@gmail.com>2017-02-20 06:30:31 -0500
committerSean Bright <sean.bright@gmail.com>2017-02-20 07:05:41 -0500
commitdd3efdf52585cde5f0c6035268d16b9ba010ad5e (patch)
treef71d61f0942a7f779b9fc9da3d930dc20e434a07 /res/res_config_ldap.c
parentd6d86f1c09f041ef00c1d106d924cf918172974a (diff)
res_config_ldap: Fix configuration inheritance from _general
The "_general" configuration section allows administrators to provide both general configuration options (host, port, url, etc.) as well as a global realtime-to-LDAP-attribute mapping that is a fallback if one of the later sections do not override it. This neglected to exclude the general configuration options from the mapping. As an example, during my testing, chan_sip requested 'port' from realtime, and because I did not have it defined, it pulled in the 'port' configuration option from "_general." We now filter those out explicitly. Change-Id: I1fc61560bf96b8ba623063cfb7e0a49c4690d778
Diffstat (limited to 'res/res_config_ldap.c')
-rw-r--r--res/res_config_ldap.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c
index a8a8fe696..9ad43295d 100644
--- a/res/res_config_ldap.c
+++ b/res/res_config_ldap.c
@@ -1684,6 +1684,21 @@ static int reload(void)
return 0;
}
+static int config_can_be_inherited(const char *key)
+{
+ int i;
+ static const char * const config[] = {
+ "basedn", "host", "pass", "port", "protocol", "url", "user", "version", NULL
+ };
+
+ for (i = 0; config[i]; i++) {
+ if (!strcasecmp(key, config[i])) {
+ return 0;
+ }
+ }
+ return 1;
+}
+
/*! \brief parse the configuration file
*/
static int parse_config(void)
@@ -1774,7 +1789,9 @@ static int parse_config(void)
if (!strcasecmp(var->name, "additionalFilter")) {
table_config->additional_filter = ast_strdup(var->value);
} else {
- ldap_table_config_add_attribute(table_config, var->name, var->value);
+ if (!is_general || config_can_be_inherited(var->name)) {
+ ldap_table_config_add_attribute(table_config, var->name, var->value);
+ }
}
}
}