PolicyKit: Branch 'master' - 3 commits

Colin Walters walters at kemper.freedesktop.org
Mon Dec 12 17:20:18 UTC 2016


 configure.ac                                   |   14 -
 src/polkitbackend/Makefile.am                  |    2 
 src/polkitbackend/polkitbackendjsauthority.cpp |  199 ++++++++++---------------
 3 files changed, 89 insertions(+), 126 deletions(-)

New commits:
commit 2d4d117eeadde9b56ac49e82a2d701a6f6e387b5
Author: Jeremy Linton <jeremy.linton at arm.com>
Date:   Fri Aug 26 14:01:49 2016 -0500

    Replace autocompartment
    
    The autocompartment definition in the previous patches seems to be fine, but
    constructing the autocompartment for the lifetime of the global object is probably
    a better way to handle this.
    
    Signed-off-by: Jeremy Linton <jeremy.linton at arm.com>

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index ce3a980..6a0b4ab 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -76,6 +76,7 @@ struct _PolkitBackendJsAuthorityPrivate
   JSRuntime *rt;
   JSContext *cx;
   JSObject *js_global;
+  JSAutoCompartment *ac;
   JSObject *js_polkit;
 
   GThread *runaway_killer_thread;
@@ -335,8 +336,6 @@ reload_scripts (PolkitBackendJsAuthority *authority)
 
   JS_BeginRequest (authority->priv->cx);
 
