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

Ray Strode halfline at kemper.freedesktop.org
Mon Apr 2 21:51:57 UTC 2018


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

    Post-release version bump to 0.115

diff --git a/NEWS b/NEWS
index 79ac4d7..6bcdc1a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,34 @@
 --------------
+polkit 0.115
+--------------
+
+WARNING WARNING WARNING: This is a prerelease on the road to polkit
+1.0. Public API might change and certain parts of the code still needs
+some security review. Use at your own risk.
+
+This is polkit 0.115.
+
+Highlights:
+ TODO
+
+Build requirements
+
+ glib, gobject, gio    >= 2.32
+ mozjs185 or mozjs-17.0
+ gobject-introspection >= 0.6.2 (optional)
+ pam (optional)
+ ConsoleKit OR systemd
+
+Changes since polkit 0.114:
+
+ TODO
+
+Thanks to our contributors.
+
+Colin Walters and Miloslav Trmač,
+$DATE
+
+--------------
 polkit 0.114
 --------------
 
diff --git a/configure.ac b/configure.ac
index 130a482..36df239 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.59c)
-AC_INIT([polkit], [0.114], [http://lists.freedesktop.org/mailman/listinfo/polkit-devel], , [http://www.freedesktop.org/wiki/Software/polkit])
+AC_INIT([polkit], [0.115], [http://lists.freedesktop.org/mailman/listinfo/polkit-devel], , [http://www.freedesktop.org/wiki/Software/polkit])
 AM_INIT_AUTOMAKE([])
 AC_CONFIG_HEADERS(config.h)
 AC_CONFIG_MACRO_DIR([buildutil])
commit b4d5b6b47350ce815190456550dd0b0b9dbef2a9
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 e5f77034d7934ddabe20e7f5c0cae3147b347ef7
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>

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 2398f782bc509b08e4bf29e66c6cfc238d380380
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>

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 45b285578782bdb3b38ea0c75ae09fd0534764a8
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>

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 9b1f57e240b9cf36a3443da539baf864668525be
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>

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 067ab4ecf77bb525d3efc9cee607f6464d19498e
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>

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 16c76b4f3c578a4d9fd2e5c13dd022806250aa39
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>

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 b284ca3cc8ff9b3d7be846cef84c8802f42fa14e
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>

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 3ce1fa4dcbc1ab2b4fa81a5a4454ccb6dae6a37c
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>

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 591b12bde932092aa4be9b673db13e231efb6574
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>

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 6372ef029b534c871e7b33d978489a041022abfa
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>

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 c42be6f1c415678c7b18ecfea9c281137ad02031
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>

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 718d21a57314bd2426926f1406b2596ef7786788
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>

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 737f5851373cc79dedcc31bd8180737c8f72c8f8
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>

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 a836118d23bbc34f534b85879a88d4b4c41d46f0
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>

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 763c334cbe8c42eeb1de13a8fcb5dbf7017aa5b2
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>

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 738ec1e4d5b450278c975e879cfcc9b8c69389ea
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>

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 a9a5224117b5e51f5a06e5a7df706ab7cdd4a008
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>

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 14e79556ca0141a582d80ae5b86bdad4f09705f4
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>

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 32818ff6cfcc9ee6bca383787620f40593cc5607
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>

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 dc0ec9faf6640af881048878a9206fad6af8fa19
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>

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 9d2b35b6c37e2c170185a7b88f52c02386d59346
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>

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 59db3364c8acaa489977e560755d4bf5358521f0
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>

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 28bd0a9ffb4529a95c752cd140fd272dd3685b8f
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>

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 2f25e7552fadbe6e401ffb66dff025f4df1cf677
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>

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 ec9e1d899e6e483a236255950423047052f245a4
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>

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 936ed49658a3204188559479b1025e3d4aa41d2b
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>

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 15b9b1018b142a7ee0a11fc7518570d3e008adbe
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>

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 436f87200d00d3ac5f4f62d803d1a4b6cab72e98
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>

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 5b0c9b82df728bf056631ca19c71a1e2c20d6a52
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>

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 69dab5b930ce3679d651c88d9c5cb1b5d2eaaaa1
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>

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 27ab0169069bc7f2f549e8537ac357161b301ffe
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>

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 b831b0ce2fa8cf50e1a8658aaeb6bb4b3e8d8819
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>

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 7443ae6a1587724faa1eee57eb0a026625a6a01e
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>

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 5c587259cd9183e20c06d9b0b2e44c818e51e906
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>

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)
commit 4fea8580c3011740f864e82c21e2cec02e95c8fc
Author: Stef Walter <stefw at redhat.com>
Date:   Fri May 2 16:38:25 2014 +0200

    polkitagent: No double warnings in polkit_agent_listener_register()
    
    The caller of polkit_agent_listener_register() or similar is
    responsible for handling returned errors (and/or print them).
    
    Remove undconditional warning.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=78193

diff --git a/src/polkitagent/polkitagentlistener.c b/src/polkitagent/polkitagentlistener.c
index 1431458..debd1bb 100644
--- a/src/polkitagent/polkitagentlistener.c
+++ b/src/polkitagent/polkitagentlistener.c
@@ -156,7 +156,6 @@ server_register (Server   *server,
                                                                          NULL,
                                                                          &local_error))
     {
-      g_warning ("Unable to register authentication agent: %s", local_error->message);
       g_propagate_error (error, local_error);
     }
   else
commit 62ec5e453a0c75c2a2400ea45ccd7637c4ac8201
Author: Jiří Klimeš <jklimes at redhat.com>
Date:   Wed Oct 29 12:14:14 2014 +0100

    trivial: fix deprecated indication for polkit_agent_register_listener()
    
    polkit_agent_register_listener() is deprecated for a new function named
    polkit_agent_listener_register(), not polkit_authority_listener_register().
    
    Signed-off-by: Jiří Klimeš <jklimes at redhat.com>

diff --git a/src/polkitagent/polkitagentlistener.h b/src/polkitagent/polkitagentlistener.h
index c3cbcfb..854e36d 100644
--- a/src/polkitagent/polkitagentlistener.h
+++ b/src/polkitagent/polkitagentlistener.h
@@ -112,7 +112,7 @@ gboolean  polkit_agent_listener_initiate_authentication_finish  (PolkitAgentList
 gboolean  polkit_agent_register_listener                        (PolkitAgentListener      *listener,
                                                                  PolkitSubject            *subject,
                                                                  const gchar              *object_path,
-                                                                 GError                  **error) G_GNUC_DEPRECATED_FOR (polkit_authority_listener_register);
+                                                                 GError                  **error) G_GNUC_DEPRECATED_FOR (polkit_agent_listener_register);
 
 /**
  * PolkitAgentRegisterFlags:
commit d3fb5ca7b6cc592e71d94f8fc784b0316bdba139
Author: Colin Walters <walters at verbum.org>
Date:   Wed Jun 3 16:31:12 2015 -0400

    tests: Correct boundary test for overflow
    
    The offset has to be strictly less than the max.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=87716

diff --git a/test/mocklibc/src/netgroup.c b/test/mocklibc/src/netgroup.c
index bc99555..06a8a89 100644
--- a/test/mocklibc/src/netgroup.c
+++ b/test/mocklibc/src/netgroup.c
@@ -326,7 +326,7 @@ struct entry *netgroup_iter_next(struct netgroup_iter *iter) {
 
       // Grow the stack
       iter->depth++;
-      if (iter->depth > NETGROUP_MAX_DEPTH) {
+      if (iter->depth >= NETGROUP_MAX_DEPTH) {
         iter->depth = -1;
         return NULL; // Too much recursion
       }
commit f69121b84ca4c47e51877b53d073cf0408bf34ea
Author: Colin Walters <walters at verbum.org>
Date:   Thu Jun 4 13:00:42 2015 -0400

    build: Use AC_USE_SYSTEM_EXTENSIONS
    
    This ensures that we get all of the extensions consistently, rather
    than having just a few files `#define _GNU_SOURCE`.

diff --git a/configure.ac b/configure.ac
index 4af973b..8112171 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,7 @@ AC_SUBST(LT_CURRENT)
 AC_SUBST(LT_REVISION)
 AC_SUBST(LT_AGE)
 
+AC_USE_SYSTEM_EXTENSIONS
 AC_ISC_POSIX
 AC_PROG_CC
 AC_HEADER_STDC
diff --git a/src/examples/frobnicate.c b/src/examples/frobnicate.c
index 7ca6c46..29e0cbf 100644
--- a/src/examples/frobnicate.c
+++ b/src/examples/frobnicate.c
@@ -19,7 +19,8 @@
  * Author: David Zeuthen <davidz at redhat.com>
  */
 
-#define _GNU_SOURCE
+#include "config.h"
+
 #include <glib.h>
 #include <unistd.h>
 #include <stdlib.h>
diff --git a/src/polkitagent/polkitagenthelperprivate.h b/src/polkitagent/polkitagenthelperprivate.h
index 547fdcc..c5145b5 100644
--- a/src/polkitagent/polkitagenthelperprivate.h
+++ b/src/polkitagent/polkitagenthelperprivate.h
@@ -22,7 +22,6 @@
 #ifndef __POLKIT_AGENT_HELPER_PRIVATE_H
 #define __POLKIT_AGENT_HELPER_PRIVATE_H
 
-#define _GNU_SOURCE
 #include <polkit/polkit.h>
 
 /* Development aid: define PAH_DEBUG to get debugging output. Do _NOT_
diff --git a/src/programs/pkexec.c b/src/programs/pkexec.c
index 32c204d..7698c5c 100644
--- a/src/programs/pkexec.c
+++ b/src/programs/pkexec.c
@@ -23,8 +23,6 @@
 #  include "config.h"
 #endif
 
-#define _GNU_SOURCE
-
 #include <string.h>
 #include <stdlib.h>
 #include <sys/types.h>
commit 7ddfd621320fa3ae84177be45e33bad507bf63a5
Author: Miloslav Trmač <mitr at redhat.com>
Date:   Thu Jun 18 22:08:06 2015 +0200

    Move to current GLib
    
    Set up glib to use the installed version for deprecation warnings
    instead of limiting ourselves to [2.30,2.34]; this will let us use
    newer API, and help us keep up to date with future deprecations.
    
    Then fix all the warnings (as of GLib 2.44.1).
    
    https://bugs.freedesktop.org/show_bug.cgi?id=91198

diff --git a/configure.ac b/configure.ac
index 39e25c3..4af973b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -77,10 +77,6 @@ AC_SUBST(WARN_CFLAGS)
 PKG_CHECK_MODULES(GLIB, [gmodule-2.0 gio-unix-2.0 >= 2.30.0])
 AC_SUBST(GLIB_CFLAGS)
 AC_SUBST(GLIB_LIBS)
-AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_30],
-	[Avoid warning spew about g_type_init() being deprecated])
-AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [G_ENCODE_VERSION(2,34)],
-        [Notify us when we'll need to transition away from g_type_init()])
 
 PKG_CHECK_MODULES(LIBJS, [mozjs-24])
 
diff --git a/src/examples/cancel.c b/src/examples/cancel.c
index 1470025..02a8b63 100644
--- a/src/examples/cancel.c
+++ b/src/examples/cancel.c
@@ -102,8 +102,6 @@ main (int argc, char *argv[])
   PolkitAuthority *authority;
   GCancellable *cancellable;
 
-  g_type_init ();
-
   if (argc != 2)
     {
       g_printerr ("usage: %s <action_id>\n", argv[0]);
diff --git a/src/polkitagent/polkitagenthelperprivate.c b/src/polkitagent/polkitagenthelperprivate.c
index e23f9f5..1f32c0a 100644
--- a/src/polkitagent/polkitagenthelperprivate.c
+++ b/src/polkitagent/polkitagenthelperprivate.c
@@ -88,8 +88,6 @@ send_dbus_message (const char *cookie, const char *user)
 
   ret = FALSE;
 
-  g_type_init ();
-
   error = NULL;
   authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
   if (authority == NULL)
diff --git a/src/polkitagent/polkitagentlistener.c b/src/polkitagent/polkitagentlistener.c
index 4704b03..1431458 100644
--- a/src/polkitagent/polkitagentlistener.c
+++ b/src/polkitagent/polkitagentlistener.c
@@ -422,10 +422,8 @@ polkit_agent_listener_register_with_options (PolkitAgentListener      *listener,
 
   if (flags & POLKIT_AGENT_REGISTER_FLAGS_RUN_IN_THREAD)
     {
-      server->thread = g_thread_create (server_thread_func,
-                                        server,
-                                        TRUE,
-                                        error);
+      server->thread = g_thread_try_new ("polkit agent listener",
+					 server_thread_func, server, error);
       if (server->thread == NULL)
         {
           server_free (server);
diff --git a/src/polkitbackend/polkitd.c b/src/polkitbackend/polkitd.c
index 42397e1..6c57151 100644
--- a/src/polkitbackend/polkitd.c
+++ b/src/polkitbackend/polkitd.c
@@ -173,8 +173,6 @@ main (int    argc,
   /* Disable remote file access from GIO. */
   setenv ("GIO_USE_VFS", "local", 1);
 
-  g_type_init ();
-
   opt_context = g_option_context_new ("polkit system daemon");
   g_option_context_add_main_entries (opt_context, opt_entries, NULL);
   error = NULL;
diff --git a/src/programs/pkaction.c b/src/programs/pkaction.c
index 221662a..6dd6877 100644
--- a/src/programs/pkaction.c
+++ b/src/programs/pkaction.c
@@ -125,8 +125,6 @@ main (int argc, char *argv[])
   /* Disable remote file access from GIO. */
   setenv ("GIO_USE_VFS", "local", 1);
 
-  g_type_init ();
-
   opt_show_version = FALSE;
   opt_verbose = FALSE;
 
diff --git a/src/programs/pkcheck.c b/src/programs/pkcheck.c
index 33db128..f1bb4e1 100644
--- a/src/programs/pkcheck.c
+++ b/src/programs/pkcheck.c
@@ -366,8 +366,6 @@ main (int argc, char *argv[])
   /* Disable remote file access from GIO. */
   setenv ("GIO_USE_VFS", "local", 1);
 
-  g_type_init ();
-
   details = polkit_details_new ();
 
   opt_show_help = FALSE;
diff --git a/src/programs/pkexec.c b/src/programs/pkexec.c
index 3b29b24..32c204d 100644
--- a/src/programs/pkexec.c
+++ b/src/programs/pkexec.c
@@ -707,11 +707,6 @@ main (int argc, char *argv[])
       goto out;
     }
 
-  /* Initialize the GLib type system - this is needed to interact with the
-   * PolicyKit daemon
-   */
-  g_type_init ();
-
   /* make sure we are nuked if the parent process dies */
 #ifdef __linux__
   if (prctl (PR_SET_PDEATHSIG, SIGTERM) != 0)
diff --git a/src/programs/pkttyagent.c b/src/programs/pkttyagent.c
index 533f4a8..bfe00bd 100644
--- a/src/programs/pkttyagent.c
+++ b/src/programs/pkttyagent.c
@@ -78,8 +78,6 @@ main (int argc, char *argv[])
   /* Disable remote file access from GIO. */
   setenv ("GIO_USE_VFS", "local", 1);
 
-  g_type_init ();
-
   error = NULL;
   context = g_option_context_new ("");
   s = g_strdup_printf (_("Report bugs to: %s\n"
diff --git a/test/polkit/polkitidentitytest.c b/test/polkit/polkitidentitytest.c
index 3b8dd5e..e91967b 100644
--- a/test/polkit/polkitidentitytest.c
+++ b/test/polkit/polkitidentitytest.c
@@ -170,7 +170,6 @@ add_comparison_tests (void)
 int
 main (int argc, char *argv[])
 {
-  g_type_init ();
   g_test_init (&argc, &argv, NULL);
 
   g_test_add_data_func ("/PolkitIdentity/user_string_0", "unix-user:root", test_string);
diff --git a/test/polkit/polkitunixgrouptest.c b/test/polkit/polkitunixgrouptest.c
index f1417b3..6c4959e 100644
--- a/test/polkit/polkitunixgrouptest.c
+++ b/test/polkit/polkitunixgrouptest.c
@@ -73,7 +73,6 @@ test_set_gid (void)
 int
 main (int argc, char *argv[])
 {
-  g_type_init ();
   g_test_init (&argc, &argv, NULL);
   g_test_add_func ("/PolkitUnixGroup/new", test_new);
   g_test_add_func ("/PolkitUnixGroup/new_for_name", test_new_for_name);
diff --git a/test/polkit/polkitunixnetgrouptest.c b/test/polkit/polkitunixnetgrouptest.c
index c67822e..3701ba1 100644
--- a/test/polkit/polkitunixnetgrouptest.c
+++ b/test/polkit/polkitunixnetgrouptest.c
@@ -68,7 +68,6 @@ test_set_name (void)
 int
 main (int argc, char *argv[])
 {
-  g_type_init ();
   g_test_init (&argc, &argv, NULL);
   g_test_add_func ("/PolkitUnixNetgroup/new", test_new);
   g_test_add_func ("/PolkitUnixNetgroup/set_name", test_set_name);
diff --git a/test/polkit/polkitunixusertest.c b/test/polkit/polkitunixusertest.c
index ce35088..fc4c774 100644
--- a/test/polkit/polkitunixusertest.c
+++ b/test/polkit/polkitunixusertest.c
@@ -95,7 +95,6 @@ test_set_uid (void)
 int
 main (int argc, char *argv[])
 {
-  g_type_init ();
   g_test_init (&argc, &argv, NULL);
   g_test_add_func ("/PolkitUnixUser/new", test_new);
   g_test_add_func ("/PolkitUnixUser/new_for_name", test_new_for_name);
diff --git a/test/polkitbackend/test-polkitbackendjsauthority.c b/test/polkitbackend/test-polkitbackendjsauthority.c
index dfb894f..984110c 100644
--- a/test/polkitbackend/test-polkitbackendjsauthority.c
+++ b/test/polkitbackend/test-polkitbackendjsauthority.c
@@ -403,7 +403,6 @@ main (int argc, char *argv[])
 {
   setlocale (LC_ALL, "");
 
-  g_type_init ();
   g_test_init (&argc, &argv, NULL);
   //polkit_test_redirect_logs ();
 
commit 4d3ad67431ff3efe9ae51d1f0cf00ffc91aafa89
Author: Miloslav Trmač <mitr at redhat.com>
Date:   Mon Apr 2 11:11:32 2018 -0400

    Fix a race condition when terminating runaway_killer_thread
    
    The code used to call g_main_loop_quit() from the main thread, without
    having any guarantee that runaway_killer_thread_func() has even entered
    its g_main_loop_run().  If a main loop is not running,
    g_main_loop_quit() has no effect.
    
    This could occasionally be reproduced in
    test-polkitbackendjsauthority.c, which is creating several very
    short-lived PolkitBackendJSAuthority instances.  Real polkitd should not
    generally be affected, because it is using a single instance running for
    the life of the process ~ for the uptime of the system, enough time to
    enter the runaway_killer_thread main loop.
    
    To fix this, use g_idle_source_new () to make sure g_main_loop_quit ()
    is called from within the running main loop.
    
    Also, simplify the initialization of runaway_killer_thread by moving the
    creation of rkt_context and rkt_loop into the main thread; this makes
    the condition variable and its associated mutex completely unnecessary.
    
    Finally, only destroy rkt_timeout_pending_mutex _after_ the thread
    terminates; before, we were certain that rkt_source was destroyed by
    that time, but AFAICS that does not ensure that the rkt_on_timeout ()
    callback has already terminated.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=95513
    
    Signed-off-by: Miloslav Trmač <mitr at redhat.com>

diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 6a0b4ab..0f3761b 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -80,8 +80,6 @@ struct _PolkitBackendJsAuthorityPrivate
   JSObject *js_polkit;
 
   GThread *runaway_killer_thread;
-  GMutex rkt_init_mutex;
-  GCond rkt_init_cond;
   GMainContext *rkt_context;
   GMainLoop *rkt_loop;
   GSource *rkt_source;
@@ -125,6 +123,7 @@ enum
 /* ---------------------------------------------------------------------------------------------------- */
 
 static gpointer runaway_killer_thread_func (gpointer user_data);
+static void runaway_killer_terminate (PolkitBackendJsAuthority *authority);
 
 static GList *polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveAuthority *authority,
                                                                      PolkitSubject                     *caller,
@@ -512,20 +511,14 @@ polkit_backend_js_authority_constructed (GObject *object)
         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);
+    authority->priv->rkt_context = g_main_context_new ();
+    authority->priv->rkt_loop = g_main_loop_new (authority->priv->rkt_context, FALSE);
     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);
   }
@@ -549,15 +542,11 @@ polkit_backend_js_authority_finalize (GObject *object)
   PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (object);
   guint n;
 
-  g_mutex_clear (&authority->priv->rkt_init_mutex);
-  g_cond_clear (&authority->priv->rkt_init_cond);
-  g_mutex_clear (&authority->priv->rkt_timeout_pending_mutex);
+  runaway_killer_terminate (authority);
 
-  /* shut down the killer thread */
-  g_assert (authority->priv->rkt_loop != NULL);
-  g_main_loop_quit (authority->priv->rkt_loop);
-  g_thread_join (authority->priv->runaway_killer_thread);
-  g_assert (authority->priv->rkt_loop == NULL);
+  g_mutex_clear (&authority->priv->rkt_timeout_pending_mutex);
+  g_main_loop_unref (authority->priv->rkt_loop);
+  g_main_context_unref (authority->priv->rkt_context);
 
   for (n = 0; authority->priv->dir_monitors != NULL && authority->priv->dir_monitors[n] != NULL; n++)
     {
@@ -915,25 +904,9 @@ runaway_killer_thread_func (gpointer user_data)
 {
   PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (user_data);
 
-  g_mutex_lock (&authority->priv->rkt_init_mutex);
-
-  authority->priv->rkt_context = g_main_context_new ();
-  authority->priv->rkt_loop = g_main_loop_new (authority->priv->rkt_context, FALSE);
   g_main_context_push_thread_default (authority->priv->rkt_context);
-
-  /* Signal the main thread that we're done constructing */
-  g_cond_signal (&authority->priv->rkt_init_cond);
-  g_mutex_unlock (&authority->priv->rkt_init_mutex);
-
   g_main_loop_run (authority->priv->rkt_loop);
-
   g_main_context_pop_thread_default (authority->priv->rkt_context);
-
-  g_main_loop_unref (authority->priv->rkt_loop);
-  authority->priv->rkt_loop = NULL;
-  g_main_context_unref (authority->priv->rkt_context);
-  authority->priv->rkt_context = NULL;
-
   return NULL;
 }
 
@@ -1016,6 +989,38 @@ runaway_killer_teardown (PolkitBackendJsAuthority *authority)
   authority->priv->rkt_source = NULL;
 }
 
+static gboolean
+runaway_killer_call_g_main_quit (gpointer user_data)
+{
+  PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (user_data);
+  g_main_loop_quit (authority->priv->rkt_loop);
+  return G_SOURCE_REMOVE;
+}
+
+static void
+runaway_killer_terminate (PolkitBackendJsAuthority *authority)
+{
+  GSource *source;
+
+  /* Use a g_idle_source_new () to ensure g_main_loop_quit () is called from
+   * inside a running rkt_loop. This prevents a possible race condition, where
+   * we could be calling g_main_loop_quit () on the main thread before
+   * runaway_killer_thread_func () starts its g_main_loop_run () call;
+   * g_main_loop_quit () before g_main_loop_run () does nothing, so in such
+   * a case we would not terminate the thread and become blocked in
+   * g_thread_join () below.
+   */
+  g_assert (authority->priv->rkt_loop != NULL);
+
+  source = g_idle_source_new ();
+  g_source_set_callback (source, runaway_killer_call_g_main_quit, authority,
+			 NULL);
+  g_source_attach (source, authority->priv->rkt_context);
+  g_source_unref (source);
+
+  g_thread_join (authority->priv->runaway_killer_thread);
+}
+
 static JSBool
 execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
                                     JSScript                 *script,
commit 3345c10cf93dd42cb37f06c7074669ae315c3280
Author: Sebastien Bacher <seb128 at ubuntu.com>
Date:   Mon Apr 2 10:52:47 2018 -0400

    Support polkit session agent running outside user session
    
    commit a68f5dfd7662767b7b9822090b70bc5bd145c50c made
    session applications that are running from a user bus
    work with polkitd, by falling back to using the currently
    active session.
    
    This commit is similar, but for the polkit agent.  It allows,
    a polkit agent to be run from a systemd --user service
    that's not running directly in the users session.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=96977

diff --git a/src/polkit/polkitunixsession-systemd.c b/src/polkit/polkitunixsession-systemd.c
index 8a8bf65..c34f36a 100644
--- a/src/polkit/polkitunixsession-systemd.c
+++ b/src/polkit/polkitunixsession-systemd.c
@@ -451,6 +451,7 @@ polkit_unix_session_initable_init (GInitable     *initable,
   PolkitUnixSession *session = POLKIT_UNIX_SESSION (initable);
   gboolean ret = FALSE;
   char *s;
+  uid_t uid;
 
   if (session->session_id != NULL)
     {
@@ -467,6 +468,19 @@ polkit_unix_session_initable_init (GInitable     *initable,
       goto out;
     }
 
+  /* Now do process -> uid -> graphical session (systemd version 213)*/
+  if (sd_pid_get_owner_uid (session->pid, &uid) < 0)
+    goto error;
+
+  if (sd_uid_get_display (uid, &s) >= 0)
+    {
+      session->session_id =  g_strdup (s);
+      free (s);
+      ret = TRUE;
+      goto out;
+    }
+
+error:
   g_set_error (error,
                POLKIT_ERROR,
                POLKIT_ERROR_FAILED,
commit 8600ad832a49bccef795a3ef5b81533283f57409
Author: Philip Withnall <philip.withnall at collabora.co.uk>
Date:   Wed Aug 3 23:43:45 2016 +0100

    polkitbackend: Fix typos in a couple of initialisation error messages
    
    https://bugs.freedesktop.org/show_bug.cgi?id=97342

diff --git a/src/polkitbackend/polkitd.c b/src/polkitbackend/polkitd.c
index 8d54ed7..42397e1 100644
--- a/src/polkitbackend/polkitd.c
+++ b/src/polkitbackend/polkitd.c
@@ -180,7 +180,7 @@ main (int    argc,
   error = NULL;
   if (!g_option_context_parse (opt_context, &argc, &argv, &error))
     {
-      g_printerr ("Error parsing options: %s", error->message);
+      g_printerr ("Error parsing options: %s\n", error->message);
       g_error_free (error);
       goto out;
     }
@@ -207,7 +207,7 @@ main (int    argc,
   error = NULL;
   if (!become_user (POLKITD_USER, &error))
     {
-      g_printerr ("Error switcing to user %s: %s\n",
+      g_printerr ("Error switching to user %s: %s\n",
                   POLKITD_USER, error->message);
       g_clear_error (&error);
       goto out;
commit 574f8e5caa590d61175044829b27ef47213c1fc0
Author: Sven Eden <sven.eden at gmx.de>
Date:   Mon Apr 2 10:04:56 2018 -0400

    configure: enable elogind support in PolicyKit
    
    Currently configure.ac allows the usage of either libsystemd-login or
    ConsoleKit for session tracking.
    
    The elogind project (https://github.com/wingo/elogind) provides
    systemd-logind as a stand-alone daemon.  To allow users of systems not
    run by the full systemd suite, for whatever reason there might be, to at
    least be able to not have to use ConsoleKit for session tracking, an
    integration of elogind usage into PolicyKit would be very helpfull.
    
    As elogind provides the same interface as systemd-logind, integration is
    easy.
    
    This commit changes configure.ac to look for elogind in the same way
    it looks for systemd-logind.

diff --git a/configure.ac b/configure.ac
index af2c8dd..39e25c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -132,10 +132,11 @@ AC_ARG_ENABLE([test],
 AM_CONDITIONAL(BUILD_TEST, [test "x$enable_test" = "xyes"])
 
 dnl ---------------------------------------------------------------------------
-dnl - Select wether to use libsystemd-login or ConsoleKit for session tracking
+dnl - Select wether to use libsystemd-login, libelogind or ConsoleKit for session tracking
 dnl ---------------------------------------------------------------------------
 
 have_libsystemd=no
+have_libelogind=no
 SESSION_TRACKING=ConsoleKit
 
 AC_ARG_ENABLE([libsystemd-login],
@@ -156,16 +157,48 @@ if test "$enable_libsystemd_login" != "no"; then
       ],
       [have_libsystemd=no])])
   if test "$have_libsystemd" = "yes"; then
-    SESSION_TRACKING=libsystemd-login
-    AC_DEFINE([HAVE_LIBSYSTEMD], 1, [Define to 1 if libsystemd is available])
-    save_LIBS=$LIBS
-    LIBS=$LIBSYSTEMD_LIBS
-    AC_CHECK_FUNCS(sd_uid_get_display)
-    LIBS=$save_LIBS
+      SESSION_TRACKING=libsystemd-login
+  fi
+fi
+
+AC_ARG_ENABLE([libelogind],
+              [AS_HELP_STRING([--enable-libelogind[=@<:@auto/yes/no@:>@]], [Use libelogind (auto/yes/no)])],
+              [enable_libelogind=$enableval],
+              [enable_libelogind=auto])
+dnl Using libelogind makes no sense when libsystemd-login is already in use
+if test "$have_libsystemd" = "yes"; then
+  enable_libelogind=no
+fi
+if test "$enable_libelogind" != "no"; then
+  PKG_CHECK_MODULES([LIBELOGIND],
+    [libelogind],
+    [have_libelogind=yes])
+  if test "$have_libelogind" = "yes"; then
+      SESSION_TRACKING=libelogind
+  fi
+fi
+
+dnl libelogind is a drop-in replacement for libsystemd-login, so using it does
+dnl not need any different actions than using libsystemd-login.
+if test "$SESSION_TRACKING" != "ConsoleKit"; then
+  AC_DEFINE([HAVE_LIBSYSTEMD], 1, [Define to 1 if libsystemd or libelogind is available])
+  save_LIBS=$LIBS
+  if test "$have_libelogind" = "yes"; then
+    LIBS=$LIBELOGIND_LIBS
+    dnl We have to act like this was libsystemd-login
+    LIBSYSTEMD_CFLAGS=$LIBELOGIND_CFLAGS
+    LIBSYSTEMD_LIBS=$LIBELOGIND_LIBS
   else
-    if test "$enable_libsystemd_login" = "yes"; then
-      AC_MSG_ERROR([libsystemd support requested but libsystemd or libsystemd-login library not found])
-    fi
+    LIBS=$LIBSYSTEMD_LIBS
+  fi
+  AC_CHECK_FUNCS(sd_uid_get_display)
+  LIBS=$save_LIBS
+else
+  if test "$enable_libsystemd_login" = "yes"; then
+    AC_MSG_ERROR([libsystemd support requested but libsystemd or libsystemd-login library not found])
+  fi
+  if test "$enable_libelogind" = "yes"; then
+    AC_MSG_ERROR([libelogind support requested but libelogind library not found])
   fi
 fi
 
commit 2a1eee2369b08e1e2b775efdb750f07fe6ef4a51
Author: Miloslav Trmač <mitr at redhat.com>
Date:   Thu Oct 22 16:30:45 2015 +0200

    Fix help for (pkttyagent -s)
    
    https://bugs.freedesktop.org/show_bug.cgi?id=92581

diff --git a/src/programs/pkttyagent.c b/src/programs/pkttyagent.c
index 8aac7dd..533f4a8 100644
--- a/src/programs/pkttyagent.c
+++ b/src/programs/pkttyagent.c
@@ -55,7 +55,7 @@ main (int argc, char *argv[])
       },
       {
 	"system-bus-name", 's', 0, G_OPTION_ARG_STRING, &opt_system_bus_name,
-	N_("Register the agent owner of BUS_NAME"), N_("BUS_NAME")
+	N_("Register the agent for the owner of BUS_NAME"), N_("BUS_NAME")
       },
       {
 	"version", 0, 0, G_OPTION_ARG_NONE, &opt_show_version,
commit 58b7f4e72abb3849ecb8ef56e70874e0aec1a574
Author: Miloslav Trmač <mitr at redhat.com>
Date:   Thu Feb 9 19:58:12 2017 +0100

    Fix a memory leak on agent authentication cancellation
    
    (This is cancellation by the daemon, possibly requested by the client, not by the agent.)
    
    https://bugs.freedesktop.org/show_bug.cgi?id=99741
    
    Signed-off-by: Miloslav Trmač <mitr at redhat.com>

diff --git a/src/polkitbackend/polkitbackendinteractiveauthority.c b/src/polkitbackend/polkitbackendinteractiveauthority.c
index 270d3ea..1cd60d3 100644
--- a/src/polkitbackend/polkitbackendinteractiveauthority.c
+++ b/src/polkitbackend/polkitbackendinteractiveauthority.c
@@ -2437,13 +2437,18 @@ authentication_agent_cancel_cb (GDBusProxy   *proxy,
                                 GAsyncResult *res,
                                 gpointer      user_data)
 {
+  GVariant *result;
   GError *error;
+
   error = NULL;
-  if (!g_dbus_proxy_call_finish (proxy, res, &error))
+  result = g_dbus_proxy_call_finish (proxy, res, &error);
+  if (result == NULL)
     {
       g_printerr ("Error cancelling authentication: %s\n", error->message);
       g_error_free (error);
     }
+  else
+    g_variant_unref (result);
 }
 
 static void
commit 54c19b05d1ca3eeb95b12e89ac2a967374af7a4a
Author: Miloslav Trmač <mitr at redhat.com>
Date:   Thu Feb 9 19:53:54 2017 +0100

    Fix a memory leak per agent authentication
    
    https://bugs.freedesktop.org/show_bug.cgi?id=99741
    
    Signed-off-by: Miloslav Trmač <mitr at redhat.com>

diff --git a/src/polkitbackend/polkitbackendinteractiveauthority.c b/src/polkitbackend/polkitbackendinteractiveauthority.c
index 7511381..270d3ea 100644
--- a/src/polkitbackend/polkitbackendinteractiveauthority.c
+++ b/src/polkitbackend/polkitbackendinteractiveauthority.c
@@ -1906,15 +1906,15 @@ authentication_agent_begin_cb (GDBusProxy   *proxy,
   AuthenticationSession *session = user_data;
   gboolean gained_authorization;
   gboolean was_dismissed;
+  GVariant *result;
   GError *error;
 
   was_dismissed = FALSE;
   gained_authorization = FALSE;
 
   error = NULL;
-  if (!g_dbus_proxy_call_finish (proxy,
-                                 res,
-                                 &error))
+  result = g_dbus_proxy_call_finish (proxy, res, &error);
+  if (result == NULL)
     {
       g_printerr ("Error performing authentication: %s (%s %d)\n",
                   error->message,
@@ -1926,6 +1926,7 @@ authentication_agent_begin_cb (GDBusProxy   *proxy,
     }
   else
     {
+      g_variant_unref (result);
       gained_authorization = session->is_authenticated;
       g_debug ("Authentication complete, is_authenticated = %d", session->is_authenticated);
     }
commit 6b5e0e7a9c1f832759cb32f780d654daca445abd
Author: Miloslav Trmač <mitr at redhat.com>
Date:   Thu Feb 9 19:38:17 2017 +0100

    Fix error handling in polkit_authority_enumerate_temporary_authorizations_finish
    
    Fix memory leaks, and don't return a pointer to freed memory.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=99741
    
    Signed-off-by: Miloslav Trmač <mitr at redhat.com>

diff --git a/src/polkit/polkitauthority.c b/src/polkit/polkitauthority.c
index 15a81ac..71d527c 100644
--- a/src/polkit/polkitauthority.c
+++ b/src/polkit/polkitauthority.c
@@ -1698,11 +1698,13 @@ polkit_authority_enumerate_temporary_authorizations_finish (PolkitAuthority *aut
           g_prefix_error (error, "Error serializing return value of EnumerateTemporaryAuthorizations: ");
           g_list_foreach (ret, (GFunc) g_object_unref, NULL);
           g_list_free (ret);
-          goto out;
+          ret = NULL;
+          goto out_array;
         }
       ret = g_list_prepend (ret, auth);
     }
   ret = g_list_reverse (ret);
+ out_array:
   g_variant_unref (array);
   g_variant_unref (value);
 
commit e05f67d2bb2052a713449da23e7ae8cfbb33717e
Author: Miloslav Trmač <mitr at redhat.com>
Date:   Wed Feb 8 23:03:06 2017 +0100

    Fix memory leaks in server_handle_*_temporary_authorizations
    
    https://bugs.freedesktop.org/show_bug.cgi?id=99741
    
    Signed-off-by: Miloslav Trmač <mitr at redhat.com>

diff --git a/src/polkitbackend/polkitbackendauthority.c b/src/polkitbackend/polkitbackendauthority.c
index d1e3585..0d1fac4 100644
--- a/src/polkitbackend/polkitbackendauthority.c
+++ b/src/polkitbackend/polkitbackendauthority.c
@@ -1165,6 +1165,7 @@ server_handle_enumerate_temporary_authorizations (Server                 *server
   g_dbus_method_invocation_return_value (invocation, g_variant_new ("(a(ss(sa{sv})tt))", &builder));
 
  out:
+  g_variant_unref (subject_gvariant);
   if (subject != NULL)
     g_object_unref (subject);
 }
@@ -1211,6 +1212,7 @@ server_handle_revoke_temporary_authorizations (Server                 *server,
   g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
 
  out:
+  g_variant_unref (subject_gvariant);
   if (subject != NULL)
     g_object_unref (subject);
 }
commit eb71471fb57c718eb52bf2b1b9cdb6790d0fc9d4
Author: Miloslav Trmač <mitr at redhat.com>
Date:   Wed Feb 8 22:57:21 2017 +0100

    Fix a memory leak in server_handle_authentication_agent_response{,2}
    
    https://bugs.freedesktop.org/show_bug.cgi?id=99741
    
    Signed-off-by: Miloslav Trmač <mitr at redhat.com>

diff --git a/src/polkitbackend/polkitbackendauthority.c b/src/polkitbackend/polkitbackendauthority.c
index 5b2c89e..d1e3585 100644
--- a/src/polkitbackend/polkitbackendauthority.c
+++ b/src/polkitbackend/polkitbackendauthority.c
@@ -1054,6 +1054,7 @@ server_handle_authentication_agent_response (Server                 *server,
   g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
 
  out:
+  g_variant_unref (identity_gvariant);
   if (identity != NULL)
     g_object_unref (identity);
 }
@@ -1104,6 +1105,7 @@ server_handle_authentication_agent_response2 (Server                 *server,
   g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
 
  out:
+  g_variant_unref (identity_gvariant);
   if (identity != NULL)
     g_object_unref (identity);
 }
commit 3e74d1ef0b3f3d4c262e5660cb90ea31928cbce1
Author: Miloslav Trmač <mitr at redhat.com>
Date:   Wed Feb 8 22:55:10 2017 +0100

    Fix a memory leak in server_handle_unregister_authentication_agent
    
    https://bugs.freedesktop.org/show_bug.cgi?id=99741
    
    Signed-off-by: Miloslav Trmač <mitr at redhat.com>

diff --git a/src/polkitbackend/polkitbackendauthority.c b/src/polkitbackend/polkitbackendauthority.c
index c519bab..5b2c89e 100644
--- a/src/polkitbackend/polkitbackendauthority.c
+++ b/src/polkitbackend/polkitbackendauthority.c
@@ -1003,6 +1003,7 @@ server_handle_unregister_authentication_agent (Server                 *server,
   g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
 
  out:
+  g_variant_unref (subject_gvariant);
   if (subject != NULL)
     g_object_unref (subject);
 }
commit 74579dd976c36e1a2f9155f130ecbdca45237a03
Author: Miloslav Trmač <mitr at redhat.com>
Date:   Wed Feb 8 22:53:58 2017 +0100

    Fix a memory leak in server_handle_register_authentication_agent_with_options
    
    https://bugs.freedesktop.org/show_bug.cgi?id=99741
    
    Signed-off-by: Miloslav Trmač <mitr at redhat.com>

diff --git a/src/polkitbackend/polkitbackendauthority.c b/src/polkitbackend/polkitbackendauthority.c
index 27d8e51..c519bab 100644
--- a/src/polkitbackend/polkitbackendauthority.c
+++ b/src/polkitbackend/polkitbackendauthority.c
@@ -951,6 +951,7 @@ server_handle_register_authentication_agent_with_options (Server
   g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
 
  out:
+  g_variant_unref (subject_gvariant);
   if (options != NULL)
       g_variant_unref (options);
   if (subject != NULL)
commit 2431806da4db5faff0d4081416d2eaf581e79955
Author: Miloslav Trmač <mitr at redhat.com>
Date:   Wed Feb 8 22:27:11 2017 +0100

    Fix a memory leak on an error path of lookup_asv (twice)
    
    https://bugs.freedesktop.org/show_bug.cgi?id=99741
    
    Signed-off-by: Miloslav Trmač <mitr at redhat.com>

diff --git a/src/polkit/polkitidentity.c b/src/polkit/polkitidentity.c
index b0b46bf..3aa1f7f 100644
--- a/src/polkit/polkitidentity.c
+++ b/src/polkit/polkitidentity.c
@@ -266,6 +266,7 @@ lookup_asv (GVariant            *dict,
                            g_variant_get_type_string (value),
                            type_string);
               g_free (type_string);
+              g_variant_unref (value);
               goto out;
             }
           ret = value;
diff --git a/src/polkit/polkitsubject.c b/src/polkit/polkitsubject.c
index 4a36941..d4c1182 100644
--- a/src/polkit/polkitsubject.c
+++ b/src/polkit/polkitsubject.c
@@ -362,6 +362,7 @@ lookup_asv (GVariant            *dict,
                            g_variant_get_type_string (value),
                            type_string);
               g_free (type_string);
+              g_variant_unref (value);
               goto out;
             }
           ret = value;
commit 03f6b6cf7c586bcfc01a028fd6eed8df756703f8
Author: Miloslav Trmač <mitr at redhat.com>
Date:   Wed Feb 8 22:26:37 2017 +0100

    Simplify GVariant reference counting
    
    For (non-public-API) *_to_gvariant, explicitly document that they return
    a floating value, and rely on it in callers to avoid a
    variable/sink/unref combo.
    
    This should not change behavior.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=99741
    
    Signed-off-by: Miloslav Trmač <mitr at redhat.com>

diff --git a/src/polkit/polkitactiondescription.c b/src/polkit/polkitactiondescription.c
index 4bd9604..ed0655e 100644
--- a/src/polkit/polkitactiondescription.c
+++ b/src/polkit/polkitactiondescription.c
@@ -352,10 +352,10 @@ polkit_action_description_new_for_gvariant (GVariant *value)
   return action_description;
 }
 
+/* Note that this returns a floating value. */
 GVariant *
 polkit_action_description_to_gvariant (PolkitActionDescription *action_description)
 {
-  GVariant *value;
   GVariantBuilder builder;
   GHashTableIter iter;
   const gchar *a_key;
@@ -368,17 +368,15 @@ polkit_action_description_to_gvariant (PolkitActionDescription *action_descripti
     g_variant_builder_add (&builder, "{ss}", a_key, a_value);
 
   /* TODO: note 'foo ? : ""' is a gcc specific extension (it's a short-hand for 'foo ? foo : ""') */
-  value = g_variant_new ("(ssssssuuua{ss})",
-                         action_description->action_id ? : "",
-                         action_description->description ? : "",
-                         action_description->message ? : "",
-                         action_description->vendor_name ? : "",
-                         action_description->vendor_url ? : "",
-                         action_description->icon_name ? : "",
-                         action_description->implicit_any,
-                         action_description->implicit_inactive,
-                         action_description->implicit_active,
-                         &builder);
-
-  return value;
+  return g_variant_new ("(ssssssuuua{ss})",
+                        action_description->action_id ? : "",
+                        action_description->description ? : "",
+                        action_description->message ? : "",
+                        action_description->vendor_name ? : "",
+                        action_description->vendor_url ? : "",
+                        action_description->icon_name ? : "",
+                        action_description->implicit_any,
+                        action_description->implicit_inactive,
+                        action_description->implicit_active,
+                        &builder);
 }
diff --git a/src/polkit/polkitauthority.c b/src/polkit/polkitauthority.c
index 7c4db7b..15a81ac 100644
--- a/src/polkit/polkitauthority.c
+++ b/src/polkit/polkitauthority.c
@@ -886,8 +886,6 @@ polkit_authority_check_authorization (PolkitAuthority               *authority,
                                       GAsyncReadyCallback            callback,
                                       gpointer                       user_data)
 {
-  GVariant *subject_value;
-  GVariant *details_value;
   CheckAuthData *data;
 
   g_return_if_fail (POLKIT_IS_AUTHORITY (authority));
@@ -896,11 +894,6 @@ polkit_authority_check_authorization (PolkitAuthority               *authority,
   g_return_if_fail (details == NULL || POLKIT_IS_DETAILS (details));
   g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
 
-  subject_value = polkit_subject_to_gvariant (subject);
-  details_value = polkit_details_to_gvariant (details);
-  g_variant_ref_sink (subject_value);
-  g_variant_ref_sink (details_value);
-
   data = g_new0 (CheckAuthData, 1);
   data->authority = g_object_ref (authority);
   data->simple = g_simple_async_result_new (G_OBJECT (authority),
@@ -915,9 +908,9 @@ polkit_authority_check_authorization (PolkitAuthority               *authority,
   g_dbus_proxy_call (authority->proxy,
                      "CheckAuthorization",
                      g_variant_new ("(@(sa{sv})s at a{ss}us)",
-                                    subject_value,
+                                    polkit_subject_to_gvariant (subject), /* A floating value */
                                     action_id,
-                                    details_value,
+                                    polkit_details_to_gvariant (details), /* A floating value */
                                     flags,
                                     data->cancellation_id != NULL ? data->cancellation_id : ""),
                      G_DBUS_CALL_FLAGS_NONE,
@@ -925,8 +918,6 @@ polkit_authority_check_authorization (PolkitAuthority               *authority,
                      cancellable,
                      (GAsyncReadyCallback) check_authorization_cb,
                      data);
-  g_variant_unref (subject_value);
-  g_variant_unref (details_value);
 }
 
 /**
@@ -1058,20 +1049,16 @@ polkit_authority_register_authentication_agent (PolkitAuthority      *authority,
                                                 GAsyncReadyCallback   callback,
                                                 gpointer              user_data)
 {
-  GVariant *subject_value;
-
   g_return_if_fail (POLKIT_IS_AUTHORITY (authority));
   g_return_if_fail (POLKIT_IS_SUBJECT (subject));
   g_return_if_fail (locale != NULL);
   g_return_if_fail (g_variant_is_object_path (object_path));
   g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
 
-  subject_value = polkit_subject_to_gvariant (subject);
-  g_variant_ref_sink (subject_value);
   g_dbus_proxy_call (authority->proxy,
                      "RegisterAuthenticationAgent",
                      g_variant_new ("(@(sa{sv})ss)",
-                                    subject_value,
+                                    polkit_subject_to_gvariant (subject), /* A floating value */
                                     locale,
                                     object_path),
                      G_DBUS_CALL_FLAGS_NONE,
@@ -1082,7 +1069,6 @@ polkit_authority_register_authentication_agent (PolkitAuthority      *authority,
                                                 callback,
                                                 user_data,
                                                 polkit_authority_register_authentication_agent));
-  g_variant_unref (subject_value);
 }
 
 /**
@@ -1375,19 +1361,15 @@ polkit_authority_unregister_authentication_agent (PolkitAuthority      *authorit
                                                   GAsyncReadyCallback   callback,
                                                   gpointer              user_data)
 {
-  GVariant *subject_value;
-
   g_return_if_fail (POLKIT_IS_AUTHORITY (authority));
   g_return_if_fail (POLKIT_IS_SUBJECT (subject));
   g_return_if_fail (g_variant_is_object_path (object_path));
   g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
 
-  subject_value = polkit_subject_to_gvariant (subject);
-  g_variant_ref_sink (subject_value);
   g_dbus_proxy_call (authority->proxy,
                      "UnregisterAuthenticationAgent",
                      g_variant_new ("(@(sa{sv})s)",
-                                    subject_value,
+                                    polkit_subject_to_gvariant (subject), /* A floating value */
                                     object_path),
                      G_DBUS_CALL_FLAGS_NONE,
                      -1,
@@ -1397,7 +1379,6 @@ polkit_authority_unregister_authentication_agent (PolkitAuthority      *authorit
                                                 callback,
                                                 user_data,
                                                 polkit_authority_unregister_authentication_agent));
-  g_variant_unref (subject_value);
 }
 
 /**
@@ -1511,7 +1492,6 @@ polkit_authority_authentication_agent_response (PolkitAuthority      *authority,
                                                 GAsyncReadyCallback   callback,
                                                 gpointer              user_data)
 {
-  GVariant *identity_value;
   /* Note that in reality, this API is only accessible to root, and
    * only called from the setuid helper `polkit-agent-helper-1`.
    *
@@ -1526,14 +1506,12 @@ polkit_authority_authentication_agent_response (PolkitAuthority      *authority,
   g_return_if_fail (POLKIT_IS_IDENTITY (identity));
   g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
 
-  identity_value = polkit_identity_to_gvariant (identity);
-  g_variant_ref_sink (identity_value);
   g_dbus_proxy_call (authority->proxy,
                      "AuthenticationAgentResponse2",
                      g_variant_new ("(us@(sa{sv}))",
                                     (guint32)uid,
                                     cookie,
-                                    identity_value),
+                                    polkit_identity_to_gvariant (identity)), /* A floating value */
                      G_DBUS_CALL_FLAGS_NONE,
                      -1,
                      cancellable,
@@ -1542,7 +1520,6 @@ polkit_authority_authentication_agent_response (PolkitAuthority      *authority,
                                                 callback,
                                                 user_data,
                                                 polkit_authority_authentication_agent_response));
-  g_variant_unref (identity_value);
 }
 
 /**
@@ -1653,18 +1630,14 @@ polkit_authority_enumerate_temporary_authorizations (PolkitAuthority     *author
                                                      GAsyncReadyCallback  callback,
                                                      gpointer             user_data)
 {
-  GVariant *subject_value;
-
   g_return_if_fail (POLKIT_IS_AUTHORITY (authority));
   g_return_if_fail (POLKIT_IS_SUBJECT (subject));
   g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
 
-  subject_value = polkit_subject_to_gvariant (subject);
-  g_variant_ref_sink (subject_value);
   g_dbus_proxy_call (authority->proxy,
                      "EnumerateTemporaryAuthorizations",
                      g_variant_new ("(@(sa{sv}))",
-                                    subject_value),
+                                    polkit_subject_to_gvariant (subject)), /* A floating value */
                      G_DBUS_CALL_FLAGS_NONE,
                      -1,
                      cancellable,
@@ -1673,7 +1646,6 @@ polkit_authority_enumerate_temporary_authorizations (PolkitAuthority     *author
                                                 callback,
                                                 user_data,
                                                 polkit_authority_enumerate_temporary_authorizations));
-  g_variant_unref (subject_value);
 }
 
 /**
@@ -1805,18 +1777,14 @@ polkit_authority_revoke_temporary_authorizations (PolkitAuthority     *authority
                                                   GAsyncReadyCallback  callback,
                                                   gpointer             user_data)
 {
-  GVariant *subject_value;
-
   g_return_if_fail (POLKIT_IS_AUTHORITY (authority));
   g_return_if_fail (POLKIT_IS_SUBJECT (subject));
   g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
 
-  subject_value = polkit_subject_to_gvariant (subject);
-  g_variant_ref_sink (subject_value);
   g_dbus_proxy_call (authority->proxy,
                      "RevokeTemporaryAuthorizations",
                      g_variant_new ("(@(sa{sv}))",
-                                    subject_value),
+                                    polkit_subject_to_gvariant (subject)), /* A floating value */
                      G_DBUS_CALL_FLAGS_NONE,
                      -1,
                      cancellable,
@@ -1825,7 +1793,6 @@ polkit_authority_revoke_temporary_authorizations (PolkitAuthority     *authority
                                                 callback,
                                                 user_data,
                                                 polkit_authority_revoke_temporary_authorizations));
-  g_variant_unref (subject_value);
 }
 
 /**
diff --git a/src/polkit/polkitauthorizationresult.c b/src/polkit/polkitauthorizationresult.c
index dd3d761..877a9a6 100644
--- a/src/polkit/polkitauthorizationresult.c
+++ b/src/polkit/polkitauthorizationresult.c
@@ -290,19 +290,15 @@ polkit_authorization_result_new_for_gvariant (GVariant *value)
   return ret;
 }
 
+/* Note that this returns a floating value. */
 GVariant *
 polkit_authorization_result_to_gvariant (PolkitAuthorizationResult *authorization_result)
 {
-  GVariant *ret;
-  GVariant *details_gvariant;
-
-  details_gvariant = polkit_details_to_gvariant (polkit_authorization_result_get_details (authorization_result));
-  g_variant_ref_sink (details_gvariant);
-  ret = g_variant_new ("(bb at a{ss})",
-                       polkit_authorization_result_get_is_authorized (authorization_result),
-                       polkit_authorization_result_get_is_challenge (authorization_result),
-                       details_gvariant);
-  g_variant_unref (details_gvariant);
+  PolkitDetails *details;
 
-  return ret;
+  details = polkit_authorization_result_get_details (authorization_result);
+  return g_variant_new ("(bb at a{ss})",
+                        polkit_authorization_result_get_is_authorized (authorization_result),
+                        polkit_authorization_result_get_is_challenge (authorization_result),
+                        polkit_details_to_gvariant (details)); /* A floating value */
 }
diff --git a/src/polkit/polkitdetails.c b/src/polkit/polkitdetails.c
index 07a6f63..b16aadc 100644
--- a/src/polkit/polkitdetails.c
+++ b/src/polkit/polkitdetails.c
@@ -195,10 +195,10 @@ polkit_details_get_keys (PolkitDetails *details)
   return ret;
 }
 
+/* Note that this returns a floating value. */
 GVariant *
 polkit_details_to_gvariant (PolkitDetails *details)
 {
-  GVariant *ret;
   GVariantBuilder builder;
 
   g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}"));
@@ -212,8 +212,7 @@ polkit_details_to_gvariant (PolkitDetails *details)
       while (g_hash_table_iter_next (&hash_iter, (gpointer) &key, (gpointer) &value))
         g_variant_builder_add (&builder, "{ss}", key, value);
     }
-  ret = g_variant_builder_end (&builder);
-  return ret;
+  return g_variant_builder_end (&builder);
 }
 
 PolkitDetails *
diff --git a/src/polkit/polkitidentity.c b/src/polkit/polkitidentity.c
index 7813c2c..b0b46bf 100644
--- a/src/polkit/polkitidentity.c
+++ b/src/polkit/polkitidentity.c
@@ -198,12 +198,12 @@ polkit_identity_from_string  (const gchar   *str,
   return identity;
 }
 
+/* Note that this returns a floating value. */
 GVariant *
 polkit_identity_to_gvariant (PolkitIdentity *identity)
 {
   GVariantBuilder builder;
   GVariant *dict;
-  GVariant *ret;
   const gchar *kind;
 
   kind = "";
@@ -233,8 +233,7 @@ polkit_identity_to_gvariant (PolkitIdentity *identity)
     }
 
   dict = g_variant_builder_end (&builder);
-  ret = g_variant_new ("(s at a{sv})", kind, dict);
-  return ret;
+  return g_variant_new ("(s at a{sv})", kind, dict);
 }
 
 static GVariant *
