[gnome-panel] Check errors returned by PolicyKit
- From: Matthias Clasen <matthiasc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-panel] Check errors returned by PolicyKit
- Date: Tue, 12 Jan 2010 19:33:02 +0000 (UTC)
commit ed98774a1116a8ec3868615d9d8723ff9c832f6d
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jan 12 14:30:35 2010 -0500
Check errors returned by PolicyKit
Not checking them could lead to crashes. See bug 604678.
applets/clock/gnome-clock-applet-mechanism.c | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/applets/clock/gnome-clock-applet-mechanism.c b/applets/clock/gnome-clock-applet-mechanism.c
index b5ee23e..84e10e7 100644
--- a/applets/clock/gnome-clock-applet-mechanism.c
+++ b/applets/clock/gnome-clock-applet-mechanism.c
@@ -241,9 +241,16 @@ _check_polkit_for_action (GnomeClockAppletMechanism *mechanism, DBusGMethodInvoc
action,
NULL,
POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
- NULL, NULL);
+ NULL, &error);
g_object_unref (subject);
+ if (error) {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+
+ return FALSE;
+ }
+
if (!polkit_authorization_result_get_is_authorized (result)) {
error = g_error_new (GNOME_CLOCK_APPLET_MECHANISM_ERROR,
GNOME_CLOCK_APPLET_MECHANISM_ERROR_NOT_PRIVILEGED,
@@ -565,19 +572,28 @@ check_can_do (GnomeClockAppletMechanism *mechanism,
const char *sender;
PolkitSubject *subject;
PolkitAuthorizationResult *result;
+ GError *error;
/* Check that caller is privileged */
sender = dbus_g_method_get_sender (context);
subject = polkit_system_bus_name_new (sender);
+ error = NULL;
result = polkit_authority_check_authorization_sync (mechanism->priv->auth,
subject,
action,
NULL,
0,
- NULL, NULL);
+ NULL,
+ &error);
g_object_unref (subject);
+ if (error) {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
+ }
+
if (polkit_authorization_result_get_is_authorized (result)) {
dbus_g_method_return (context, 2);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]