-  JSAutoCompartment ac(authority->priv->cx,  authority->priv->js_global);
-
   if (!JS_CallFunctionName(authority->priv->cx,
                            authority->priv->js_polkit,
                            "_deleteRules",
@@ -467,10 +466,15 @@ polkit_backend_js_authority_constructed (GObject *object)
     JS::CompartmentOptions compart_opts;
     compart_opts.setVersion(JSVERSION_LATEST);
     authority->priv->js_global = JS_NewGlobalObject (authority->priv->cx, &js_global_class, NULL, compart_opts);
-    JSAutoCompartment ac(authority->priv->cx,  authority->priv->js_global);
 
     if (authority->priv->js_global == NULL)
       goto fail;
+
+    authority->priv->ac = new JSAutoCompartment(authority->priv->cx,  authority->priv->js_global);
+
+    if (authority->priv->ac == NULL)
+      goto fail;
+
     JS_AddObjectRoot (authority->priv->cx, &authority->priv->js_global);
 
     if (!JS_InitStandardClasses (authority->priv->cx, authority->priv->js_global))
@@ -568,6 +572,7 @@ polkit_backend_js_authority_finalize (GObject *object)
 
   JS_BeginRequest (authority->priv->cx);
   JS_RemoveObjectRoot (authority->priv->cx, &authority->priv->js_polkit);
+  delete authority->priv->ac;
   JS_RemoveObjectRoot (authority->priv->cx, &authority->priv->js_global);
   JS_EndRequest (authority->priv->cx);
 
@@ -1071,8 +1076,6 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
 
   JS_BeginRequest (authority->priv->cx);
 
-  JSAutoCompartment ac(authority->priv->cx,  authority->priv->js_global);
-
   if (!action_and_details_to_jsval (authority, action_id, details, &argv[0], &error))
     {
       polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
@@ -1182,8 +1185,6 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
 
   JS_BeginRequest (authority->priv->cx);
 
-  JSAutoCompartment ac(authority->priv->cx,  authority->priv->js_global);
-
   if (!action_and_details_to_jsval (authority, action_id, details, &argv[0], &error))
     {
       polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
commit e845ef53aec8ec502c8edac957929e2d337b2302
Author: Jeremy Linton <jeremy.linton at arm.com>
Date:   Fri Aug 26 14:01:48 2016 -0500

    Fix warnings caused by building with C++
    
    C++ needs explicit casts for many pointer type conversions
    For example char * to void * should have a cast. Fix a
    number of these cases. Also, correct a white space indentation
    error left in the last patch for review clarity.
    
    Signed-off-by: Jeremy Linton <jeremy.linton at arm.com>

diff --git a/src/polkitbackend/Makefile.am b/src/polkitbackend/Makefile.am
index 5655d17..ca62474 100644
--- a/src/polkitbackend/Makefile.am
+++ b/src/polkitbackend/Makefile.am
@@ -53,7 +53,7 @@ libpolkit_backend_1_la_CFLAGS =                                        	\
 	$(LIBJS_CFLAGS)							\
         $(NULL)
 
-libpolkit_backend_1_la_CXXFLAGS = $(libpolkit_backend_1_la_CFLAGS) -fpermissive
+libpolkit_backend_1_la_CXXFLAGS = $(libpolkit_backend_1_la_CFLAGS)
 
 libpolkit_backend_1_la_LIBADD =                               		\
         $(GLIB_LIBS)							\
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 1541856..ce3a980 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -287,7 +287,7 @@ load_scripts (PolkitBackendJsAuthority  *authority)
 
   for (l = files; l != NULL; l = l->next)
     {
-      const gchar *filename = l->data;
+      const gchar *filename = (gchar *)l->data;
       JS::RootedScript script(authority->priv->cx);
       JS::CompileOptions options(authority->priv->cx);
       JS::RootedObject   obj(authority->priv->cx,authority->priv->js_global);
@@ -464,66 +464,66 @@ polkit_backend_js_authority_constructed (GObject *object)
   entered_request = TRUE;
 
   {
-  JS::CompartmentOptions compart_opts;
-  compart_opts.setVersion(JSVERSION_LATEST);
-  authority->priv->js_global = JS_NewGlobalObject (authority->priv->cx, &js_global_class, NULL, compart_opts);
-  JSAutoCompartment ac(authority->priv->cx,  authority->priv->js_global);
-
-  if (authority->priv->js_global == NULL)
-    goto fail;
-  JS_AddObjectRoot (authority->priv->cx, &authority->priv->js_global);
-
-  if (!JS_InitStandardClasses (authority->priv->cx, authority->priv->js_global))
-    goto fail;
-
-  authority->priv->js_polkit = JS_DefineObject (authority->priv->cx,
-                                                authority->priv->js_global,
-                                                "polkit",
-                                                &js_polkit_class,
-                                                NULL,
-                                                JSPROP_ENUMERATE);
-  if (authority->priv->js_polkit == NULL)
-    goto fail;
-  JS_AddObjectRoot (authority->priv->cx, &authority->priv->js_polkit);
-
-  if (!JS_DefineFunctions (authority->priv->cx,
-                           authority->priv->js_polkit,
-                           js_polkit_functions))
-    goto fail;
+    JS::CompartmentOptions compart_opts;
+    compart_opts.setVersion(JSVERSION_LATEST);
+    authority->priv->js_global = JS_NewGlobalObject (authority->priv->cx, &js_global_class, NULL, compart_opts);
+    JSAutoCompartment ac(authority->priv->cx,  authority->priv->js_global);
 
-  if (!JS_EvaluateScript (authority->priv->cx,
-                          authority->priv->js_global,
-                          init_js, strlen (init_js), /* init.js */
-                          "init.js",  /* filename */
-                          0,     /* lineno */
-                          NULL)) /* rval */
-    {
+    if (authority->priv->js_global == NULL)
       goto fail;
-    }
-
-  if (authority->priv->rules_dirs == NULL)
-    {
-      authority->priv->rules_dirs = g_new0 (gchar *, 3);
-      authority->priv->rules_dirs[0] = g_strdup (PACKAGE_SYSCONF_DIR "/polkit-1/rules.d");
-      authority->priv->rules_dirs[1] = g_strdup (PACKAGE_DATA_DIR "/polkit-1/rules.d");
-    }
+    JS_AddObjectRoot (authority->priv->cx, &authority->priv->js_global);
 
-  g_mutex_init (&authority->priv->rkt_init_mutex);
-  g_cond_init (&authority->priv->rkt_init_cond);
-  g_mutex_init (&authority->priv->rkt_timeout_pending_mutex);
+    if (!JS_InitStandardClasses (authority->priv->cx, authority->priv->js_global))
+      goto fail;
 
-  authority->priv->runaway_killer_thread = g_thread_new ("runaway-killer-thread",
-                                                         runaway_killer_thread_func,
-                                                         authority);
+    authority->priv->js_polkit = JS_DefineObject (authority->priv->cx,
+                                                  authority->priv->js_global,
+                                                  "polkit",
+                                                  &js_polkit_class,
+                                                  NULL,
+                                                  JSPROP_ENUMERATE);
+    if (authority->priv->js_polkit == NULL)
+      goto fail;
+    JS_AddObjectRoot (authority->priv->cx, &authority->priv->js_polkit);
 
-  /* wait for runaway_killer_thread to set up its GMainContext */
-  g_mutex_lock (&authority->priv->rkt_init_mutex);
-  while (authority->priv->rkt_context == NULL)
-    g_cond_wait (&authority->priv->rkt_init_cond, &authority->priv->rkt_init_mutex);
-  g_mutex_unlock (&authority->priv->rkt_init_mutex);
+    if (!JS_DefineFunctions (authority->priv->cx,
+                             authority->priv->js_polkit,
+                             js_polkit_functions))
+      goto fail;
 
-  setup_file_monitors (authority);
-  load_scripts (authority);
+    if (!JS_EvaluateScript (authority->priv->cx,
+                            authority->priv->js_global,
+                            init_js, strlen (init_js), /* init.js */
+                            "init.js",  /* filename */
+                            0,     /* lineno */
+                            NULL)) /* rval */
+      {
+        goto fail;
+      }
+
+    if (authority->priv->rules_dirs == NULL)
+      {
+        authority->priv->rules_dirs = g_new0 (gchar *, 3);
+        authority->priv->rules_dirs[0] = g_strdup (PACKAGE_SYSCONF_DIR "/polkit-1/rules.d");
+        authority->priv->rules_dirs[1] = g_strdup (PACKAGE_DATA_DIR "/polkit-1/rules.d");
+      }
+
+    g_mutex_init (&authority->priv->rkt_init_mutex);
+    g_cond_init (&authority->priv->rkt_init_cond);
+    g_mutex_init (&authority->priv->rkt_timeout_pending_mutex);
+
+    authority->priv->runaway_killer_thread = g_thread_new ("runaway-killer-thread",
+                                                           runaway_killer_thread_func,
+                                                           authority);
+
+    /* wait for runaway_killer_thread to set up its GMainContext */
+    g_mutex_lock (&authority->priv->rkt_init_mutex);
+    while (authority->priv->rkt_context == NULL)
+      g_cond_wait (&authority->priv->rkt_init_cond, &authority->priv->rkt_init_mutex);
+    g_mutex_unlock (&authority->priv->rkt_init_mutex);
+
+    setup_file_monitors (authority);
+    load_scripts (authority);
   }
   JS_EndRequest (authority->priv->cx);
   entered_request = FALSE;
@@ -559,7 +559,7 @@ polkit_backend_js_authority_finalize (GObject *object)
     {
       GFileMonitor *monitor = authority->priv->dir_monitors[n];
       g_signal_handlers_disconnect_by_func (monitor,
-                                            G_CALLBACK (on_dir_monitor_changed),
+                                            (gpointer*)G_CALLBACK (on_dir_monitor_changed),
                                             authority);
       g_object_unref (monitor);
     }
@@ -645,7 +645,7 @@ polkit_backend_js_authority_class_init (PolkitBackendJsAuthorityClass *klass)
                                                        NULL,
                                                        NULL,
                                                        G_TYPE_STRV,
-                                                       G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+                                                       GParamFlags(G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE)));
 
 
   g_type_class_add_private (klass, sizeof (PolkitBackendJsAuthorityPrivate));
@@ -685,7 +685,7 @@ set_property_strv (PolkitBackendJsAuthority  *authority,
       JSString *jsstr;
       jsval val;
 
-      jsstr = JS_NewStringCopyZ (authority->priv->cx, g_ptr_array_index(value, n));
+      jsstr = JS_NewStringCopyZ (authority->priv->cx, (char *)g_ptr_array_index(value, n));
       val = STRING_TO_JSVAL (jsstr);
       JS_SetElement (authority->priv->cx, array_object, n, &val);
     }
@@ -1347,8 +1347,8 @@ spawn_cb (GObject       *source_object,
           GAsyncResult  *res,
           gpointer       user_data)
 {
-  SpawnData *data = user_data;
-  data->res = g_object_ref (res);
+  SpawnData *data = (SpawnData *)user_data;
+  data->res = (GAsyncResult*)g_object_ref (res);
   g_main_loop_quit (data->loop);
 }
 
@@ -1657,7 +1657,7 @@ static void
 utils_on_cancelled (GCancellable *cancellable,
                     gpointer      user_data)
 {
-  UtilsSpawnData *data = user_data;
+  UtilsSpawnData *data = (UtilsSpawnData *)user_data;
   GError *error;
 
   error = NULL;
@@ -1672,7 +1672,7 @@ utils_read_child_stderr (GIOChannel *channel,
                          GIOCondition condition,
                          gpointer user_data)
 {
-  UtilsSpawnData *data = user_data;
+  UtilsSpawnData *data = (UtilsSpawnData *)user_data;
   gchar buf[1024];
   gsize bytes_read;
 
@@ -1686,7 +1686,7 @@ utils_read_child_stdout (GIOChannel *channel,
                          GIOCondition condition,
                          gpointer user_data)
 {
-  UtilsSpawnData *data = user_data;
+  UtilsSpawnData *data = (UtilsSpawnData *)user_data;
   gchar buf[1024];
   gsize bytes_read;
 
@@ -1700,7 +1700,7 @@ utils_child_watch_cb (GPid     pid,
                       gint     status,
                       gpointer user_data)
 {
-  UtilsSpawnData *data = user_data;
+  UtilsSpawnData *data = (UtilsSpawnData *)user_data;
   gchar *buf;
   gsize buf_size;
 
@@ -1729,7 +1729,7 @@ utils_child_watch_cb (GPid     pid,
 static gboolean
 utils_timeout_cb (gpointer user_data)
 {
-  UtilsSpawnData *data = user_data;
+  UtilsSpawnData *data = (UtilsSpawnData *)user_data;
 
   data->timed_out = TRUE;
 
@@ -1758,12 +1758,12 @@ utils_spawn (const gchar *const  *argv,
   data->simple = g_simple_async_result_new (NULL,
                                             callback,
                                             user_data,
-                                            utils_spawn);
+                                            (gpointer*)utils_spawn);
   data->main_context = g_main_context_get_thread_default ();
   if (data->main_context != NULL)
     g_main_context_ref (data->main_context);
 
-  data->cancellable = cancellable != NULL ? g_object_ref (cancellable) : NULL;
+  data->cancellable = cancellable != NULL ? (GCancellable*)g_object_ref (cancellable) : NULL;
 
   data->child_stdout = g_string_new (NULL);
   data->child_stderr = g_string_new (NULL);
@@ -1796,7 +1796,7 @@ utils_spawn (const gchar *const  *argv,
   if (!g_spawn_async_with_pipes (NULL, /* working directory */
                                  (gchar **) argv,
                                  NULL, /* envp */
-                                 G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+                                 GSpawnFlags(G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD),
                                  NULL, /* child_setup */
                                  NULL, /* child_setup's user_data */
                                  &(data->child_pid),
@@ -1863,7 +1863,7 @@ utils_spawn_finish (GAsyncResult   *res,
   if (g_simple_async_result_propagate_error (simple, error))
     goto out;
 
-  data = g_simple_async_result_get_op_res_gpointer (simple);
+  data = (UtilsSpawnData*)g_simple_async_result_get_op_res_gpointer (simple);
 
   if (data->timed_out)
     {
commit 03dafd1fac8154c0a581395f1b7bf29e56a83491
Author: Jeremy Linton <jeremy.linton at arm.com>
Date:   Fri Aug 26 14:01:47 2016 -0500

    Switch to hard requiring mozjs24
    
    Remove mozjs185 and mozjs17 from autoconf and replace them
    with mozjs24.
    
    Now that polkitbackendjsauthority is compiling in C++ mode
    and the autoconf supports mozjs24, update the module so
    that it builds with mozjs24.
    
    Signed-off-by: Jeremy Linton <jeremy.linton at arm.com>

diff --git a/configure.ac b/configure.ac
index 18c1f4e..f457a84 100644
--- a/configure.ac
+++ b/configure.ac
@@ -131,18 +131,8 @@ AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_30],
 AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [G_ENCODE_VERSION(2,34)],
         [Notify us when we'll need to transition away from g_type_init()])
 
-AC_ARG_WITH(mozjs, AS_HELP_STRING([--with-mozjs=@<:@mozjs185/mozjs-17.0|auto@:>@],
-		                  [Specify version of Spidermonkey to use]),,
-            with_mozjs=auto)
-AS_IF([test x${with_mozjs} != xauto], [
-  PKG_CHECK_MODULES(LIBJS, ${with_mozjs})
-], [
-  PKG_CHECK_MODULES(LIBJS, [mozjs185], have_mozjs185=yes, have_mozjs185=no)
-  AS_IF([test x${have_mozjs185} = xno], [
-  PKG_CHECK_MODULES(LIBJS, [mozjs-17.0], have_mozjs17=yes,
-   [AC_MSG_ERROR([Could not find mozjs185 or mozjs-17.0; see http://ftp.mozilla.org/pub/mozilla.org/js/])])
-  ])
-])
+PKG_CHECK_MODULES(LIBJS, [mozjs-24])
+
 AC_SUBST(LIBJS_CFLAGS)
 AC_SUBST(LIBJS_CXXFLAGS)
 AC_SUBST(LIBJS_LIBS)
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 2112868..1541856 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -92,11 +92,7 @@ struct _PolkitBackendJsAuthorityPrivate
 };
 
 static JSBool execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
-#if JS_VERSION == 186
                                                   JSScript                 *script,
-#else
-                                                  JSObject                 *script,
-#endif
                                                   jsval                    *rval);
 
 static void utils_spawn (const gchar *const  *argv,
@@ -157,17 +153,13 @@ static JSClass js_global_class = {
   "global",
   JSCLASS_GLOBAL_FLAGS,
   JS_PropertyStub,
-  JS_PropertyStub,
+  JS_DeletePropertyStub,
   JS_PropertyStub,
   JS_StrictPropertyStub,
   JS_EnumerateStub,
   JS_ResolveStub,
   JS_ConvertStub,
-#if JS_VERSION == 186      
   NULL,
-#else
-  JS_FinalizeStub,
-#endif
   JSCLASS_NO_OPTIONAL_MEMBERS
 };
 
@@ -177,17 +169,13 @@ static JSClass js_polkit_class = {
   "Polkit",
   0,
   JS_PropertyStub,
-  JS_PropertyStub,
+  JS_DeletePropertyStub,
   JS_PropertyStub,
   JS_StrictPropertyStub,
   JS_EnumerateStub,
   JS_ResolveStub,
   JS_ConvertStub,
-#if JS_VERSION == 186      
   NULL,
-#else
-  JS_FinalizeStub,
-#endif
   JSCLASS_NO_OPTIONAL_MEMBERS
 };
 
@@ -300,22 +288,14 @@ load_scripts (PolkitBackendJsAuthority  *authority)
   for (l = files; l != NULL; l = l->next)
     {
       const gchar *filename = l->data;
-#if JS_VERSION == 186
-      JSScript *script;
-#else
-      JSObject *script;
-#endif
+      JS::RootedScript script(authority->priv->cx);
+      JS::CompileOptions options(authority->priv->cx);
+      JS::RootedObject   obj(authority->priv->cx,authority->priv->js_global);
+      options.setUTF8(true);
+      script = JS::Compile (authority->priv->cx,
+                            obj, options,
+                            filename);
 
-#if JS_VERSION == 186
-      script = JS_CompileUTF8File (authority->priv->cx,
-				   authority->priv->js_global,
-				   filename);
-      
-#else
-      script = JS_CompileFile (authority->priv->cx,
-			       authority->priv->js_global,
-			       filename);
-#endif
       if (script == NULL)
         {
           polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
@@ -355,6 +335,8 @@ reload_scripts (PolkitBackendJsAuthority *authority)
 
   JS_BeginRequest (authority->priv->cx);
 
+  JSAutoCompartment ac(authority->priv->cx,  authority->priv->js_global);
+
   if (!JS_CallFunctionName(authority->priv->cx,
                            authority->priv->js_polkit,
                            "_deleteRules",
@@ -369,11 +351,7 @@ reload_scripts (PolkitBackendJsAuthority *authority)
 
   polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
                                 "Collecting garbage unconditionally...");
-#if JS_VERSION == 186
   JS_GC (authority->priv->rt);
-#else
-  JS_GC (authority->priv->cx);
-#endif
 
   load_scripts (authority);
 
@@ -465,7 +443,7 @@ polkit_backend_js_authority_constructed (GObject *object)
   PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (object);
   gboolean entered_request = FALSE;
 
-  authority->priv->rt = JS_NewRuntime (8L * 1024L * 1024L);
+  authority->priv->rt = JS_NewRuntime (8L * 1024L * 1024L, JS_USE_HELPER_THREADS);
   if (authority->priv->rt == NULL)
     goto fail;
 
@@ -479,19 +457,17 @@ polkit_backend_js_authority_constructed (GObject *object)
   JS_SetOptions (authority->priv->cx,
                  JSOPTION_VAROBJFIX
                  /* | JSOPTION_JIT | JSOPTION_METHODJIT*/);
-  JS_SetVersion(authority->priv->cx, JSVERSION_LATEST);
   JS_SetErrorReporter(authority->priv->cx, report_error);
   JS_SetContextPrivate (authority->priv->cx, authority);
 
   JS_BeginRequest(authority->priv->cx);
   entered_request = TRUE;
 
-  authority->priv->js_global =
-#if JS_VERSION == 186
-    JS_NewGlobalObject (authority->priv->cx, &js_global_class, NULL);
-#else
-    JS_NewCompartmentAndGlobalObject (authority->priv->cx, &js_global_class, NULL);
-#endif
+  {
+  JS::CompartmentOptions compart_opts;
+  compart_opts.setVersion(JSVERSION_LATEST);
+  authority->priv->js_global = JS_NewGlobalObject (authority->priv->cx, &js_global_class, NULL, compart_opts);
+  JSAutoCompartment ac(authority->priv->cx,  authority->priv->js_global);
 
   if (authority->priv->js_global == NULL)
     goto fail;
@@ -548,11 +524,12 @@ polkit_backend_js_authority_constructed (GObject *object)
 
   setup_file_monitors (authority);
   load_scripts (authority);
-
+  }
   JS_EndRequest (authority->priv->cx);
   entered_request = FALSE;
 
   G_OBJECT_CLASS (polkit_backend_js_authority_parent_class)->constructed (object);
+
   return;
 
  fail:
@@ -766,7 +743,6 @@ subject_to_jsval (PolkitBackendJsAuthority  *authority,
   char *session_str = NULL;
 
   src = "new Subject();";
-
   if (!JS_EvaluateScript (authority->priv->cx,
                           authority->priv->js_global,
                           src, strlen (src),
@@ -999,11 +975,7 @@ rkt_on_timeout (gpointer user_data)
   g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex);
 
   /* Supposedly this is thread-safe... */
-#if JS_VERSION == 186
   JS_TriggerOperationCallback (authority->priv->rt);
-#else
-  JS_TriggerOperationCallback (authority->priv->cx);
-#endif
 
   /* keep source around so we keep trying to kill even if the JS bit catches the exception
    * thrown in js_operation_callback()
@@ -1041,11 +1013,7 @@ runaway_killer_teardown (PolkitBackendJsAuthority *authority)
 
 static JSBool
 execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
-#if JS_VERSION == 186
                                     JSScript                 *script,
-#else
-                                    JSObject                 *script,
-#endif
                                     jsval                    *rval)
 {
   JSBool ret;
@@ -1103,6 +1071,8 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
 
   JS_BeginRequest (authority->priv->cx);
 
+  JSAutoCompartment ac(authority->priv->cx,  authority->priv->js_global);
+
   if (!action_and_details_to_jsval (authority, action_id, details, &argv[0], &error))
     {
       polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
@@ -1212,6 +1182,8 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
 
   JS_BeginRequest (authority->priv->cx);
 
+  JSAutoCompartment ac(authority->priv->cx,  authority->priv->js_global);
+
   if (!action_and_details_to_jsval (authority, action_id, details, &argv[0], &error))
     {
       polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),


More information about the hal-commit mailing list