]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_dptools] Implement disable_system_app_commands global variable to make system...
authorKen <krice@freeswitch.org>
Wed, 3 Nov 2021 13:14:25 +0000 (08:14 -0500)
committerAndrey Volk <andywolk@gmail.com>
Fri, 5 Nov 2021 14:46:07 +0000 (17:46 +0300)
adds a check on startup for global variable disable_system_app_commands. if the
global variable is set to true, the system and bgsystem dialplan apps will not
have their app_interface loaded via SWITCH_ADD_APP() leaving them effectively
disabled at run time.

src/mod/applications/mod_dptools/mod_dptools.c

index d755640c358bc601d58747f4ccfbc1ee5c3eb174..b9ef0708d8e1175b0f3e97460e4e479a8f23275d 100644 (file)
@@ -6427,6 +6427,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
        switch_dialplan_interface_t *dp_interface;
        switch_chat_interface_t *chat_interface;
        switch_file_interface_t *file_interface;
+       int use_system_commands = 1;
+
+       if (switch_true(switch_core_get_variable("disable_system_app_commands"))) {
+               use_system_commands = 0;
+       }
 
        if (switch_event_reserve_subclass(FILE_STRING_CLOSE) != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", FILE_STRING_CLOSE);
@@ -6704,10 +6709,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
                                   SAF_NONE);
        SWITCH_ADD_APP(app_interface, "bridge", "Bridge Audio", "Bridge the audio between two sessions", audio_bridge_function, "<channel_url>",
                                   SAF_SUPPORT_NOMEDIA|SAF_SUPPORT_TEXT_ONLY);
-       SWITCH_ADD_APP(app_interface, "system", "Execute a system command", "Execute a system command", system_session_function, "<command>",
-                                  SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC);
-       SWITCH_ADD_APP(app_interface, "bgsystem", "Execute a system command in the background", "Execute a background system command", bgsystem_session_function, "<command>",
-                                  SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC);
+       if (use_system_commands) {
+               SWITCH_ADD_APP(app_interface, "system", "Execute a system command", "Execute a system command", system_session_function, "<command>",
+                               SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC);
+               SWITCH_ADD_APP(app_interface, "bgsystem", "Execute a system command in the background", "Execute a background system command", bgsystem_session_function, "<command>",
+                               SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC);
+       }
        SWITCH_ADD_APP(app_interface, "say", "say", "say", say_function, SAY_SYNTAX, SAF_NONE);
 
        SWITCH_ADD_APP(app_interface, "detect_audio", "detect_audio", "detect_audio", detect_audio_function, DETECT_AUDIO_SYNTAX,