diff --git a/src/polkit/polkitsubject.c b/src/polkit/polkitsubject.c
index df8e1aa..4a36941 100644
--- a/src/polkit/polkitsubject.c
+++ b/src/polkit/polkitsubject.c
@@ -290,12 +290,12 @@ polkit_subject_from_string  (const gchar   *str,
   return subject;
 }
 
+/* Note that this returns a floating value. */
 GVariant *
 polkit_subject_to_gvariant (PolkitSubject *subject)
 {
   GVariantBuilder builder;
   GVariant *dict;
-  GVariant *ret;
   const gchar *kind;
 
   kind = "";
@@ -329,8 +329,7 @@ polkit_subject_to_gvariant (PolkitSubject *subject)
     }
 
   dict = g_variant_builder_end (&builder);
-  ret = g_variant_new ("(s at a{sv})", kind, dict);
-  return ret;
+  return g_variant_new ("(s at a{sv})", kind, dict);
 }
 
 static GVariant *
diff --git a/src/polkit/polkittemporaryauthorization.c b/src/polkit/polkittemporaryauthorization.c
index b2c6003..5e07678 100644
--- a/src/polkit/polkittemporaryauthorization.c
+++ b/src/polkit/polkittemporaryauthorization.c
@@ -212,22 +212,15 @@ polkit_temporary_authorization_new_for_gvariant (GVariant  *value,
   return authorization;
 }
 
