mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-31 15:44:21 +00:00
run indent on the whole tree and update copyright dates in prep for 1.0.5
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16579 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
7b347417e5
commit
886e1ddb4d
229 files changed
+20252
-20192
No files matched your search
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
static struct {
|
||||
char *cred;
|
||||
char *urls[MAX_URLS+1];
|
||||
char *urls[MAX_URLS + 1];
|
||||
int url_count;
|
||||
int url_index;
|
||||
switch_thread_rwlock_t *log_path_lock;
|
||||
@@ -110,27 +110,23 @@ static switch_status_t set_xml_cdr_log_dirs()
|
||||
switch_safe_free(globals.log_dir);
|
||||
globals.log_dir = path;
|
||||
switch_thread_rwlock_unlock(globals.log_path_lock);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new mod_xml_cdr log_dir path\n");
|
||||
switch_safe_free(path);
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to generate new mod_xml_cdr log_dir path\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Setting log file path to %s\n", globals.base_log_dir);
|
||||
if ((path = switch_safe_strdup(globals.base_log_dir))) {
|
||||
switch_thread_rwlock_wrlock(globals.log_path_lock);
|
||||
switch_safe_free(globals.log_dir);
|
||||
globals.log_dir = path;
|
||||
switch_thread_rwlock_unlock(globals.log_path_lock);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set log_dir path\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
@@ -152,27 +148,23 @@ static switch_status_t set_xml_cdr_log_dirs()
|
||||
switch_safe_free(globals.err_log_dir);
|
||||
globals.err_log_dir = path;
|
||||
switch_thread_rwlock_unlock(globals.log_path_lock);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new mod_xml_cdr err_log_dir path\n");
|
||||
switch_safe_free(path);
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to generate new mod_xml_cdr err_log_dir path\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Setting err log file path to %s\n", globals.base_err_log_dir);
|
||||
if ((path = switch_safe_strdup(globals.base_err_log_dir))) {
|
||||
switch_thread_rwlock_wrlock(globals.log_path_lock);
|
||||
switch_safe_free(globals.err_log_dir);
|
||||
globals.err_log_dir = path;
|
||||
switch_thread_rwlock_unlock(globals.log_path_lock);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set err_log_dir path\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
@@ -199,7 +191,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
int is_b;
|
||||
const char * a_prefix = "";
|
||||
const char *a_prefix = "";
|
||||
|
||||
if (globals.shutdown) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -209,7 +201,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
|
||||
if (!globals.log_b && is_b) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
if (!is_b && globals.prefix_a) a_prefix = "a_";
|
||||
if (!is_b && globals.prefix_a)
|
||||
a_prefix = "a_";
|
||||
|
||||
if (switch_ivr_generate_xml_cdr(session, &cdr) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Generating Data!\n");
|
||||
@@ -236,7 +229,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
|
||||
#ifdef _MSC_VER
|
||||
if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
|
||||
#else
|
||||
if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR| S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) > -1) {
|
||||
if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) > -1) {
|
||||
#endif
|
||||
int wrote;
|
||||
wrote = write(fd, xml_text, (unsigned) strlen(xml_text));
|
||||
@@ -253,14 +246,13 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
|
||||
}
|
||||
switch_safe_free(path);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch_thread_rwlock_unlock(globals.log_path_lock);
|
||||
}
|
||||
|
||||
/* try to post it to the web server */
|
||||
if (globals.url_count) {
|
||||
char* destUrl = NULL;
|
||||
char *destUrl = NULL;
|
||||
curl_handle = curl_easy_init();
|
||||
|
||||
if (globals.encode == ENCODING_TEXTXML) {
|
||||
@@ -306,19 +298,19 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
|
||||
slist = curl_slist_append(slist, "Expect:");
|
||||
curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, slist);
|
||||
}
|
||||
|
||||
|
||||
if (globals.ssl_cert_file) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSLCERT, globals.ssl_cert_file);
|
||||
}
|
||||
|
||||
|
||||
if (globals.ssl_key_file) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSLKEY, globals.ssl_key_file);
|
||||
}
|
||||
|
||||
|
||||
if (globals.ssl_key_password) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSLKEYPASSWD, globals.ssl_key_password);
|
||||
}
|
||||
|
||||
|
||||
if (globals.ssl_version) {
|
||||
if (!strcasecmp(globals.ssl_version, "SSLv3")) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, CURL_SSLVERSION_SSLv3);
|
||||
@@ -326,7 +318,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (globals.ssl_cacert_file) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_CAINFO, globals.ssl_cacert_file);
|
||||
}
|
||||
@@ -340,7 +332,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
|
||||
if (cur_try > 0) {
|
||||
switch_yield(globals.delay * 1000000);
|
||||
}
|
||||
|
||||
|
||||
destUrl = switch_mprintf("%s?uuid=%s", globals.urls[globals.url_index], switch_core_session_get_uuid(session));
|
||||
curl_easy_setopt(curl_handle, CURLOPT_URL, destUrl);
|
||||
|
||||
@@ -348,11 +340,11 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
}
|
||||
|
||||
|
||||
if (globals.enable_cacert_check) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, TRUE);
|
||||
}
|
||||
|
||||
|
||||
if (globals.enable_ssl_verifyhost) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 2);
|
||||
}
|
||||
@@ -363,7 +355,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
|
||||
if (httpRes == 200) {
|
||||
goto success;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Got error [%ld] posting to web server [%s]\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Got error [%ld] posting to web server [%s]\n",
|
||||
httpRes, globals.urls[globals.url_index]);
|
||||
globals.url_index++;
|
||||
switch_assert(globals.url_count <= MAX_URLS);
|
||||
@@ -449,11 +441,11 @@ static switch_state_handler_table_t state_handlers = {
|
||||
/*.on_hangup */ NULL,
|
||||
/*.on_exchange_media */ NULL,
|
||||
/*.on_soft_execute */ NULL,
|
||||
/*.on_consume_media*/ NULL,
|
||||
/*.on_hibernate*/ NULL,
|
||||
/*.on_reset*/ NULL,
|
||||
/*.on_park*/ NULL,
|
||||
/*.on_reporting*/ my_on_reporting
|
||||
/*.on_consume_media */ NULL,
|
||||
/*.on_hibernate */ NULL,
|
||||
/*.on_reset */ NULL,
|
||||
/*.on_park */ NULL,
|
||||
/*.on_reporting */ my_on_reporting
|
||||
};
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load)
|
||||
@@ -477,7 +469,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load)
|
||||
globals.disable100continue = 0;
|
||||
globals.pool = pool;
|
||||
globals.auth_scheme = CURLAUTH_BASIC;
|
||||
|
||||
|
||||
switch_thread_rwlock_create(&globals.log_path_lock, pool);
|
||||
|
||||
/* parse the config */
|
||||
@@ -558,7 +550,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load)
|
||||
globals.auth_scheme = 0;
|
||||
val++;
|
||||
}
|
||||
|
||||
|
||||
if (!strcasecmp(val, "basic")) {
|
||||
globals.auth_scheme |= CURLAUTH_BASIC;
|
||||
} else if (!strcasecmp(val, "digest")) {
|
||||
@@ -603,7 +595,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_cdr_shutdown)
|
||||
{
|
||||
|
||||
globals.shutdown = 1;
|
||||
|
||||
|
||||
switch_core_remove_state_handler(&state_handlers);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -74,14 +74,14 @@ struct config_data {
|
||||
};
|
||||
|
||||
typedef struct hash_node {
|
||||
switch_hash_t* hash;
|
||||
struct hash_node* next;
|
||||
switch_hash_t *hash;
|
||||
struct hash_node *next;
|
||||
} hash_node_t;
|
||||
|
||||
static struct {
|
||||
switch_memory_pool_t* pool;
|
||||
hash_node_t* hash_root;
|
||||
hash_node_t* hash_tail;
|
||||
switch_memory_pool_t *pool;
|
||||
hash_node_t *hash_root;
|
||||
hash_node_t *hash_tail;
|
||||
} globals;
|
||||
|
||||
#define XML_CURL_SYNTAX "[debug_on|debug_off]"
|
||||
@@ -120,7 +120,7 @@ static size_t file_callback(void *ptr, size_t size, size_t nmemb, void *data)
|
||||
config_data->bytes += realsize;
|
||||
|
||||
if (config_data->bytes > config_data->max_bytes) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int)config_data->bytes);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int) config_data->bytes);
|
||||
config_data->err = 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -154,7 +154,7 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
|
||||
char basic_data[512];
|
||||
char *uri = NULL;
|
||||
char *dynamic_url = NULL;
|
||||
|
||||
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
|
||||
if (!binding) {
|
||||
@@ -170,7 +170,7 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
|
||||
switch_snprintf(basic_data, sizeof(basic_data), "hostname=%s§ion=%s&tag_name=%s&key_name=%s&key_value=%s",
|
||||
hostname, section, switch_str_nil(tag_name), switch_str_nil(key_name), switch_str_nil(key_value));
|
||||
|
||||
@@ -198,7 +198,7 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
|
||||
uri = malloc(strlen(data) + strlen(dynamic_url) + 16);
|
||||
switch_assert(uri);
|
||||
sprintf(uri, "%s%c%s", dynamic_url, strchr(dynamic_url, '?') != NULL ? '&' : '?', data);
|
||||
}
|
||||
}
|
||||
|
||||
switch_uuid_get(&uuid);
|
||||
switch_uuid_format(uuid_str, &uuid);
|
||||
@@ -237,7 +237,7 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
|
||||
|
||||
if (binding->timeout) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, binding->timeout);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
|
||||
}
|
||||
|
||||
if (binding->disable100continue) {
|
||||
@@ -248,19 +248,19 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
|
||||
if (binding->enable_cacert_check) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, TRUE);
|
||||
}
|
||||
|
||||
|
||||
if (binding->ssl_cert_file) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSLCERT, binding->ssl_cert_file);
|
||||
}
|
||||
|
||||
|
||||
if (binding->ssl_key_file) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSLKEY, binding->ssl_key_file);
|
||||
}
|
||||
|
||||
|
||||
if (binding->ssl_key_password) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSLKEYPASSWD, binding->ssl_key_password);
|
||||
}
|
||||
|
||||
|
||||
if (binding->ssl_version) {
|
||||
if (!strcasecmp(binding->ssl_version, "SSLv3")) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, CURL_SSLVERSION_SSLv3);
|
||||
@@ -268,15 +268,15 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (binding->ssl_cacert_file) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_CAINFO, binding->ssl_cacert_file);
|
||||
}
|
||||
|
||||
|
||||
if (binding->enable_ssl_verifyhost) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 2);
|
||||
}
|
||||
|
||||
|
||||
if (binding->cookie_file) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, binding->cookie_file);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, binding->cookie_file);
|
||||
@@ -301,7 +301,8 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing Result!\n");
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received HTTP error %ld trying to fetch %s\ndata: [%s]\n", httpRes, binding->url, data);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received HTTP error %ld trying to fetch %s\ndata: [%s]\n", httpRes, binding->url,
|
||||
data);
|
||||
xml = NULL;
|
||||
}
|
||||
}
|
||||
@@ -359,7 +360,7 @@ static switch_status_t do_config(void)
|
||||
char *ssl_cacert_file = NULL;
|
||||
uint32_t enable_ssl_verifyhost = 0;
|
||||
char *cookie_file = NULL;
|
||||
hash_node_t* hash_node;
|
||||
hash_node_t *hash_node;
|
||||
int auth_scheme = CURLAUTH_BASIC;
|
||||
need_vars_map = 0;
|
||||
vars_map = NULL;
|
||||
@@ -381,7 +382,7 @@ static switch_status_t do_config(void)
|
||||
auth_scheme = 0;
|
||||
val++;
|
||||
}
|
||||
|
||||
|
||||
if (!strcasecmp(val, "basic")) {
|
||||
auth_scheme |= CURLAUTH_BASIC;
|
||||
} else if (!strcasecmp(val, "digest")) {
|
||||
@@ -442,13 +443,13 @@ static switch_status_t do_config(void)
|
||||
if (!url) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Binding has no url!\n");
|
||||
if (vars_map)
|
||||
switch_core_hash_destroy(&vars_map);
|
||||
switch_core_hash_destroy(&vars_map);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(binding = malloc(sizeof(*binding)))) {
|
||||
if (vars_map)
|
||||
switch_core_hash_destroy(&vars_map);
|
||||
switch_core_hash_destroy(&vars_map);
|
||||
goto done;
|
||||
}
|
||||
memset(binding, 0, sizeof(*binding));
|
||||
@@ -472,53 +473,53 @@ static switch_status_t do_config(void)
|
||||
}
|
||||
|
||||
binding->disable100continue = disable100continue;
|
||||
binding->use_get_style = method != NULL && strcasecmp(method,"post") != 0;
|
||||
binding->use_get_style = method != NULL && strcasecmp(method, "post") != 0;
|
||||
binding->use_dynamic_url = use_dynamic_url;
|
||||
binding->enable_cacert_check = enable_cacert_check;
|
||||
|
||||
|
||||
if (ssl_cert_file) {
|
||||
binding->ssl_cert_file = strdup(ssl_cert_file);
|
||||
}
|
||||
|
||||
|
||||
if (ssl_key_file) {
|
||||
binding->ssl_key_file = strdup(ssl_key_file);
|
||||
}
|
||||
|
||||
|
||||
if (ssl_key_password) {
|
||||
binding->ssl_key_password = strdup(ssl_key_password);
|
||||
}
|
||||
|
||||
|
||||
if (ssl_version) {
|
||||
binding->ssl_version = strdup(ssl_version);
|
||||
}
|
||||
|
||||
|
||||
if (ssl_cacert_file) {
|
||||
binding->ssl_cacert_file = strdup(ssl_cacert_file);
|
||||
}
|
||||
|
||||
|
||||
binding->enable_ssl_verifyhost = enable_ssl_verifyhost;
|
||||
|
||||
|
||||
if (cookie_file) {
|
||||
binding->cookie_file = strdup(cookie_file);
|
||||
}
|
||||
|
||||
binding->vars_map = vars_map;
|
||||
|
||||
|
||||
if (vars_map) {
|
||||
switch_zmalloc(hash_node,sizeof(hash_node_t));
|
||||
hash_node->hash = vars_map;
|
||||
hash_node->next = NULL;
|
||||
|
||||
if (!globals.hash_root) {
|
||||
globals.hash_root = hash_node;
|
||||
globals.hash_tail = globals.hash_root;
|
||||
}
|
||||
|
||||
else {
|
||||
globals.hash_tail->next = hash_node;
|
||||
globals.hash_tail = globals.hash_tail->next;
|
||||
}
|
||||
|
||||
switch_zmalloc(hash_node, sizeof(hash_node_t));
|
||||
hash_node->hash = vars_map;
|
||||
hash_node->next = NULL;
|
||||
|
||||
if (!globals.hash_root) {
|
||||
globals.hash_root = hash_node;
|
||||
globals.hash_tail = globals.hash_root;
|
||||
}
|
||||
|
||||
else {
|
||||
globals.hash_tail->next = hash_node;
|
||||
globals.hash_tail = globals.hash_tail->next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding [%s] XML Fetch Function [%s] [%s]\n",
|
||||
@@ -541,7 +542,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_curl_load)
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
memset(&globals,0,sizeof(globals));
|
||||
memset(&globals, 0, sizeof(globals));
|
||||
globals.pool = pool;
|
||||
globals.hash_root = NULL;
|
||||
globals.hash_tail = NULL;
|
||||
@@ -562,15 +563,15 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_curl_load)
|
||||
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_curl_shutdown)
|
||||
{
|
||||
hash_node_t* ptr = NULL;
|
||||
hash_node_t *ptr = NULL;
|
||||
|
||||
while(globals.hash_root) {
|
||||
ptr = globals.hash_root;
|
||||
switch_core_hash_destroy(&ptr->hash);
|
||||
globals.hash_root = ptr->next;
|
||||
switch_safe_free(ptr);
|
||||
while (globals.hash_root) {
|
||||
ptr = globals.hash_root;
|
||||
switch_core_hash_destroy(&ptr->hash);
|
||||
globals.hash_root = ptr->next;
|
||||
switch_safe_free(ptr);
|
||||
}
|
||||
|
||||
|
||||
switch_xml_unbind_search_function_ptr(xml_url_fetch);
|
||||
curl_global_cleanup();
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
@@ -23,36 +23,23 @@
|
||||
* Include file for lutil LDAP routines
|
||||
*/
|
||||
|
||||
LDAP_BEGIN_DECL
|
||||
LDAP_BEGIN_DECL LDAP_LUTIL_F(void)
|
||||
lutil_sasl_freedefs LDAP_P((void *defaults));
|
||||
|
||||
LDAP_LUTIL_F( void )
|
||||
lutil_sasl_freedefs LDAP_P((
|
||||
void *defaults ));
|
||||
LDAP_LUTIL_F(void *)
|
||||
lutil_sasl_defaults LDAP_P((LDAP * ld, char *mech, char *realm, char *authcid, char *passwd, char *authzid));
|
||||
|
||||
LDAP_LUTIL_F( void * )
|
||||
lutil_sasl_defaults LDAP_P((
|
||||
LDAP *ld,
|
||||
char *mech,
|
||||
char *realm,
|
||||
char *authcid,
|
||||
char *passwd,
|
||||
char *authzid ));
|
||||
|
||||
LDAP_LUTIL_F( int )
|
||||
lutil_sasl_interact LDAP_P((
|
||||
LDAP *ld, unsigned flags, void *defaults, void *p ));
|
||||
LDAP_LUTIL_F(int)
|
||||
lutil_sasl_interact LDAP_P((LDAP * ld, unsigned flags, void *defaults, void *p));
|
||||
|
||||
LDAP_END_DECL
|
||||
|
||||
#endif /* _LUTIL_LDAP_H */
|
||||
|
||||
typedef struct lutil_sasl_defaults_s {
|
||||
char *mech;
|
||||
char *realm;
|
||||
char *authcid;
|
||||
char *passwd;
|
||||
char *authzid;
|
||||
char **resps;
|
||||
int nresps;
|
||||
} lutilSASLdefaults;
|
||||
|
||||
typedef struct lutil_sasl_defaults_s {
|
||||
char *mech;
|
||||
char *realm;
|
||||
char *authcid;
|
||||
char *passwd;
|
||||
char *authzid;
|
||||
char **resps;
|
||||
int nresps;
|
||||
} lutilSASLdefaults;
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -111,7 +111,8 @@ SWITCH_STANDARD_API(xml_ldap_function)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t xml_ldap_result(void *ldap_connection, xml_binding_t *binding, switch_xml_t *xml, int *off, const xml_ldap_query_type_t query_type)
|
||||
static switch_status_t xml_ldap_result(void *ldap_connection, xml_binding_t *binding, switch_xml_t *xml, int *off,
|
||||
const xml_ldap_query_type_t query_type)
|
||||
{
|
||||
switch (query_type) {
|
||||
case XML_LDAP_DIRECTORY:
|
||||
@@ -334,7 +335,7 @@ static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, c
|
||||
|
||||
|
||||
|
||||
if ((ldap->ld = (LDAP*)ldap_init(binding->host, LDAP_PORT)) == NULL) {
|
||||
if ((ldap->ld = (LDAP *) ldap_init(binding->host, LDAP_PORT)) == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to connect to ldap server.%s\n", binding->host);
|
||||
goto cleanup;
|
||||
}
|
||||
@@ -343,7 +344,7 @@ static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, c
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ldap_set_option( ldap->ld, LDAP_OPT_X_SASL_SECPROPS, &ldap->sp );
|
||||
ldap_set_option(ldap->ld, LDAP_OPT_X_SASL_SECPROPS, &ldap->sp);
|
||||
|
||||
|
||||
|
||||
@@ -353,8 +354,11 @@ static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, c
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
if (ldap_sasl_interactive_bind_s(ldap->ld, NULL, binding->defaults->mech, NULL, NULL, (unsigned)(intptr_t)LDAP_SASL_SIMPLE, lutil_sasl_interact, binding->defaults ) != LDAP_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to sasl_bind to ldap server %s as %s\n", binding->host, binding->defaults->authcid);
|
||||
if (ldap_sasl_interactive_bind_s
|
||||
(ldap->ld, NULL, binding->defaults->mech, NULL, NULL, (unsigned) (intptr_t) LDAP_SASL_SIMPLE, lutil_sasl_interact,
|
||||
binding->defaults) != LDAP_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to sasl_bind to ldap server %s as %s\n", binding->host,
|
||||
binding->defaults->authcid);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
@@ -459,8 +463,7 @@ static switch_status_t do_config(void)
|
||||
}
|
||||
|
||||
if (!binding->basedn || !binding->filter) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"You must define \"basedn\", and \"filter\" in mod_xml_ldap.conf.xml\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "You must define \"basedn\", and \"filter\" in mod_xml_ldap.conf.xml\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,12 +77,12 @@ SWITCH_MODULE_DEFINITION(mod_xml_ldap, mod_xml_ldap_load, mod_xml_ldap_shutdown,
|
||||
|
||||
|
||||
static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params,
|
||||
void *user_data);
|
||||
void *user_data);
|
||||
|
||||
static switch_status_t trydir(switch_xml_t *, int *, LDAP *, char *, char *, xml_binding_t *);
|
||||
static switch_status_t do_config(void);
|
||||
static switch_status_t trysearch( switch_xml_t *pxml, int *xoff, LDAP *ld, char *basedn, char *filter);
|
||||
void rec( switch_xml_t *, int*, LDAP *ld, char *);
|
||||
static switch_status_t trysearch(switch_xml_t *pxml, int *xoff, LDAP * ld, char *basedn, char *filter);
|
||||
void rec(switch_xml_t *, int *, LDAP * ld, char *);
|
||||
|
||||
#define XML_LDAP_SYNTAX ""
|
||||
|
||||
@@ -115,9 +115,10 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_ldap_shutdown)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t do_config(void) {
|
||||
static switch_status_t do_config(void)
|
||||
{
|
||||
char *cf = "xml_ldap.conf";
|
||||
switch_xml_t cfg, xml, bindings_tag, binding_tag, param,tran;
|
||||
switch_xml_t cfg, xml, bindings_tag, binding_tag, param, tran;
|
||||
xml_binding_t *binding = NULL;
|
||||
xml_ldap_attribute_t *attr_list = NULL;
|
||||
int x = 0;
|
||||
@@ -149,14 +150,14 @@ static switch_status_t do_config(void) {
|
||||
if (!strcasecmp(var, "filter")) {
|
||||
binding->bindings = (char *) switch_xml_attr_soft(param, "bindings");
|
||||
|
||||
if (!strncmp(binding->bindings, "configuration",strlen(binding->bindings))) {
|
||||
if (!strncmp(binding->bindings, "configuration", strlen(binding->bindings))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setting type XML_LDAP_CONFIG\n");
|
||||
binding->bt = XML_LDAP_CONFIG;
|
||||
} else if (!strncmp(binding->bindings, "directory",strlen(binding->bindings))) {
|
||||
} else if (!strncmp(binding->bindings, "directory", strlen(binding->bindings))) {
|
||||
binding->bt = XML_LDAP_DIRECTORY;
|
||||
} else if (!strncmp(binding->bindings, "dialplain",strlen(binding->bindings))) {
|
||||
} else if (!strncmp(binding->bindings, "dialplain", strlen(binding->bindings))) {
|
||||
binding->bt = XML_LDAP_DIALPLAN;
|
||||
} else if (!strncmp(binding->bindings, "phrases",strlen(binding->bindings))) {
|
||||
} else if (!strncmp(binding->bindings, "phrases", strlen(binding->bindings))) {
|
||||
binding->bt = XML_LDAP_PHRASE;
|
||||
}
|
||||
|
||||
@@ -176,72 +177,72 @@ static switch_status_t do_config(void) {
|
||||
|
||||
}
|
||||
|
||||
if ( binding && binding->bt == XML_LDAP_DIRECTORY ) {
|
||||
if (binding && binding->bt == XML_LDAP_DIRECTORY) {
|
||||
attr_list = malloc(sizeof(*attr_list));
|
||||
attr_list = memset(attr_list,0,sizeof(*attr_list));
|
||||
attr_list = memset(attr_list, 0, sizeof(*attr_list));
|
||||
binding->attr_list = attr_list;
|
||||
|
||||
param = switch_xml_child(binding_tag, "trans");
|
||||
for ( tran = switch_xml_child(param, "tran"); tran; tran = tran->next) {
|
||||
for (tran = switch_xml_child(param, "tran"); tran; tran = tran->next) {
|
||||
char *n = (char *) switch_xml_attr_soft(tran, "name");
|
||||
char *m = (char *) switch_xml_attr_soft(tran, "mapfrom");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, " adding map %s => %s\n", m , n);
|
||||
if (!strncasecmp("id",n,strlen(n))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, " adding map %s => %s\n", m, n);
|
||||
if (!strncasecmp("id", n, strlen(n))) {
|
||||
attr_list->type = LDAP_EXTEN_ID;
|
||||
attr_list->len = strlen(m);
|
||||
attr_list->val = strdup(m);
|
||||
attr_list->next = malloc(sizeof(*attr_list));
|
||||
attr_list->next = memset(attr_list->next,0,sizeof(*attr_list));
|
||||
attr_list->next = memset(attr_list->next, 0, sizeof(*attr_list));
|
||||
attr_list = attr_list->next;
|
||||
} else if (!strncasecmp("mailbox", n, strlen(n))) {
|
||||
attr_list->type = LDAP_EXTEN_VM_MAILBOX;
|
||||
attr_list->len = strlen(m);
|
||||
attr_list->val = strdup(m);
|
||||
attr_list->next = malloc(sizeof(*attr_list));
|
||||
attr_list->next = memset(attr_list->next, 0, sizeof(*attr_list));
|
||||
attr_list = attr_list->next;
|
||||
} else if (!strncasecmp("password", n, strlen(n))) {
|
||||
attr_list->type = LDAP_EXTEN_PASSWORD;
|
||||
attr_list->len = strlen(m);
|
||||
attr_list->val = strdup(m);
|
||||
attr_list->next = malloc(sizeof(*attr_list));
|
||||
attr_list->next = memset(attr_list->next, 0, sizeof(*attr_list));
|
||||
attr_list = attr_list->next;
|
||||
} else if (!strncasecmp("vm-password", n, strlen(n))) {
|
||||
attr_list->type = LDAP_EXTEN_VM_PASSWORD;
|
||||
attr_list->len = strlen(m);
|
||||
attr_list->val = strdup(m);
|
||||
attr_list->next = malloc(sizeof(*attr_list));
|
||||
attr_list->next = memset(attr_list->next, 0, sizeof(*attr_list));
|
||||
attr_list = attr_list->next;
|
||||
} else if (!strncasecmp("email-addr", n, strlen(n))) {
|
||||
attr_list->type = LDAP_EXTEN_VM_EMAILADDR;
|
||||
attr_list->len = strlen(m);
|
||||
attr_list->val = strdup(m);
|
||||
attr_list->next = malloc(sizeof(*attr_list));
|
||||
attr_list->next = memset(attr_list->next, 0, sizeof(*attr_list));
|
||||
attr_list = attr_list->next;
|
||||
} else if (!strncasecmp("vm-email-all-messages", n, strlen(n))) {
|
||||
attr_list->type = LDAP_EXTEN_VM_EMAILMSG;
|
||||
attr_list->len = strlen(m);
|
||||
attr_list->val = strdup(m);
|
||||
attr_list->next = malloc(sizeof(*attr_list));
|
||||
attr_list->next = memset(attr_list->next, 0, sizeof(*attr_list));
|
||||
attr_list = attr_list->next;
|
||||
} else if (!strncasecmp("vm-delete-file", n, strlen(n))) {
|
||||
attr_list->type = LDAP_EXTEN_VM_DELETE;
|
||||
attr_list->len = strlen(m);
|
||||
attr_list->val = strdup(m);
|
||||
attr_list->next = malloc(sizeof(*attr_list));
|
||||
attr_list->next = memset(attr_list->next, 0, sizeof(*attr_list));
|
||||
attr_list = attr_list->next;
|
||||
} else if (!strncasecmp("vm-attach-file", n, strlen(n))) {
|
||||
attr_list->type = LDAP_EXTEN_VM_ATTACHAUDIO;
|
||||
attr_list->len = strlen(m);
|
||||
attr_list->val = strdup(m);
|
||||
attr_list->next = malloc(sizeof(*attr_list));
|
||||
attr_list->next = memset(attr_list->next, 0, sizeof(*attr_list));
|
||||
attr_list = attr_list->next;
|
||||
} else if ( !strncasecmp("mailbox",n,strlen(n))) {
|
||||
attr_list->type = LDAP_EXTEN_VM_MAILBOX;
|
||||
attr_list->len = strlen(m);
|
||||
attr_list->val = strdup(m);
|
||||
attr_list->next = malloc(sizeof(*attr_list));
|
||||
attr_list->next = memset(attr_list->next,0,sizeof(*attr_list));
|
||||
attr_list = attr_list->next;
|
||||
} else if ( !strncasecmp("password",n,strlen(n))) {
|
||||
attr_list->type = LDAP_EXTEN_PASSWORD;
|
||||
attr_list->len = strlen(m);
|
||||
attr_list->val = strdup(m);
|
||||
attr_list->next = malloc(sizeof(*attr_list));
|
||||
attr_list->next = memset(attr_list->next,0,sizeof(*attr_list));
|
||||
attr_list = attr_list->next;
|
||||
} else if ( !strncasecmp("vm-password",n,strlen(n))) {
|
||||
attr_list->type = LDAP_EXTEN_VM_PASSWORD;
|
||||
attr_list->len = strlen(m);
|
||||
attr_list->val = strdup(m);
|
||||
attr_list->next = malloc(sizeof(*attr_list));
|
||||
attr_list->next = memset(attr_list->next,0,sizeof(*attr_list));
|
||||
attr_list = attr_list->next;
|
||||
} else if ( !strncasecmp("email-addr",n,strlen(n))) {
|
||||
attr_list->type = LDAP_EXTEN_VM_EMAILADDR;
|
||||
attr_list->len = strlen(m);
|
||||
attr_list->val = strdup(m);
|
||||
attr_list->next = malloc(sizeof(*attr_list));
|
||||
attr_list->next = memset(attr_list->next,0,sizeof(*attr_list));
|
||||
attr_list = attr_list->next;
|
||||
} else if ( !strncasecmp("vm-email-all-messages",n,strlen(n))) {
|
||||
attr_list->type = LDAP_EXTEN_VM_EMAILMSG;
|
||||
attr_list->len = strlen(m);
|
||||
attr_list->val = strdup(m);
|
||||
attr_list->next = malloc(sizeof(*attr_list));
|
||||
attr_list->next = memset(attr_list->next,0,sizeof(*attr_list));
|
||||
attr_list = attr_list->next;
|
||||
} else if ( !strncasecmp("vm-delete-file",n,strlen(n))) {
|
||||
attr_list->type = LDAP_EXTEN_VM_DELETE;
|
||||
attr_list->len = strlen(m);
|
||||
attr_list->val = strdup(m);
|
||||
attr_list->next = malloc(sizeof(*attr_list));
|
||||
attr_list->next = memset(attr_list->next,0,sizeof(*attr_list));
|
||||
attr_list = attr_list->next;
|
||||
} else if ( !strncasecmp("vm-attach-file",n,strlen(n))) {
|
||||
attr_list->type = LDAP_EXTEN_VM_ATTACHAUDIO;
|
||||
attr_list->len = strlen(m);
|
||||
attr_list->val = strdup(m);
|
||||
attr_list->next = malloc(sizeof(*attr_list));
|
||||
attr_list->next = memset(attr_list->next,0,sizeof(*attr_list));
|
||||
attr_list = attr_list->next;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -250,8 +251,7 @@ static switch_status_t do_config(void) {
|
||||
|
||||
|
||||
if (!binding->basedn || !binding->filter || !binding->url) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"You must define \"basedn\", and \"filter\" in mod_xml_ldap.conf.xml\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "You must define \"basedn\", and \"filter\" in mod_xml_ldap.conf.xml\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -271,26 +271,29 @@ static switch_status_t do_config(void) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t trydir(switch_xml_t *pxml, int *xoff, LDAP *ld, char *dir_domain, char *dir_exten, xml_binding_t *binding) {
|
||||
static switch_status_t trydir(switch_xml_t *pxml, int *xoff, LDAP * ld, char *dir_domain, char *dir_exten, xml_binding_t *binding)
|
||||
{
|
||||
switch_status_t ret = SWITCH_STATUS_FALSE;
|
||||
int off = *xoff;
|
||||
char *key = NULL;
|
||||
char *key = NULL;
|
||||
char *basedn = NULL, *filter = NULL;
|
||||
char **val = NULL;
|
||||
BerElement *ber = NULL;
|
||||
switch_xml_t xml = *pxml, params = NULL, vars = NULL, cur = NULL;
|
||||
LDAPMessage *msg, *entry;
|
||||
static char *fsattr[] = { "id" , "mailbox", "password", "vm-password", "email-addr", "vm-email-all-messages", "vm-delete-file", "vm-attach-file", NULL };
|
||||
char **val = NULL;
|
||||
BerElement *ber = NULL;
|
||||
switch_xml_t xml = *pxml, params = NULL, vars = NULL, cur = NULL;
|
||||
LDAPMessage *msg, *entry;
|
||||
static char *fsattr[] =
|
||||
{ "id", "mailbox", "password", "vm-password", "email-addr", "vm-email-all-messages", "vm-delete-file", "vm-attach-file", NULL };
|
||||
|
||||
basedn = switch_mprintf(binding->basedn,dir_domain);
|
||||
filter = switch_mprintf(binding->filter,dir_exten);
|
||||
basedn = switch_mprintf(binding->basedn, dir_domain);
|
||||
filter = switch_mprintf(binding->filter, dir_exten);
|
||||
xml_ldap_attribute_t *attr = NULL;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "searching in basedn %s with filter %s\n",basedn,filter );
|
||||
|
||||
if ( (ldap_search_s(ld, basedn, LDAP_SCOPE_SUB, filter, NULL, 0, &msg) != LDAP_SUCCESS) ) goto cleanup;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "searching in basedn %s with filter %s\n", basedn, filter);
|
||||
|
||||
if ( ldap_count_entries(ld, msg) > 0 ) {
|
||||
if ((ldap_search_s(ld, basedn, LDAP_SCOPE_SUB, filter, NULL, 0, &msg) != LDAP_SUCCESS))
|
||||
goto cleanup;
|
||||
|
||||
if (ldap_count_entries(ld, msg) > 0) {
|
||||
ret = SWITCH_STATUS_SUCCESS;
|
||||
xml = switch_xml_add_child_d(xml, "section", off++);
|
||||
switch_xml_set_attr_d(xml, "name", "directory");
|
||||
@@ -304,31 +307,25 @@ static switch_status_t trydir(switch_xml_t *pxml, int *xoff, LDAP *ld, char *dir
|
||||
params = switch_xml_add_child_d(xml, "params", off++);
|
||||
|
||||
|
||||
for (
|
||||
entry = ldap_first_entry(ld, msg);
|
||||
entry != NULL;
|
||||
entry = ldap_next_entry(ld, entry) ) {
|
||||
for (entry = ldap_first_entry(ld, msg); entry != NULL; entry = ldap_next_entry(ld, entry)) {
|
||||
|
||||
|
||||
for (
|
||||
key = ldap_first_attribute(ld, entry, &ber);
|
||||
key != NULL;
|
||||
key = ldap_next_attribute(ld, entry, ber) ) {
|
||||
for (key = ldap_first_attribute(ld, entry, &ber); key != NULL; key = ldap_next_attribute(ld, entry, ber)) {
|
||||
|
||||
for( attr = binding->attr_list; attr ; attr = attr->next ) {
|
||||
if ( strlen(key) == attr->len ) {
|
||||
if ( !strncasecmp(attr->val,key,strlen(key)) ) {
|
||||
val = ldap_get_values(ld,entry,key);
|
||||
if ( ldap_count_values(val) == 1 ) {
|
||||
for (attr = binding->attr_list; attr; attr = attr->next) {
|
||||
if (strlen(key) == attr->len) {
|
||||
if (!strncasecmp(attr->val, key, strlen(key))) {
|
||||
val = ldap_get_values(ld, entry, key);
|
||||
if (ldap_count_values(val) == 1) {
|
||||
if (attr->type < 2) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "setting %s = %s ", fsattr[attr->type], val[0]);
|
||||
switch_xml_set_attr_d(xml,fsattr[attr->type],val[0]);
|
||||
} else if ( attr->type < 8 ) {
|
||||
cur = switch_xml_add_child_d(params,"param",0);
|
||||
switch_xml_set_attr_d(cur,fsattr[attr->type],val[0]);
|
||||
switch_xml_set_attr_d(xml, fsattr[attr->type], val[0]);
|
||||
} else if (attr->type < 8) {
|
||||
cur = switch_xml_add_child_d(params, "param", 0);
|
||||
switch_xml_set_attr_d(cur, fsattr[attr->type], val[0]);
|
||||
} else {
|
||||
cur = switch_xml_add_child_d(vars,"variable",0);
|
||||
switch_xml_set_attr_d(cur,fsattr[attr->type],val[0]);
|
||||
cur = switch_xml_add_child_d(vars, "variable", 0);
|
||||
switch_xml_set_attr_d(cur, fsattr[attr->type], val[0]);
|
||||
}
|
||||
} else {
|
||||
/* multi val attrs */
|
||||
@@ -339,29 +336,30 @@ static switch_status_t trydir(switch_xml_t *pxml, int *xoff, LDAP *ld, char *dir
|
||||
}
|
||||
}
|
||||
ldap_memfree(key);
|
||||
}
|
||||
ber_free(ber,0);
|
||||
}
|
||||
}
|
||||
ber_free(ber, 0);
|
||||
}
|
||||
|
||||
ldap_msgfree(entry);
|
||||
ldap_msgfree(msg);
|
||||
} else {
|
||||
ret = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
ldap_msgfree(entry);
|
||||
ldap_msgfree(msg);
|
||||
} else {
|
||||
ret = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
switch_safe_free(filter);
|
||||
cleanup:
|
||||
switch_safe_free(filter);
|
||||
switch_safe_free(basedn)
|
||||
switch_safe_free(dir_exten);
|
||||
switch_safe_free(dir_exten);
|
||||
switch_safe_free(dir_domain);
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static switch_status_t trysearch ( switch_xml_t *pxml, int *xoff, LDAP *ld, char *basedn, char *filter) {
|
||||
|
||||
static switch_status_t trysearch(switch_xml_t *pxml, int *xoff, LDAP * ld, char *basedn, char *filter)
|
||||
{
|
||||
switch_status_t ret;
|
||||
int off = *xoff;
|
||||
char *key = NULL;
|
||||
@@ -373,43 +371,38 @@ static switch_status_t trysearch ( switch_xml_t *pxml, int *xoff, LDAP *ld, char
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "trying search in base %s with filter %s\n", basedn, filter);
|
||||
|
||||
if ( (ldap_search_s(ld, basedn, LDAP_SCOPE_ONE, filter, NULL, 0, &msg) != LDAP_SUCCESS) ) goto cleanup;
|
||||
if ((ldap_search_s(ld, basedn, LDAP_SCOPE_ONE, filter, NULL, 0, &msg) != LDAP_SUCCESS))
|
||||
goto cleanup;
|
||||
|
||||
|
||||
if ( ldap_count_entries(ld, msg) > 0 ) {
|
||||
if (ldap_count_entries(ld, msg) > 0) {
|
||||
ret = SWITCH_STATUS_SUCCESS;
|
||||
for (
|
||||
entry = ldap_first_entry(ld, msg);
|
||||
entry != NULL;
|
||||
entry = ldap_next_entry(ld, entry) ) {
|
||||
for (entry = ldap_first_entry(ld, msg); entry != NULL; entry = ldap_next_entry(ld, entry)) {
|
||||
|
||||
val = ldap_get_values(ld,entry,"fstag" );
|
||||
val = ldap_get_values(ld, entry, "fstag");
|
||||
xml = switch_xml_add_child_d(xml, val[0], off);
|
||||
ldap_value_free(val);
|
||||
|
||||
for (
|
||||
key = ldap_first_attribute(ld, entry, &ber);
|
||||
key != NULL;
|
||||
key = ldap_next_attribute(ld, entry, ber) ) {
|
||||
for (key = ldap_first_attribute(ld, entry, &ber); key != NULL; key = ldap_next_attribute(ld, entry, ber)) {
|
||||
|
||||
if ( !strncasecmp(key,"fstag",strlen(key)) || !strncasecmp(key,"objectclass",strlen(key)) ) {
|
||||
if (!strncasecmp(key, "fstag", strlen(key)) || !strncasecmp(key, "objectclass", strlen(key))) {
|
||||
ldap_memfree(key);
|
||||
continue;
|
||||
}
|
||||
|
||||
val = ldap_get_values(ld,entry,key);
|
||||
val = ldap_get_values(ld, entry, key);
|
||||
switch_xml_set_attr_d(xml, key, val[0]);
|
||||
|
||||
ldap_memfree(key);
|
||||
ldap_value_free(val);
|
||||
|
||||
}
|
||||
ber_free(ber,0);
|
||||
ber_free(ber, 0);
|
||||
|
||||
dn = ldap_get_dn(ld,entry);
|
||||
rec(&xml,&off,ld,dn);
|
||||
dn = ldap_get_dn(ld, entry);
|
||||
rec(&xml, &off, ld, dn);
|
||||
|
||||
*xoff=1;
|
||||
*xoff = 1;
|
||||
}
|
||||
|
||||
ldap_msgfree(entry);
|
||||
@@ -418,19 +411,20 @@ static switch_status_t trysearch ( switch_xml_t *pxml, int *xoff, LDAP *ld, char
|
||||
ret = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
switch_safe_free(basedn);
|
||||
switch_safe_free(filter);
|
||||
switch_safe_free(key);
|
||||
|
||||
return ret;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void rec( switch_xml_t *pxml, int *xoff, LDAP *ld, char *dn) {
|
||||
void rec(switch_xml_t *pxml, int *xoff, LDAP * ld, char *dn)
|
||||
{
|
||||
int off = *xoff;
|
||||
char *key;
|
||||
char **val;
|
||||
@@ -443,34 +437,28 @@ void rec( switch_xml_t *pxml, int *xoff, LDAP *ld, char *dn) {
|
||||
ldap_search_s(ld, dn, LDAP_SCOPE_ONE, NULL, NULL, 0, &msg);
|
||||
switch_safe_free(dn);
|
||||
|
||||
if ( ldap_count_entries(ld, msg) > 0 ) {
|
||||
if (ldap_count_entries(ld, msg) > 0) {
|
||||
|
||||
for (
|
||||
entry = ldap_first_entry(ld, msg);
|
||||
entry != NULL;
|
||||
entry = ldap_next_entry(ld, entry) ) {
|
||||
for (entry = ldap_first_entry(ld, msg); entry != NULL; entry = ldap_next_entry(ld, entry)) {
|
||||
|
||||
val = ldap_get_values(ld,entry,"fstag" );
|
||||
new = switch_xml_add_child_d(xml, val[0], off);
|
||||
val = ldap_get_values(ld, entry, "fstag");
|
||||
new = switch_xml_add_child_d(xml, val[0], off);
|
||||
ldap_value_free(val);
|
||||
|
||||
for (
|
||||
key = ldap_first_attribute(ld, entry,&ber);
|
||||
key != NULL;
|
||||
key = ldap_next_attribute(ld,entry,ber) ) {
|
||||
for (key = ldap_first_attribute(ld, entry, &ber); key != NULL; key = ldap_next_attribute(ld, entry, ber)) {
|
||||
|
||||
if ( !strncasecmp("fstag",key,5) || !strncasecmp("objectclass",key,10) ) {
|
||||
if (!strncasecmp("fstag", key, 5) || !strncasecmp("objectclass", key, 10)) {
|
||||
ldap_memfree(key);
|
||||
continue;
|
||||
}
|
||||
|
||||
val = ldap_get_values(ld,entry,key);
|
||||
switch_xml_set_attr_d(new, key, val[0]);
|
||||
val = ldap_get_values(ld, entry, key);
|
||||
switch_xml_set_attr_d(new, key, val[0]);
|
||||
ldap_memfree(key);
|
||||
ldap_value_free(val);
|
||||
}
|
||||
ber_free(ber,0);
|
||||
rec( &new, xoff , ld, ldap_get_dn(ld,entry) );
|
||||
ber_free(ber, 0);
|
||||
rec(&new, xoff, ld, ldap_get_dn(ld, entry));
|
||||
}
|
||||
|
||||
ldap_msgfree(entry);
|
||||
@@ -481,7 +469,8 @@ void rec( switch_xml_t *pxml, int *xoff, LDAP *ld, char *dn) {
|
||||
|
||||
|
||||
static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params,
|
||||
void *user_data) {
|
||||
void *user_data)
|
||||
{
|
||||
|
||||
xml_binding_t *binding = (xml_binding_t *) user_data;
|
||||
switch_event_header_t *hi;
|
||||
@@ -492,8 +481,8 @@ static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, c
|
||||
|
||||
char *basedn = NULL, *filter = NULL;
|
||||
char *dir_domain = NULL, *dir_exten = NULL;
|
||||
|
||||
char *buf;
|
||||
|
||||
char *buf;
|
||||
buf = malloc(4096);
|
||||
|
||||
LDAP *ld;
|
||||
@@ -501,8 +490,8 @@ static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, c
|
||||
|
||||
int xoff = 0;
|
||||
|
||||
xml = switch_xml_new("document");
|
||||
switch_xml_set_attr_d(xml, "type", "freeswitch/xml");
|
||||
xml = switch_xml_new("document");
|
||||
switch_xml_set_attr_d(xml, "type", "freeswitch/xml");
|
||||
|
||||
if (params) {
|
||||
if ((hi = params->headers)) {
|
||||
@@ -512,7 +501,7 @@ static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, c
|
||||
break;
|
||||
|
||||
case XML_LDAP_DIRECTORY:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "from cb got %s=%s\n", hi->name, hi->value);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "from cb got %s=%s\n", hi->name, hi->value);
|
||||
if (!strncmp(hi->name, "user", strlen(hi->name))) {
|
||||
dir_exten = strdup(hi->value);
|
||||
} else if (!strncmp(hi->name, "domain", strlen(hi->name))) {
|
||||
@@ -530,45 +519,47 @@ static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, c
|
||||
|
||||
|
||||
|
||||
if ( (ldap_initialize(&ld,binding->url)) != LDAP_SUCCESS ) goto cleanup;
|
||||
if ( (ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &desired_version)) != LDAP_SUCCESS ) goto cleanup;
|
||||
if ( (ldap_bind_s(ld, binding->binddn, binding->bindpass, auth_method)) != LDAP_SUCCESS ) goto cleanup;
|
||||
if ((ldap_initialize(&ld, binding->url)) != LDAP_SUCCESS)
|
||||
goto cleanup;
|
||||
if ((ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &desired_version)) != LDAP_SUCCESS)
|
||||
goto cleanup;
|
||||
if ((ldap_bind_s(ld, binding->binddn, binding->bindpass, auth_method)) != LDAP_SUCCESS)
|
||||
goto cleanup;
|
||||
|
||||
switch (binding->bt) {
|
||||
case XML_LDAP_CONFIG:
|
||||
xml = switch_xml_add_child_d(xml, "section", xoff++);
|
||||
switch_xml_set_attr_d(xml, "name", "configuration");
|
||||
filter = switch_mprintf(binding->filter,key_name,key_value);
|
||||
basedn = switch_mprintf(binding->basedn,tag_name);
|
||||
ret = trysearch(&xml,&xoff,ld, basedn, filter);
|
||||
break;
|
||||
case XML_LDAP_CONFIG:
|
||||
xml = switch_xml_add_child_d(xml, "section", xoff++);
|
||||
switch_xml_set_attr_d(xml, "name", "configuration");
|
||||
filter = switch_mprintf(binding->filter, key_name, key_value);
|
||||
basedn = switch_mprintf(binding->basedn, tag_name);
|
||||
ret = trysearch(&xml, &xoff, ld, basedn, filter);
|
||||
break;
|
||||
|
||||
case XML_LDAP_DIRECTORY:
|
||||
ret = trydir(&xml,&xoff,ld,dir_domain,dir_exten, binding);
|
||||
break;
|
||||
case XML_LDAP_DIRECTORY:
|
||||
ret = trydir(&xml, &xoff, ld, dir_domain, dir_exten, binding);
|
||||
break;
|
||||
|
||||
case XML_LDAP_DIALPLAN:
|
||||
break;
|
||||
case XML_LDAP_DIALPLAN:
|
||||
break;
|
||||
|
||||
case XML_LDAP_PHRASE:
|
||||
break;
|
||||
case XML_LDAP_PHRASE:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
ldap_unbind_s(ld);
|
||||
|
||||
switch_xml_toxml_buf(xml,buf,0,0,1);
|
||||
printf("providing:\n%s\n", buf);
|
||||
switch_xml_toxml_buf(xml, buf, 0, 0, 1);
|
||||
printf("providing:\n%s\n", buf);
|
||||
switch_safe_free(buf);
|
||||
|
||||
if (ret != SWITCH_STATUS_SUCCESS) {
|
||||
switch_xml_free(xml);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -161,9 +161,8 @@ static switch_status_t http_stream_write(switch_stream_handle_t *handle, const c
|
||||
return ret ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static abyss_bool user_attributes (const char *user, const char *domain_name,
|
||||
const char **ppasswd, const char **pvm_passwd,
|
||||
const char **palias, const char **pallowed_commands)
|
||||
static abyss_bool user_attributes(const char *user, const char *domain_name,
|
||||
const char **ppasswd, const char **pvm_passwd, const char **palias, const char **pallowed_commands)
|
||||
{
|
||||
const char *passwd;
|
||||
const char *vm_passwd;
|
||||
@@ -183,7 +182,7 @@ static abyss_bool user_attributes (const char *user, const char *domain_name,
|
||||
switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS);
|
||||
switch_assert(params);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "number_alias", "check");
|
||||
|
||||
|
||||
if (switch_xml_locate_user("id", user, domain_name, NULL, &x_domain_root, &x_domain, &x_user, NULL, params) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_destroy(¶ms);
|
||||
if (x_domain_root) {
|
||||
@@ -196,11 +195,11 @@ static abyss_bool user_attributes (const char *user, const char *domain_name,
|
||||
alias = switch_xml_attr(x_user, "number-alias");
|
||||
|
||||
if ((x_params = switch_xml_child(x_domain, "params"))) {
|
||||
|
||||
|
||||
for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
|
||||
const char *var = switch_xml_attr_soft(x_param, "name");
|
||||
const char *val = switch_xml_attr_soft(x_param, "value");
|
||||
|
||||
|
||||
if (!strcasecmp(var, "password")) {
|
||||
passwd = val;
|
||||
} else if (!strcasecmp(var, "vm-password")) {
|
||||
@@ -216,7 +215,7 @@ static abyss_bool user_attributes (const char *user, const char *domain_name,
|
||||
for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
|
||||
const char *var = switch_xml_attr_soft(x_param, "name");
|
||||
const char *val = switch_xml_attr_soft(x_param, "value");
|
||||
|
||||
|
||||
if (!strcasecmp(var, "password")) {
|
||||
passwd = val;
|
||||
} else if (!strcasecmp(var, "vm-password")) {
|
||||
@@ -235,7 +234,7 @@ static abyss_bool user_attributes (const char *user, const char *domain_name,
|
||||
*palias = strdup(alias);
|
||||
if (pallowed_commands)
|
||||
*pallowed_commands = strdup(allowed_commands);
|
||||
|
||||
|
||||
|
||||
if (x_domain_root) {
|
||||
switch_xml_free(x_domain_root);
|
||||
@@ -244,7 +243,7 @@ static abyss_bool user_attributes (const char *user, const char *domain_name,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static abyss_bool is_authorized (const TSession *r, const char *command)
|
||||
static abyss_bool is_authorized(const TSession * r, const char *command)
|
||||
{
|
||||
char *user = NULL, *domain_name = NULL;
|
||||
char *allowed_commands;
|
||||
@@ -263,7 +262,7 @@ static abyss_bool is_authorized (const TSession *r, const char *command)
|
||||
}
|
||||
|
||||
if (!r->requestInfo.user) {
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
user = strdup(r->requestInfo.user);
|
||||
@@ -277,14 +276,14 @@ static abyss_bool is_authorized (const TSession *r, const char *command)
|
||||
switch_safe_free(user);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
if (zstr(user) || zstr(domain_name)) {
|
||||
switch_safe_free(user);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (!user_attributes (user, domain_name, NULL, NULL, NULL, &allowed_commands)) {
|
||||
|
||||
if (!user_attributes(user, domain_name, NULL, NULL, NULL, &allowed_commands)) {
|
||||
switch_safe_free(user);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -295,21 +294,21 @@ static abyss_bool is_authorized (const TSession *r, const char *command)
|
||||
return FALSE;
|
||||
|
||||
dup = allowed_commands;
|
||||
argc = switch_separate_string (dup, ',', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
argc = switch_separate_string(dup, ',', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
if (!strcasecmp(argv[i], command)
|
||||
|| !strcasecmp(argv[i], "any")) {
|
||||
|| !strcasecmp(argv[i], "any")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch_safe_free (dup);
|
||||
switch_safe_free(dup);
|
||||
|
||||
return i < argc ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
static abyss_bool http_directory_auth(TSession *r, char *domain_name)
|
||||
static abyss_bool http_directory_auth(TSession * r, char *domain_name)
|
||||
{
|
||||
char *p;
|
||||
char *x;
|
||||
@@ -321,7 +320,7 @@ static abyss_bool http_directory_auth(TSession *r, char *domain_name)
|
||||
int at = 0;
|
||||
char *dp;
|
||||
abyss_bool rval = FALSE;
|
||||
|
||||
|
||||
p = RequestHeaderValue(r, "authorization");
|
||||
|
||||
if (p) {
|
||||
@@ -334,13 +333,13 @@ static abyss_bool http_directory_auth(TSession *r, char *domain_name)
|
||||
if ((pass = strchr(user, ':'))) {
|
||||
*pass++ = '\0';
|
||||
}
|
||||
|
||||
|
||||
if ((dp = strchr(user, '@'))) {
|
||||
*dp++ = '\0';
|
||||
domain_name = dp;
|
||||
at++;
|
||||
}
|
||||
|
||||
|
||||
if (!domain_name) {
|
||||
if (globals.virtual_host) {
|
||||
if ((domain_name = (char *) r->requestInfo.host)) {
|
||||
@@ -375,7 +374,7 @@ static abyss_bool http_directory_auth(TSession *r, char *domain_name)
|
||||
}
|
||||
}
|
||||
|
||||
if (!user_attributes (user, domain_name, &mypass1, &mypass2, &box, NULL)) {
|
||||
if (!user_attributes(user, domain_name, &mypass1, &mypass2, &box, NULL)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -441,7 +440,7 @@ static abyss_bool http_directory_auth(TSession *r, char *domain_name)
|
||||
goto fail;
|
||||
|
||||
authed:
|
||||
|
||||
|
||||
switch_snprintf(z, sizeof(z), "%s@%s", (box ? box : user), domain_name);
|
||||
r->requestInfo.user = strdup(z);
|
||||
|
||||
@@ -453,18 +452,18 @@ static abyss_bool http_directory_auth(TSession *r, char *domain_name)
|
||||
}
|
||||
}
|
||||
|
||||
fail:
|
||||
fail:
|
||||
|
||||
switch_snprintf(z, sizeof(z), "Basic realm=\"%s\"", domain_name ? domain_name : globals.realm);
|
||||
ResponseAddField(r, "WWW-Authenticate", z);
|
||||
ResponseStatus(r, 401);
|
||||
|
||||
done:
|
||||
done:
|
||||
|
||||
switch_safe_free(mypass1);
|
||||
switch_safe_free(mypass2);
|
||||
switch_safe_free(box);
|
||||
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
@@ -614,7 +613,6 @@ abyss_bool handler_hook(TSession * r)
|
||||
if (is_authorized(r, command)) {
|
||||
goto auth;
|
||||
}
|
||||
|
||||
//unauth:
|
||||
ResponseStatus(r, 403);
|
||||
ResponseError(r);
|
||||
@@ -626,7 +624,7 @@ abyss_bool handler_hook(TSession * r)
|
||||
|
||||
if (switch_event_create(&stream.param_event, SWITCH_EVENT_API) == SWITCH_STATUS_SUCCESS) {
|
||||
const char *const content_length = RequestHeaderValue(r, "content-length");
|
||||
|
||||
|
||||
if (html)
|
||||
switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "Content-type", "text/html");
|
||||
else if (text)
|
||||
@@ -639,7 +637,7 @@ abyss_bool handler_hook(TSession * r)
|
||||
switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "FreeSWITCH-Domain", fs_domain);
|
||||
if (path_info)
|
||||
switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "HTTP-Path-Info", path_info);
|
||||
switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "HTTP-URI", r->requestInfo.uri);
|
||||
switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "HTTP-URI", r->requestInfo.uri);
|
||||
if (r->requestInfo.query)
|
||||
switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "HTTP-QUERY", r->requestInfo.query);
|
||||
if (r->requestInfo.host)
|
||||
@@ -827,7 +825,7 @@ static xmlrpc_value *freeswitch_api(xmlrpc_env * const envP, xmlrpc_value * cons
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!is_authorized((const TSession *)callInfo, command)) {
|
||||
if (!is_authorized((const TSession *) callInfo, command)) {
|
||||
val = xmlrpc_build_value(envP, "s", "UNAUTHORIZED!");
|
||||
goto end;
|
||||
}
|
||||
@@ -838,7 +836,7 @@ static xmlrpc_value *freeswitch_api(xmlrpc_env * const envP, xmlrpc_value * cons
|
||||
freed = 1;
|
||||
command = "bgapi";
|
||||
arg = "unload mod_xml_rpc";
|
||||
} else if (switch_stristr("reload", command) && switch_stristr("mod_xml_rpc", arg)) {
|
||||
} else if (switch_stristr("reload", command) && switch_stristr("mod_xml_rpc", arg)) {
|
||||
switch_safe_free(command);
|
||||
switch_safe_free(arg);
|
||||
freed = 1;
|
||||
@@ -855,7 +853,7 @@ static xmlrpc_value *freeswitch_api(xmlrpc_env * const envP, xmlrpc_value * cons
|
||||
val = xmlrpc_build_value(envP, "s", "ERROR!");
|
||||
}
|
||||
|
||||
end:
|
||||
end:
|
||||
|
||||
/* xmlrpc-c requires us to free memory it malloced from xmlrpc_decompose_value */
|
||||
if (!freed) {
|
||||
@@ -977,7 +975,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_rpc_shutdown)
|
||||
//globals.abyssServer.running = 0;
|
||||
//shutdown(globals.abyssServer.listensock, 2);
|
||||
ServerTerminate(&globals.abyssServer);
|
||||
|
||||
|
||||
do {
|
||||
switch_yield(100000);
|
||||
} while (globals.running);
|
||||
|
||||
Reference in new issue
Block a user