...
 
Commits (55)
...@@ -9,24 +9,165 @@ some security review. Use at your own risk. ...@@ -9,24 +9,165 @@ some security review. Use at your own risk.
This is polkit 0.114. This is polkit 0.114.
Highlights: 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 Build requirements
glib, gobject, gio >= 2.30 glib, gobject, gio >= 2.32
mozjs185 or mozjs-17.0 mozjs-52
gobject-introspection >= 0.6.2 (optional) gobject-introspection >= 0.6.2 (optional)
pam (optional) pam (optional)
ConsoleKit OR systemd ConsoleKit OR systemd
Changes since polkit 0.113: 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@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. Thanks to our contributors.
Colin Walters and Miloslav Trmač, Colin Walters and Miloslav Trmač,
$DATE April 2, 2017
-------------- --------------
polkit 0.113 polkit 0.113
......
...@@ -23,6 +23,7 @@ AC_SUBST(LT_CURRENT) ...@@ -23,6 +23,7 @@ AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION) AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE) AC_SUBST(LT_AGE)
AC_USE_SYSTEM_EXTENSIONS
AC_ISC_POSIX AC_ISC_POSIX
AC_PROG_CC AC_PROG_CC
AC_HEADER_STDC AC_HEADER_STDC
...@@ -77,12 +78,8 @@ AC_SUBST(WARN_CFLAGS) ...@@ -77,12 +78,8 @@ AC_SUBST(WARN_CFLAGS)
PKG_CHECK_MODULES(GLIB, [gmodule-2.0 gio-unix-2.0 >= 2.30.0]) PKG_CHECK_MODULES(GLIB, [gmodule-2.0 gio-unix-2.0 >= 2.30.0])
AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS) 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]) PKG_CHECK_MODULES(LIBJS, [mozjs-52])
AC_SUBST(LIBJS_CFLAGS) AC_SUBST(LIBJS_CFLAGS)
AC_SUBST(LIBJS_CXXFLAGS) AC_SUBST(LIBJS_CXXFLAGS)
...@@ -132,10 +129,11 @@ AC_ARG_ENABLE([test], ...@@ -132,10 +129,11 @@ AC_ARG_ENABLE([test],
AM_CONDITIONAL(BUILD_TEST, [test "x$enable_test" = "xyes"]) AM_CONDITIONAL(BUILD_TEST, [test "x$enable_test" = "xyes"])
dnl --------------------------------------------------------------------------- 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 --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
have_libsystemd=no have_libsystemd=no
have_libelogind=no
SESSION_TRACKING=ConsoleKit SESSION_TRACKING=ConsoleKit
AC_ARG_ENABLE([libsystemd-login], AC_ARG_ENABLE([libsystemd-login],
...@@ -156,16 +154,48 @@ if test "$enable_libsystemd_login" != "no"; then ...@@ -156,16 +154,48 @@ if test "$enable_libsystemd_login" != "no"; then
], ],
[have_libsystemd=no])]) [have_libsystemd=no])])
if test "$have_libsystemd" = "yes"; then if test "$have_libsystemd" = "yes"; then
SESSION_TRACKING=libsystemd-login SESSION_TRACKING=libsystemd-login
AC_DEFINE([HAVE_LIBSYSTEMD], 1, [Define to 1 if libsystemd is available]) fi
save_LIBS=$LIBS fi
LIBS=$LIBSYSTEMD_LIBS
AC_CHECK_FUNCS(sd_uid_get_display) AC_ARG_ENABLE([libelogind],
LIBS=$save_LIBS [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 else
if test "$enable_libsystemd_login" = "yes"; then LIBS=$LIBSYSTEMD_LIBS
AC_MSG_ERROR([libsystemd support requested but libsystemd or libsystemd-login library not found]) fi
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
fi fi
......
...@@ -37,7 +37,7 @@ pkgconfig_DATA = polkit-gobject-1.pc polkit-agent-1.pc ...@@ -37,7 +37,7 @@ pkgconfig_DATA = polkit-gobject-1.pc polkit-agent-1.pc
# ---------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------
itsdir = $(datadir)/gettext/its itsdir = $(datadir)/gettext/its
its_DATA = polkit.loc polkit.its dist_its_DATA = polkit.loc polkit.its
# ---------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------
......
...@@ -102,8 +102,6 @@ main (int argc, char *argv[]) ...@@ -102,8 +102,6 @@ main (int argc, char *argv[])
PolkitAuthority *authority; PolkitAuthority *authority;
GCancellable *cancellable; GCancellable *cancellable;
g_type_init ();
if (argc != 2) if (argc != 2)
{ {
g_printerr ("usage: %s <action_id>\n", argv[0]); g_printerr ("usage: %s <action_id>\n", argv[0]);
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
* Author: David Zeuthen <davidz@redhat.com> * Author: David Zeuthen <davidz@redhat.com>
*/ */
#define _GNU_SOURCE #include "config.h"
#include <glib.h> #include <glib.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
......
...@@ -352,10 +352,10 @@ polkit_action_description_new_for_gvariant (GVariant *value) ...@@ -352,10 +352,10 @@ polkit_action_description_new_for_gvariant (GVariant *value)
return action_description; return action_description;
} }
/* Note that this returns a floating value. */
GVariant * GVariant *
polkit_action_description_to_gvariant (PolkitActionDescription *action_description) polkit_action_description_to_gvariant (PolkitActionDescription *action_description)
{ {
GVariant *value;
GVariantBuilder builder; GVariantBuilder builder;
GHashTableIter iter; GHashTableIter iter;
const gchar *a_key; const gchar *a_key;
...@@ -368,17 +368,15 @@ polkit_action_description_to_gvariant (PolkitActionDescription *action_descripti ...@@ -368,17 +368,15 @@ polkit_action_description_to_gvariant (PolkitActionDescription *action_descripti
g_variant_builder_add (&builder, "{ss}", a_key, a_value); 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 : ""') */ /* TODO: note 'foo ? : ""' is a gcc specific extension (it's a short-hand for 'foo ? foo : ""') */
value = g_variant_new ("(ssssssuuua{ss})", return g_variant_new ("(ssssssuuua{ss})",
action_description->action_id ? : "", action_description->action_id ? : "",
action_description->description ? : "", action_description->description ? : "",
action_description->message ? : "", action_description->message ? : "",
action_description->vendor_name ? : "", action_description->vendor_name ? : "",
action_description->vendor_url ? : "", action_description->vendor_url ? : "",
action_description->icon_name ? : "", action_description->icon_name ? : "",
action_description->implicit_any, action_description->implicit_any,
action_description->implicit_inactive, action_description->implicit_inactive,
action_description->implicit_active, action_description->implicit_active,
&builder); &builder);
return value;
} }
...@@ -886,8 +886,6 @@ polkit_authority_check_authorization (PolkitAuthority *authority, ...@@ -886,8 +886,6 @@ polkit_authority_check_authorization (PolkitAuthority *authority,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GVariant *subject_value;
GVariant *details_value;
CheckAuthData *data; CheckAuthData *data;
g_return_if_fail (POLKIT_IS_AUTHORITY (authority)); g_return_if_fail (POLKIT_IS_AUTHORITY (authority));
...@@ -896,11 +894,6 @@ polkit_authority_check_authorization (PolkitAuthority *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 (details == NULL || POLKIT_IS_DETAILS (details));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); 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 = g_new0 (CheckAuthData, 1);
data->authority = g_object_ref (authority); data->authority = g_object_ref (authority);
data->simple = g_simple_async_result_new (G_OBJECT (authority), data->simple = g_simple_async_result_new (G_OBJECT (authority),
...@@ -915,9 +908,9 @@ polkit_authority_check_authorization (PolkitAuthority *authority, ...@@ -915,9 +908,9 @@ polkit_authority_check_authorization (PolkitAuthority *authority,
g_dbus_proxy_call (authority->proxy, g_dbus_proxy_call (authority->proxy,
"CheckAuthorization", "CheckAuthorization",
g_variant_new ("(@(sa{sv})s@a{ss}us)", g_variant_new ("(@(sa{sv})s@a{ss}us)",
subject_value, polkit_subject_to_gvariant (subject), /* A floating value */
action_id, action_id,
details_value, polkit_details_to_gvariant (details), /* A floating value */
flags, flags,
data->cancellation_id != NULL ? data->cancellation_id : ""), data->cancellation_id != NULL ? data->cancellation_id : ""),
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
...@@ -925,8 +918,6 @@ polkit_authority_check_authorization (PolkitAuthority *authority, ...@@ -925,8 +918,6 @@ polkit_authority_check_authorization (PolkitAuthority *authority,
cancellable, cancellable,
(GAsyncReadyCallback) check_authorization_cb, (GAsyncReadyCallback) check_authorization_cb,
data); data);
g_variant_unref (subject_value);
g_variant_unref (details_value);
} }
/** /**
...@@ -1058,20 +1049,16 @@ polkit_authority_register_authentication_agent (PolkitAuthority *authority, ...@@ -1058,20 +1049,16 @@ polkit_authority_register_authentication_agent (PolkitAuthority *authority,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GVariant *subject_value;
g_return_if_fail (POLKIT_IS_AUTHORITY (authority)); g_return_if_fail (POLKIT_IS_AUTHORITY (authority));
g_return_if_fail (POLKIT_IS_SUBJECT (subject)); g_return_if_fail (POLKIT_IS_SUBJECT (subject));
g_return_if_fail (locale != NULL); g_return_if_fail (locale != NULL);
g_return_if_fail (g_variant_is_object_path (object_path)); g_return_if_fail (g_variant_is_object_path (object_path));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); 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, g_dbus_proxy_call (authority->proxy,
"RegisterAuthenticationAgent", "RegisterAuthenticationAgent",
g_variant_new ("(@(sa{sv})ss)", g_variant_new ("(@(sa{sv})ss)",
subject_value, polkit_subject_to_gvariant (subject), /* A floating value */
locale, locale,
object_path), object_path),
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
...@@ -1082,7 +1069,6 @@ polkit_authority_register_authentication_agent (PolkitAuthority *authority, ...@@ -1082,7 +1069,6 @@ polkit_authority_register_authentication_agent (PolkitAuthority *authority,
callback, callback,
user_data, user_data,
polkit_authority_register_authentication_agent)); polkit_authority_register_authentication_agent));
g_variant_unref (subject_value);
} }
/** /**
...@@ -1375,19 +1361,15 @@ polkit_authority_unregister_authentication_agent (PolkitAuthority *authorit ...@@ -1375,19 +1361,15 @@ polkit_authority_unregister_authentication_agent (PolkitAuthority *authorit
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GVariant *subject_value;
g_return_if_fail (POLKIT_IS_AUTHORITY (authority)); g_return_if_fail (POLKIT_IS_AUTHORITY (authority));
g_return_if_fail (POLKIT_IS_SUBJECT (subject)); g_return_if_fail (POLKIT_IS_SUBJECT (subject));
g_return_if_fail (g_variant_is_object_path (object_path)); g_return_if_fail (g_variant_is_object_path (object_path));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); 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, g_dbus_proxy_call (authority->proxy,
"UnregisterAuthenticationAgent", "UnregisterAuthenticationAgent",
g_variant_new ("(@(sa{sv})s)", g_variant_new ("(@(sa{sv})s)",
subject_value, polkit_subject_to_gvariant (subject), /* A floating value */
object_path), object_path),
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
-1, -1,
...@@ -1397,7 +1379,6 @@ polkit_authority_unregister_authentication_agent (PolkitAuthority *authorit ...@@ -1397,7 +1379,6 @@ polkit_authority_unregister_authentication_agent (PolkitAuthority *authorit
callback, callback,
user_data, user_data,
polkit_authority_unregister_authentication_agent)); polkit_authority_unregister_authentication_agent));
g_variant_unref (subject_value);
} }
/** /**
...@@ -1511,7 +1492,6 @@ polkit_authority_authentication_agent_response (PolkitAuthority *authority, ...@@ -1511,7 +1492,6 @@ polkit_authority_authentication_agent_response (PolkitAuthority *authority,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GVariant *identity_value;
/* Note that in reality, this API is only accessible to root, and /* Note that in reality, this API is only accessible to root, and
* only called from the setuid helper `polkit-agent-helper-1`. * only called from the setuid helper `polkit-agent-helper-1`.
* *
...@@ -1526,14 +1506,12 @@ polkit_authority_authentication_agent_response (PolkitAuthority *authority, ...@@ -1526,14 +1506,12 @@ polkit_authority_authentication_agent_response (PolkitAuthority *authority,
g_return_if_fail (POLKIT_IS_IDENTITY (identity)); g_return_if_fail (POLKIT_IS_IDENTITY (identity));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); 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, g_dbus_proxy_call (authority->proxy,
"AuthenticationAgentResponse2", "AuthenticationAgentResponse2",
g_variant_new ("(us@(sa{sv}))", g_variant_new ("(us@(sa{sv}))",
(guint32)uid, (guint32)uid,
cookie, cookie,
identity_value), polkit_identity_to_gvariant (identity)), /* A floating value */
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
-1, -1,
cancellable, cancellable,
...@@ -1542,7 +1520,6 @@ polkit_authority_authentication_agent_response (PolkitAuthority *authority, ...@@ -1542,7 +1520,6 @@ polkit_authority_authentication_agent_response (PolkitAuthority *authority,
callback, callback,
user_data, user_data,
polkit_authority_authentication_agent_response)); polkit_authority_authentication_agent_response));
g_variant_unref (identity_value);
} }
/** /**
...@@ -1653,18 +1630,14 @@ polkit_authority_enumerate_temporary_authorizations (PolkitAuthority *author ...@@ -1653,18 +1630,14 @@ polkit_authority_enumerate_temporary_authorizations (PolkitAuthority *author
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GVariant *subject_value;
g_return_if_fail (POLKIT_IS_AUTHORITY (authority)); g_return_if_fail (POLKIT_IS_AUTHORITY (authority));
g_return_if_fail (POLKIT_IS_SUBJECT (subject)); g_return_if_fail (POLKIT_IS_SUBJECT (subject));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); 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, g_dbus_proxy_call (authority->proxy,
"EnumerateTemporaryAuthorizations", "EnumerateTemporaryAuthorizations",
g_variant_new ("(@(sa{sv}))", g_variant_new ("(@(sa{sv}))",
subject_value), polkit_subject_to_gvariant (subject)), /* A floating value */
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
-1, -1,
cancellable, cancellable,
...@@ -1673,7 +1646,6 @@ polkit_authority_enumerate_temporary_authorizations (PolkitAuthority *author ...@@ -1673,7 +1646,6 @@ polkit_authority_enumerate_temporary_authorizations (PolkitAuthority *author
callback, callback,
user_data, user_data,
polkit_authority_enumerate_temporary_authorizations)); polkit_authority_enumerate_temporary_authorizations));
g_variant_unref (subject_value);
} }
/** /**
...@@ -1726,11 +1698,13 @@ polkit_authority_enumerate_temporary_authorizations_finish (PolkitAuthority *aut ...@@ -1726,11 +1698,13 @@ polkit_authority_enumerate_temporary_authorizations_finish (PolkitAuthority *aut
g_prefix_error (error, "Error serializing return value of EnumerateTemporaryAuthorizations: "); g_prefix_error (error, "Error serializing return value of EnumerateTemporaryAuthorizations: ");
g_list_foreach (ret, (GFunc) g_object_unref, NULL); g_list_foreach (ret, (GFunc) g_object_unref, NULL);
g_list_free (ret); g_list_free (ret);
goto out; ret = NULL;
goto out_array;
} }
ret = g_list_prepend (ret, auth); ret = g_list_prepend (ret, auth);
} }
ret = g_list_reverse (ret); ret = g_list_reverse (ret);
out_array:
g_variant_unref (array); g_variant_unref (array);
g_variant_unref (value); g_variant_unref (value);
...@@ -1805,18 +1779,14 @@ polkit_authority_revoke_temporary_authorizations (PolkitAuthority *authority ...@@ -1805,18 +1779,14 @@ polkit_authority_revoke_temporary_authorizations (PolkitAuthority *authority
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GVariant *subject_value;
g_return_if_fail (POLKIT_IS_AUTHORITY (authority)); g_return_if_fail (POLKIT_IS_AUTHORITY (authority));
g_return_if_fail (POLKIT_IS_SUBJECT (subject)); g_return_if_fail (POLKIT_IS_SUBJECT (subject));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); 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, g_dbus_proxy_call (authority->proxy,
"RevokeTemporaryAuthorizations", "RevokeTemporaryAuthorizations",
g_variant_new ("(@(sa{sv}))", g_variant_new ("(@(sa{sv}))",
subject_value), polkit_subject_to_gvariant (subject)), /* A floating value */
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
-1, -1,
cancellable, cancellable,
...@@ -1825,7 +1795,6 @@ polkit_authority_revoke_temporary_authorizations (PolkitAuthority *authority ...@@ -1825,7 +1795,6 @@ polkit_authority_revoke_temporary_authorizations (PolkitAuthority *authority
callback, callback,
user_data, user_data,
polkit_authority_revoke_temporary_authorizations)); polkit_authority_revoke_temporary_authorizations));
g_variant_unref (subject_value);
} }
/** /**
......
...@@ -290,19 +290,15 @@ polkit_authorization_result_new_for_gvariant (GVariant *value) ...@@ -290,19 +290,15 @@ polkit_authorization_result_new_for_gvariant (GVariant *value)
return ret; return ret;
} }
/* Note that this returns a floating value. */
GVariant * GVariant *
polkit_authorization_result_to_gvariant (PolkitAuthorizationResult *authorization_result) polkit_authorization_result_to_gvariant (PolkitAuthorizationResult *authorization_result)
{ {
GVariant *ret; PolkitDetails *details;
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@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);
return ret; details = polkit_authorization_result_get_details (authorization_result);
return g_variant_new ("(bb@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 */
} }
...@@ -195,10 +195,10 @@ polkit_details_get_keys (PolkitDetails *details) ...@@ -195,10 +195,10 @@ polkit_details_get_keys (PolkitDetails *details)
return ret; return ret;
} }
/* Note that this returns a floating value. */
GVariant * GVariant *
polkit_details_to_gvariant (PolkitDetails *details) polkit_details_to_gvariant (PolkitDetails *details)
{ {
GVariant *ret;
GVariantBuilder builder; GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}")); g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}"));
...@@ -212,8 +212,7 @@ polkit_details_to_gvariant (PolkitDetails *details) ...@@ -212,8 +212,7 @@ polkit_details_to_gvariant (PolkitDetails *details)
while (g_hash_table_iter_next (&hash_iter, (gpointer) &key, (gpointer) &value)) while (g_hash_table_iter_next (&hash_iter, (gpointer) &key, (gpointer) &value))
g_variant_builder_add (&builder, "{ss}", key, value); g_variant_builder_add (&builder, "{ss}", key, value);
} }
ret = g_variant_builder_end (&builder); return g_variant_builder_end (&builder);
return ret;
} }
PolkitDetails * PolkitDetails *
......
...@@ -198,12 +198,12 @@ polkit_identity_from_string (const gchar *str, ...@@ -198,12 +198,12 @@ polkit_identity_from_string (const gchar *str,
return identity; return identity;
} }
/* Note that this returns a floating value. */
GVariant * GVariant *
polkit_identity_to_gvariant (PolkitIdentity *identity) polkit_identity_to_gvariant (PolkitIdentity *identity)
{ {
GVariantBuilder builder; GVariantBuilder builder;
GVariant *dict; GVariant *dict;
GVariant *ret;
const gchar *kind; const gchar *kind;
kind = ""; kind = "";
...@@ -233,8 +233,7 @@ polkit_identity_to_gvariant (PolkitIdentity *identity) ...@@ -233,8 +233,7 @@ polkit_identity_to_gvariant (PolkitIdentity *identity)
} }
dict = g_variant_builder_end (&builder); dict = g_variant_builder_end (&builder);
ret = g_variant_new ("(s@a{sv})", kind, dict); return g_variant_new ("(s@a{sv})", kind, dict);
return ret;
} }
static GVariant * static GVariant *
...@@ -267,6 +266,7 @@ lookup_asv (GVariant *dict, ...@@ -267,6 +266,7 @@ lookup_asv (GVariant *dict,
g_variant_get_type_string (value), g_variant_get_type_string (value),
type_string); type_string);
g_free (type_string); g_free (type_string);
g_variant_unref (value);
goto out; goto out;
} }
ret = value; ret = value;
......
...@@ -290,12 +290,12 @@ polkit_subject_from_string (const gchar *str, ...@@ -290,12 +290,12 @@ polkit_subject_from_string (const gchar *str,
return subject; return subject;
} }
/* Note that this returns a floating value. */
GVariant * GVariant *
polkit_subject_to_gvariant (PolkitSubject *subject) polkit_subject_to_gvariant (PolkitSubject *subject)
{ {
GVariantBuilder builder; GVariantBuilder builder;
GVariant *dict; GVariant *dict;
GVariant *ret;
const gchar *kind; const gchar *kind;
kind = ""; kind = "";
...@@ -329,8 +329,7 @@ polkit_subject_to_gvariant (PolkitSubject *subject) ...@@ -329,8 +329,7 @@ polkit_subject_to_gvariant (PolkitSubject *subject)
} }
dict = g_variant_builder_end (&builder); dict = g_variant_builder_end (&builder);
ret = g_variant_new ("(s@a{sv})", kind, dict); return g_variant_new ("(s@a{sv})", kind, dict);
return ret;
} }
static GVariant * static GVariant *
...@@ -363,6 +362,7 @@ lookup_asv (GVariant *dict, ...@@ -363,6 +362,7 @@ lookup_asv (GVariant *dict,
g_variant_get_type_string (value), g_variant_get_type_string (value),
type_string); type_string);
g_free (type_string); g_free (type_string);
g_variant_unref (value);
goto out; goto out;
} }
ret = value; ret = value;
......
...@@ -212,22 +212,15 @@ polkit_temporary_authorization_new_for_gvariant (GVariant *value, ...@@ -212,22 +212,15 @@ polkit_temporary_authorization_new_for_gvariant (GVariant *value,
return authorization; return authorization;
} }
/* Note that this returns a floating value. */
GVariant * GVariant *
polkit_temporary_authorization_to_gvariant (PolkitTemporaryAuthorization *authorization) polkit_temporary_authorization_to_gvariant (PolkitTemporaryAuthorization *authorization)
{ {
GVariant *ret; return g_variant_new ("(ss@(sa{sv})tt)",
GVariant *subject_gvariant; authorization->id,
authorization->action_id,
subject_gvariant = polkit_subject_to_gvariant (authorization->subject); polkit_subject_to_gvariant (authorization->subject), /* A floating value */
g_variant_ref_sink (subject_gvariant); authorization->time_obtained,
ret = g_variant_new ("(ss@(sa{sv})tt)", authorization->time_expires);
authorization->id,
authorization->action_id,
subject_gvariant,
authorization->time_obtained,
authorization->time_expires);
g_variant_unref (subject_gvariant);
return ret;
} }
...@@ -451,6 +451,7 @@ polkit_unix_session_initable_init (GInitable *initable, ...@@ -451,6 +451,7 @@ polkit_unix_session_initable_init (GInitable *initable,
PolkitUnixSession *session = POLKIT_UNIX_SESSION (initable); PolkitUnixSession *session = POLKIT_UNIX_SESSION (initable);
gboolean ret = FALSE; gboolean ret = FALSE;
char *s; char *s;
uid_t uid;
if (session->session_id != NULL) if (session->session_id != NULL)
{ {
...@@ -467,6 +468,19 @@ polkit_unix_session_initable_init (GInitable *initable, ...@@ -467,6 +468,19 @@ polkit_unix_session_initable_init (GInitable *initable,
goto out; 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, g_set_error (error,
POLKIT_ERROR, POLKIT_ERROR,
POLKIT_ERROR_FAILED, POLKIT_ERROR_FAILED,
......
...@@ -88,8 +88,6 @@ send_dbus_message (const char *cookie, const char *user) ...@@ -88,8 +88,6 @@ send_dbus_message (const char *cookie, const char *user)
ret = FALSE; ret = FALSE;
g_type_init ();
error = NULL; error = NULL;
authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error); authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
if (authority == NULL) if (authority == NULL)
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#ifndef __POLKIT_AGENT_HELPER_PRIVATE_H #ifndef __POLKIT_AGENT_HELPER_PRIVATE_H
#define __POLKIT_AGENT_HELPER_PRIVATE_H #define __POLKIT_AGENT_HELPER_PRIVATE_H
#define _GNU_SOURCE
#include <polkit/polkit.h> #include <polkit/polkit.h>
/* Development aid: define PAH_DEBUG to get debugging output. Do _NOT_ /* Development aid: define PAH_DEBUG to get debugging output. Do _NOT_
......
...@@ -156,7 +156,6 @@ server_register (Server *server, ...@@ -156,7 +156,6 @@ server_register (Server *server,
NULL, NULL,
&local_error)) &local_error))
{ {
g_warning ("Unable to register authentication agent: %s", local_error->message);
g_propagate_error (error, local_error); g_propagate_error (error, local_error);
} }
else else
...@@ -422,10 +421,8 @@ polkit_agent_listener_register_with_options (PolkitAgentListener *listener, ...@@ -422,10 +421,8 @@ polkit_agent_listener_register_with_options (PolkitAgentListener *listener,
if (flags & POLKIT_AGENT_REGISTER_FLAGS_RUN_IN_THREAD) if (flags & POLKIT_AGENT_REGISTER_FLAGS_RUN_IN_THREAD)
{ {
server->thread = g_thread_create (server_thread_func, server->thread = g_thread_try_new ("polkit agent listener",
server, server_thread_func, server, error);
TRUE,
error);
if (server->thread == NULL) if (server->thread == NULL)
{ {
server_free (server); server_free (server);
......
...@@ -112,7 +112,7 @@ gboolean polkit_agent_listener_initiate_authentication_finish (PolkitAgentList ...@@ -112,7 +112,7 @@ gboolean polkit_agent_listener_initiate_authentication_finish (PolkitAgentList
gboolean polkit_agent_register_listener (PolkitAgentListener *listener, gboolean polkit_agent_register_listener (PolkitAgentListener *listener,
PolkitSubject *subject, PolkitSubject *subject,
const gchar *object_path, 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: * PolkitAgentRegisterFlags:
......
...@@ -645,11 +645,8 @@ server_handle_enumerate_actions (Server *server, ...@@ -645,11 +645,8 @@ server_handle_enumerate_actions (Server *server,
for (l = actions; l != NULL; l = l->next) for (l = actions; l != NULL; l = l->next)
{ {
PolkitActionDescription *ad = POLKIT_ACTION_DESCRIPTION (l->data); PolkitActionDescription *ad = POLKIT_ACTION_DESCRIPTION (l->data);
GVariant *value; g_variant_builder_add_value (&builder,
value = polkit_action_description_to_gvariant (ad); polkit_action_description_to_gvariant (ad)); /* A floating value */
g_variant_ref_sink (value);
g_variant_builder_add_value (&builder, value);
g_variant_unref (value);
} }
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(a(ssssssuuua{ss}))", &builder)); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(a(ssssssuuua{ss}))", &builder));
...@@ -709,11 +706,9 @@ check_auth_cb (GObject *source_object, ...@@ -709,11 +706,9 @@ check_auth_cb (GObject *source_object,
} }
else else
{ {
GVariant *value; g_dbus_method_invocation_return_value (data->invocation,
value = polkit_authorization_result_to_gvariant (result); g_variant_new ("(@(bba{ss}))",
g_variant_ref_sink (value); polkit_authorization_result_to_gvariant (result))); /* A floating value */
g_dbus_method_invocation_return_value (data->invocation, g_variant_new ("(@(bba{ss}))", value));
g_variant_unref (value);
g_object_unref (result); g_object_unref (result);
} }
...@@ -956,6 +951,7 @@ server_handle_register_authentication_agent_with_options (Server ...@@ -956,6 +951,7 @@ server_handle_register_authentication_agent_with_options (Server
g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
out: out:
g_variant_unref (subject_gvariant);
if (options != NULL) if (options != NULL)
g_variant_unref (options); g_variant_unref (options);
if (subject != NULL) if (subject != NULL)
...@@ -1007,6 +1003,7 @@ server_handle_unregister_authentication_agent (Server *server, ...@@ -1007,6 +1003,7 @@ server_handle_unregister_authentication_agent (Server *server,
g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
out: out:
g_variant_unref (subject_gvariant);
if (subject != NULL) if (subject != NULL)
g_object_unref (subject); g_object_unref (subject);
} }
...@@ -1057,6 +1054,7 @@ server_handle_authentication_agent_response (Server *server, ...@@ -1057,6 +1054,7 @@ server_handle_authentication_agent_response (Server *server,
g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
out: out:
g_variant_unref (identity_gvariant);
if (identity != NULL) if (identity != NULL)
g_object_unref (identity); g_object_unref (identity);
} }
...@@ -1107,6 +1105,7 @@ server_handle_authentication_agent_response2 (Server *server, ...@@ -1107,6 +1105,7 @@ server_handle_authentication_agent_response2 (Server *server,
g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
out: out:
g_variant_unref (identity_gvariant);
if (identity != NULL) if (identity != NULL)
g_object_unref (identity); g_object_unref (identity);
} }
...@@ -1158,17 +1157,15 @@ server_handle_enumerate_temporary_authorizations (Server *server ...@@ -1158,17 +1157,15 @@ server_handle_enumerate_temporary_authorizations (Server *server
for (l = authorizations; l != NULL; l = l->next) for (l = authorizations; l != NULL; l = l->next)
{ {
PolkitTemporaryAuthorization *a = POLKIT_TEMPORARY_AUTHORIZATION (l->data); PolkitTemporaryAuthorization *a = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
GVariant *value; g_variant_builder_add_value (&builder,
value = polkit_temporary_authorization_to_gvariant (a); polkit_temporary_authorization_to_gvariant (a)); /* A floating value */
g_variant_ref_sink (value);
g_variant_builder_add_value (&builder, value);
g_variant_unref (value);
} }
g_list_foreach (authorizations, (GFunc) g_object_unref, NULL); g_list_foreach (authorizations, (GFunc) g_object_unref, NULL);
g_list_free (authorizations); g_list_free (authorizations);
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(a(ss(sa{sv})tt))", &builder)); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(a(ss(sa{sv})tt))", &builder));
out: out:
g_variant_unref (subject_gvariant);
if (subject != NULL) if (subject != NULL)
g_object_unref (subject); g_object_unref (subject);
} }
...@@ -1215,6 +1212,7 @@ server_handle_revoke_temporary_authorizations (Server *server, ...@@ -1215,6 +1212,7 @@ server_handle_revoke_temporary_authorizations (Server *server,
g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
out: out:
g_variant_unref (subject_gvariant);
if (subject != NULL) if (subject != NULL)
g_object_unref (subject); g_object_unref (subject);
} }
......
...@@ -1906,15 +1906,15 @@ authentication_agent_begin_cb (GDBusProxy *proxy, ...@@ -1906,15 +1906,15 @@ authentication_agent_begin_cb (GDBusProxy *proxy,
AuthenticationSession *session = user_data; AuthenticationSession *session = user_data;
gboolean gained_authorization; gboolean gained_authorization;
gboolean was_dismissed; gboolean was_dismissed;
GVariant *result;
GError *error; GError *error;
was_dismissed = FALSE; was_dismissed = FALSE;
gained_authorization = FALSE; gained_authorization = FALSE;
error = NULL; error = NULL;
if (!g_dbus_proxy_call_finish (proxy, result = g_dbus_proxy_call_finish (proxy, res, &error);
res, if (result == NULL)
&error))
{ {
g_printerr ("Error performing authentication: %s (%s %d)\n", g_printerr ("Error performing authentication: %s (%s %d)\n",
error->message, error->message,
...@@ -1926,6 +1926,7 @@ authentication_agent_begin_cb (GDBusProxy *proxy, ...@@ -1926,6 +1926,7 @@ authentication_agent_begin_cb (GDBusProxy *proxy,
} }
else else
{ {
g_variant_unref (result);
gained_authorization = session->is_authenticated; gained_authorization = session->is_authenticated;
g_debug ("Authentication complete, is_authenticated = %d", session->is_authenticated); g_debug ("Authentication complete, is_authenticated = %d", session->is_authenticated);
} }
...@@ -2299,7 +2300,6 @@ authentication_agent_initiate_challenge (AuthenticationAgent *agent, ...@@ -2299,7 +2300,6 @@ authentication_agent_initiate_challenge (AuthenticationAgent *agent,
gchar *localized_message; gchar *localized_message;
gchar *localized_icon_name; gchar *localized_icon_name;
PolkitDetails *localized_details; PolkitDetails *localized_details;
GVariant *details_gvariant;
GList *user_identities = NULL; GList *user_identities = NULL;
GVariantBuilder identities_builder; GVariantBuilder identities_builder;
GVariant *parameters; GVariant *parameters;
...@@ -2397,28 +2397,21 @@ authentication_agent_initiate_challenge (AuthenticationAgent *agent, ...@@ -2397,28 +2397,21 @@ authentication_agent_initiate_challenge (AuthenticationAgent *agent,
add_pid (localized_details, caller, "polkit.caller-pid"); add_pid (localized_details, caller, "polkit.caller-pid");
add_pid (localized_details, subject, "polkit.subject-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})")); g_variant_builder_init (&identities_builder, G_VARIANT_TYPE ("a(sa{sv})"));
for (l = user_identities; l != NULL; l = l->next) for (l = user_identities; l != NULL; l = l->next)
{ {
PolkitIdentity *identity = POLKIT_IDENTITY (l->data); PolkitIdentity *identity = POLKIT_IDENTITY (l->data);
GVariant *value; g_variant_builder_add_value (&identities_builder,
value = polkit_identity_to_gvariant (identity); polkit_identity_to_gvariant (identity)); /* A floating value */
g_variant_ref_sink (value);
g_variant_builder_add_value (&identities_builder, value);
g_variant_unref (value);
} }
parameters = g_variant_new ("(sss@a{ss}sa(sa{sv}))", parameters = g_variant_new ("(sss@a{ss}sa(sa{sv}))",
action_id, action_id,
localized_message, localized_message,
localized_icon_name, localized_icon_name,
details_gvariant, polkit_details_to_gvariant (localized_details), /* A floating value */
session->cookie, session->cookie,
&identities_builder); &identities_builder);
g_variant_unref (details_gvariant);
g_dbus_proxy_call (agent->proxy, g_dbus_proxy_call (agent->proxy,
"BeginAuthentication", "BeginAuthentication",
...@@ -2444,13 +2437,18 @@ authentication_agent_cancel_cb (GDBusProxy *proxy, ...@@ -2444,13 +2437,18 @@ authentication_agent_cancel_cb (GDBusProxy *proxy,
GAsyncResult *res, GAsyncResult *res,
gpointer user_data) gpointer user_data)
{ {
GVariant *result;
GError *error; GError *error;
error = NULL; 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_printerr ("Error cancelling authentication: %s\n", error->message);
g_error_free (error); g_error_free (error);
} }
else
g_variant_unref (result);
} }
static void static void
......
...@@ -173,14 +173,12 @@ main (int argc, ...@@ -173,14 +173,12 @@ main (int argc,
/* Disable remote file access from GIO. */ /* Disable remote file access from GIO. */
setenv ("GIO_USE_VFS", "local", 1); setenv ("GIO_USE_VFS", "local", 1);
g_type_init ();
opt_context = g_option_context_new ("polkit system daemon"); opt_context = g_option_context_new ("polkit system daemon");
g_option_context_add_main_entries (opt_context, opt_entries, NULL); g_option_context_add_main_entries (opt_context, opt_entries, NULL);
error = NULL; error = NULL;
if (!g_option_context_parse (opt_context, &argc, &argv, &error)) 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); g_error_free (error);
goto out; goto out;
} }
...@@ -207,7 +205,7 @@ main (int argc, ...@@ -207,7 +205,7 @@ main (int argc,
error = NULL; error = NULL;
if (!become_user (POLKITD_USER, &error)) 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); POLKITD_USER, error->message);
g_clear_error (&error); g_clear_error (&error);
goto out; goto out;
......
...@@ -125,8 +125,6 @@ main (int argc, char *argv[]) ...@@ -125,8 +125,6 @@ main (int argc, char *argv[])
/* Disable remote file access from GIO. */ /* Disable remote file access from GIO. */
setenv ("GIO_USE_VFS", "local", 1); setenv ("GIO_USE_VFS", "local", 1);
g_type_init ();
opt_show_version = FALSE; opt_show_version = FALSE;
opt_verbose = FALSE; opt_verbose = FALSE;
......
...@@ -366,8 +366,6 @@ main (int argc, char *argv[]) ...@@ -366,8 +366,6 @@ main (int argc, char *argv[])
/* Disable remote file access from GIO. */ /* Disable remote file access from GIO. */
setenv ("GIO_USE_VFS", "local", 1); setenv ("GIO_USE_VFS", "local", 1);
g_type_init ();
details = polkit_details_new (); details = polkit_details_new ();
opt_show_help = FALSE; opt_show_help = FALSE;
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
# include "config.h" # include "config.h"
#endif #endif
#define _GNU_SOURCE
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
...@@ -707,11 +705,6 @@ main (int argc, char *argv[]) ...@@ -707,11 +705,6 @@ main (int argc, char *argv[])
goto out; 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 */ /* make sure we are nuked if the parent process dies */
#ifdef __linux__ #ifdef __linux__
if (prctl (PR_SET_PDEATHSIG, SIGTERM) != 0) if (prctl (PR_SET_PDEATHSIG, SIGTERM) != 0)
......
...@@ -55,7 +55,7 @@ main (int argc, char *argv[]) ...@@ -55,7 +55,7 @@ main (int argc, char *argv[])
}, },
{ {
"system-bus-name", 's', 0, G_OPTION_ARG_STRING, &opt_system_bus_name, "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, "version", 0, 0, G_OPTION_ARG_NONE, &opt_show_version,
...@@ -78,8 +78,6 @@ main (int argc, char *argv[]) ...@@ -78,8 +78,6 @@ main (int argc, char *argv[])
/* Disable remote file access from GIO. */ /* Disable remote file access from GIO. */
setenv ("GIO_USE_VFS", "local", 1); setenv ("GIO_USE_VFS", "local", 1);
g_type_init ();
error = NULL; error = NULL;
context = g_option_context_new (""); context = g_option_context_new ("");
s = g_strdup_printf (_("Report bugs to: %s\n" s = g_strdup_printf (_("Report bugs to: %s\n"
......
...@@ -326,7 +326,7 @@ struct entry *netgroup_iter_next(struct netgroup_iter *iter) { ...@@ -326,7 +326,7 @@ struct entry *netgroup_iter_next(struct netgroup_iter *iter) {
// Grow the stack // Grow the stack
iter->depth++; iter->depth++;
if (iter->depth > NETGROUP_MAX_DEPTH) { if (iter->depth >= NETGROUP_MAX_DEPTH) {
iter->depth = -1; iter->depth = -1;
return NULL; // Too much recursion return NULL; // Too much recursion
} }
......
...@@ -170,7 +170,6 @@ add_comparison_tests (void) ...@@ -170,7 +170,6 @@ add_comparison_tests (void)
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
g_type_init ();
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
g_test_add_data_func ("/PolkitIdentity/user_string_0", "unix-user:root", test_string); g_test_add_data_func ("/PolkitIdentity/user_string_0", "unix-user:root", test_string);
......
...@@ -73,7 +73,6 @@ test_set_gid (void) ...@@ -73,7 +73,6 @@ test_set_gid (void)
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
g_type_init ();
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
g_test_add_func ("/PolkitUnixGroup/new", test_new); g_test_add_func ("/PolkitUnixGroup/new", test_new);
g_test_add_func ("/PolkitUnixGroup/new_for_name", test_new_for_name); g_test_add_func ("/PolkitUnixGroup/new_for_name", test_new_for_name);
......
...@@ -68,7 +68,6 @@ test_set_name (void) ...@@ -68,7 +68,6 @@ test_set_name (void)
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
g_type_init ();
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
g_test_add_func ("/PolkitUnixNetgroup/new", test_new); g_test_add_func ("/PolkitUnixNetgroup/new", test_new);
g_test_add_func ("/PolkitUnixNetgroup/set_name", test_set_name); g_test_add_func ("/PolkitUnixNetgroup/set_name", test_set_name);
......
...@@ -95,7 +95,6 @@ test_set_uid (void) ...@@ -95,7 +95,6 @@ test_set_uid (void)
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
g_type_init ();
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
g_test_add_func ("/PolkitUnixUser/new", test_new); g_test_add_func ("/PolkitUnixUser/new", test_new);
g_test_add_func ("/PolkitUnixUser/new_for_name", test_new_for_name); g_test_add_func ("/PolkitUnixUser/new_for_name", test_new_for_name);
......
...@@ -182,6 +182,14 @@ static const RulesTestCase rules_test_cases[] = { ...@@ -182,6 +182,14 @@ static const RulesTestCase rules_test_cases[] = {
NULL, NULL,
POLKIT_IMPLICIT_AUTHORIZATION_AUTHENTICATION_REQUIRED, 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 /* Ordering tests ... we have four rules files, check they are
* evaluated in order by checking the detail set by each rules * evaluated in order by checking the detail set by each rules
...@@ -403,7 +411,6 @@ main (int argc, char *argv[]) ...@@ -403,7 +411,6 @@ main (int argc, char *argv[])
{ {
setlocale (LC_ALL, ""); setlocale (LC_ALL, "");
g_type_init ();
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
//polkit_test_redirect_logs (); //polkit_test_redirect_logs ();
......