summaryrefslogtreecommitdiff
path: root/src/up-polkit.c
diff options
context:
space:
mode:
authorMatthias Clasen <matthias.clasen@gmail.com>2010-08-19 13:04:38 +0200
committerMartin Pitt <martin.pitt@ubuntu.com>2010-08-19 13:04:38 +0200
commit3967e062ef5a58c4f3f283f34d591c6e8a5d8788 (patch)
tree99ba577a7f76857c5871267077c0da86d7c6e556 /src/up-polkit.c
parentd815c491eb105c49a7dbcb29c355ca9aaa8d92c4 (diff)
downloadupower-3967e062ef5a58c4f3f283f34d591c6e8a5d8788.tar.gz
Fix double D-BUS return in up_daemon_*_allowed
Do not send a D-BUS return message any more in up_polkit_is_allowed(), since this makes it hard for callers to ensure that they return exactly one result to the D-BUS caller. Instead, just pass a GError to the caller. Update up_daemon_suspend_allowed() and up_daemon_hibernate_allowed() accordingly, to always return either a result or an error. Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
Diffstat (limited to 'src/up-polkit.c')
-rw-r--r--src/up-polkit.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/up-polkit.c b/src/up-polkit.c
index 9b86394..ab2c66d 100644
--- a/src/up-polkit.c
+++ b/src/up-polkit.c
@@ -103,10 +103,9 @@ out:
* up_polkit_is_allowed:
**/
gboolean
-up_polkit_is_allowed (UpPolkit *polkit, PolkitSubject *subject, const gchar *action_id, DBusGMethodInvocation *context)
+up_polkit_is_allowed (UpPolkit *polkit, PolkitSubject *subject, const gchar *action_id, GError **error)
{
gboolean ret = FALSE;
- GError *error;
GError *error_local = NULL;
PolkitAuthorizationResult *result;
@@ -116,10 +115,8 @@ up_polkit_is_allowed (UpPolkit *polkit, PolkitSubject *subject, const gchar *act
POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE,
NULL, &error_local);
if (result == NULL) {
- error = g_error_new (UP_DAEMON_ERROR, UP_DAEMON_ERROR_GENERAL, "failed to check authorisation: %s", error_local->message);
- dbus_g_method_return_error (context, error);
+ g_set_error (error, UP_DAEMON_ERROR, UP_DAEMON_ERROR_GENERAL, "failed to check authorisation: %s", error_local->message);
g_error_free (error_local);
- g_error_free (error);
goto out;
}