PolicyKit: Branch 'master'

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 24 06:44:55 UTC 2023


 src/polkitbackend/polkitbackendduktapeauthority.c |   39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)

New commits:
commit 5615ed043fa8d9756ea79c60f09110f29efaa081
Author: Laurent Gauthier <laurent.gauthier at soccasys.com>
Date:   Wed May 24 06:44:53 2023 +0000

    duktape: prevent wrongful termination of runaway thread

diff --git a/src/polkitbackend/polkitbackendduktapeauthority.c b/src/polkitbackend/polkitbackendduktapeauthority.c
index 02dbcfe..dc13971 100644
--- a/src/polkitbackend/polkitbackendduktapeauthority.c
+++ b/src/polkitbackend/polkitbackendduktapeauthority.c
@@ -556,12 +556,25 @@ runaway_killer_thread_execute_js (gpointer user_data)
   }
   g_free(contents);
 
+  if ((pthread_err = pthread_mutex_lock(&ctx->mutex))) {
+    polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (ctx->authority),
+                                  "Error locking mutex: %s",
+                                  strerror(pthread_err));
+    return NULL;
+  }
+
   ctx->ret = RUNAWAY_KILLER_THREAD_EXIT_STATUS_SUCCESS;
   goto end;
 
 free_err:
   g_free(contents);
 err:
+  if ((pthread_err = pthread_mutex_lock(&ctx->mutex))) {
+    polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (ctx->authority),
+                                  "Error locking mutex: %s",
+                                  strerror(pthread_err));
+    return NULL;
+  }
   ctx->ret = RUNAWAY_KILLER_THREAD_EXIT_STATUS_FAILURE;
 end:
   if ((pthread_err = pthread_cond_signal(&ctx->cond))) {
@@ -570,6 +583,12 @@ end:
                                   strerror(pthread_err));
     ctx->ret = RUNAWAY_KILLER_THREAD_EXIT_STATUS_FAILURE;
   }
+  if ((pthread_err = pthread_mutex_unlock(&ctx->mutex))) {
+    polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (ctx->authority),
+                                  "Error unlocking mutex: %s",
+                                  strerror(pthread_err));
+    ctx->ret = RUNAWAY_KILLER_THREAD_EXIT_STATUS_FAILURE;
+  }
   return NULL;
 }
 
@@ -595,10 +614,23 @@ runaway_killer_thread_call_js (gpointer user_data)
       goto err;
     }
 
+  if ((pthread_err = pthread_mutex_lock(&ctx->mutex))) {
+    polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (ctx->authority),
+                                  "Error locking mutex: %s",
+                                  strerror(pthread_err));
+    return NULL;
+  }
+
   ctx->ret = RUNAWAY_KILLER_THREAD_EXIT_STATUS_SUCCESS;
   goto end;
 
 err:
+  if ((pthread_err = pthread_mutex_lock(&ctx->mutex))) {
+    polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (ctx->authority),
+                                  "Error locking mutex: %s",
+                                  strerror(pthread_err));
+    return NULL;
+  }
   ctx->ret = RUNAWAY_KILLER_THREAD_EXIT_STATUS_FAILURE;
 end:
   if ((pthread_err = pthread_cond_signal(&ctx->cond))) {
@@ -607,6 +639,13 @@ end:
                                   strerror(pthread_err));
     ctx->ret = RUNAWAY_KILLER_THREAD_EXIT_STATUS_FAILURE;
   }
+  if ((pthread_err = pthread_mutex_unlock(&ctx->mutex))) {
+    polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (ctx->authority),
+                                  "Error unlocking mutex: %s",
+                                  strerror(pthread_err));
+    ctx->ret = RUNAWAY_KILLER_THREAD_EXIT_STATUS_FAILURE;
+  }
+
   return NULL;
 }
 


More information about the hal-commit mailing list