From 9671c55b36a2d13d860dc2af9cd38ddb28d375a4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 21 Jun 2018 17:29:51 +0100 Subject: [PATCH 16/44] fixup! bus: Make bus_driver_send_name_owner_changed take DBusConnections Justify why the names can't be NULL, and add assertions --- bus/driver.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bus/driver.c b/bus/driver.c index 0acbef5c..6145e5bb 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -258,6 +258,22 @@ bus_driver_send_name_owner_changed (const char *service_name, if (new_owner != NULL) new_owner_name = bus_connection_get_name (new_owner); + /* In principle bus_connection_get_name() can return NULL for inactive + * connections, but we know that only active connections, i.e. + * connections that have called Hello(), can own names. If a connection + * has ever been active, it remains active forever (a closed connection + * doesn't become inactive, it just goes away). + * + * While we're making a connection active, we give it its unique name + * before we call this function. The other sort of names that might + * be owned are well-known names, but you can only get one of those + * by calling RequestName(), and inactive connections can't do that: + * bus_context_check_security_policy() hard-codes that the only + * thing inactive connections can do is to call o.fd.DBus.Hello() + * on the dbus-daemon. */ + _dbus_assert (old_owner_name != NULL); + _dbus_assert (new_owner_name != NULL); + _dbus_verbose ("sending name owner changed: %s [%s -> %s]\n", service_name, old_owner_name, -- 2.18.0.rc2