diff options
author | Vivek Dasmohapatra <vivek@collabora.co.uk> | 2011-06-24 16:36:12 +0100 |
---|---|---|
committer | Vivek Dasmohapatra <vivek@collabora.co.uk> | 2011-07-22 13:22:46 +0100 |
commit | 1191b793e3c445cc836194c63c2d52b8dc42e56b (patch) | |
tree | 97c3e059ba84c562b03aae6a59dfdd11c73f97a8 | |
parent | aae2f108921f4a8eedd861f76e8650c128e2d0cc (diff) | |
download | telepathy-mission-control-1191b793e3c445cc836194c63c2d52b8dc42e56b.tar.gz |
The Aegis ACL plugin must activate handlers to check their credentials
-rw-r--r-- | plugins/mcp-dbus-aegis-acl.c | 39 |
1 files 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) |