diff --git a/res/Makefile b/res/Makefile index 36b55a1721540e7242b5154d52e6b3c779a149ed..0fa79207aee438b9f5cb5856ca295b64c491e434 100644 --- a/res/Makefile +++ b/res/Makefile @@ -21,10 +21,6 @@ include $(ASTTOPDIR)/Makefile.moddir_rules LIBS += ../main/dt_logger.o -ifneq ($(DATAMODEL_UCI_PATH),) -_ASTCFLAGS += -DUCI_CONFIG_DIR=\"$(DATAMODEL_UCI_PATH)\" -endif - ifneq ($(findstring $(OSARCH), mingw32 cygwin ),) # cygwin has some dependencies among res_ things. # We use order-only dependencies, and then add the libraries as required. @@ -34,7 +30,6 @@ endif res_pjsip_pubsub.so: LIBS+=-lubus -lubox -lpicoevent res_pjsip_outbound_registration.so: LIBS+=-lubus -lubox -lpicoevent -res_pjsip.so: LIBS+=-luci res_config_ldap.o: _ASTCFLAGS+=-DLDAP_DEPRECATED diff --git a/res/res_pjsip/pjsip_distributor.c b/res/res_pjsip/pjsip_distributor.c index 3d50847d86e59c364741e9ee98a6daa132de3074..a75bff902c606b04bbd03916632ecb4b41a707af 100644 --- a/res/res_pjsip/pjsip_distributor.c +++ b/res/res_pjsip/pjsip_distributor.c @@ -19,7 +19,6 @@ #include "asterisk.h" #include <pjsip.h> -#include <uci.h> #include "asterisk/res_pjsip.h" #include "asterisk/acl.h" @@ -28,11 +27,6 @@ #include "asterisk/threadpool.h" #include "asterisk/res_pjsip_cli.h" -#ifndef UCI_CONFIG_DIR -#define UCI_CONFIG_DIR "/etc/config/" -#endif -static const char uciStrConfig[] = "asterisk"; - static int distribute(void *data); static pj_bool_t distributor(pjsip_rx_data *rdata); static pj_status_t record_serializer(pjsip_tx_data *tdata); @@ -883,77 +877,6 @@ static int apply_endpoint_contact_acl(pjsip_rx_data *rdata, struct ast_sip_endpo return forbidden; } -static void disable_registrar_uci(char* registrar) -{ - struct uci_context *context = NULL; - struct uci_package *package = NULL; - struct uci_section *section = NULL; - struct uci_element *element = NULL; - struct uci_ptr ptr = {0}; - char option_enable[32]; - const char *ext_number = NULL, *ext_provider = NULL; - int res; - FILE *fp = NULL; - char file_name[32] = ""; - char package_path[32]; - - context = uci_alloc_context(); - if (!context) { - ast_log(LOG_ERROR, "failed to alloc context %s\n"); - return; - } - - uci_set_confdir(context, UCI_CONFIG_DIR); - snprintf(package_path, sizeof(package_path), "%s%s", UCI_CONFIG_DIR, uciStrConfig); - res = uci_load(context, package_path, &package); - if (res != 0 || !package) { - ast_log(LOG_ERROR, "failed to load load uci, conf dir: %s, conf file: %s\n", UCI_CONFIG_DIR, uciStrConfig); - } else { - uci_foreach_element(&package->sections, element) { - section = uci_to_section(element); - if (strcasecmp(section->type, "extension") == 0) { - ext_number = uci_lookup_option_string(context, section, "extension_number"); - if (ext_number && strcasecmp(ext_number, registrar) == 0) { - ext_provider = uci_lookup_option_string(context, section, "provider"); - if (ext_provider) { - snprintf(option_enable, sizeof(option_enable), "asterisk.%s.enable", ext_provider); - if (uci_lookup_ptr(context, &ptr, option_enable, true)) { - ast_log(LOG_ERROR, "Failed to find section %s\n", option_enable); - } else { - ptr.value = "2"; - if (uci_set(context, &ptr) != UCI_OK) { - ast_log(LOG_ERROR, "Failed to uci_set, package: %s\n", ptr.package); - } else { - if (uci_commit(context, &ptr.p, true) != UCI_OK) { - ast_log(LOG_ERROR, "Failed to uci_commit\n"); - } else { - snprintf(file_name, sizeof(file_name), "/tmp/registrar.%s", ext_provider); - break; - } - } - } - } - } - } - } - } - // Free the memory - if (package) - uci_unload(context, package); - if (context) - uci_free_context(context); - - // create /tmp/registrar.ext_provider file and reload asterisk - // reload will trigger config_asterisk.sh re-run - if (file_name[0] != '\0') { - fp = fopen(file_name, "w"); - if (fp) { - fclose(fp); - } - system("systemctl reload asterisk"); - } -} - static pj_bool_t authenticate(pjsip_rx_data *rdata) { RAII_VAR(struct ast_sip_endpoint *, endpoint, ast_pjsip_rdata_get_endpoint(rdata), ao2_cleanup); @@ -968,7 +891,6 @@ static pj_bool_t authenticate(pjsip_rx_data *rdata) if (ast_sip_requires_authentication(endpoint, rdata)) { pjsip_tx_data *tdata; struct unidentified_request *unid; - char client[24] = {0}; pjsip_endpt_create_response(ast_sip_get_pjsip_endpoint(), rdata, 401, NULL, &tdata); switch (ast_sip_check_authentication(endpoint, rdata, tdata)) { @@ -991,6 +913,7 @@ static pj_bool_t authenticate(pjsip_rx_data *rdata) case AST_SIP_AUTHENTICATION_FAILED: pjsip_tx_data_dec_ref(tdata); // dec_ref for tdata with 401 pjsip_endpt_create_response(ast_sip_get_pjsip_endpoint(), rdata, 403, NULL, &tdata); // create tdata with 403 + if (pjsip_endpt_send_response2(ast_sip_get_pjsip_endpoint(), rdata, tdata, NULL, NULL) != PJ_SUCCESS) { pjsip_tx_data_dec_ref(tdata); } @@ -1000,14 +923,9 @@ static pj_bool_t authenticate(pjsip_rx_data *rdata) pjsip_contact_hdr *contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL); if (contact_hdr && contact_hdr->uri) { pjsip_sip_uri *client_uri = pjsip_uri_get_uri(contact_hdr->uri); - /* IPX101 and disable registrar */ + /* IPX101 */ if (client_uri) { ast_log_dt(LOG_EVENT_CODE_IPX101, (int) client_uri->user.slen, client_uri->user.ptr, 403, (int) client_uri->host.slen, client_uri->host.ptr); - - ast_copy_pj_str(client, &client_uri->user, sizeof(client)); - if (client[0] != '\0') { - disable_registrar_uci(client); - } } } }