mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-02-01 08:00:30 +01:00
Add missing D-Bus return in up_qos_cancel_request()
Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
This commit is contained in:
parent
43ed5814cf
commit
1fc5aae71f
4 changed files with 34 additions and 12 deletions
|
|
@ -480,7 +480,7 @@ up_daemon_suspend (UpDaemon *daemon, DBusGMethodInvocation *context)
|
|||
if (subject == NULL)
|
||||
goto out;
|
||||
|
||||
if (!up_polkit_check_auth (priv->polkit, subject, "org.freedesktop.upower.suspend", context))
|
||||
if (!up_polkit_check_auth (priv->polkit, subject, "org.freedesktop.upower.suspend", NULL))
|
||||
goto out;
|
||||
|
||||
/* already requested */
|
||||
|
|
@ -511,13 +511,21 @@ up_daemon_suspend_allowed (UpDaemon *daemon, DBusGMethodInvocation *context)
|
|||
gboolean ret;
|
||||
PolkitSubject *subject = NULL;
|
||||
UpDaemonPrivate *priv = daemon->priv;
|
||||
GError *error;
|
||||
|
||||
subject = up_polkit_get_subject (priv->polkit, context);
|
||||
if (subject == NULL)
|
||||
goto out;
|
||||
|
||||
ret = up_polkit_is_allowed (priv->polkit, subject, "org.freedesktop.upower.suspend", context);
|
||||
dbus_g_method_return (context, ret);
|
||||
error = NULL;
|
||||
ret = up_polkit_is_allowed (priv->polkit, subject, "org.freedesktop.upower.suspend", &error);
|
||||
if (error) {
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_error_free (error);
|
||||
}
|
||||
else {
|
||||
dbus_g_method_return (context, ret);
|
||||
}
|
||||
|
||||
out:
|
||||
if (subject != NULL)
|
||||
|
|
@ -627,13 +635,21 @@ up_daemon_hibernate_allowed (UpDaemon *daemon, DBusGMethodInvocation *context)
|
|||
gboolean ret;
|
||||
PolkitSubject *subject = NULL;
|
||||
UpDaemonPrivate *priv = daemon->priv;
|
||||
GError *error;
|
||||
|
||||
subject = up_polkit_get_subject (priv->polkit, context);
|
||||
if (subject == NULL)
|
||||
goto out;
|
||||
|
||||
ret = up_polkit_is_allowed (priv->polkit, subject, "org.freedesktop.upower.hibernate", context);
|
||||
dbus_g_method_return (context, ret);
|
||||
error = NULL;
|
||||
ret = up_polkit_is_allowed (priv->polkit, subject, "org.freedesktop.upower.hibernate", &error);
|
||||
if (error) {
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_error_free (error);
|
||||
}
|
||||
else {
|
||||
dbus_g_method_return (context, ret);
|
||||
}
|
||||
|
||||
out:
|
||||
if (subject != NULL)
|
||||
|
|
|
|||
|
|
@ -52,12 +52,19 @@ static gpointer up_polkit_object = NULL;
|
|||
PolkitSubject *
|
||||
up_polkit_get_subject (UpPolkit *polkit, DBusGMethodInvocation *context)
|
||||
{
|
||||
GError *error;
|
||||
const gchar *sender;
|
||||
PolkitSubject *subject;
|
||||
|
||||
sender = dbus_g_method_get_sender (context);
|
||||
subject = polkit_system_bus_name_new (sender);
|
||||
|
||||
if (subject == NULL) {
|
||||
error = g_error_new (UP_DAEMON_ERROR, UP_DAEMON_ERROR_GENERAL, "failed to get PolicyKit subject");
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
return subject;
|
||||
}
|
||||
|
||||
|
|
@ -103,10 +110,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 +122,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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,11 +56,11 @@ PolkitSubject *up_polkit_get_subject (UpPolkit *polkit,
|
|||
gboolean up_polkit_check_auth (UpPolkit *polkit,
|
||||
PolkitSubject *subject,
|
||||
const gchar *action_id,
|
||||
DBusGMethodInvocation *context);
|
||||
DBusGMethodInvocation *context);
|
||||
gboolean up_polkit_is_allowed (UpPolkit *polkit,
|
||||
PolkitSubject *subject,
|
||||
const gchar *action_id,
|
||||
DBusGMethodInvocation *context);
|
||||
GError **error);
|
||||
gboolean up_polkit_get_uid (UpPolkit *polkit,
|
||||
PolkitSubject *subject,
|
||||
uid_t *uid);
|
||||
|
|
|
|||
|
|
@ -395,6 +395,8 @@ up_qos_cancel_request (UpQos *qos, guint cookie, DBusGMethodInvocation *context)
|
|||
/* TODO: if persistent remove from datadase */
|
||||
|
||||
g_signal_emit (qos, signals [REQUESTS_CHANGED], 0);
|
||||
|
||||
dbus_g_method_return (context, NULL);
|
||||
out:
|
||||
if (subject != NULL)
|
||||
g_object_unref (subject);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue