From 777707ed8dff6958972a93894a87ec1945c65c14 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 14 Apr 2003 02:29:21 +0000 Subject: 2003-04-13 Havoc Pennington * dbus/dbus-mainloop.c: fix some reentrancy issues by refcounting callbacks * test/data/valid-config-files/debug-allow-all.conf.in: allow all users * dbus/dbus-transport.c (_dbus_transport_get_dispatch_status): fix to only recover unused bytes if we're already authenticated (_dbus_transport_get_is_authenticated): fix to still mark us authenticated if there are unused bytes. * bus/dispatch.c: implement security policy checking * bus/connection.c (bus_transaction_send_from_driver): new * bus/bus.c (bus_context_check_security_policy): new * bus/dispatch.c (send_service_nonexistent_error): delete this, now we just set the DBusError and it gets converted to an error reply. * bus/connection.c (allow_user_function): enable code using actual data from the config file * bus/policy.c (list_allows_user): handle wildcard rules for user/group connection perms --- bus/driver.c | 55 ++++++++++++++----------------------------------------- 1 file changed, 14 insertions(+), 41 deletions(-) (limited to 'bus/driver.c') diff --git a/bus/driver.c b/bus/driver.c index f89b70a3..c7d66d53 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -67,7 +67,7 @@ bus_driver_send_service_deleted (const char *service_name, return FALSE; } - retval = bus_dispatch_broadcast_message (transaction, message, error); + retval = bus_dispatch_broadcast_message (transaction, NULL, message, error); dbus_message_unref (message); return retval; @@ -107,7 +107,7 @@ bus_driver_send_service_created (const char *service_name, return FALSE; } - retval = bus_dispatch_broadcast_message (transaction, message, error); + retval = bus_dispatch_broadcast_message (transaction, NULL, message, error); dbus_message_unref (message); return retval; @@ -131,13 +131,6 @@ bus_driver_send_service_lost (DBusConnection *connection, return FALSE; } - if (!dbus_message_set_sender (message, DBUS_SERVICE_DBUS)) - { - dbus_message_unref (message); - BUS_SET_OOM (error); - return FALSE; - } - if (!dbus_message_append_args (message, DBUS_TYPE_STRING, service_name, 0)) @@ -147,7 +140,7 @@ bus_driver_send_service_lost (DBusConnection *connection, return FALSE; } - if (!bus_transaction_send_message (transaction, connection, message)) + if (!bus_transaction_send_from_driver (transaction, connection, message)) { dbus_message_unref (message); BUS_SET_OOM (error); @@ -178,13 +171,6 @@ bus_driver_send_service_acquired (DBusConnection *connection, return FALSE; } - if (!dbus_message_set_sender (message, DBUS_SERVICE_DBUS)) - { - dbus_message_unref (message); - BUS_SET_OOM (error); - return FALSE; - } - if (!dbus_message_append_args (message, DBUS_TYPE_STRING, service_name, 0)) @@ -194,7 +180,7 @@ bus_driver_send_service_acquired (DBusConnection *connection, return FALSE; } - if (!bus_transaction_send_message (transaction, connection, message)) + if (!bus_transaction_send_from_driver (transaction, connection, message)) { dbus_message_unref (message); BUS_SET_OOM (error); @@ -347,13 +333,6 @@ bus_driver_send_welcome_message (DBusConnection *connection, return FALSE; } - if (!dbus_message_set_sender (welcome, DBUS_SERVICE_DBUS)) - { - dbus_message_unref (welcome); - BUS_SET_OOM (error); - return FALSE; - } - if (!dbus_message_append_args (welcome, DBUS_TYPE_STRING, name, NULL)) @@ -363,7 +342,7 @@ bus_driver_send_welcome_message (DBusConnection *connection, return FALSE; } - if (!bus_transaction_send_message (transaction, connection, welcome)) + if (!bus_transaction_send_from_driver (transaction, connection, welcome)) { dbus_message_unref (welcome); BUS_SET_OOM (error); @@ -417,7 +396,7 @@ bus_driver_handle_list_services (DBusConnection *connection, dbus_free_string_array (services); - if (!bus_transaction_send_message (transaction, connection, reply)) + if (!bus_transaction_send_from_driver (transaction, connection, reply)) { dbus_message_unref (reply); BUS_SET_OOM (error); @@ -474,19 +453,13 @@ bus_driver_handle_acquire_service (DBusConnection *connection, goto out; } - if (!dbus_message_set_sender (reply, DBUS_SERVICE_DBUS)) - { - BUS_SET_OOM (error); - goto out; - } - if (!dbus_message_append_args (reply, DBUS_TYPE_UINT32, service_reply, DBUS_TYPE_INVALID)) { BUS_SET_OOM (error); goto out; } - if (!bus_transaction_send_message (transaction, connection, reply)) + if (!bus_transaction_send_from_driver (transaction, connection, reply)) { BUS_SET_OOM (error); goto out; @@ -534,12 +507,6 @@ bus_driver_handle_service_exists (DBusConnection *connection, BUS_SET_OOM (error); goto out; } - - if (!dbus_message_set_sender (reply, DBUS_SERVICE_DBUS)) - { - BUS_SET_OOM (error); - goto out; - } if (!dbus_message_append_args (reply, DBUS_TYPE_UINT32, service != NULL, @@ -549,7 +516,7 @@ bus_driver_handle_service_exists (DBusConnection *connection, goto out; } - if (!bus_transaction_send_message (transaction, connection, reply)) + if (!bus_transaction_send_from_driver (transaction, connection, reply)) { BUS_SET_OOM (error); goto out; @@ -653,6 +620,12 @@ bus_driver_handle_message (DBusConnection *connection, return FALSE; } + if (dbus_message_get_reply_serial (message) != -1) + { + _dbus_verbose ("Client sent a reply to the bus driver, ignoring it\n"); + return TRUE; + } + i = 0; while (i < _DBUS_N_ELEMENTS (message_handlers)) { -- cgit