PolicyKit: Branch 'wip/halfline/new-release' - 35 commits

Ray Strode halfline at kemper.freedesktop.org
Tue Apr 3 17:39:19 UTC 2018


Rebased ref, commits from common ancestor:
commit fb817188ae28d9df8d1208b160089a19779ec29e
Author: Ray Strode <rstrode at redhat.com>
Date:   Mon Apr 2 16:05:56 2018 -0400

    Update NEWS for release

diff --git a/NEWS b/NEWS
index 2d2c8fc..79ac4d7 100644
--- a/NEWS
+++ b/NEWS
@@ -9,24 +9,165 @@ some security review. Use at your own risk.
 This is polkit 0.114.
 
 Highlights:
- TODO
+ Port to mozjs 52, the latest version of the firefox JavaScript engine.
+
+ Add gettext support for policy files
+
+ Fixes for various memory leaks
 
 Build requirements
 
- glib, gobject, gio    >= 2.30
- mozjs185 or mozjs-17.0
+ glib, gobject, gio    >= 2.32
+ mozjs-52
  gobject-introspection >= 0.6.2 (optional)
  pam (optional)
  ConsoleKit OR systemd
 
 Changes since polkit 0.113:
 
- TODO
+Anders Jonsson (2):
+      pkcheck: fix man typos
+      Add Swedish translation
+
+Antoine Jacoutot (1):
+      Add support for OpenBSD
+
+Christian Kirbach (1):
+      Add German translation
+
+Colin Walters (3):
+      build: Pull in GCC warning infra from ostree
+      build: Use AC_USE_SYSTEM_EXTENSIONS
+      tests: Correct boundary test for overflow
+
+Dariusz Gadomski (2):
+      Fix multi-line pam text info.
+      Refactor send_to_helper usage
+
+Gabor Kelemen (1):
+      Add initial Hungarian translation, and add hu to LINGUAS
+
+Jeremy Linton (5):
+      change mozjs interface module to c++
+      Switch to hard requiring mozjs24
+      Fix warnings caused by building with C++
+      Replace autocompartment
+      test: Add a test case to handle actions without explicit rules
+
+Jiří Klimeš (1):
+      trivial: fix deprecated indication for polkit_agent_register_listener()
+
+Matthias Clasen (1):
+      Add gettext support for .policy files
+
+Miloslav Trmač (21):
+      Post-release version bump to 0.114
+      Consistently use HAVE_NETGROUP_H instead of HAVE_OPENBSD
+      Fix a memory leak of PolkitAgentListener's Server object
+      Remove polkitbackendconfigsource.[ch]
+      Add Slovak translation by Dusan Kazik <prescott66 at gmail.com>
+      Add Indonesian translation by Andika Triwidada
+      Add Chinese (Taiwan) translation
+      Fix a typo in polkit(8)
+      Simplify GVariant reference counting
+      Fix a memory leak on an error path of lookup_asv (twice)
+      Fix a memory leak in server_handle_register_authentication_agent_with_options
+      Fix a memory leak in server_handle_unregister_authentication_agent
+      Fix a memory leak in server_handle_authentication_agent_response{,2}
+      Fix memory leaks in server_handle_*_temporary_authorizations
+      Fix error handling in polkit_authority_enumerate_temporary_authorizations_finish
+      Fix a memory leak per agent authentication
+      Fix a memory leak on agent authentication cancellation
+      Audit and fix GVariant reference counting
+      Fix help for (pkttyagent -s)
+      Fix a race condition when terminating runaway_killer_thread
+      Move to current GLib
+
+Mingye Wang (Arthur2e5) (1):
+      Add zh_CN translation
+
+Muhammet Kara (1):
+      Added Turkish translation
+
+OBATA Akio (1):
+      Add support for NetBSD
+
+Peter Hutterer (1):
+      gettext: switch to default-translate "no"
+
+Philip Withnall (3):
+      polkit: Add g_autoptr() support for GObject-derived polkit types
+      data: Set GIO_USE_VFS=local in the environment
+      polkitbackend: Fix typos in a couple of initialisation error messages
+
+Piotr Drąg (1):
+      Add Polish translation
+
+Rafael Fontenelle (1):
+      Add Brazilian Portuguese translation
+
+Ray Strode (34):
+      configure: bump mozjs requirement to 52
+      jsauthority: fix how classes are defined
+      jsauthority: use JS_FN instead of JS_FS
+      jsauthority: get rid of JSRuntime
+      jsauthority: change how setVersion is called
+      jsauthority: call JS_Init
+      jsauthority: call JS_InitSelfHostedCode
+      jsauthority: change how JIT is disabled
+      jsauthority: JS::SetWarningReporter instead of JS_SetErrorReporter
+      jsauthority: add UTF8 suffix to renamed functions
+      jsauthority: pass "%s" format string to report functions
+      jsauthority: s/JSBool/bool/
+      jsauthority: s/jsval/JS::Value/
+      jsauthority: s/JSVAL_NULL/JS::NullValue()/
+      jsauthority: s/JSVAL_VOID/JS::UndefinedValue()/
+      jsauthority: s/OBJECT_TO_JSVAL/JS::ObjectValue/
+      jsauthority: s/STRING_TO_JSVAL/JS::StringValue/
+      jsauthority: s/BOOLEAN_TO_JSVAL/JS::BooleanValue/
+      jsauthority: JSVAL_TO_OBJECT (o) to o.toObjectOrNull()
+      jsauthority: JSVAL_TO_STRING (s) to s.toString()
+      jsauthority: JSVAL_IS_STRING (s) to s.isString()
+      jsauthority: JSVAL_IS_NULL (o) to o.isNull()
+      jsauthority: Fix up JS_CallFunctionName invocations
+      jsauthority: use InterruptCallback api instead of OperationCallback
+      jsauthority: redo how global objects are set up
+      jsauthority: root some locals to the context
+      jsauthority: adapt arguments for new JS::Compile API
+      jsauthority: adapt arguments for new JS_ExecuteScript API
+      jsauthority: use JS::Evaluate instead of JS_EvaluateScript
+      jsauthority: fix up set_property methods
+      jsauthority: stop using JS_GetStringCharsZ
+      jsauthority: switch from JS_ConvertArguments to JS::CallArgsFromVp
+      jsauthority: re-enable JIT
+      Port JavaScript authority to mozjs52
+
+Rui Matos (1):
+      polkitpermission: Fix a memory leak on authority changes
+
+Sebastien Bacher (1):
+      Support polkit session agent running outside user session
+
+Stef Walter (2):
+      polkitagent: Fix access after dereference on hashtable
+      polkitagent: No double warnings in polkit_agent_listener_register()
+
+Sven Eden (1):
+      configure: enable elogind support in PolicyKit
+
+Yuri Chornoivan (1):
+      Add Ukrainian translation
+
+enkore (1):
+      Fix abnomal formatting of authentication header lines
+
+muzena (1):
+      Add hr.po
 
 Thanks to our contributors.
 
 Colin Walters and Miloslav Trmač,
-$DATE
+April 2, 2017
 
 --------------
 polkit 0.113
commit b78f200e0f08db4fbc30283cee6c0dfb6d55a1d9
Author: Jeremy Linton <jeremy.linton at arm.com>
Date:   Wed Apr 12 22:26:30 2017 -0500

    test: Add a test case to handle actions without explicit rules
    
    An implicit authorization parameter is provided to
    polkit_backend_js_authority_check_authorization_sync() for actions
    without corresponding explicit rules. Assure that is honored rather
    than simply being denied.
    
    Signed-off-by: Jeremy Linton <jeremy.linton at arm.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/test/polkitbackend/test-polkitbackendjsauthority.c b/test/polkitbackend/test-polkitbackendjsauthority.c
index 984110c..b484a26 100644
--- a/test/polkitbackend/test-polkitbackendjsauthority.c
+++ b/test/polkitbackend/test-polkitbackendjsauthority.c
@@ -182,6 +182,14 @@ static const RulesTestCase rules_test_cases[] = {
     NULL,
     POLKIT_IMPLICIT_AUTHORIZATION_AUTHENTICATION_REQUIRED,
   },
+  /* actions without explict rules aren't automatically NOT_AUTHORIZED */
+  {
+    "basic2",
+    "net.company.productA.action2",
+    "unix-user:john",
+    NULL,
+    POLKIT_IMPLICIT_AUTHORIZATION_UNKNOWN,
+  },
 
   /* Ordering tests ... we have four rules files, check they are
    * evaluated in order by checking the detail set by each rules
commit 0dda2a1e714633258ce0ac45b85dddeac0d02835
Author: Ray Strode <rstrode at redhat.com>
Date:   Wed Mar 28 15:28:28 2018 -0400

    jsauthority: re-enable JIT
    
    seems to work with mozjs52
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index ef1a900..9746c47 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -457,13 +457,10 @@ polkit_backend_js_authority_constructed (GObject *object)
   if (!JS::InitSelfHostedCode (authority->priv->cx))
     goto fail;
 
-  /* TODO: JIT'ing doesn't work will with killing runaway scripts... I think
-   *       this is just a SpiderMonkey bug. So disable the JIT for now.
-   */
   JS::ContextOptionsRef (authority->priv->cx)
-      .setIon (FALSE)
-      .setBaseline (FALSE)
-      .setAsmJS (FALSE);
+      .setIon (TRUE)
+      .setBaseline (TRUE)
+      .setAsmJS (TRUE);
   JS::SetWarningReporter(authority->priv->cx, report_error);
   JS_SetContextPrivate (authority->priv->cx, authority);
 
