Merge "asterisk.c: When astcanary dies on linux, reset priority on all threads."
[asterisk/asterisk.git] / main / pbx_functions.c
index bc738b0..558be46 100644 (file)
@@ -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 */