[Asterisk-code-review] res config ldap: Fix configuration inheritance from general (asterisk[master])

Sean Bright asteriskteam at digium.com
Mon Feb 20 05:58:19 CST 2017


Sean Bright has uploaded a new change for review. ( https://gerrit.asterisk.org/5012 )

Change subject: res_config_ldap: Fix configuration inheritance from _general
......................................................................

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
---
M res/res_config_ldap.c
1 file changed, 18 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/12/5012/1

diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c
index 5e95853..4ff190e 100644
--- a/res/res_config_ldap.c
+++ b/res/res_config_ldap.c
@@ -1681,6 +1681,21 @@
 	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)
@@ -1771,7 +1786,9 @@
 				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);
+					}
 				}
 			}
 		}

-- 
To view, visit https://gerrit.asterisk.org/5012
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1fc61560bf96b8ba623063cfb7e0a49c4690d778
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>



More information about the asterisk-code-review mailing list