commit c51b8102eee7344756ebc11611e3b95090c674dd
Author: Ray Strode <rstrode at redhat.com>
Date:   Fri Mar 23 15:22:59 2018 -0400

    jsauthority: switch from JS_ConvertArguments to JS::CallArgsFromVp
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 686de3f..ef1a900 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1290,20 +1290,18 @@ js_polkit_log (JSContext  *cx,
 {
   /* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
   bool ret = false;
-  JSString *str;
   char *s;
 
-  if (!JS_ConvertArguments (cx, argc, JS_ARGV (cx, vp), "S", &str))
-    goto out;
+  JS::CallArgs args = JS::CallArgsFromVp (argc, vp);
 
-  s = JS_EncodeString (cx, str);
+  s = JS_EncodeString (cx, args[0].toString ());
   JS_ReportWarningUTF8 (cx, s);
   JS_free (cx, s);
 
   ret = true;
 
-  JS_SET_RVAL (cx, vp, JS::UndefinedValue());  /* return undefined */
- out:
+  args.rval ().setUndefined (); /* return undefined */
+
   return ret;
 }
 
@@ -1375,7 +1373,7 @@ js_polkit_spawn (JSContext  *cx,
 {
   /* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
   bool ret = false;
-  JSObject *array_object;
+  JS::RootedObject array_object(cx);
   gchar *standard_output = NULL;
   gchar *standard_error = NULL;
   gint exit_status;
@@ -1388,8 +1386,8 @@ js_polkit_spawn (JSContext  *cx,
   SpawnData data = {0};
   guint n;
 
-  if (!JS_ConvertArguments (cx, js_argc, JS_ARGV (cx, vp), "o", &array_object))
-    goto out;
+  JS::CallArgs args = JS::CallArgsFromVp (js_argc, vp);
+  array_object = &args[0].toObject();
 
   if (!JS_GetArrayLength (cx, array_object, &array_len))
     {
@@ -1400,7 +1398,7 @@ js_polkit_spawn (JSContext  *cx,
   argv = g_new0 (gchar*, array_len + 1);
   for (n = 0; n < array_len; n++)
     {
-      JS::Value elem_val;
+      JS::RootedValue elem_val(cx);
       char *s;
 
       if (!JS_GetElement (cx, array_object, n, &elem_val))
@@ -1474,7 +1472,7 @@ js_polkit_spawn (JSContext  *cx,
   ret = true;
 
   ret_jsstr = JS_NewStringCopyZ (cx, standard_output);
-  JS_SET_RVAL (cx, vp, JS::StringValue (ret_jsstr));
+  args.rval ().setString (ret_jsstr);
 
  out:
   g_strfreev (argv);
@@ -1498,17 +1496,14 @@ js_polkit_user_is_in_netgroup (JSContext  *cx,
 {
   /* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
   bool ret = false;
-  JSString *user_str;
-  JSString *netgroup_str;
   char *user;
   char *netgroup;
   bool is_in_netgroup = false;
 
-  if (!JS_ConvertArguments (cx, argc, JS_ARGV (cx, vp), "SS", &user_str, &netgroup_str))
-    goto out;
+  JS::CallArgs args = JS::CallArgsFromVp (argc, vp);
 
-  user = JS_EncodeString (cx, user_str);
-  netgroup = JS_EncodeString (cx, netgroup_str);
+  user = JS_EncodeString (cx, args[0].toString());
+  netgroup = JS_EncodeString (cx, args[1].toString());
 
   if (innetgr (netgroup,
                NULL,  /* host */
@@ -1523,8 +1518,8 @@ js_polkit_user_is_in_netgroup (JSContext  *cx,
 
   ret = true;
 
-  JS_SET_RVAL (cx, vp, JS::BooleanValue (is_in_netgroup));
- out:
+  args.rval ().setBoolean (is_in_netgroup);
+
   return ret;
 }
 
commit cda7a100f38eb93e2ff1b93a1505ae33bb0c0cac
Author: Ray Strode <rstrode at redhat.com>
Date:   Fri Mar 23 11:03:52 2018 -0400

    jsauthority: stop using JS_GetStringCharsZ
    
    it's not around anymore.
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 80bf06e..686de3f 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1090,7 +1090,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
   JS::RootedValue rval(authority->priv->cx);
   guint n;
   GError *error = NULL;
-  JSString *ret_jsstr;
+  JS::RootedString ret_jsstr (authority->priv->cx);
   gchar *ret_str = NULL;
   gchar **ret_strs = NULL;
 
@@ -1137,10 +1137,10 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
     }
 
   ret_jsstr = rval.toString();
-  ret_str = g_utf16_to_utf8 (JS_GetStringCharsZ (authority->priv->cx, ret_jsstr), -1, NULL, NULL, NULL);
+  ret_str = JS_EncodeStringToUTF8 (authority->priv->cx, ret_jsstr);
   if (ret_str == NULL)
     {
-      g_warning ("Error converting resulting string to UTF-8: %s", error->message);
+      g_warning ("Error converting resulting string to UTF-8");
       goto out;
     }
 
@@ -1197,8 +1197,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
   JS::AutoValueArray<2> args(authority->priv->cx);
   JS::RootedValue rval(authority->priv->cx);
   GError *error = NULL;
-  JSString *ret_jsstr;
-  const jschar *ret_utf16;
+  JS::RootedString ret_jsstr (authority->priv->cx);
   gchar *ret_str = NULL;
   gboolean good = FALSE;
 
@@ -1252,12 +1251,10 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
     }
 
   ret_jsstr = rval.toString();
-  ret_utf16 = JS_GetStringCharsZ (authority->priv->cx, ret_jsstr);
-  ret_str = g_utf16_to_utf8 (ret_utf16, -1, NULL, NULL, &error);
+  ret_str = JS_EncodeStringToUTF8 (authority->priv->cx, ret_jsstr);
   if (ret_str == NULL)
     {
-      g_warning ("Error converting resulting string to UTF-8: %s", error->message);
-      g_clear_error (&error);
+      g_warning ("Error converting resulting string to UTF-8");
       goto out;
     }
 
commit 25242465c21fe7d3af1ed53f58e47e2e1728fa80
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: fix up set_property methods
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 022ba7c..80bf06e 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -660,66 +660,75 @@ polkit_backend_js_authority_class_init (PolkitBackendJsAuthorityClass *klass)
 /* authority->priv->cx must be within a request */
 static void
 set_property_str (PolkitBackendJsAuthority  *authority,
-                  JSObject                  *obj,
+                  JS::HandleObject           obj,
                   const gchar               *name,
                   const gchar               *value)
 {
-  JSString *value_jsstr;
-  JS::Value value_jsval;
-  value_jsstr = JS_NewStringCopyZ (authority->priv->cx, value);
-  value_jsval = JS::StringValue (value_jsstr);
-  JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
+  JS::RootedValue value_jsval(authority->priv->cx);
+  if (value)
+    {
+      JS::ConstUTF8CharsZ chars(value, strlen(value));
+      JS::RootedString str(authority->priv->cx, JS_NewStringCopyUTF8Z(authority->priv->cx, chars));
+      value_jsval = JS::StringValue (str);
+    }
+  else
+    value_jsval = JS::NullValue ();
+  JS_SetProperty (authority->priv->cx, obj, name, value_jsval);
 }
 
 /* authority->priv->cx must be within a request */
 static void
 set_property_strv (PolkitBackendJsAuthority  *authority,
-                   JSObject                  *obj,
+                   JS::HandleObject           obj,
                    const gchar               *name,
                    GPtrArray                 *value)
 {
-  JS::Value value_jsval;
-  JSObject *array_object;
+  JS::RootedValue value_jsval(authority->priv->cx);
+  JS::AutoValueVector elems(authority->priv->cx);
   guint n;
 
-  array_object = JS_NewArrayObject (authority->priv->cx, 0, NULL);
-
+  elems.resize(value->len);
   for (n = 0; n < value->len; n++)
     {
-      JSString *jsstr;
-      JS::Value val;
-
-      jsstr = JS_NewStringCopyZ (authority->priv->cx, (char *)g_ptr_array_index(value, n));
-      val = JS::StringValue (jsstr);
-      JS_SetElement (authority->priv->cx, array_object, n, &val);
+      const char *c_string = (const char *) g_ptr_array_index(value, n);
+      if (c_string)
+        {
+          JS::ConstUTF8CharsZ chars(c_string, strlen(c_string));
+          JS::RootedString str(authority->priv->cx, JS_NewStringCopyUTF8Z(authority->priv->cx, chars));
+          elems[n].setString(str);
+        }
+      else
+        elems[n].setNull ();
     }
 
+  JS::RootedObject array_object(authority->priv->cx, JS_NewArrayObject (authority->priv->cx, elems));
+
   value_jsval = JS::ObjectValue (*array_object);
-  JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
+  JS_SetProperty (authority->priv->cx, obj, name, value_jsval);
 }
 
 /* authority->priv->cx must be within a request */
 static void
 set_property_int32 (PolkitBackendJsAuthority  *authority,
-                    JSObject                  *obj,
+                    JS::HandleObject           obj,
                     const gchar               *name,
                     gint32                     value)
 {
-  JS::Value value_jsval;
-  value_jsval = INT_TO_JSVAL ((gint32) value);
-  JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
+  JS::RootedValue value_jsval(authority->priv->cx);
+  value_jsval = JS::Int32Value ((gint32) value);
+  JS_SetProperty (authority->priv->cx, obj, name, value_jsval);
 }
 
 /* authority->priv->cx must be within a request */
 static void
 set_property_bool (PolkitBackendJsAuthority  *authority,
-                   JSObject                  *obj,
+                   JS::HandleObject           obj,
                    const gchar               *name,
                    gboolean                   value)
 {
-  JS::Value value_jsval;
-  value_jsval = BOOLEAN_TO_JSVAL ((bool) value);
-  JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
+  JS::RootedValue value_jsval(authority->priv->cx);
+  value_jsval = JS::BooleanValue ((bool) value);
+  JS_SetProperty (authority->priv->cx, obj, name, value_jsval);
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
commit f564456063fc2e6554a8e764e0ad0414fb0577b2
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: use JS::Evaluate instead of JS_EvaluateScript
    
    JS_EvaluateScript is no longer in the API set, so use
    JS::Evaluate instead.
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index a19e926..022ba7c 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -507,12 +507,12 @@ polkit_backend_js_authority_constructed (GObject *object)
                              js_polkit_functions))
       goto fail;
 
