summaryrefslogtreecommitdiff
path: root/plugins/screensaver-proxy
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2019-04-01 17:14:20 +0200
committerBenjamin Berg <benjamin@sipsolutions.net>2019-04-15 16:23:20 +0000
commitabdaa8f83cda9f1d2cf9335ae47cc0f4862208a3 (patch)
treed1680054a1b9dbdd01d69de62640361eef8c1c77 /plugins/screensaver-proxy
parent69c781c2e3edccf224b874a539ff9c7c44135893 (diff)
downloadgnome-settings-daemon-abdaa8f83cda9f1d2cf9335ae47cc0f4862208a3.tar.gz
screensaver-proxy: Fix missing error returns for DBus method calls
Many of the error cases were not handled, resulting in the sender to never get a reply. Fix these by adding appropriate error return paths (simply returning a generic GError in some cases). Fixes: #344
Diffstat (limited to 'plugins/screensaver-proxy')
-rw-r--r--plugins/screensaver-proxy/gsd-screensaver-proxy-manager.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/plugins/screensaver-proxy/gsd-screensaver-proxy-manager.c b/plugins/screensaver-proxy/gsd-screensaver-proxy-manager.c
index 43ee2ac5..e434eb90 100644
--- a/plugins/screensaver-proxy/gsd-screensaver-proxy-manager.c
+++ b/plugins/screensaver-proxy/gsd-screensaver-proxy-manager.c
@@ -192,10 +192,14 @@ handle_method_call (GDBusConnection *connection,
gpointer user_data)
{
GsdScreensaverProxyManager *manager = GSD_SCREENSAVER_PROXY_MANAGER (user_data);
+ g_autoptr(GError) error = NULL;
/* Check session pointer as a proxy for whether the manager is in the
start or stop state */
if (manager->session == NULL) {
+ g_dbus_method_invocation_return_dbus_error (invocation,
+ "org.freedesktop.DBus.Error.NotSupported",
+ "Session is unavailable");
return;
}
@@ -216,7 +220,11 @@ handle_method_call (GDBusConnection *connection,
g_variant_new ("(susu)",
app_id, 0, reason, GSM_INHIBITOR_FLAG_IDLE),
G_DBUS_CALL_FLAGS_NONE,
- -1, NULL, NULL);
+ -1, NULL, &error);
+
+ if (!ret)
+ goto error;
+
g_variant_get (ret, "(u)", &cookie);
g_hash_table_insert (manager->cookie_ht,
GUINT_TO_POINTER (cookie),
@@ -237,14 +245,19 @@ handle_method_call (GDBusConnection *connection,
}
g_dbus_method_invocation_return_value (invocation, ret);
} else if (g_strcmp0 (method_name, "UnInhibit") == 0) {
+ GVariant *ret;
guint cookie;
g_variant_get (parameters, "(u)", &cookie);
- g_dbus_proxy_call_sync (G_DBUS_PROXY (manager->session),
- "Uninhibit",
- parameters,
- G_DBUS_CALL_FLAGS_NONE,
- -1, NULL, NULL);
+ ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (manager->session),
+ "Uninhibit",
+ parameters,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, &error);
+
+ if (!ret)
+ goto error;
+
g_debug ("Removing cookie %u from the list for %s", cookie, sender);
g_hash_table_remove (manager->cookie_ht, GUINT_TO_POINTER (cookie));
g_dbus_method_invocation_return_value (invocation, NULL);
@@ -272,6 +285,9 @@ unimplemented:
g_dbus_method_invocation_return_dbus_error (invocation,
"org.freedesktop.DBus.Error.NotSupported",
"This method is not implemented");
+ return;
+error:
+ g_dbus_method_invocation_return_gerror (invocation, error);
}
static const GDBusInterfaceVTable interface_vtable =