From 1191b793e3c445cc836194c63c2d52b8dc42e56b Mon Sep 17 00:00:00 2001 From: Vivek Dasmohapatra Date: Fri, 24 Jun 2011 16:36:12 +0100 Subject: The Aegis ACL plugin must activate handlers to check their credentials --- plugins/mcp-dbus-aegis-acl.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/plugins/mcp-dbus-aegis-acl.c b/plugins/mcp-dbus-aegis-acl.c index fc0daabb..b67a8681 100644 --- a/plugins/mcp-dbus-aegis-acl.c +++ b/plugins/mcp-dbus-aegis-acl.c @@ -196,7 +196,8 @@ caller_creds_are_enough (const gchar *name, static gboolean check_peer_creds_sync (DBusGConnection *dgc, - const gchar *bus_name) + const gchar *bus_name, + gboolean activate) { DBusGProxy *proxy = dbus_g_proxy_new_for_name (dgc, DBUS_SERVICE_DBUS, @@ -204,7 +205,7 @@ check_peer_creds_sync (DBusGConnection *dgc, AEGIS_INTERFACE); GArray *au = NULL; GError *error = NULL; - gboolean ok; + gboolean ok = FALSE; if (dbus_g_proxy_call (proxy, "GetConnectionCredentials", &error, G_TYPE_STRING, bus_name, @@ -215,6 +216,34 @@ check_peer_creds_sync (DBusGConnection *dgc, ok = caller_creds_are_enough (bus_name, au); g_array_unref (au); } + else if (activate && error->code == DBUS_GERROR_NAME_HAS_NO_OWNER) + { + guint status; + GError *start_error = NULL; + DBusGProxy *dbus = dbus_g_proxy_new_for_name (dgc, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); + + DEBUG ("Trying to activate %s for aegis credentials check", bus_name); + if (dbus_g_proxy_call (dbus, "StartServiceByName", &start_error, + G_TYPE_STRING, bus_name, + G_TYPE_UINT, 0, + G_TYPE_INVALID, + G_TYPE_UINT, &status, + G_TYPE_INVALID)) + { + ok = check_peer_creds_sync (dgc, bus_name, FALSE); + } + else + { + DEBUG ("GetConnectionCredentials failed: %s", start_error->message); + g_clear_error (&start_error); + } + + g_object_unref (dbus); + g_clear_error (&error); + } else { DEBUG ("GetConnectionCredentials failed: %s", error->message); @@ -241,7 +270,7 @@ caller_authorised (const McpDBusAcl *self, { gchar *caller = dbus_g_method_get_sender ((DBusGMethodInvocation *) call); - ok = check_peer_creds_sync (dgc, caller); + ok = check_peer_creds_sync (dgc, caller, FALSE); g_free (caller); } @@ -372,14 +401,14 @@ handler_is_suitable_async (McpDispatchOperationPolicy *self, if (!tp_str_empty (unique_name)) { ok = check_peer_creds_sync (tp_proxy_get_dbus_connection (dbus), - unique_name); + unique_name, TRUE); } else { g_assert (recipient != NULL); ok = check_peer_creds_sync (tp_proxy_get_dbus_connection (dbus), - tp_proxy_get_bus_name (recipient)); + tp_proxy_get_bus_name (recipient), TRUE); } if (!ok) -- cgit v1.2.1