[asterisk-commits] oej: branch oej/pinedirectory-trunk r231188 - /team/oej/pinedirectory-trunk/res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Nov 25 07:06:16 CST 2009
Author: oej
Date: Wed Nov 25 07:06:12 2009
New Revision: 231188
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=231188
Log:
- Make sure that global variables are reset properly everytime we load configuration file
- change "database" to "directory" in log messages
Modified:
team/oej/pinedirectory-trunk/res/res_config_ldap.c
Modified: team/oej/pinedirectory-trunk/res/res_config_ldap.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedirectory-trunk/res/res_config_ldap.c?view=diff&rev=231188&r1=231187&r2=231188
==============================================================================
--- team/oej/pinedirectory-trunk/res/res_config_ldap.c (original)
+++ team/oej/pinedirectory-trunk/res/res_config_ldap.c Wed Nov 25 07:06:12 2009
@@ -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);
@@ -569,7 +569,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);
@@ -585,7 +585,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;
@@ -805,7 +805,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) {
@@ -820,7 +820,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
@@ -1047,7 +1047,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