-    if (!JS_EvaluateScript (authority->priv->cx,
-                            global,
-                            init_js, strlen (init_js), /* init.js */
-                            "init.js",  /* filename */
-                            0,     /* lineno */
-                            NULL)) /* rval */
+    JS::CompileOptions options(authority->priv->cx, JSVERSION_UNKNOWN);
+    JS::RootedValue rval(authority->priv->cx);
+    if (!JS::Evaluate (authority->priv->cx,
+                       options,
+                       init_js, strlen (init_js), /* init.js */
+                       &rval)) /* rval */
       {
         goto fail;
       }
@@ -731,11 +731,11 @@ subject_to_jsval (PolkitBackendJsAuthority  *authority,
                   PolkitIdentity            *user_for_subject,
                   gboolean                   subject_is_local,
                   gboolean                   subject_is_active,
-                  JS::Value                     *out_jsval,
+                  JS::MutableHandleValue     out_jsval,
                   GError                   **error)
 {
   gboolean ret = FALSE;
-  JS::Value ret_jsval;
+  JS::CompileOptions options(authority->priv->cx, JSVERSION_UNKNOWN);
   const char *src;
   JS::RootedObject obj(authority->priv->cx);
   pid_t pid;
@@ -748,17 +748,16 @@ subject_to_jsval (PolkitBackendJsAuthority  *authority,
   JS::RootedObject global(authority->priv->cx, authority->priv->js_global->get ());
 
   src = "new Subject();";
-  if (!JS_EvaluateScript (authority->priv->cx,
-                          global,
-                          src, strlen (src),
-                          __FILE__, __LINE__,
-                          &ret_jsval))
+  if (!JS::Evaluate (authority->priv->cx,
+                     options,
+                     src, strlen (src),
+                     out_jsval))
     {
       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Evaluating '%s' failed", src);
       goto out;
     }
 
-  obj = ret_jsval.toObjectOrNull();
+  obj = out_jsval.toObjectOrNull();
 
   if (POLKIT_IS_UNIX_PROCESS (subject))
     {
@@ -849,9 +848,6 @@ subject_to_jsval (PolkitBackendJsAuthority  *authority,
   if (groups != NULL)
     g_ptr_array_unref (groups);
 
-  if (ret && out_jsval != NULL)
-    *out_jsval = ret_jsval;
-
   return ret;
 }
 
@@ -862,11 +858,11 @@ static gboolean
 action_and_details_to_jsval (PolkitBackendJsAuthority  *authority,
                              const gchar               *action_id,
                              PolkitDetails             *details,
-                             JS::Value                     *out_jsval,
+                             JS::MutableHandleValue     out_jsval,
                              GError                   **error)
 {
   gboolean ret = FALSE;
-  JS::Value ret_jsval;
+  JS::CompileOptions options(authority->priv->cx, JSVERSION_UNKNOWN);
   const char *src;
   JS::RootedObject obj(authority->priv->cx);
   gchar **keys;
@@ -874,17 +870,17 @@ action_and_details_to_jsval (PolkitBackendJsAuthority  *authority,
   JS::RootedObject global(authority->priv->cx, authority->priv->js_global->get ());
 
   src = "new Action();";
-  if (!JS_EvaluateScript (authority->priv->cx,
-                          global,
-                          src, strlen (src),
-                          __FILE__, __LINE__,
-                          &ret_jsval))
+
+  if (!JS::Evaluate (authority->priv->cx,
+                     options,
+                     src, strlen (src),
+                     out_jsval))
     {
       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Evaluating '%s' failed", src);
       goto out;
     }
 
-  obj = ret_jsval.toObjectOrNull();
+  obj = out_jsval.toObjectOrNull();
 
   set_property_str (authority, obj, "id", action_id);
 
@@ -903,9 +899,6 @@ action_and_details_to_jsval (PolkitBackendJsAuthority  *authority,
   ret = TRUE;
 
  out:
-  if (ret && out_jsval != NULL)
-    *out_jsval = ret_jsval;
-
   return ret;
 }
 
commit 16e846bcde223fde0e063801976c3d661bc8f88a
Author: Ray Strode <rstrode at redhat.com>
Date:   Fri Mar 23 10:16:17 2018 -0400

    jsauthority: adapt arguments for new JS_ExecuteScript API
    
    JS_ExecuteScript no longer takes a global argument.
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index f20ec9d..a19e926 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1044,7 +1044,6 @@ execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
 
   runaway_killer_setup (authority);
   ret = JS_ExecuteScript (authority->priv->cx,
-                          authority->priv->js_global,
                           script,
                           rval);
   runaway_killer_teardown (authority);
commit 0b3c5d2a252d8873907833a8f8bb991fa758ac68
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: adapt arguments for new JS::Compile API
    
    The global object is implicit now and the result is an
    out arg.
    
    This commit adapts to the new api.
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 9bb6da8..f20ec9d 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -302,13 +302,8 @@ load_scripts (PolkitBackendJsAuthority  *authority)
       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);
       options.setUTF8(true);
-      script = JS::Compile (authority->priv->cx,
-                            obj, options,
-                            filename);
-
-      if (script == NULL)
+      if (!JS::Compile (authority->priv->cx, options, filename, &script))
         {
           polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
                                         "Error compiling script %s",
commit a6d5f53e048c742e52119c81be88113faef4248b
Author: Ray Strode <rstrode at redhat.com>
Date:   Fri Mar 23 10:16:17 2018 -0400

    jsauthority: root some locals to the context
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index be83df8..9bb6da8 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -317,7 +317,7 @@ load_scripts (PolkitBackendJsAuthority  *authority)
         }
 
       /* evaluate the script */
-      JS::Value rval;
+      JS::RootedValue rval(authority->priv->cx);
       if (!execute_script_with_runaway_killer (authority,
                                                script,
                                                &rval))
@@ -742,7 +742,7 @@ subject_to_jsval (PolkitBackendJsAuthority  *authority,
   gboolean ret = FALSE;
   JS::Value ret_jsval;
   const char *src;
-  JSObject *obj;
+  JS::RootedObject obj(authority->priv->cx);
   pid_t pid;
   uid_t uid;
   gchar *user_name = NULL;
@@ -873,7 +873,7 @@ action_and_details_to_jsval (PolkitBackendJsAuthority  *authority,
   gboolean ret = FALSE;
   JS::Value ret_jsval;
   const char *src;
-  JSObject *obj;
+  JS::RootedObject obj(authority->priv->cx);
   gchar **keys;
   guint n;
   JS::RootedObject global(authority->priv->cx, authority->priv->js_global->get ());
@@ -934,7 +934,7 @@ js_operation_callback (JSContext *cx)
 {
   PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx));
   JSString *val_str;
-  JS::Value val;
+  JS::RootedValue val(cx);
 
   /* This callback can be called by the runtime at any time without us causing
    * it by JS_TriggerOperationCallback().
commit ef9e2119e4e3f10b9842d14b8a51ef479073eb93
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: redo how global objects are set up
    
    This commit drops usage of JS_AddObjectRoot and switches
    the global object over to being wrapped in a JS::Heap
    pointer. It stops using JS_DefineObject which no longer
    seems to be available, and adds a new JS::FireOnNewGlobalHook
    which seems to be required.
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 830f5cd..be83df8 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -75,9 +75,9 @@ struct _PolkitBackendJsAuthorityPrivate
   GFileMonitor **dir_monitors; /* NULL-terminated array of GFileMonitor instances */
 
   JSContext *cx;
-  JSObject *js_global;
+  JS::Heap<JSObject*> *js_global;
   JSAutoCompartment *ac;
-  JSObject *js_polkit;
+  JS::Heap<JSObject*> *js_polkit;
 
   GThread *runaway_killer_thread;
   GMainContext *rkt_context;
@@ -478,38 +478,42 @@ polkit_backend_js_authority_constructed (GObject *object)
   {
     JS::CompartmentOptions compart_opts;
     compart_opts.behaviors().setVersion(JSVERSION_LATEST);
-    authority->priv->js_global = JS_NewGlobalObject (authority->priv->cx, &js_global_class, NULL, compart_opts);
+    JS::RootedObject global(authority->priv->cx);
 
-    if (authority->priv->js_global == NULL)
+    authority->priv->js_global = new JS::Heap<JSObject*> (JS_NewGlobalObject (authority->priv->cx, &js_global_class, NULL, JS::FireOnNewGlobalHook, compart_opts));
+
+    global = authority->priv->js_global->get ();
+
+    if (global == NULL)
       goto fail;
 
-    authority->priv->ac = new JSAutoCompartment(authority->priv->cx,  authority->priv->js_global);
+    authority->priv->ac = new JSAutoCompartment(authority->priv->cx,  global);
 
     if (authority->priv->ac == NULL)
       goto fail;
 
-    JS_AddObjectRoot (authority->priv->cx, &authority->priv->js_global);
+    if (!JS_InitStandardClasses (authority->priv->cx, global))
+      goto fail;
+
+    JS::RootedObject polkit(authority->priv->cx);
+
+    authority->priv->js_polkit = new JS::Heap<JSObject *> (JS_NewObject (authority->priv->cx, &js_polkit_class));
 
-    if (!JS_InitStandardClasses (authority->priv->cx, authority->priv->js_global))
+    polkit = authority->priv->js_polkit->get ();
+
+    if (polkit == NULL)
       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)
+    if (!JS_DefineProperty(authority->priv->cx, global, "polkit", polkit, JSPROP_ENUMERATE))
       goto fail;
-    JS_AddObjectRoot (authority->priv->cx, &authority->priv->js_polkit);
 
     if (!JS_DefineFunctions (authority->priv->cx,
-                             authority->priv->js_polkit,
+                             polkit,
                              js_polkit_functions))
       goto fail;
 
     if (!JS_EvaluateScript (authority->priv->cx,
-                            authority->priv->js_global,
+                            global,
                             init_js, strlen (init_js), /* init.js */
                             "init.js",  /* filename */
                             0,     /* lineno */
@@ -573,11 +577,7 @@ polkit_backend_js_authority_finalize (GObject *object)
   g_free (authority->priv->dir_monitors);
   g_strfreev (authority->priv->rules_dirs);
 
-  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);
 
   JS_DestroyContext (authority->priv->cx);
   /* JS_ShutDown (); */
@@ -750,10 +750,11 @@ subject_to_jsval (PolkitBackendJsAuthority  *authority,
   struct passwd *passwd;
   char *seat_str = NULL;
   char *session_str = NULL;
+  JS::RootedObject global(authority->priv->cx, authority->priv->js_global->get ());
 
   src = "new Subject();";
   if (!JS_EvaluateScript (authority->priv->cx,
-                          authority->priv->js_global,
+                          global,
                           src, strlen (src),
                           __FILE__, __LINE__,
                           &ret_jsval))
@@ -875,10 +876,11 @@ action_and_details_to_jsval (PolkitBackendJsAuthority  *authority,
   JSObject *obj;
   gchar **keys;
   guint n;
+  JS::RootedObject global(authority->priv->cx, authority->priv->js_global->get ());
 
   src = "new Action();";
   if (!JS_EvaluateScript (authority->priv->cx,
-                          authority->priv->js_global,
+                          global,
                           src, strlen (src),
                           __FILE__, __LINE__,
                           &ret_jsval))
commit fdf050f2672eb8bcab5d392a97ef8fba75c38267
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: use InterruptCallback api instead of OperationCallback
    
    seems like it got renamed.
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 2e26af9..830f5cd 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -950,11 +950,11 @@ js_operation_callback (JSContext *cx)
   polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Terminating runaway script");
 
   /* Throw an exception - this way the JS code can ignore the runaway script handling */
-  JS_SetOperationCallback (authority->priv->cx, NULL);
+  JS_ResetInterruptCallback (authority->priv->cx, TRUE);
   val_str = JS_NewStringCopyZ (cx, "Terminating runaway script");
   val = JS::StringValue (val_str);
   JS_SetPendingException (authority->priv->cx, val);
-  JS_SetOperationCallback (authority->priv->cx, js_operation_callback);
+  JS_ResetInterruptCallback (authority->priv->cx, FALSE);
   return false;
 }
 
@@ -968,7 +968,7 @@ rkt_on_timeout (gpointer user_data)
   g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex);
 
   /* Supposedly this is thread-safe... */
-  JS_TriggerOperationCallback (authority->priv->rt);
+  JS_RequestInterruptCallback (authority->priv->cx);
 
   /* keep source around so we keep trying to kill even if the JS bit catches the exception
    * thrown in js_operation_callback()
@@ -992,13 +992,15 @@ runaway_killer_setup (PolkitBackendJsAuthority *authority)
   /* ... rkt_on_timeout() will then poke the JSContext so js_operation_callback() is
    * called... and from there we throw an exception
    */
-  JS_SetOperationCallback (authority->priv->cx, js_operation_callback);
+  JS_AddInterruptCallback (authority->priv->cx, js_operation_callback);
+  JS_ResetInterruptCallback (authority->priv->cx, FALSE);
 }
 
 static void
 runaway_killer_teardown (PolkitBackendJsAuthority *authority)
 {
-  JS_SetOperationCallback (authority->priv->cx, NULL);
+  JS_ResetInterruptCallback (authority->priv->cx, TRUE);
+
   g_source_destroy (authority->priv->rkt_source);
   g_source_unref (authority->priv->rkt_source);
   authority->priv->rkt_source = NULL;
commit ecdcdb6e25da48d1b9074a711ecf375f1a46c8b8
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: Fix up JS_CallFunctionName invocations
    
    The way args are passed in changed.
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index e8fff15..2e26af9 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -91,8 +91,8 @@ struct _PolkitBackendJsAuthorityPrivate
 };
 
 static bool execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
-                                                  JSScript                 *script,
-                                                  JS::Value                    *rval);
+                                    JS::HandleScript                 script,
+                                    JS::MutableHandleValue           rval);
 
 static void utils_spawn (const gchar *const  *argv,
                          guint                timeout_seconds,
@@ -342,16 +342,18 @@ load_scripts (PolkitBackendJsAuthority  *authority)
 static void
 reload_scripts (PolkitBackendJsAuthority *authority)
 {
-  JS::Value argv[1] = {JS::NullValue()};
-  JS::Value rval = JS::NullValue();
-
   JS_BeginRequest (authority->priv->cx);
 
+  JS::AutoValueArray<1> args(authority->priv->cx);
+  JS::RootedValue rval(authority->priv->cx);
+
+  JS::RootedObject js_polkit(authority->priv->cx, authority->priv->js_polkit->get ());
+
+  args[0].setUndefined ();
   if (!JS_CallFunctionName(authority->priv->cx,
-                           authority->priv->js_polkit,
+                           js_polkit,
                            "_deleteRules",
-                           0,
-                           argv,
+                           args,
                            &rval))
     {
       polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
@@ -1036,8 +1038,8 @@ runaway_killer_terminate (PolkitBackendJsAuthority *authority)
 
 static bool
 execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
-                                    JSScript                 *script,
-                                    JS::Value                    *rval)
+                                    JS::HandleScript                 script,
+                                    JS::MutableHandleValue           rval)
 {
   bool ret;
 
@@ -1054,17 +1056,17 @@ execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
 static bool
 call_js_function_with_runaway_killer (PolkitBackendJsAuthority *authority,
                                       const char               *function_name,
-                                      unsigned                  argc,
-                                      JS::Value                    *argv,
-                                      JS::Value                    *rval)
+                                      const JS::HandleValueArray     &args,
+                                      JS::RootedValue          *rval)
 {
   bool ret;
+  JS::RootedObject js_polkit(authority->priv->cx, authority->priv->js_polkit->get ());
+
   runaway_killer_setup (authority);
   ret = JS_CallFunctionName(authority->priv->cx,
-                            authority->priv->js_polkit,
+                            js_polkit,
                             function_name,
-                            argc,
-                            argv,
+                            args,
                             rval);
   runaway_killer_teardown (authority);
   return ret;
@@ -1084,8 +1086,8 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
 {
   PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (_authority);
   GList *ret = NULL;
-  JS::Value argv[2] = {JS::NullValue(), JS::NullValue()};
-  JS::Value rval = JS::NullValue();
+  JS::AutoValueArray<2> args(authority->priv->cx);
+  JS::RootedValue rval(authority->priv->cx);
   guint n;
   GError *error = NULL;
   JSString *ret_jsstr;
@@ -1094,7 +1096,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
 
   JS_BeginRequest (authority->priv->cx);
 
-  if (!action_and_details_to_jsval (authority, action_id, details, &argv[0], &error))
+  if (!action_and_details_to_jsval (authority, action_id, details, args[0], &error))
     {
       polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
                                     "Error converting action and details to JS object: %s",
@@ -1108,7 +1110,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
                          user_for_subject,
                          subject_is_local,
                          subject_is_active,
-                         &argv[1],
+                         args[1],
                          &error))
     {
       polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
@@ -1120,8 +1122,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
 
   if (!call_js_function_with_runaway_killer (authority,
                                              "_runAdminRules",
-                                             G_N_ELEMENTS (argv),
-                                             argv,
+                                             args,
                                              &rval))
     {
       polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
@@ -1193,8 +1194,8 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
 {
   PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (_authority);
   PolkitImplicitAuthorization ret = implicit;
-  JS::Value argv[2] = {JS::NullValue(), JS::NullValue()};
-  JS::Value rval = JS::NullValue();
+  JS::AutoValueArray<2> args(authority->priv->cx);
+  JS::RootedValue rval(authority->priv->cx);
   GError *error = NULL;
   JSString *ret_jsstr;
   const jschar *ret_utf16;
@@ -1203,7 +1204,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
 
   JS_BeginRequest (authority->priv->cx);
 
-  if (!action_and_details_to_jsval (authority, action_id, details, &argv[0], &error))
+  if (!action_and_details_to_jsval (authority, action_id, details, args[0], &error))
     {
       polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
                                     "Error converting action and details to JS object: %s",
@@ -1217,7 +1218,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
                          user_for_subject,
                          subject_is_local,
                          subject_is_active,
-                         &argv[1],
+                         args[1],
                          &error))
     {
       polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
@@ -1229,8 +1230,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
 
   if (!call_js_function_with_runaway_killer (authority,
                                              "_runRules",
-                                             G_N_ELEMENTS (argv),
-                                             argv,
+                                             args,
                                              &rval))
     {
       polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
commit 55678d4abcc051ac50707b0bdee40da810443d7f
Author: Ray Strode <rstrode at redhat.com>
Date:   Fri Mar 23 10:48:44 2018 -0400

    jsauthority: JSVAL_IS_NULL (o) to o.isNull()
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 71394d7..e8fff15 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1238,7 +1238,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
       goto out;
     }
 
-  if (JSVAL_IS_NULL (rval))
+  if (rval.isNull())
     {
       /* this fine, means there was no match, use implicit authorizations */
       good = TRUE;
commit 04e696c3c812834ba07fb3673da4ee08e8106b0d
Author: Ray Strode <rstrode at redhat.com>
Date:   Fri Mar 23 10:48:44 2018 -0400

    jsauthority: JSVAL_IS_STRING (s) to s.isString()
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index bc33a59..71394d7 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1129,7 +1129,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
       goto out;
     }
 
-  if (!JSVAL_IS_STRING (rval))
+  if (!rval.isString())
     {
       g_warning ("Expected a string");
       goto out;
@@ -1245,7 +1245,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
       goto out;
     }
 
-  if (!JSVAL_IS_STRING (rval))
+  if (!rval.isString())
     {
       g_warning ("Expected a string");
       goto out;
@@ -1411,7 +1411,7 @@ js_polkit_spawn (JSContext  *cx,
           JS_ReportErrorUTF8 (cx, "Failed to get element %d", n);
           goto out;
         }
-      if (!JSVAL_IS_STRING (elem_val))
+      if (!elem_val.isString())
 	{
           JS_ReportErrorUTF8 (cx, "Element %d is not a string", n);
           goto out;
commit 2fe43b5d3bb8f5277ae647b278363f9bb8e69083
Author: Ray Strode <rstrode at redhat.com>
Date:   Fri Mar 23 10:48:44 2018 -0400

    jsauthority: JSVAL_TO_STRING (s) to s.toString()
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 1b36703..bc33a59 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1135,7 +1135,7 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
       goto out;
     }
 
-  ret_jsstr = JSVAL_TO_STRING (rval);
+  ret_jsstr = rval.toString();
   ret_str = g_utf16_to_utf8 (JS_GetStringCharsZ (authority->priv->cx, ret_jsstr), -1, NULL, NULL, NULL);
   if (ret_str == NULL)
     {
@@ -1251,7 +1251,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
       goto out;
     }
 
-  ret_jsstr = JSVAL_TO_STRING (rval);
+  ret_jsstr = rval.toString();
   ret_utf16 = JS_GetStringCharsZ (authority->priv->cx, ret_jsstr);
   ret_str = g_utf16_to_utf8 (ret_utf16, -1, NULL, NULL, &error);
   if (ret_str == NULL)
@@ -1416,7 +1416,7 @@ js_polkit_spawn (JSContext  *cx,
           JS_ReportErrorUTF8 (cx, "Element %d is not a string", n);
           goto out;
 	}
-      s = JS_EncodeString (cx, JSVAL_TO_STRING (elem_val));
+      s = JS_EncodeString (cx, elem_val.toString());
       argv[n] = g_strdup (s);
       JS_free (cx, s);
     }
commit ff675a5ba3505df7d70200c715ff5c4a14faaa8b
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: JSVAL_TO_OBJECT (o) to o.toObjectOrNull()
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 16d3645..1b36703 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -760,7 +760,7 @@ subject_to_jsval (PolkitBackendJsAuthority  *authority,
       goto out;
     }
 
-  obj = JSVAL_TO_OBJECT (ret_jsval);
+  obj = ret_jsval.toObjectOrNull();
 
   if (POLKIT_IS_UNIX_PROCESS (subject))
     {
@@ -885,7 +885,7 @@ action_and_details_to_jsval (PolkitBackendJsAuthority  *authority,
       goto out;
     }
 
-  obj = JSVAL_TO_OBJECT (ret_jsval);
+  obj = ret_jsval.toObjectOrNull();
 
   set_property_str (authority, obj, "id", action_id);
 
commit cdcc2ccb5a7fc6514b58e7ffaa9438440bdb4559
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: s/BOOLEAN_TO_JSVAL/JS::BooleanValue/
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 7c74d83..16d3645 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1526,7 +1526,7 @@ js_polkit_user_is_in_netgroup (JSContext  *cx,
 
   ret = true;
 
-  JS_SET_RVAL (cx, vp, BOOLEAN_TO_JSVAL (is_in_netgroup));
+  JS_SET_RVAL (cx, vp, JS::BooleanValue (is_in_netgroup));
  out:
   return ret;
 }
commit 884d22a8a5128291a0601d52860be26396a3fc1d
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: s/STRING_TO_JSVAL/JS::StringValue/
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 5bbf125..7c74d83 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -670,7 +670,7 @@ set_property_str (PolkitBackendJsAuthority  *authority,
   JSString *value_jsstr;
   JS::Value value_jsval;
   value_jsstr = JS_NewStringCopyZ (authority->priv->cx, value);
-  value_jsval = STRING_TO_JSVAL (value_jsstr);
+  value_jsval = JS::StringValue (value_jsstr);
   JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
 }
 
@@ -693,7 +693,7 @@ set_property_strv (PolkitBackendJsAuthority  *authority,
       JS::Value val;
 
       jsstr = JS_NewStringCopyZ (authority->priv->cx, (char *)g_ptr_array_index(value, n));
-      val = STRING_TO_JSVAL (jsstr);
+      val = JS::StringValue (jsstr);
       JS_SetElement (authority->priv->cx, array_object, n, &val);
     }
 
@@ -950,7 +950,7 @@ js_operation_callback (JSContext *cx)
   /* Throw an exception - this way the JS code can ignore the runaway script handling */
   JS_SetOperationCallback (authority->priv->cx, NULL);
   val_str = JS_NewStringCopyZ (cx, "Terminating runaway script");
-  val = STRING_TO_JSVAL (val_str);
+  val = JS::StringValue (val_str);
   JS_SetPendingException (authority->priv->cx, val);
   JS_SetOperationCallback (authority->priv->cx, js_operation_callback);
   return false;
@@ -1477,7 +1477,7 @@ js_polkit_spawn (JSContext  *cx,
   ret = true;
 
   ret_jsstr = JS_NewStringCopyZ (cx, standard_output);
-  JS_SET_RVAL (cx, vp, STRING_TO_JSVAL (ret_jsstr));
+  JS_SET_RVAL (cx, vp, JS::StringValue (ret_jsstr));
 
  out:
   g_strfreev (argv);
commit 5c0fbed84bd235d019eda2de33f0d4a3be5f7006
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: s/OBJECT_TO_JSVAL/JS::ObjectValue/
    
    This commit does a global search and replace
    for OBJECT_TO_JSVAL to JS::ObjectValue()
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index cef1b1a..5bbf125 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -697,7 +697,7 @@ set_property_strv (PolkitBackendJsAuthority  *authority,
       JS_SetElement (authority->priv->cx, array_object, n, &val);
     }
 
-  value_jsval = OBJECT_TO_JSVAL (array_object);
+  value_jsval = JS::ObjectValue (*array_object);
   JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
 }
 
commit c91a99e6591b1e75e596566215eed76584f0c77a
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: s/JSVAL_VOID/JS::UndefinedValue()/
    
    This commit does a global search and replace
    for JSVAL_VOID to JS::UndefinedValue()
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index eb22597..cef1b1a 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1305,7 +1305,7 @@ js_polkit_log (JSContext  *cx,
 
   ret = true;
 
-  JS_SET_RVAL (cx, vp, JSVAL_VOID);  /* return undefined */
+  JS_SET_RVAL (cx, vp, JS::UndefinedValue());  /* return undefined */
  out:
   return ret;
 }
commit dbd710c12ec60a2256ab0ffc95f4a94d2b5c5ee4
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: s/JSVAL_NULL/JS::NullValue()/
    
    This commit does a global search and replace
    for JSVAL_NULL to JS::NullValue()
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 73251a8..eb22597 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -342,8 +342,8 @@ load_scripts (PolkitBackendJsAuthority  *authority)
 static void
 reload_scripts (PolkitBackendJsAuthority *authority)
 {
-  JS::Value argv[1] = {JSVAL_NULL};
-  JS::Value rval = JSVAL_NULL;
+  JS::Value argv[1] = {JS::NullValue()};
+  JS::Value rval = JS::NullValue();
 
   JS_BeginRequest (authority->priv->cx);
 
@@ -1084,8 +1084,8 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
 {
   PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (_authority);
   GList *ret = NULL;
-  JS::Value argv[2] = {JSVAL_NULL, JSVAL_NULL};
-  JS::Value rval = JSVAL_NULL;
+  JS::Value argv[2] = {JS::NullValue(), JS::NullValue()};
+  JS::Value rval = JS::NullValue();
   guint n;
   GError *error = NULL;
   JSString *ret_jsstr;
@@ -1193,8 +1193,8 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
 {
   PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (_authority);
   PolkitImplicitAuthorization ret = implicit;
-  JS::Value argv[2] = {JSVAL_NULL, JSVAL_NULL};
-  JS::Value rval = JSVAL_NULL;
+  JS::Value argv[2] = {JS::NullValue(), JS::NullValue()};
+  JS::Value rval = JS::NullValue();
   GError *error = NULL;
   JSString *ret_jsstr;
   const jschar *ret_utf16;
commit 2f39096f2d819e846e95dfbe4292a2ca0f6236bd
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: s/jsval/JS::Value/
    
    The API got renamed in mozjs31.
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 5777dab..73251a8 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -92,7 +92,7 @@ struct _PolkitBackendJsAuthorityPrivate
 
 static bool execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
                                                   JSScript                 *script,
-                                                  jsval                    *rval);
+                                                  JS::Value                    *rval);
 
 static void utils_spawn (const gchar *const  *argv,
                          guint                timeout_seconds,
@@ -192,9 +192,9 @@ static JSClass js_polkit_class = {
   &js_polkit_class_ops
 };
 
-static bool js_polkit_log (JSContext *cx, unsigned argc, jsval *vp);
-static bool js_polkit_spawn (JSContext *cx, unsigned argc, jsval *vp);
-static bool js_polkit_user_is_in_netgroup (JSContext *cx, unsigned argc, jsval *vp);
+static bool js_polkit_log (JSContext *cx, unsigned argc, JS::Value *vp);
+static bool js_polkit_spawn (JSContext *cx, unsigned argc, JS::Value *vp);
+static bool js_polkit_user_is_in_netgroup (JSContext *cx, unsigned argc, JS::Value *vp);
 
 static JSFunctionSpec js_polkit_functions[] =
 {
@@ -317,7 +317,7 @@ load_scripts (PolkitBackendJsAuthority  *authority)
         }
 
       /* evaluate the script */
-      jsval rval;
+      JS::Value rval;
       if (!execute_script_with_runaway_killer (authority,
                                                script,
                                                &rval))
@@ -342,8 +342,8 @@ load_scripts (PolkitBackendJsAuthority  *authority)
 static void
 reload_scripts (PolkitBackendJsAuthority *authority)
 {
-  jsval argv[1] = {JSVAL_NULL};
-  jsval rval = JSVAL_NULL;
+  JS::Value argv[1] = {JSVAL_NULL};
+  JS::Value rval = JSVAL_NULL;
 
   JS_BeginRequest (authority->priv->cx);
 
@@ -668,7 +668,7 @@ set_property_str (PolkitBackendJsAuthority  *authority,
                   const gchar               *value)
 {
   JSString *value_jsstr;
-  jsval value_jsval;
+  JS::Value value_jsval;
   value_jsstr = JS_NewStringCopyZ (authority->priv->cx, value);
   value_jsval = STRING_TO_JSVAL (value_jsstr);
   JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
@@ -681,7 +681,7 @@ set_property_strv (PolkitBackendJsAuthority  *authority,
                    const gchar               *name,
                    GPtrArray                 *value)
 {
-  jsval value_jsval;
+  JS::Value value_jsval;
   JSObject *array_object;
   guint n;
 
@@ -690,7 +690,7 @@ set_property_strv (PolkitBackendJsAuthority  *authority,
   for (n = 0; n < value->len; n++)
     {
       JSString *jsstr;
-      jsval val;
+      JS::Value val;
 
       jsstr = JS_NewStringCopyZ (authority->priv->cx, (char *)g_ptr_array_index(value, n));
       val = STRING_TO_JSVAL (jsstr);
@@ -708,7 +708,7 @@ set_property_int32 (PolkitBackendJsAuthority  *authority,
                     const gchar               *name,
                     gint32                     value)
 {
-  jsval value_jsval;
+  JS::Value value_jsval;
   value_jsval = INT_TO_JSVAL ((gint32) value);
   JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
 }
@@ -720,7 +720,7 @@ set_property_bool (PolkitBackendJsAuthority  *authority,
                    const gchar               *name,
                    gboolean                   value)
 {
-  jsval value_jsval;
+  JS::Value value_jsval;
   value_jsval = BOOLEAN_TO_JSVAL ((bool) value);
   JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
 }
@@ -734,11 +734,11 @@ subject_to_jsval (PolkitBackendJsAuthority  *authority,
                   PolkitIdentity            *user_for_subject,
                   gboolean                   subject_is_local,
                   gboolean                   subject_is_active,
-                  jsval                     *out_jsval,
+                  JS::Value                     *out_jsval,
                   GError                   **error)
 {
   gboolean ret = FALSE;
-  jsval ret_jsval;
+  JS::Value ret_jsval;
   const char *src;
   JSObject *obj;
   pid_t pid;
@@ -864,11 +864,11 @@ static gboolean
 action_and_details_to_jsval (PolkitBackendJsAuthority  *authority,
                              const gchar               *action_id,
                              PolkitDetails             *details,
-                             jsval                     *out_jsval,
+                             JS::Value                     *out_jsval,
                              GError                   **error)
 {
   gboolean ret = FALSE;
-  jsval ret_jsval;
+  JS::Value ret_jsval;
   const char *src;
   JSObject *obj;
   gchar **keys;
@@ -930,7 +930,7 @@ js_operation_callback (JSContext *cx)
 {
   PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx));
   JSString *val_str;
-  jsval val;
+  JS::Value val;
 
   /* This callback can be called by the runtime at any time without us causing
    * it by JS_TriggerOperationCallback().
@@ -1037,7 +1037,7 @@ runaway_killer_terminate (PolkitBackendJsAuthority *authority)
 static bool
 execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
                                     JSScript                 *script,
-                                    jsval                    *rval)
+                                    JS::Value                    *rval)
 {
   bool ret;
 
@@ -1055,8 +1055,8 @@ static bool
 call_js_function_with_runaway_killer (PolkitBackendJsAuthority *authority,
                                       const char               *function_name,
                                       unsigned                  argc,
-                                      jsval                    *argv,
-                                      jsval                    *rval)
+                                      JS::Value                    *argv,
+                                      JS::Value                    *rval)
 {
   bool ret;
   runaway_killer_setup (authority);
@@ -1084,8 +1084,8 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA
 {
   PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (_authority);
   GList *ret = NULL;
-  jsval argv[2] = {JSVAL_NULL, JSVAL_NULL};
-  jsval rval = JSVAL_NULL;
+  JS::Value argv[2] = {JSVAL_NULL, JSVAL_NULL};
+  JS::Value rval = JSVAL_NULL;
   guint n;
   GError *error = NULL;
   JSString *ret_jsstr;
@@ -1193,8 +1193,8 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
 {
   PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (_authority);
   PolkitImplicitAuthorization ret = implicit;
-  jsval argv[2] = {JSVAL_NULL, JSVAL_NULL};
-  jsval rval = JSVAL_NULL; 
+  JS::Value argv[2] = {JSVAL_NULL, JSVAL_NULL};
+  JS::Value rval = JSVAL_NULL;
   GError *error = NULL;
   JSString *ret_jsstr;
   const jschar *ret_utf16;
@@ -1289,7 +1289,7 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
 static bool
 js_polkit_log (JSContext  *cx,
                unsigned    argc,
-               jsval      *vp)
+               JS::Value      *vp)
 {
   /* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
   bool ret = false;
@@ -1374,7 +1374,7 @@ spawn_cb (GObject       *source_object,
 static bool
 js_polkit_spawn (JSContext  *cx,
                  unsigned    js_argc,
-                 jsval      *vp)
+                 JS::Value      *vp)
 {
   /* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
   bool ret = false;
@@ -1403,7 +1403,7 @@ js_polkit_spawn (JSContext  *cx,
   argv = g_new0 (gchar*, array_len + 1);
   for (n = 0; n < array_len; n++)
     {
-      jsval elem_val;
+      JS::Value elem_val;
       char *s;
 
       if (!JS_GetElement (cx, array_object, n, &elem_val))
@@ -1497,7 +1497,7 @@ js_polkit_spawn (JSContext  *cx,
 static bool
 js_polkit_user_is_in_netgroup (JSContext  *cx,
                                unsigned    argc,
-                               jsval      *vp)
+                               JS::Value      *vp)
 {
   /* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
   bool ret = false;
commit 3561d4074988887b640d7167ba9a3c04c2fa0091
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: s/JSBool/bool/
    
    It's been gone since mozjs31
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 7c2d032..5777dab 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -90,7 +90,7 @@ struct _PolkitBackendJsAuthorityPrivate
   GList *scripts;
 };
 
-static JSBool execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
+static bool execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
                                                   JSScript                 *script,
                                                   jsval                    *rval);
 
@@ -192,9 +192,9 @@ static JSClass js_polkit_class = {
   &js_polkit_class_ops
 };
 
-static JSBool js_polkit_log (JSContext *cx, unsigned argc, jsval *vp);
-static JSBool js_polkit_spawn (JSContext *cx, unsigned argc, jsval *vp);
-static JSBool js_polkit_user_is_in_netgroup (JSContext *cx, unsigned argc, jsval *vp);
+static bool js_polkit_log (JSContext *cx, unsigned argc, jsval *vp);
+static bool js_polkit_spawn (JSContext *cx, unsigned argc, jsval *vp);
+static bool js_polkit_user_is_in_netgroup (JSContext *cx, unsigned argc, jsval *vp);
 
 static JSFunctionSpec js_polkit_functions[] =
 {
@@ -721,7 +721,7 @@ set_property_bool (PolkitBackendJsAuthority  *authority,
                    gboolean                   value)
 {
   jsval value_jsval;
-  value_jsval = BOOLEAN_TO_JSVAL ((JSBool) value);
+  value_jsval = BOOLEAN_TO_JSVAL ((bool) value);
   JS_SetProperty (authority->priv->cx, obj, name, &value_jsval);
 }
 
@@ -925,7 +925,7 @@ runaway_killer_thread_func (gpointer user_data)
 
 /* ---------------------------------------------------------------------------------------------------- */
 
-static JSBool
+static bool
 js_operation_callback (JSContext *cx)
 {
   PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx));
@@ -939,7 +939,7 @@ js_operation_callback (JSContext *cx)
   if (!authority->priv->rkt_timeout_pending)
     {
       g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex);
-      return JS_TRUE;
+      return true;
     }
   authority->priv->rkt_timeout_pending = FALSE;
   g_mutex_unlock (&authority->priv->rkt_timeout_pending_mutex);
@@ -953,7 +953,7 @@ js_operation_callback (JSContext *cx)
   val = STRING_TO_JSVAL (val_str);
   JS_SetPendingException (authority->priv->cx, val);
   JS_SetOperationCallback (authority->priv->cx, js_operation_callback);
-  return JS_FALSE;
+  return false;
 }
 
 static gboolean
@@ -1034,12 +1034,12 @@ runaway_killer_terminate (PolkitBackendJsAuthority *authority)
   g_thread_join (authority->priv->runaway_killer_thread);
 }
 
-static JSBool
+static bool
 execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
                                     JSScript                 *script,
                                     jsval                    *rval)
 {
-  JSBool ret;
+  bool ret;
 
   runaway_killer_setup (authority);
   ret = JS_ExecuteScript (authority->priv->cx,
@@ -1051,14 +1051,14 @@ execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
   return ret;
 }
 
-static JSBool
+static bool
 call_js_function_with_runaway_killer (PolkitBackendJsAuthority *authority,
                                       const char               *function_name,
                                       unsigned                  argc,
                                       jsval                    *argv,
                                       jsval                    *rval)
 {
-  JSBool ret;
+  bool ret;
   runaway_killer_setup (authority);
   ret = JS_CallFunctionName(authority->priv->cx,
                             authority->priv->js_polkit,
@@ -1286,13 +1286,13 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
 
 /* ---------------------------------------------------------------------------------------------------- */
 
-static JSBool
+static bool
 js_polkit_log (JSContext  *cx,
                unsigned    argc,
                jsval      *vp)
 {
   /* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
-  JSBool ret = JS_FALSE;
+  bool ret = false;
   JSString *str;
   char *s;
 
@@ -1303,7 +1303,7 @@ js_polkit_log (JSContext  *cx,
   JS_ReportWarningUTF8 (cx, s);
   JS_free (cx, s);
 
-  ret = JS_TRUE;
+  ret = true;
 
   JS_SET_RVAL (cx, vp, JSVAL_VOID);  /* return undefined */
  out:
@@ -1371,13 +1371,13 @@ spawn_cb (GObject       *source_object,
   g_main_loop_quit (data->loop);
 }
 
-static JSBool
+static bool
 js_polkit_spawn (JSContext  *cx,
                  unsigned    js_argc,
                  jsval      *vp)
 {
   /* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
-  JSBool ret = JS_FALSE;
+  bool ret = false;
   JSObject *array_object;
   gchar *standard_output = NULL;
   gchar *standard_error = NULL;
@@ -1474,7 +1474,7 @@ js_polkit_spawn (JSContext  *cx,
       goto out;
     }
 
-  ret = JS_TRUE;
+  ret = true;
 
   ret_jsstr = JS_NewStringCopyZ (cx, standard_output);
   JS_SET_RVAL (cx, vp, STRING_TO_JSVAL (ret_jsstr));
@@ -1494,18 +1494,18 @@ js_polkit_spawn (JSContext  *cx,
 /* ---------------------------------------------------------------------------------------------------- */
 
 
-static JSBool
+static bool
 js_polkit_user_is_in_netgroup (JSContext  *cx,
                                unsigned    argc,
                                jsval      *vp)
 {
   /* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
-  JSBool ret = JS_FALSE;
+  bool ret = false;
   JSString *user_str;
   JSString *netgroup_str;
   char *user;
   char *netgroup;
-  JSBool is_in_netgroup = JS_FALSE;
+  bool is_in_netgroup = false;
 
   if (!JS_ConvertArguments (cx, argc, JS_ARGV (cx, vp), "SS", &user_str, &netgroup_str))
     goto out;
@@ -1518,13 +1518,13 @@ js_polkit_user_is_in_netgroup (JSContext  *cx,
                user,
                NULL)) /* domain */
     {
-      is_in_netgroup =  JS_TRUE;
+      is_in_netgroup =  true;
     }
 
   JS_free (cx, netgroup);
   JS_free (cx, user);
 
-  ret = JS_TRUE;
+  ret = true;
 
   JS_SET_RVAL (cx, vp, BOOLEAN_TO_JSVAL (is_in_netgroup));
  out:
commit ebf152027cd5b39598c9a5f237f5fd17551a2ef2
Author: Ray Strode <rstrode at redhat.com>
Date:   Wed Mar 28 15:28:28 2018 -0400

    jsauthority: pass "%s" format string to report functions
    
    This just avoids the potential for security problems down the line.
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index e8714cf..7c2d032 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1469,7 +1469,7 @@ js_polkit_spawn (JSContext  *cx,
         }
       g_string_append_printf (gstr, ", stdout=`%s', stderr=`%s'",
                               standard_output, standard_error);
-      JS_ReportErrorUTF8 (cx, gstr->str);
+      JS_ReportErrorUTF8 (cx, "%s", gstr->str);
       g_string_free (gstr, TRUE);
       goto out;
     }
commit 4334feaacedabf828dbd82ec9c12a15a4727bd46
Author: Ray Strode <rstrode at redhat.com>
Date:   Fri Mar 23 10:48:44 2018 -0400

    jsauthority: add UTF8 suffix to renamed functions
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index a3a21f1..e8714cf 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1300,7 +1300,7 @@ js_polkit_log (JSContext  *cx,
     goto out;
 
   s = JS_EncodeString (cx, str);
-  JS_ReportWarning (cx, s);
+  JS_ReportWarningUTF8 (cx, s);
   JS_free (cx, s);
 
   ret = JS_TRUE;
@@ -1396,7 +1396,7 @@ js_polkit_spawn (JSContext  *cx,
 
   if (!JS_GetArrayLength (cx, array_object, &array_len))
     {
-      JS_ReportError (cx, "Failed to get array length");
+      JS_ReportErrorUTF8 (cx, "Failed to get array length");
       goto out;
     }
 
@@ -1408,12 +1408,12 @@ js_polkit_spawn (JSContext  *cx,
 
       if (!JS_GetElement (cx, array_object, n, &elem_val))
         {
-          JS_ReportError (cx, "Failed to get element %d", n);
+          JS_ReportErrorUTF8 (cx, "Failed to get element %d", n);
           goto out;
         }
       if (!JSVAL_IS_STRING (elem_val))
 	{
-          JS_ReportError (cx, "Element %d is not a string", n);
+          JS_ReportErrorUTF8 (cx, "Element %d is not a string", n);
           goto out;
 	}
       s = JS_EncodeString (cx, JSVAL_TO_STRING (elem_val));
@@ -1443,7 +1443,7 @@ js_polkit_spawn (JSContext  *cx,
                            &standard_error,
                            &error))
     {
-      JS_ReportError (cx,
+      JS_ReportErrorUTF8 (cx,
                       "Error spawning helper: %s (%s, %d)",
                       error->message, g_quark_to_string (error->domain), error->code);
       g_clear_error (&error);
@@ -1469,7 +1469,7 @@ js_polkit_spawn (JSContext  *cx,
         }
       g_string_append_printf (gstr, ", stdout=`%s', stderr=`%s'",
                               standard_output, standard_error);
-      JS_ReportError (cx, gstr->str);
+      JS_ReportErrorUTF8 (cx, gstr->str);
       g_string_free (gstr, TRUE);
       goto out;
     }
commit 5c18293aa2ce39b5dc857cf227e309d221fcb768
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: JS::SetWarningReporter instead of JS_SetErrorReporter
    
    This commit changes the code to use JS::SetWarningReporter instead
    of JS_SetErrorReporter.  The latter, as far as I can tell, is
    just a slightly renamed version of the former with the args moved
    around a little bit.
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 394e743..a3a21f1 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -207,7 +207,6 @@ static JSFunctionSpec js_polkit_functions[] =
 /* ---------------------------------------------------------------------------------------------------- */
 
 static void report_error (JSContext     *cx,
-                          const char    *message,
                           JSErrorReport *report)
 {
   PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx));
@@ -215,7 +214,7 @@ static void report_error (JSContext     *cx,
                                 "%s:%u: %s",
                                 report->filename ? report->filename : "<no filename>",
                                 (unsigned int) report->lineno,
-                                message);
+                                report->message().c_str());
 }
 
 static void
@@ -468,7 +467,7 @@ polkit_backend_js_authority_constructed (GObject *object)
       .setIon (FALSE)
       .setBaseline (FALSE)
       .setAsmJS (FALSE);
-  JS_SetErrorReporter(authority->priv->cx, report_error);
+  JS::SetWarningReporter(authority->priv->cx, report_error);
   JS_SetContextPrivate (authority->priv->cx, authority);
 
   JS_BeginRequest(authority->priv->cx);
commit 1ac9c65ed049120cb2f4685ca92f6a55687a82f9
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: change how JIT is disabled
    
    JS_SetOptions seems to be replaced with JS::ContextOptionsRef now.
    Also, disabling the JIT seems to be three options now instead of just
    one.
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 9fe151b..394e743 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -464,9 +464,10 @@ polkit_backend_js_authority_constructed (GObject *object)
   /* TODO: JIT'ing doesn't work will with killing runaway scripts... I think
    *       this is just a SpiderMonkey bug. So disable the JIT for now.
    */
-  JS_SetOptions (authority->priv->cx,
-                 JSOPTION_VAROBJFIX
-                 /* | JSOPTION_JIT | JSOPTION_METHODJIT*/);
+  JS::ContextOptionsRef (authority->priv->cx)
+      .setIon (FALSE)
+      .setBaseline (FALSE)
+      .setAsmJS (FALSE);
   JS_SetErrorReporter(authority->priv->cx, report_error);
   JS_SetContextPrivate (authority->priv->cx, authority);
 
commit 32347fb54b27de7a3ac3216ac306b86e69ce572b
Author: Ray Strode <rstrode at redhat.com>
Date:   Fri Mar 23 15:22:59 2018 -0400

    jsauthority: call JS_InitSelfHostedCode
    
    This is now required
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 7e98adb..9fe151b 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -458,6 +458,9 @@ polkit_backend_js_authority_constructed (GObject *object)
   if (authority->priv->cx == NULL)
     goto fail;
 
+  if (!JS::InitSelfHostedCode (authority->priv->cx))
+    goto fail;
+
   /* TODO: JIT'ing doesn't work will with killing runaway scripts... I think
    *       this is just a SpiderMonkey bug. So disable the JIT for now.
    */
commit 4ad5a4aaf77d1763526ae85c29986160473645f7
Author: Ray Strode <rstrode at redhat.com>
Date:   Fri Mar 23 15:22:59 2018 -0400

    jsauthority: call JS_Init
    
    This is now required
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 5a5fd5e..7e98adb 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -43,6 +43,7 @@
 #include <systemd/sd-login.h>
 #endif /* HAVE_LIBSYSTEMD */
 
+#include <js/Initialization.h>
 #include <jsapi.h>
 
 #include "initjs.h" /* init.js */
@@ -650,6 +651,8 @@ polkit_backend_js_authority_class_init (PolkitBackendJsAuthorityClass *klass)
 
 
   g_type_class_add_private (klass, sizeof (PolkitBackendJsAuthorityPrivate));
+
+  JS_Init ();
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
commit 9865ad93b654c3e1907296e5d78f274145204712
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: change how setVersion is called
    
    it's now part of a behaviors method in CompartmentOptions
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 7bcfda9..5a5fd5e 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -471,7 +471,7 @@ polkit_backend_js_authority_constructed (GObject *object)
 
   {
     JS::CompartmentOptions compart_opts;
-    compart_opts.setVersion(JSVERSION_LATEST);
+    compart_opts.behaviors().setVersion(JSVERSION_LATEST);
     authority->priv->js_global = JS_NewGlobalObject (authority->priv->cx, &js_global_class, NULL, compart_opts);
 
     if (authority->priv->js_global == NULL)
commit 473ebe9e4aa39d81525ae5e4fb3df8202f074b5b
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: get rid of JSRuntime
    
    Seems like JSContext is the only thing that matters now.
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 3706470..7bcfda9 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -73,7 +73,6 @@ struct _PolkitBackendJsAuthorityPrivate
   gchar **rules_dirs;
   GFileMonitor **dir_monitors; /* NULL-terminated array of GFileMonitor instances */
 
-  JSRuntime *rt;
   JSContext *cx;
   JSObject *js_global;
   JSAutoCompartment *ac;
@@ -362,7 +361,7 @@ reload_scripts (PolkitBackendJsAuthority *authority)
 
   polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
                                 "Collecting garbage unconditionally...");
-  JS_GC (authority->priv->rt);
+  JS_GC (authority->priv->cx);
 
   load_scripts (authority);
 
@@ -454,11 +453,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, JS_USE_HELPER_THREADS);
-  if (authority->priv->rt == NULL)
-    goto fail;
-
-  authority->priv->cx = JS_NewContext (authority->priv->rt, 8192);
+  authority->priv->cx = JS_NewContext (8L * 1024L * 1024L);
   if (authority->priv->cx == NULL)
     goto fail;
 
@@ -579,7 +574,6 @@ polkit_backend_js_authority_finalize (GObject *object)
   JS_EndRequest (authority->priv->cx);
 
   JS_DestroyContext (authority->priv->cx);
-  JS_DestroyRuntime (authority->priv->rt);
   /* JS_ShutDown (); */
 
   G_OBJECT_CLASS (polkit_backend_js_authority_parent_class)->finalize (object);
commit bc16389c434485eff691f50638df25f752990d5d
Author: Ray Strode <rstrode at redhat.com>
Date:   Fri Mar 23 16:28:42 2018 -0400

    jsauthority: use JS_FN instead of JS_FS
    
    since it doesn't crash if i do that
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 384ea79..3706470 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -198,9 +198,9 @@ static JSBool js_polkit_user_is_in_netgroup (JSContext *cx, unsigned argc, jsval
 
 static JSFunctionSpec js_polkit_functions[] =
 {
-  JS_FS("log",            js_polkit_log,            0, 0),
-  JS_FS("spawn",          js_polkit_spawn,          0, 0),
-  JS_FS("_userIsInNetGroup", js_polkit_user_is_in_netgroup,          0, 0),
+  JS_FN("log",            js_polkit_log,            0, 0),
+  JS_FN("spawn",          js_polkit_spawn,          0, 0),
+  JS_FN("_userIsInNetGroup", js_polkit_user_is_in_netgroup,          0, 0),
   JS_FS_END
 };
 
commit 0e5762a48df91b127f6976a1adb4df7bfa24d1b2
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 13:00:33 2018 -0400

    jsauthority: fix how classes are defined
    
    mozjs no longer has public stub functions that implementers of
    JSClass objects are supposed to use.  Instead NULL means
    to use the default stub implementations.
    
    Furthermore, the structure has been broken out into a JSClassOps
    sub structure now.
    
    This commit adapts the code to the new layout.
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 0f3761b..384ea79 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -149,34 +149,47 @@ G_DEFINE_TYPE (PolkitBackendJsAuthority, polkit_backend_js_authority, POLKIT_BAC
 
 /* ---------------------------------------------------------------------------------------------------- */
 
+static const struct JSClassOps js_global_class_ops = {
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL
+};
+
 static JSClass js_global_class = {
   "global",
   JSCLASS_GLOBAL_FLAGS,
-  JS_PropertyStub,
-  JS_DeletePropertyStub,
-  JS_PropertyStub,
-  JS_StrictPropertyStub,
-  JS_EnumerateStub,
-  JS_ResolveStub,
-  JS_ConvertStub,
-  NULL,
-  JSCLASS_NO_OPTIONAL_MEMBERS
+  &js_global_class_ops
 };
 
 /* ---------------------------------------------------------------------------------------------------- */
+static const struct JSClassOps js_polkit_class_ops = {
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL
+};
 
 static JSClass js_polkit_class = {
   "Polkit",
   0,
-  JS_PropertyStub,
-  JS_DeletePropertyStub,
-  JS_PropertyStub,
-  JS_StrictPropertyStub,
-  JS_EnumerateStub,
-  JS_ResolveStub,
-  JS_ConvertStub,
-  NULL,
-  JSCLASS_NO_OPTIONAL_MEMBERS
+  &js_polkit_class_ops
 };
 
 static JSBool js_polkit_log (JSContext *cx, unsigned argc, jsval *vp);
commit 188b1da7b4132c103cc630bf4ade77a735fbccda
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 22 12:59:46 2018 -0400

    configure: bump mozjs requirement to 52
    
    This is going to briefly break the build.
    
    Signed-off-by: Ray Strode <rstrode at redhat.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=105865

diff --git a/configure.ac b/configure.ac
index 8112171..130a482 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,7 +79,7 @@ PKG_CHECK_MODULES(GLIB, [gmodule-2.0 gio-unix-2.0 >= 2.30.0])
 AC_SUBST(GLIB_CFLAGS)
 AC_SUBST(GLIB_LIBS)
 
-PKG_CHECK_MODULES(LIBJS, [mozjs-24])
+PKG_CHECK_MODULES(LIBJS, [mozjs-52])
 
 AC_SUBST(LIBJS_CFLAGS)
 AC_SUBST(LIBJS_CXXFLAGS)


More information about the hal-commit mailing list