+/* Note that this returns a floating value. */
 GVariant *
 polkit_temporary_authorization_to_gvariant (PolkitTemporaryAuthorization *authorization)
 {
-  GVariant *ret;
-  GVariant *subject_gvariant;
-
-  subject_gvariant = polkit_subject_to_gvariant (authorization->subject);
-  g_variant_ref_sink (subject_gvariant);
-  ret = g_variant_new ("(ss@(sa{sv})tt)",
-                       authorization->id,
-                       authorization->action_id,
-                       subject_gvariant,
-                       authorization->time_obtained,
-                       authorization->time_expires);
-  g_variant_unref (subject_gvariant);
-
-  return ret;
+  return g_variant_new ("(ss@(sa{sv})tt)",
+                        authorization->id,
+                        authorization->action_id,
+                        polkit_subject_to_gvariant (authorization->subject), /* A floating value */
+                        authorization->time_obtained,
+                        authorization->time_expires);
 }
 
diff --git a/src/polkitbackend/polkitbackendauthority.c b/src/polkitbackend/polkitbackendauthority.c
index 64560e1..27d8e51 100644
--- a/src/polkitbackend/polkitbackendauthority.c
+++ b/src/polkitbackend/polkitbackendauthority.c
@@ -645,11 +645,8 @@ server_handle_enumerate_actions (Server                 *server,
   for (l = actions; l != NULL; l = l->next)
     {
       PolkitActionDescription *ad = POLKIT_ACTION_DESCRIPTION (l->data);
-      GVariant *value;
-      value = polkit_action_description_to_gvariant (ad);
-      g_variant_ref_sink (value);
-      g_variant_builder_add_value (&builder, value);
-      g_variant_unref (value);
+      g_variant_builder_add_value (&builder,
+                                   polkit_action_description_to_gvariant (ad)); /* A floating value */
     }
   g_dbus_method_invocation_return_value (invocation, g_variant_new ("(a(ssssssuuua{ss}))", &builder));
 
@@ -709,11 +706,9 @@ check_auth_cb (GObject      *source_object,
     }
   else
     {
-      GVariant *value;
-      value = polkit_authorization_result_to_gvariant (result);
-      g_variant_ref_sink (value);
-      g_dbus_method_invocation_return_value (data->invocation, g_variant_new ("(@(bba{ss}))", value));
-      g_variant_unref (value);
+      g_dbus_method_invocation_return_value (data->invocation,
+                                             g_variant_new ("(@(bba{ss}))",
+                                                            polkit_authorization_result_to_gvariant (result))); /* A floating value */
       g_object_unref (result);
     }
 
@@ -1158,11 +1153,8 @@ server_handle_enumerate_temporary_authorizations (Server                 *server
   for (l = authorizations; l != NULL; l = l->next)
     {
       PolkitTemporaryAuthorization *a = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
-      GVariant *value;
-      value = polkit_temporary_authorization_to_gvariant (a);
-      g_variant_ref_sink (value);
-      g_variant_builder_add_value (&builder, value);
-      g_variant_unref (value);
+      g_variant_builder_add_value (&builder,
+                                   polkit_temporary_authorization_to_gvariant (a)); /* A floating value */
     }
   g_list_foreach (authorizations, (GFunc) g_object_unref, NULL);
   g_list_free (authorizations);
diff --git a/src/polkitbackend/polkitbackendinteractiveauthority.c b/src/polkitbackend/polkitbackendinteractiveauthority.c
index ccfd608..7511381 100644
--- a/src/polkitbackend/polkitbackendinteractiveauthority.c
+++ b/src/polkitbackend/polkitbackendinteractiveauthority.c
@@ -2299,7 +2299,6 @@ authentication_agent_initiate_challenge (AuthenticationAgent         *agent,
   gchar *localized_message;
   gchar *localized_icon_name;
   PolkitDetails *localized_details;
-  GVariant *details_gvariant;
   GList *user_identities = NULL;
   GVariantBuilder identities_builder;
   GVariant *parameters;
@@ -2397,28 +2396,21 @@ authentication_agent_initiate_challenge (AuthenticationAgent         *agent,
   add_pid (localized_details, caller, "polkit.caller-pid");
   add_pid (localized_details, subject, "polkit.subject-pid");
 
-  details_gvariant = polkit_details_to_gvariant (localized_details);
-  g_variant_ref_sink (details_gvariant);
-
   g_variant_builder_init (&identities_builder, G_VARIANT_TYPE ("a(sa{sv})"));
   for (l = user_identities; l != NULL; l = l->next)
     {
       PolkitIdentity *identity = POLKIT_IDENTITY (l->data);
-      GVariant *value;
-      value = polkit_identity_to_gvariant (identity);
-      g_variant_ref_sink (value);
-      g_variant_builder_add_value (&identities_builder, value);
-      g_variant_unref (value);
+      g_variant_builder_add_value (&identities_builder,
+                                   polkit_identity_to_gvariant (identity)); /* A floating value */
     }
 
   parameters = g_variant_new ("(sss at a{ss}sa(sa{sv}))",
                               action_id,
                               localized_message,
                               localized_icon_name,
-                              details_gvariant,
+                              polkit_details_to_gvariant (localized_details), /* A floating value */
                               session->cookie,
                               &identities_builder);
-  g_variant_unref (details_gvariant);
 
   g_dbus_proxy_call (agent->proxy,
                      "BeginAuthentication",
commit 51b92dfcbf0563a49827fa6370eae1ca6035c001
Author: Ray Strode <rstrode at redhat.com>
Date:   Mon Apr 2 16:11:27 2018 -0400

    Ensure gettext files are included in dist tarball
    
    commit c78819245ff8a270f97c9f800773e727918be838 added
    gettext support for policy files.  That commit included
    its/loc files in git, but not in the disted tarballs.
    
    This commit fixes that.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=96940
    Signed-off-by: Ray Strode <rstrode at redhat.com>

diff --git a/data/Makefile.am b/data/Makefile.am
index 18693fe..7c53902 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -37,7 +37,7 @@ pkgconfig_DATA = polkit-gobject-1.pc polkit-agent-1.pc
 # ----------------------------------------------------------------------------------------------------
 
 itsdir = $(datadir)/gettext/its
-its_DATA = polkit.loc polkit.its
+dist_its_DATA = polkit.loc polkit.its
 
 # ----------------------------------------------------------------------------------------------------
 


More information about the hal-commit mailing list