[asterisk-commits] oej: trunk r278875 - /trunk/res/res_config_ldap.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 23 08:37:20 CDT 2010


Author: oej
Date: Fri Jul 23 08:37:17 2010
New Revision: 278875

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=278875
Log:
Minor corrections to the LDAP realtime driver

Review: https://reviewboard.asterisk.org/r/798/

Thanks Mark for a quick review!

Modified:
    trunk/res/res_config_ldap.c

Modified: trunk/res/res_config_ldap.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_config_ldap.c?view=diff&rev=278875&r1=278874&r2=278875
==============================================================================
--- trunk/res/res_config_ldap.c (original)
+++ trunk/res/res_config_ldap.c Fri Jul 23 08:37:17 2010
@@ -67,7 +67,7 @@
 static char user[512];
 static char pass[50];
 static char base_distinguished_name[512];
-static int version = 3;
+static int version;
 static time_t connect_time;
 
 static int parse_config(void);
@@ -571,7 +571,7 @@
 			result = ldap_search_ext_s(ldapConn, dn, LDAP_SCOPE_BASE,
 					   "(objectclass=*)", NULL, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &ldap_result_msg);
 			if (result != LDAP_SUCCESS && is_ldap_connect_error(result)) {
-				ast_log(LOG_WARNING, "Failed to query database. Try %d/3\n", tries + 1);
+				ast_log(LOG_WARNING, "Failed to query directory. Try %d/3\n", tries + 1);
 				tries++;
 				if (tries < 3) {
 					usleep(500000L * tries);
@@ -587,7 +587,7 @@
 		} while (result != LDAP_SUCCESS && tries < 3 && is_ldap_connect_error(result));
 
 		if (result != LDAP_SUCCESS) {
-			ast_log(LOG_WARNING, "Failed to query database. Error: %s.\n", ldap_err2string(result));
+			ast_log(LOG_WARNING, "Failed to query directory. Error: %s.\n", ldap_err2string(result));
 			ast_debug(2, "dn=%s\n", dn);
 			ast_mutex_unlock(&ldap_lock);
 			return NULL;
@@ -807,7 +807,7 @@
 				  LDAP_SCOPE_SUBTREE, ast_str_buffer(filter), NULL, 0, NULL, NULL, NULL, LDAP_NO_LIMIT,
 				  &ldap_result_msg);
 		if (result != LDAP_SUCCESS && is_ldap_connect_error(result)) {
-			ast_log(LOG_DEBUG, "Failed to query database. Try %d/10\n", tries + 1);
+			ast_log(LOG_DEBUG, "Failed to query directory. Try %d/10\n", tries + 1);
 			if (++tries < 10) {
 				usleep(1);
 				if (ldapConn) {
@@ -822,7 +822,7 @@
 	} while (result != LDAP_SUCCESS && tries < 10 && is_ldap_connect_error(result));
 
 	if (result != LDAP_SUCCESS) {
-		ast_log(LOG_WARNING, "Failed to query database. Error: %s.\n", ldap_err2string(result));
+		ast_log(LOG_WARNING, "Failed to query directory. Error: %s.\n", ldap_err2string(result));
 		ast_log(LOG_WARNING, "Query: %s\n", ast_str_buffer(filter));
 	} else {
 		/* this is where we create the variables from the search result 
@@ -1049,7 +1049,7 @@
 	vars = realtime_ldap_base(&vars_count, basedn, table_name, "filename", file, "commented", "FALSE", NULL);
 
 	if (!vars) {
-		ast_log(LOG_WARNING, "Could not find config '%s' in database.\n", file);
+		ast_log(LOG_WARNING, "Could not find config '%s' in directory.\n", file);
 		return NULL;
 	}
 
@@ -1267,7 +1267,7 @@
 				  LDAP_SCOPE_SUBTREE, ast_str_buffer(filter), NULL, 0, NULL, NULL, NULL, LDAP_NO_LIMIT,
 				  &ldap_result_msg);
 		if (result != LDAP_SUCCESS && is_ldap_connect_error(result)) {
-			ast_log(LOG_WARNING, "Failed to query database. Try %d/3\n", tries + 1);
+			ast_log(LOG_WARNING, "Failed to query directory. Try %d/3\n", tries + 1);
 			tries++;
 			if (tries < 3) {
 				usleep(500000L * tries);
@@ -1452,7 +1452,7 @@
 				  LDAP_SCOPE_SUBTREE, ast_str_buffer(filter), NULL, 0, NULL, NULL, NULL, LDAP_NO_LIMIT,
 				  &ldap_result_msg);
 		if (result != LDAP_SUCCESS && is_ldap_connect_error(result)) {
-			ast_log(LOG_WARNING, "Failed to query database. Try %d/3\n", tries + 1);
+			ast_log(LOG_WARNING, "Failed to query directory. Try %d/3\n", tries + 1);
 			tries++;
 			if (tries < 3) {
 				usleep(500000L * tries);
@@ -1597,6 +1597,13 @@
 	int port;
 	char *category_name = NULL;
 
+	/* Make sure that global variables are reset */
+	url[0] = '\0';
+	user[0] = '\0';
+	pass[0] = '\0';
+	base_distinguished_name[0] = '\0';
+	version = 3;
+
 	config = ast_config_load(RES_CONFIG_LDAP_CONF, config_flags);
 	if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEINVALID) {
 		ast_log(LOG_ERROR, "Cannot load configuration file: %s\n", RES_CONFIG_LDAP_CONF);
@@ -1643,7 +1650,6 @@
 
 	if (!(s = ast_variable_retrieve(config, "_general", "version")) && !(s = ast_variable_retrieve(config, "_general", "protocol"))) {
 		ast_log(LOG_NOTICE, "No explicit LDAP version found, using 3 as default.\n");
-		version = 3;
 	} else if (sscanf(s, "%30d", &version) != 1 || version < 1 || version > 6) {
 		ast_log(LOG_WARNING, "Invalid LDAP version '%s', using 3 as default.\n", s);
 		version = 3;
@@ -1694,7 +1700,7 @@
 	}
 
 	if (ast_strlen_zero(url)) {
-		ast_log(LOG_ERROR, "Not enough parameters to connect to ldap database\n");
+		ast_log(LOG_ERROR, "Not enough parameters to connect to ldap directory\n");
 		return 0;
 	}
 
@@ -1719,7 +1725,7 @@
 		bind_result = ldap_sasl_bind_s(ldapConn, NULL, LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL);
 	}
 	if (bind_result == LDAP_SUCCESS) {
-		ast_debug(2, "Successfully connected to database.\n");
+		ast_debug(2, "Successfully connected to directory.\n");
 		connect_time = time(NULL);
 		return 1;
 	} else {




More information about the asterisk-commits mailing list