summaryrefslogtreecommitdiff
path: root/main/pbx_functions.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2016-07-27 17:17:53 -0500
committerRichard Mudgett <rmudgett@digium.com>2016-07-28 15:10:18 -0500
commit873fc0fda596aa33115821329dfc556848ac2e9d (patch)
tree55ace1d49d1f1a64a82dc91f7ad0aa5e09ec8027 /main/pbx_functions.c
parent7883f128d54a52c65741c0e03e69ba0cf27a4743 (diff)
pbx.c: Allow dangerous functions when adding a hint to dialplan.
We can allow dangerous functions when adding a hint since altering dialplan is itself a privileged activity. Otherwise, we could never execute dangerous functions. ASTERISK-25996 #close Reported by: Andrew Nagy Change-Id: I4929ff100ad1200a0198262d069a34f2296e77ba
Diffstat (limited to 'main/pbx_functions.c')
-rw-r--r--main/pbx_functions.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/main/pbx_functions.c b/main/pbx_functions.c
index bc738b043..558be461f 100644
--- a/main/pbx_functions.c
+++ b/main/pbx_functions.c
@@ -482,7 +482,6 @@ int ast_thread_inhibit_escalations(void)
thread_inhibit_escalations = ast_threadstorage_get(
&thread_inhibit_escalations_tl, sizeof(*thread_inhibit_escalations));
-
if (thread_inhibit_escalations == NULL) {
ast_log(LOG_ERROR, "Error inhibiting privilege escalations for current thread\n");
return -1;
@@ -492,6 +491,23 @@ int ast_thread_inhibit_escalations(void)
return 0;
}
+int ast_thread_inhibit_escalations_swap(int inhibit)
+{
+ int *thread_inhibit_escalations;
+ int orig;
+
+ thread_inhibit_escalations = ast_threadstorage_get(
+ &thread_inhibit_escalations_tl, sizeof(*thread_inhibit_escalations));
+ if (thread_inhibit_escalations == NULL) {
+ ast_log(LOG_ERROR, "Error swapping privilege escalations inhibit for current thread\n");
+ return -1;
+ }
+
+ orig = *thread_inhibit_escalations;
+ *thread_inhibit_escalations = !!inhibit;
+ return orig;
+}
+
/*!
* \brief Indicates whether the current thread inhibits the execution of
* dangerous functions.
@@ -505,7 +521,6 @@ static int thread_inhibits_escalations(void)
thread_inhibit_escalations = ast_threadstorage_get(
&thread_inhibit_escalations_tl, sizeof(*thread_inhibit_escalations));
-
if (thread_inhibit_escalations == NULL) {
ast_log(LOG_ERROR, "Error checking thread's ability to run dangerous functions\n");
/* On error, assume that we are inhibiting */