mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-30 02:10:39 +00:00
add api-expansion to switch.conf.xml and fsctl api_expansion command to control allowing apis to be expanded via variable expansion
This commit is contained in:
parent
cfb2335406
commit
293429f78d
@ -323,6 +323,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_free_port(_In_ switch
|
|||||||
SWITCH_DECLARE(void) switch_core_port_allocator_destroy(_Inout_ switch_core_port_allocator_t **alloc);
|
SWITCH_DECLARE(void) switch_core_port_allocator_destroy(_Inout_ switch_core_port_allocator_t **alloc);
|
||||||
///\}
|
///\}
|
||||||
|
|
||||||
|
|
||||||
|
SWITCH_DECLARE(int) switch_core_test_flag(int flag);
|
||||||
|
|
||||||
///\defgroup ss Startup/Shutdown
|
///\defgroup ss Startup/Shutdown
|
||||||
///\ingroup core1
|
///\ingroup core1
|
||||||
///\{
|
///\{
|
||||||
|
@ -322,7 +322,8 @@ typedef enum {
|
|||||||
SCF_THREADED_SYSTEM_EXEC = (1 << 18),
|
SCF_THREADED_SYSTEM_EXEC = (1 << 18),
|
||||||
SCF_SYNC_CLOCK_REQUESTED = (1 << 19),
|
SCF_SYNC_CLOCK_REQUESTED = (1 << 19),
|
||||||
SCF_CORE_ODBC_REQ = (1 << 20),
|
SCF_CORE_ODBC_REQ = (1 << 20),
|
||||||
SCF_DEBUG_SQL = (1 << 21)
|
SCF_DEBUG_SQL = (1 << 21),
|
||||||
|
SCF_API_EXPANSION = (1 << 22)
|
||||||
} switch_core_flag_enum_t;
|
} switch_core_flag_enum_t;
|
||||||
typedef uint32_t switch_core_flag_t;
|
typedef uint32_t switch_core_flag_t;
|
||||||
|
|
||||||
@ -1776,6 +1777,7 @@ typedef enum {
|
|||||||
SCSC_SYNC_CLOCK_WHEN_IDLE,
|
SCSC_SYNC_CLOCK_WHEN_IDLE,
|
||||||
SCSC_DEBUG_SQL,
|
SCSC_DEBUG_SQL,
|
||||||
SCSC_SQL,
|
SCSC_SQL,
|
||||||
|
SCSC_API_EXPANSION
|
||||||
} switch_session_ctl_t;
|
} switch_session_ctl_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -1854,6 +1854,15 @@ SWITCH_STANDARD_API(ctl_function)
|
|||||||
switch_core_session_ctl(SCSC_VERBOSE_EVENTS, &arg);
|
switch_core_session_ctl(SCSC_VERBOSE_EVENTS, &arg);
|
||||||
|
|
||||||
stream->write_function(stream, "+OK verbose_events is %s \n", arg ? "on" : "off");
|
stream->write_function(stream, "+OK verbose_events is %s \n", arg ? "on" : "off");
|
||||||
|
} else if (!strcasecmp(argv[0], "api_expansion")) {
|
||||||
|
arg = -1;
|
||||||
|
if (argv[1]) {
|
||||||
|
arg = switch_true(argv[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_core_session_ctl(SCSC_API_EXPANSION, &arg);
|
||||||
|
|
||||||
|
stream->write_function(stream, "+OK api_expansion is %s \n", arg ? "on" : "off");
|
||||||
} else if (!strcasecmp(argv[0], "threaded_system_exec")) {
|
} else if (!strcasecmp(argv[0], "threaded_system_exec")) {
|
||||||
arg = -1;
|
arg = -1;
|
||||||
if (argv[1]) {
|
if (argv[1]) {
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
#include <switch_channel.h>
|
#include <switch_channel.h>
|
||||||
|
|
||||||
|
|
||||||
struct switch_cause_table {
|
struct switch_cause_table {
|
||||||
const char *name;
|
const char *name;
|
||||||
switch_call_cause_t cause;
|
switch_call_cause_t cause;
|
||||||
@ -3591,7 +3592,7 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables_check(switch_channel_t *c
|
|||||||
|
|
||||||
if ((sub_val = (char *) switch_channel_get_variable_dup(channel, vname, SWITCH_TRUE, idx))) {
|
if ((sub_val = (char *) switch_channel_get_variable_dup(channel, vname, SWITCH_TRUE, idx))) {
|
||||||
if (var_list && !switch_event_check_permission_list(var_list, vname)) {
|
if (var_list && !switch_event_check_permission_list(var_list, vname)) {
|
||||||
sub_val = "INVALID";
|
sub_val = "<Variable Expansion Permission Denied>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((expanded_sub_val = switch_channel_expand_variables_check(channel, sub_val, var_list, api_list, recur+1)) == sub_val) {
|
if ((expanded_sub_val = switch_channel_expand_variables_check(channel, sub_val, var_list, api_list, recur+1)) == sub_val) {
|
||||||
@ -3645,9 +3646,9 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables_check(switch_channel_t *c
|
|||||||
vval = expanded;
|
vval = expanded;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (api_list && !switch_event_check_permission_list(api_list, vname)) {
|
if (!switch_core_test_flag(SCF_API_EXPANSION) || (api_list && !switch_event_check_permission_list(api_list, vname))) {
|
||||||
func_val = "INVALID";
|
func_val = NULL;
|
||||||
sub_val = "INVALID";
|
sub_val = "<API Execute Permission Denied>";
|
||||||
} else {
|
} else {
|
||||||
if (switch_api_execute(vname, vval, channel->session, &stream) == SWITCH_STATUS_SUCCESS) {
|
if (switch_api_execute(vname, vval, channel->session, &stream) == SWITCH_STATUS_SUCCESS) {
|
||||||
func_val = stream.data;
|
func_val = stream.data;
|
||||||
|
@ -1405,6 +1405,12 @@ static void switch_core_set_serial(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SWITCH_DECLARE(int) switch_core_test_flag(int flag)
|
||||||
|
{
|
||||||
|
return switch_test_flag((&runtime), flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switch_bool_t console, const char **err)
|
SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switch_bool_t console, const char **err)
|
||||||
{
|
{
|
||||||
switch_uuid_t uuid;
|
switch_uuid_t uuid;
|
||||||
@ -1433,6 +1439,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
|
|||||||
switch_set_flag((&runtime.dummy_cng_frame), SFF_CNG);
|
switch_set_flag((&runtime.dummy_cng_frame), SFF_CNG);
|
||||||
switch_set_flag((&runtime), SCF_AUTO_SCHEMAS);
|
switch_set_flag((&runtime), SCF_AUTO_SCHEMAS);
|
||||||
switch_set_flag((&runtime), SCF_CLEAR_SQL);
|
switch_set_flag((&runtime), SCF_CLEAR_SQL);
|
||||||
|
switch_set_flag((&runtime), SCF_API_EXPANSION);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
switch_set_flag((&runtime), SCF_THREADED_SYSTEM_EXEC);
|
switch_set_flag((&runtime), SCF_THREADED_SYSTEM_EXEC);
|
||||||
#endif
|
#endif
|
||||||
@ -1750,6 +1757,12 @@ static void switch_load_core_config(const char *file)
|
|||||||
} else {
|
} else {
|
||||||
switch_clear_flag((&runtime), SCF_CLEAR_SQL);
|
switch_clear_flag((&runtime), SCF_CLEAR_SQL);
|
||||||
}
|
}
|
||||||
|
} else if (!strcasecmp(var, "api-expansion")) {
|
||||||
|
if (switch_true(val)) {
|
||||||
|
switch_set_flag((&runtime), SCF_API_EXPANSION);
|
||||||
|
} else {
|
||||||
|
switch_clear_flag((&runtime), SCF_API_EXPANSION);
|
||||||
|
}
|
||||||
} else if (!strcasecmp(var, "enable-early-hangup") && switch_true(val)) {
|
} else if (!strcasecmp(var, "enable-early-hangup") && switch_true(val)) {
|
||||||
switch_set_flag((&runtime), SCF_EARLY_HANGUP);
|
switch_set_flag((&runtime), SCF_EARLY_HANGUP);
|
||||||
} else if (!strcasecmp(var, "colorize-console") && switch_true(val)) {
|
} else if (!strcasecmp(var, "colorize-console") && switch_true(val)) {
|
||||||
@ -2099,6 +2112,18 @@ SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, void *
|
|||||||
newintval = switch_test_flag((&runtime), SCF_VERBOSE_EVENTS);
|
newintval = switch_test_flag((&runtime), SCF_VERBOSE_EVENTS);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SCSC_API_EXPANSION:
|
||||||
|
if (intval) {
|
||||||
|
if (oldintval > -1) {
|
||||||
|
if (oldintval) {
|
||||||
|
switch_set_flag((&runtime), SCF_API_EXPANSION);
|
||||||
|
} else {
|
||||||
|
switch_clear_flag((&runtime), SCF_API_EXPANSION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newintval = switch_test_flag((&runtime), SCF_API_EXPANSION);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case SCSC_THREADED_SYSTEM_EXEC:
|
case SCSC_THREADED_SYSTEM_EXEC:
|
||||||
if (intval) {
|
if (intval) {
|
||||||
if (oldintval > -1) {
|
if (oldintval > -1) {
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
#include <switch_event.h>
|
#include <switch_event.h>
|
||||||
|
|
||||||
|
|
||||||
//#define SWITCH_EVENT_RECYCLE
|
//#define SWITCH_EVENT_RECYCLE
|
||||||
#define DISPATCH_QUEUE_LEN 100
|
#define DISPATCH_QUEUE_LEN 100
|
||||||
//#define DEBUG_DISPATCH_QUEUES
|
//#define DEBUG_DISPATCH_QUEUES
|
||||||
@ -2109,7 +2110,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (var_list && !switch_event_check_permission_list(var_list, vname)) {
|
if (var_list && !switch_event_check_permission_list(var_list, vname)) {
|
||||||
sub_val = "INVALID";
|
sub_val = "<Variable Expansion Permission Denied>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2161,9 +2162,9 @@ SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event,
|
|||||||
vval = expanded;
|
vval = expanded;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (api_list && !switch_event_check_permission_list(api_list, vname)) {
|
if (!switch_core_test_flag(SCF_API_EXPANSION) || (api_list && !switch_event_check_permission_list(api_list, vname))) {
|
||||||
func_val = "INVALID";
|
func_val = NULL;
|
||||||
sub_val = "INVALID";
|
sub_val = "<API execute Permission Denied>";
|
||||||
} else {
|
} else {
|
||||||
if (switch_api_execute(vname, vval, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
|
if (switch_api_execute(vname, vval, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
|
||||||
func_val = stream.data;
|
func_val = stream.data;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user