summaryrefslogtreecommitdiff
path: root/bus/connection.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-04-27 06:25:42 +0000
committerHavoc Pennington <hp@redhat.com>2003-04-27 06:25:42 +0000
commite8d396efef695b9868b0112c4a6266c97678fa8a (patch)
treee6702685d70c2dd65c6b301de8904a672ef7b419 /bus/connection.c
parentb3bd48edfc1aab0a9dc64bfa4c380d845d218e73 (diff)
downloaddbus-e8d396efef695b9868b0112c4a6266c97678fa8a.tar.gz
2003-04-27 Havoc Pennington <hp@pobox.com>
Unbreak my code... * dbus/dbus-transport.c (_dbus_transport_get_dispatch_status): report correct status if we finish processing authentication inside this function. * bus/activation.c (try_send_activation_failure): use bus_transaction_send_error_reply * bus/connection.c (bus_connection_get_groups): return an error explaining the problem * bus/bus.c (bus_context_check_security_policy): implement restriction here that inactive connections can only send the hello message. Also, allow bus driver to send anything to any recipient. * bus/connection.c (bus_connection_complete): create the BusClientPolicy here instead of on-demand. (bus_connection_get_policy): don't return an error * dbus/dbus-message.c (dbus_message_new_error_reply): allow NULL sender field in message being replied to * bus/bus.c (bus_context_check_security_policy): fix silly typo causing it to return FALSE always * bus/policy.c (bus_client_policy_check_can_send): fix bug where we checked sender rather than destination
Diffstat (limited to 'bus/connection.c')
-rw-r--r--bus/connection.c82
1 files changed, 40 insertions, 42 deletions
diff --git a/bus/connection.c b/bus/connection.c
index 8907227c..6bb53148 100644
--- a/bus/connection.c
+++ b/bus/connection.c
@@ -748,7 +748,8 @@ expire_incomplete_timeout (void *data)
dbus_bool_t
bus_connection_get_groups (DBusConnection *connection,
unsigned long **groups,
- int *n_groups)
+ int *n_groups,
+ DBusError *error)
{
BusConnectionData *d;
unsigned long uid;
@@ -767,8 +768,9 @@ bus_connection_get_groups (DBusConnection *connection,
{
if (!_dbus_user_database_get_groups (user_database,
uid, groups, n_groups,
- NULL))
+ error))
{
+ _DBUS_ASSERT_ERROR_IS_SET (error);
_dbus_verbose ("Did not get any groups for UID %lu\n",
uid);
return FALSE;
@@ -792,7 +794,8 @@ bus_connection_is_in_group (DBusConnection *connection,
unsigned long *group_ids;
int n_group_ids;
- if (!bus_connection_get_groups (connection, &group_ids, &n_group_ids))
+ if (!bus_connection_get_groups (connection, &group_ids, &n_group_ids,
+ NULL))
return FALSE;
i = 0;
@@ -811,47 +814,14 @@ bus_connection_is_in_group (DBusConnection *connection,
}
BusClientPolicy*
-bus_connection_get_policy (DBusConnection *connection,
- DBusError *error)
+bus_connection_get_policy (DBusConnection *connection)
{
BusConnectionData *d;
d = BUS_CONNECTION_DATA (connection);
_dbus_assert (d != NULL);
-
- if (!dbus_connection_get_is_authenticated (connection))
- {
- _dbus_verbose ("Tried to get policy for unauthenticated connection!\n");
- dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
- "Connection is not yet authenticated; the pre-authentication "
- "implicit security policy is to deny everything");
- return NULL;
- }
-
- /* We do lazy creation of the policy because
- * it can only be done post-authentication.
- */
- if (d->policy == NULL)
- {
- d->policy =
- bus_context_create_client_policy (d->connections->context,
- connection);
-
- /* we may have a NULL policy on OOM or error getting list of
- * groups for a user. In the latter case we don't handle it so
- * well currently, as it will just keep failing over and over.
- */
- }
-
- if (d->policy == NULL)
- {
- dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
- "There was an error creating the security policy for connection \"%s\"; "
- "all operations will fail for now.",
- d->name ? d->name : "(inactive)");
- return NULL;
- }
+ _dbus_assert (d->policy != NULL);
return d->policy;
}
@@ -1142,8 +1112,9 @@ bus_connection_get_n_services_owned (DBusConnection *connection)
}
dbus_bool_t
-bus_connection_set_name (DBusConnection *connection,
- const DBusString *name)
+bus_connection_complete (DBusConnection *connection,
+ const DBusString *name,
+ DBusError *error)
{
BusConnectionData *d;
unsigned long uid;
@@ -1151,19 +1122,43 @@ bus_connection_set_name (DBusConnection *connection,
d = BUS_CONNECTION_DATA (connection);
_dbus_assert (d != NULL);
_dbus_assert (d->name == NULL);
+ _dbus_assert (d->policy == NULL);
if (!_dbus_string_copy_data (name, &d->name))
- return FALSE;
+ {
+ BUS_SET_OOM (error);
+ return FALSE;
+ }
_dbus_assert (d->name != NULL);
_dbus_verbose ("Name %s assigned to %p\n", d->name, connection);
+ d->policy = bus_context_create_client_policy (d->connections->context,
+ connection,
+ error);
+
+ /* we may have a NULL policy on OOM or error getting list of
+ * groups for a user. In the latter case we don't handle it so
+ * well currently, as it will just keep failing over and over.
+ */
+
+ if (d->policy == NULL)
+ {
+ _dbus_verbose ("Failed to create security policy for connection %p\n",
+ connection);
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ dbus_free (d->name);
+ d->name = NULL;
+ return FALSE;
+ }
+
if (dbus_connection_get_unix_user (connection, &uid))
{
if (!adjust_connections_for_uid (d->connections,
uid, 1))
{
+ BUS_SET_OOM (error);
dbus_free (d->name);
d->name = NULL;
return FALSE;
@@ -1586,7 +1581,10 @@ bus_transaction_send_error_reply (BusTransaction *transaction,
_dbus_assert (error != NULL);
_DBUS_ASSERT_ERROR_IS_SET (error);
-
+
+ _dbus_verbose ("Sending error reply %s \"%s\"\n",
+ error->name, error->message);
+
reply = dbus_message_new_error_reply (in_reply_to,
error->name,
error->message);