1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* driver.c Bus client (driver)
4 * Copyright (C) 2003 CodeFactory AB
5 * Copyright (C) 2003, 2004, 2005 Red Hat, Inc.
6 * Copyright (C) 2013 Samsung Electronics
8 * Licensed under the Academic Free License version 2.1
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 #include "activation.h"
28 #include "connection.h"
37 #include <dbus/dbus-asv-util.h>
38 #include <dbus/dbus-string.h>
39 #include <dbus/dbus-internals.h>
40 #include <dbus/dbus-message.h>
41 #include <dbus/dbus-marshal-recursive.h>
44 #ifdef ENABLE_KDBUS_TRANSPORT
51 static DBusConnection *
52 bus_driver_get_conn_helper (DBusConnection *connection,
54 const char *what_we_want,
59 BusRegistry *registry;
64 if (!dbus_message_get_args (message, error,
65 DBUS_TYPE_STRING, &name,
69 _dbus_assert (name != NULL);
70 _dbus_verbose ("asked for %s of connection %s\n", what_we_want, name);
72 registry = bus_connection_get_registry (connection);
73 _dbus_string_init_const (&str, name);
74 serv = bus_registry_lookup (registry, &str);
78 dbus_set_error (error, DBUS_ERROR_NAME_HAS_NO_OWNER,
79 "Could not get %s of name '%s': no such name",
84 conn = bus_service_get_primary_owners_connection (serv);
85 _dbus_assert (conn != NULL);
93 static dbus_bool_t bus_driver_send_welcome_message (DBusConnection *connection,
94 DBusMessage *hello_message,
95 BusTransaction *transaction,
99 bus_driver_send_service_owner_changed (const char *service_name,
100 const char *old_owner,
101 const char *new_owner,
102 BusTransaction *transaction,
105 DBusMessage *message;
107 const char *null_service;
109 #ifdef ENABLE_KDBUS_TRANSPORT
110 if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
114 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
117 _dbus_verbose ("sending name owner changed: %s [%s -> %s]\n",
119 old_owner ? old_owner : null_service,
120 new_owner ? new_owner : null_service);
122 message = dbus_message_new_signal (DBUS_PATH_DBUS,
132 if (!dbus_message_set_sender (message, DBUS_SERVICE_DBUS))
135 if (!dbus_message_append_args (message,
136 DBUS_TYPE_STRING, &service_name,
137 DBUS_TYPE_STRING, old_owner ? &old_owner : &null_service,
138 DBUS_TYPE_STRING, new_owner ? &new_owner : &null_service,
142 _dbus_assert (dbus_message_has_signature (message, "sss"));
144 retval = bus_dispatch_matches (transaction, NULL, NULL, message, error);
145 dbus_message_unref (message);
150 dbus_message_unref (message);
156 bus_driver_send_service_lost (DBusConnection *connection,
157 const char *service_name,
158 BusTransaction *transaction,
161 DBusMessage *message;
163 #ifdef ENABLE_KDBUS_TRANSPORT
164 if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
168 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
170 message = dbus_message_new_signal (DBUS_PATH_DBUS,
180 if (!dbus_message_set_destination (message, bus_connection_get_name (connection)) ||
181 !dbus_message_append_args (message,
182 DBUS_TYPE_STRING, &service_name,
185 dbus_message_unref (message);
190 if (!bus_transaction_send_from_driver (transaction, connection, message))
192 dbus_message_unref (message);
198 dbus_message_unref (message);
204 bus_driver_send_service_acquired (DBusConnection *connection,
205 const char *service_name,
206 BusTransaction *transaction,
209 DBusMessage *message;
211 #ifdef ENABLE_KDBUS_TRANSPORT
212 if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
216 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
218 message = dbus_message_new_signal (DBUS_PATH_DBUS,
228 if (!dbus_message_set_destination (message, bus_connection_get_name (connection)) ||
229 !dbus_message_append_args (message,
230 DBUS_TYPE_STRING, &service_name,
233 dbus_message_unref (message);
238 if (!bus_transaction_send_from_driver (transaction, connection, message))
240 dbus_message_unref (message);
246 dbus_message_unref (message);
252 create_unique_client_name (BusRegistry *registry,
255 /* We never want to use the same unique client name twice, because
256 * we want to guarantee that if you send a message to a given unique
257 * name, you always get the same application. So we use two numbers
258 * for INT_MAX * INT_MAX combinations, should be pretty safe against
261 /* FIXME these should be in BusRegistry rather than static vars */
262 static int next_major_number = 0;
263 static int next_minor_number = 0;
266 len = _dbus_string_get_length (str);
270 /* start out with 1-0, go to 1-1, 1-2, 1-3,
271 * up to 1-MAXINT, then 2-0, 2-1, etc.
273 if (next_minor_number <= 0)
275 next_major_number += 1;
276 next_minor_number = 0;
277 if (next_major_number <= 0)
278 _dbus_assert_not_reached ("INT_MAX * INT_MAX clients were added");
281 _dbus_assert (next_major_number > 0);
282 _dbus_assert (next_minor_number >= 0);
284 /* appname:MAJOR-MINOR */
286 if (!_dbus_string_append (str, ":"))
289 if (!_dbus_string_append_int (str, next_major_number))
292 if (!_dbus_string_append (str, "."))
295 if (!_dbus_string_append_int (str, next_minor_number))
298 next_minor_number += 1;
300 /* Check if a client with the name exists */
301 if (bus_registry_lookup (registry, str) == NULL)
304 /* drop the number again, try the next one. */
305 _dbus_string_set_length (str, len);
312 bus_driver_handle_hello (DBusConnection *connection,
313 BusTransaction *transaction,
314 DBusMessage *message,
317 DBusString unique_name;
320 BusRegistry *registry;
321 BusConnections *connections;
323 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
325 if (bus_connection_is_active (connection))
327 /* We already handled an Hello message for this connection. */
328 dbus_set_error (error, DBUS_ERROR_FAILED,
329 "Already handled an Hello message");
333 /* Note that when these limits are exceeded we don't disconnect the
334 * connection; we just sort of leave it hanging there until it times
335 * out or disconnects itself or is dropped due to the max number of
336 * incomplete connections. It's even OK if the connection wants to
337 * retry the hello message, we support that.
339 connections = bus_connection_get_connections (connection);
340 if (!bus_connections_check_limits (connections, connection,
343 _DBUS_ASSERT_ERROR_IS_SET (error);
347 if (!_dbus_string_init (&unique_name))
355 registry = bus_connection_get_registry (connection);
357 if (!create_unique_client_name (registry, &unique_name))
363 if (!bus_connection_complete (connection, &unique_name, error))
365 _DBUS_ASSERT_ERROR_IS_SET (error);
369 if (!dbus_message_set_sender (message,
370 bus_connection_get_name (connection)))
376 if (!bus_driver_send_welcome_message (connection, message, transaction, error))
379 /* Create the service */
380 service = bus_registry_ensure (registry,
381 &unique_name, connection, 0, transaction, error);
385 _dbus_assert (bus_connection_is_active (connection));
389 _dbus_string_free (&unique_name);
394 bus_driver_send_welcome_message (DBusConnection *connection,
395 DBusMessage *hello_message,
396 BusTransaction *transaction,
399 DBusMessage *welcome;
402 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
404 name = bus_connection_get_name (connection);
405 _dbus_assert (name != NULL);
407 welcome = dbus_message_new_method_return (hello_message);
414 if (!dbus_message_append_args (welcome,
415 DBUS_TYPE_STRING, &name,
418 dbus_message_unref (welcome);
423 _dbus_assert (dbus_message_has_signature (welcome, DBUS_TYPE_STRING_AS_STRING));
425 if (!bus_transaction_send_from_driver (transaction, connection, welcome))
427 dbus_message_unref (welcome);
433 dbus_message_unref (welcome);
439 bus_driver_handle_list_services (DBusConnection *connection,
440 BusTransaction *transaction,
441 DBusMessage *message,
447 BusRegistry *registry;
449 DBusMessageIter iter;
452 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
454 registry = bus_connection_get_registry (connection);
456 reply = dbus_message_new_method_return (message);
463 #ifdef ENABLE_KDBUS_TRANSPORT
464 if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
466 if(!kdbus_list_services (connection, &services, &len))
468 dbus_message_unref (reply);
477 if (!bus_registry_list_services (registry, &services, &len))
479 dbus_message_unref (reply);
485 dbus_message_iter_init_append (reply, &iter);
487 if (!dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY,
488 DBUS_TYPE_STRING_AS_STRING,
491 dbus_free_string_array (services);
492 dbus_message_unref (reply);
497 #ifdef ENABLE_KDBUS_TRANSPORT
498 if(!bus_context_is_kdbus(bus_transaction_get_context (transaction))) //not needed for kdbus, we got it from kdbus_list_services
502 /* Include the bus driver in the list */
503 const char *v_STRING = DBUS_SERVICE_DBUS;
504 if (!dbus_message_iter_append_basic (&sub, DBUS_TYPE_STRING,
507 dbus_free_string_array (services);
508 dbus_message_unref (reply);
517 if (!dbus_message_iter_append_basic (&sub, DBUS_TYPE_STRING,
520 dbus_free_string_array (services);
521 dbus_message_unref (reply);
528 dbus_free_string_array (services);
530 if (!dbus_message_iter_close_container (&iter, &sub))
532 dbus_message_unref (reply);
537 if (!bus_transaction_send_from_driver (transaction, connection, reply))
539 dbus_message_unref (reply);
545 dbus_message_unref (reply);
551 bus_driver_handle_list_activatable_services (DBusConnection *connection,
552 BusTransaction *transaction,
553 DBusMessage *message,
559 BusActivation *activation;
561 DBusMessageIter iter;
564 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
566 activation = bus_connection_get_activation (connection);
568 reply = dbus_message_new_method_return (message);
575 if (!bus_activation_list_services (activation, &services, &len))
577 dbus_message_unref (reply);
582 dbus_message_iter_init_append (reply, &iter);
584 if (!dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY,
585 DBUS_TYPE_STRING_AS_STRING,
588 dbus_free_string_array (services);
589 dbus_message_unref (reply);
595 /* Include the bus driver in the list */
596 const char *v_STRING = DBUS_SERVICE_DBUS;
597 if (!dbus_message_iter_append_basic (&sub, DBUS_TYPE_STRING,
600 dbus_free_string_array (services);
601 dbus_message_unref (reply);
610 if (!dbus_message_iter_append_basic (&sub, DBUS_TYPE_STRING,
613 dbus_free_string_array (services);
614 dbus_message_unref (reply);
621 dbus_free_string_array (services);
623 if (!dbus_message_iter_close_container (&iter, &sub))
625 dbus_message_unref (reply);
630 if (!bus_transaction_send_from_driver (transaction, connection, reply))
632 dbus_message_unref (reply);
638 dbus_message_unref (reply);
644 bus_driver_handle_acquire_service (DBusConnection *connection,
645 BusTransaction *transaction,
646 DBusMessage *message,
650 DBusString service_name;
652 dbus_uint32_t service_reply;
655 BusRegistry *registry;
657 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
659 registry = bus_connection_get_registry (connection);
661 if (!dbus_message_get_args (message, error,
662 DBUS_TYPE_STRING, &name,
663 DBUS_TYPE_UINT32, &flags,
667 _dbus_verbose ("Trying to own name %s with flags 0x%x\n", name, flags);
672 #ifdef ENABLE_KDBUS_TRANSPORT
673 if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
675 if (!bus_registry_acquire_kdbus_service (registry, connection,
677 &service_reply, transaction,
685 _dbus_string_init_const (&service_name, name);
687 if (!bus_registry_acquire_service (registry, connection,
688 &service_name, flags,
689 &service_reply, transaction,
694 reply = dbus_message_new_method_return (message);
701 if (!dbus_message_append_args (reply, DBUS_TYPE_UINT32, &service_reply, DBUS_TYPE_INVALID))
707 if (!bus_transaction_send_from_driver (transaction, connection, reply))
717 dbus_message_unref (reply);
722 bus_driver_handle_release_service (DBusConnection *connection,
723 BusTransaction *transaction,
724 DBusMessage *message,
728 DBusString service_name;
730 dbus_uint32_t service_reply;
732 BusRegistry *registry;
734 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
736 if (!dbus_message_get_args (message, error,
737 DBUS_TYPE_STRING, &name,
741 _dbus_verbose ("Trying to release name %s\n", name);
746 _dbus_string_init_const (&service_name, name);
747 registry = bus_connection_get_registry (connection);
749 #ifdef ENABLE_KDBUS_TRANSPORT
750 if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
752 if (!bus_registry_release_service_kdbus (dbus_message_get_sender(message), connection,
753 &service_name, &service_reply,
759 if (!bus_registry_release_service (registry, connection,
760 &service_name, &service_reply,
764 reply = dbus_message_new_method_return (message);
771 if (!dbus_message_append_args (reply, DBUS_TYPE_UINT32, &service_reply, DBUS_TYPE_INVALID))
777 if (!bus_transaction_send_from_driver (transaction, connection, reply))
787 dbus_message_unref (reply);
792 bus_driver_handle_service_exists (DBusConnection *connection,
793 BusTransaction *transaction,
794 DBusMessage *message,
798 DBusString service_name;
800 dbus_bool_t service_exists;
803 BusRegistry *registry;
805 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
807 registry = bus_connection_get_registry (connection);
809 if (!dbus_message_get_args (message, error,
810 DBUS_TYPE_STRING, &name,
816 if (strcmp (name, DBUS_SERVICE_DBUS) == 0)
818 service_exists = TRUE;
822 #ifdef ENABLE_KDBUS_TRANSPORT
823 if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
826 struct nameInfo info;
828 inter_ret = kdbus_NameQuery(name, dbus_connection_get_transport(connection), &info);
829 if((inter_ret == 0) || (inter_ret == -ENOENT))
830 service_exists = (inter_ret == 0) ? TRUE : FALSE;
833 _dbus_verbose("kdbus error checking if name exists: err %d (%m)\n", errno);
834 dbus_set_error (error, DBUS_ERROR_FAILED, "Could not determine whether name '%s' exists", name);
835 service_exists = FALSE;
841 _dbus_string_init_const (&service_name, name);
842 service = bus_registry_lookup (registry, &service_name);
843 service_exists = service != NULL;
847 reply = dbus_message_new_method_return (message);
854 if (!dbus_message_append_args (reply,
855 DBUS_TYPE_BOOLEAN, &service_exists,
862 if (!bus_transaction_send_from_driver (transaction, connection, reply))
872 dbus_message_unref (reply);
878 bus_driver_handle_activate_service (DBusConnection *connection,
879 BusTransaction *transaction,
880 DBusMessage *message,
886 BusActivation *activation;
888 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
890 activation = bus_connection_get_activation (connection);
892 if (!dbus_message_get_args (message, error,
893 DBUS_TYPE_STRING, &name,
894 DBUS_TYPE_UINT32, &flags,
897 _DBUS_ASSERT_ERROR_IS_SET (error);
898 _dbus_verbose ("No memory to get arguments to StartServiceByName\n");
904 if (!bus_activation_activate_service (activation, connection, transaction, FALSE,
905 message, name, error))
907 _DBUS_ASSERT_ERROR_IS_SET (error);
908 _dbus_verbose ("bus_activation_activate_service() failed\n");
919 send_ack_reply (DBusConnection *connection,
920 BusTransaction *transaction,
921 DBusMessage *message,
926 if (dbus_message_get_no_reply (message))
929 reply = dbus_message_new_method_return (message);
936 if (!bus_transaction_send_from_driver (transaction, connection, reply))
939 dbus_message_unref (reply);
943 dbus_message_unref (reply);
949 bus_driver_handle_update_activation_environment (DBusConnection *connection,
950 BusTransaction *transaction,
951 DBusMessage *message,
955 BusActivation *activation;
956 DBusMessageIter iter;
957 DBusMessageIter dict_iter;
958 DBusMessageIter dict_entry_iter;
961 DBusList *keys, *key_link;
962 DBusList *values, *value_link;
964 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
966 activation = bus_connection_get_activation (connection);
968 dbus_message_iter_init (message, &iter);
970 /* The message signature has already been checked for us,
971 * so let's just assert it's right.
973 _dbus_assert (dbus_message_iter_get_arg_type (&iter) == DBUS_TYPE_ARRAY);
975 dbus_message_iter_recurse (&iter, &dict_iter);
979 /* Then loop through the sent dictionary, add the location of
980 * the environment keys and values to lists. The result will
981 * be in reverse order, so we don't have to constantly search
982 * for the end of the list in a loop.
986 while ((array_type = dbus_message_iter_get_arg_type (&dict_iter)) == DBUS_TYPE_DICT_ENTRY)
988 dbus_message_iter_recurse (&dict_iter, &dict_entry_iter);
990 while ((key_type = dbus_message_iter_get_arg_type (&dict_entry_iter)) == DBUS_TYPE_STRING)
996 dbus_message_iter_get_basic (&dict_entry_iter, &key);
997 dbus_message_iter_next (&dict_entry_iter);
999 value_type = dbus_message_iter_get_arg_type (&dict_entry_iter);
1001 if (value_type != DBUS_TYPE_STRING)
1004 dbus_message_iter_get_basic (&dict_entry_iter, &value);
1006 if (!_dbus_list_append (&keys, key))
1008 BUS_SET_OOM (error);
1012 if (!_dbus_list_append (&values, value))
1014 BUS_SET_OOM (error);
1018 dbus_message_iter_next (&dict_entry_iter);
1021 if (key_type != DBUS_TYPE_INVALID)
1024 dbus_message_iter_next (&dict_iter);
1027 if (array_type != DBUS_TYPE_INVALID)
1030 _dbus_assert (_dbus_list_get_length (&keys) == _dbus_list_get_length (&values));
1033 value_link = values;
1034 while (key_link != NULL)
1039 key = key_link->data;
1040 value = value_link->data;
1042 if (!bus_activation_set_environment_variable (activation,
1045 _DBUS_ASSERT_ERROR_IS_SET (error);
1046 _dbus_verbose ("bus_activation_set_environment_variable() failed\n");
1049 key_link = _dbus_list_get_next_link (&keys, key_link);
1050 value_link = _dbus_list_get_next_link (&values, value_link);
1053 /* FIXME: We can fail early having set only some of the environment variables,
1054 * (because of OOM failure). It's sort of hard to fix and it doesn't really
1055 * matter, so we're punting for now.
1057 if (key_link != NULL)
1060 if (!send_ack_reply (connection, transaction,
1067 _dbus_list_clear (&keys);
1068 _dbus_list_clear (&values);
1073 bus_driver_handle_add_match (DBusConnection *connection,
1074 BusTransaction *transaction,
1075 DBusMessage *message,
1081 BusMatchmaker *matchmaker;
1083 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1088 if (bus_connection_get_n_match_rules (connection) >=
1089 bus_context_get_max_match_rules_per_connection (bus_transaction_get_context (transaction)))
1091 dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED,
1092 "Connection \"%s\" is not allowed to add more match rules "
1093 "(increase limits in configuration file if required)",
1094 bus_connection_is_active (connection) ?
1095 bus_connection_get_name (connection) :
1100 if (!dbus_message_get_args (message, error,
1101 DBUS_TYPE_STRING, &text,
1104 _dbus_verbose ("No memory to get arguments to AddMatch\n");
1108 _dbus_string_init_const (&str, text);
1110 rule = bus_match_rule_parse (connection, &str, error);
1114 #ifdef ENABLE_KDBUS_TRANSPORT
1115 if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
1118 if (!kdbus_add_match_rule (connection, message, text, error))
1121 if (!send_ack_reply (connection, transaction,
1129 matchmaker = bus_connection_get_matchmaker (connection);
1131 if (!bus_matchmaker_add_rule (matchmaker, rule))
1133 BUS_SET_OOM (error);
1137 if (!send_ack_reply (connection, transaction,
1140 bus_matchmaker_remove_rule (matchmaker, rule);
1145 bus_match_rule_unref (rule);
1150 _DBUS_ASSERT_ERROR_IS_SET (error);
1152 bus_match_rule_unref (rule);
1157 bus_driver_handle_remove_match (DBusConnection *connection,
1158 BusTransaction *transaction,
1159 DBusMessage *message,
1165 BusMatchmaker *matchmaker;
1167 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1172 if (!dbus_message_get_args (message, error,
1173 DBUS_TYPE_STRING, &text,
1176 _dbus_verbose ("No memory to get arguments to RemoveMatch\n");
1180 _dbus_string_init_const (&str, text);
1182 rule = bus_match_rule_parse (connection, &str, error);
1186 #ifdef ENABLE_KDBUS_TRANSPORT
1187 if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
1189 if(!kdbus_remove_match(connection, message, error))
1194 /* Send the ack before we remove the rule, since the ack is undone
1195 * on transaction cancel, but rule removal isn't.
1197 if (!send_ack_reply (connection, transaction,
1201 #ifdef ENABLE_KDBUS_TRANSPORT
1202 if(!bus_context_is_kdbus(bus_transaction_get_context (transaction)))
1205 matchmaker = bus_connection_get_matchmaker (connection);
1207 if (!bus_matchmaker_remove_rule_by_value (matchmaker, rule, error))
1211 bus_match_rule_unref (rule);
1216 _DBUS_ASSERT_ERROR_IS_SET (error);
1218 bus_match_rule_unref (rule);
1223 bus_driver_handle_get_service_owner (DBusConnection *connection,
1224 BusTransaction *transaction,
1225 DBusMessage *message,
1229 const char *base_name;
1231 BusRegistry *registry;
1232 BusService *service;
1234 #ifdef ENABLE_KDBUS_TRANSPORT
1235 char unique_name[(unsigned int)(snprintf((char*)base_name, 0, "%llu", ULLONG_MAX) + sizeof(":1."))];
1238 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1240 registry = bus_connection_get_registry (connection);
1245 if (! dbus_message_get_args (message, error,
1246 DBUS_TYPE_STRING, &text,
1250 #ifdef ENABLE_KDBUS_TRANSPORT
1251 if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
1255 ret = kdbus_get_name_owner(connection, text, unique_name);
1257 base_name = unique_name;
1258 else if(ret == -ENOENT) //name has no owner
1260 dbus_set_error (error, DBUS_ERROR_NAME_HAS_NO_OWNER,
1261 "Could not get owner of name '%s': no such name", text);
1266 dbus_set_error (error, DBUS_ERROR_FAILED,
1267 "Could not determine unique name for '%s'", text);
1274 _dbus_string_init_const (&str, text);
1275 service = bus_registry_lookup (registry, &str);
1276 if (service == NULL &&
1277 _dbus_string_equal_c_str (&str, DBUS_SERVICE_DBUS))
1279 /* ORG_FREEDESKTOP_DBUS owns itself */
1280 base_name = DBUS_SERVICE_DBUS;
1282 else if (service == NULL)
1284 dbus_set_error (error,
1285 DBUS_ERROR_NAME_HAS_NO_OWNER,
1286 "Could not get owner of name '%s': no such name", text);
1291 base_name = bus_connection_get_name (bus_service_get_primary_owners_connection (service));
1292 if (base_name == NULL)
1294 /* FIXME - how is this error possible? */
1295 dbus_set_error (error,
1297 "Could not determine unique name for '%s'", text);
1300 _dbus_assert (*base_name == ':');
1303 _dbus_assert (base_name != NULL);
1305 reply = dbus_message_new_method_return (message);
1309 if (! dbus_message_append_args (reply,
1310 DBUS_TYPE_STRING, &base_name,
1314 if (! bus_transaction_send_from_driver (transaction, connection, reply))
1317 dbus_message_unref (reply);
1322 BUS_SET_OOM (error);
1325 _DBUS_ASSERT_ERROR_IS_SET (error);
1327 dbus_message_unref (reply);
1332 bus_driver_handle_list_queued_owners (DBusConnection *connection,
1333 BusTransaction *transaction,
1334 DBusMessage *message,
1338 DBusList *base_names;
1341 BusRegistry *registry;
1342 BusService *service;
1344 DBusMessageIter iter, array_iter;
1345 char *dbus_service_name = DBUS_SERVICE_DBUS;
1347 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1349 registry = bus_connection_get_registry (connection);
1355 if (! dbus_message_get_args (message, error,
1356 DBUS_TYPE_STRING, &text,
1360 _dbus_string_init_const (&str, text);
1361 service = bus_registry_lookup (registry, &str);
1362 if (service == NULL &&
1363 _dbus_string_equal_c_str (&str, DBUS_SERVICE_DBUS))
1365 /* ORG_FREEDESKTOP_DBUS owns itself */
1366 if (! _dbus_list_append (&base_names, dbus_service_name))
1369 else if (service == NULL)
1371 dbus_set_error (error,
1372 DBUS_ERROR_NAME_HAS_NO_OWNER,
1373 "Could not get owners of name '%s': no such name", text);
1378 if (!bus_service_list_queued_owners (service,
1384 _dbus_assert (base_names != NULL);
1386 reply = dbus_message_new_method_return (message);
1390 dbus_message_iter_init_append (reply, &iter);
1391 if (!dbus_message_iter_open_container (&iter,
1393 DBUS_TYPE_STRING_AS_STRING,
1397 link = _dbus_list_get_first_link (&base_names);
1398 while (link != NULL)
1402 _dbus_assert (link->data != NULL);
1403 uname = (char *)link->data;
1405 if (!dbus_message_iter_append_basic (&array_iter,
1410 link = _dbus_list_get_next_link (&base_names, link);
1413 if (! dbus_message_iter_close_container (&iter, &array_iter))
1417 if (! bus_transaction_send_from_driver (transaction, connection, reply))
1420 dbus_message_unref (reply);
1425 BUS_SET_OOM (error);
1428 _DBUS_ASSERT_ERROR_IS_SET (error);
1430 dbus_message_unref (reply);
1433 _dbus_list_clear (&base_names);
1439 bus_driver_handle_get_connection_unix_user (DBusConnection *connection,
1440 BusTransaction *transaction,
1441 DBusMessage *message,
1444 DBusConnection *conn;
1447 dbus_uint32_t uid32;
1448 const char *service;
1450 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1452 reply = dbus_message_new_method_return (message);
1456 #ifdef ENABLE_KDBUS_TRANSPORT
1457 if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
1461 if(!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID))
1463 if(!kdbus_get_unix_user(connection, name, &uid, error))
1469 conn = bus_driver_get_conn_helper (connection, message, "UID", &service,
1475 if (!dbus_connection_get_unix_user (conn, &uid))
1477 dbus_set_error (error,
1479 "Could not determine UID for '%s'", service);
1485 if (! dbus_message_append_args (reply,
1486 DBUS_TYPE_UINT32, &uid32,
1490 if (! bus_transaction_send_from_driver (transaction, connection, reply))
1493 dbus_message_unref (reply);
1498 BUS_SET_OOM (error);
1501 _DBUS_ASSERT_ERROR_IS_SET (error);
1503 dbus_message_unref (reply);
1508 bus_driver_handle_get_connection_unix_process_id (DBusConnection *connection,
1509 BusTransaction *transaction,
1510 DBusMessage *message,
1513 DBusConnection *conn;
1516 dbus_uint32_t pid32;
1517 const char *service;
1519 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1521 reply = dbus_message_new_method_return (message);
1524 #ifdef ENABLE_KDBUS_TRANSPORT
1525 if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
1529 if(!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID))
1531 if(!kdbus_get_connection_unix_process_id(connection, name, &pid, error))
1537 conn = bus_driver_get_conn_helper (connection, message, "PID", &service,
1542 if (!dbus_connection_get_unix_process_id (conn, &pid))
1544 dbus_set_error (error,
1545 DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN,
1546 "Could not determine PID for '%s'", service);
1552 if (! dbus_message_append_args (reply,
1553 DBUS_TYPE_UINT32, &pid32,
1557 if (! bus_transaction_send_from_driver (transaction, connection, reply))
1560 dbus_message_unref (reply);
1565 BUS_SET_OOM (error);
1568 _DBUS_ASSERT_ERROR_IS_SET (error);
1570 dbus_message_unref (reply);
1575 bus_driver_handle_get_adt_audit_session_data (DBusConnection *connection,
1576 BusTransaction *transaction,
1577 DBusMessage *message,
1580 DBusConnection *conn;
1583 dbus_uint32_t data_size;
1584 const char *service;
1586 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1590 conn = bus_driver_get_conn_helper (connection, message,
1591 "audit session data", &service, error);
1596 reply = dbus_message_new_method_return (message);
1600 if (!dbus_connection_get_adt_audit_session_data (conn, &data, &data_size) || data == NULL)
1602 dbus_set_error (error,
1603 DBUS_ERROR_ADT_AUDIT_DATA_UNKNOWN,
1604 "Could not determine audit session data for '%s'", service);
1608 if (! dbus_message_append_args (reply,
1609 DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &data, data_size,
1613 if (! bus_transaction_send_from_driver (transaction, connection, reply))
1616 dbus_message_unref (reply);
1621 BUS_SET_OOM (error);
1624 _DBUS_ASSERT_ERROR_IS_SET (error);
1626 dbus_message_unref (reply);
1631 bus_driver_handle_get_connection_selinux_security_context (DBusConnection *connection,
1632 BusTransaction *transaction,
1633 DBusMessage *message,
1636 DBusConnection *conn;
1638 BusSELinuxID *context;
1639 const char *service;
1641 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1643 reply = dbus_message_new_method_return (message);
1647 #ifdef ENABLE_KDBUS_TRANSPORT
1648 if(bus_context_is_kdbus(bus_transaction_get_context (transaction)))
1650 if(!kdbus_get_connection_unix_selinux_security_context(connection, message, reply, error))
1656 conn = bus_driver_get_conn_helper (connection, message, "security context",
1662 context = bus_connection_get_selinux_id (conn);
1665 dbus_set_error (error,
1666 DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN,
1667 "Could not determine security context for '%s'", service);
1671 if (! bus_selinux_append_context (reply, context, error))
1675 if (! bus_transaction_send_from_driver (transaction, connection, reply))
1678 dbus_message_unref (reply);
1683 BUS_SET_OOM (error);
1686 _DBUS_ASSERT_ERROR_IS_SET (error);
1688 dbus_message_unref (reply);
1693 bus_driver_handle_get_connection_credentials (DBusConnection *connection,
1694 BusTransaction *transaction,
1695 DBusMessage *message,
1698 DBusConnection *conn;
1700 DBusMessageIter reply_iter;
1701 DBusMessageIter array_iter;
1702 unsigned long ulong_val;
1703 const char *service;
1705 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1707 reply = _dbus_asv_new_method_return (message, &reply_iter, &array_iter);
1711 #ifdef ENABLE_KDBUS_TRANSPORT
1712 if(!bus_context_is_kdbus(bus_transaction_get_context (transaction)))
1715 conn = bus_driver_get_conn_helper (connection, message, "credentials",
1721 /* we can't represent > 32-bit pids; if your system needs them, please
1722 * add ProcessID64 to the spec or something */
1723 if (dbus_connection_get_unix_process_id (conn, &ulong_val) &&
1724 ulong_val <= _DBUS_UINT32_MAX)
1726 if (!_dbus_asv_add_uint32 (&array_iter, "ProcessID", ulong_val))
1730 /* we can't represent > 32-bit uids; if your system needs them, please
1731 * add UnixUserID64 to the spec or something */
1732 if (dbus_connection_get_unix_user (conn, &ulong_val) &&
1733 ulong_val <= _DBUS_UINT32_MAX)
1735 if (!_dbus_asv_add_uint32 (&array_iter, "UnixUserID", ulong_val))
1738 #ifdef ENABLE_KDBUS_TRANSPORT
1744 if(!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID))
1746 if(kdbus_get_connection_unix_process_id(connection, name, &ulong_val, error))
1748 if (!_dbus_asv_add_uint32 (&array_iter, "ProcessID", ulong_val))
1754 if(kdbus_get_unix_user(connection, name, &ulong_val, error))
1756 if (!_dbus_asv_add_uint32 (&array_iter, "UnixUserID", ulong_val))
1764 if (!_dbus_asv_close (&reply_iter, &array_iter))
1767 if (! bus_transaction_send_from_driver (transaction, connection, reply))
1769 /* this time we don't want to close the iterator again, so just
1770 * get rid of the message */
1771 dbus_message_unref (reply);
1779 BUS_SET_OOM (error);
1782 _DBUS_ASSERT_ERROR_IS_SET (error);
1786 _dbus_asv_abandon (&reply_iter, &array_iter);
1787 dbus_message_unref (reply);
1794 bus_driver_handle_reload_config (DBusConnection *connection,
1795 BusTransaction *transaction,
1796 DBusMessage *message,
1799 BusContext *context;
1802 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1806 context = bus_connection_get_context (connection);
1807 if (!bus_context_reload_config (context, error))
1810 reply = dbus_message_new_method_return (message);
1814 if (! bus_transaction_send_from_driver (transaction, connection, reply))
1817 dbus_message_unref (reply);
1821 BUS_SET_OOM (error);
1824 _DBUS_ASSERT_ERROR_IS_SET (error);
1826 dbus_message_unref (reply);
1831 bus_driver_handle_get_id (DBusConnection *connection,
1832 BusTransaction *transaction,
1833 DBusMessage *message,
1836 BusContext *context;
1839 const char *v_STRING;
1841 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1843 if (!_dbus_string_init (&uuid))
1845 BUS_SET_OOM (error);
1851 context = bus_connection_get_context (connection);
1852 if (!bus_context_get_id (context, &uuid))
1855 reply = dbus_message_new_method_return (message);
1859 v_STRING = _dbus_string_get_const_data (&uuid);
1860 if (!dbus_message_append_args (reply,
1861 DBUS_TYPE_STRING, &v_STRING,
1865 _dbus_assert (dbus_message_has_signature (reply, "s"));
1867 if (! bus_transaction_send_from_driver (transaction, connection, reply))
1870 _dbus_string_free (&uuid);
1871 dbus_message_unref (reply);
1875 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1877 BUS_SET_OOM (error);
1880 dbus_message_unref (reply);
1881 _dbus_string_free (&uuid);
1888 const char *in_args;
1889 const char *out_args;
1890 dbus_bool_t (* handler) (DBusConnection *connection,
1891 BusTransaction *transaction,
1892 DBusMessage *message,
1896 /* For speed it might be useful to sort this in order of
1897 * frequency of use (but doesn't matter with only a few items
1900 static const MessageHandler dbus_message_handlers[] = {
1903 DBUS_TYPE_STRING_AS_STRING,
1904 bus_driver_handle_hello },
1906 DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_UINT32_AS_STRING,
1907 DBUS_TYPE_UINT32_AS_STRING,
1908 bus_driver_handle_acquire_service },
1910 DBUS_TYPE_STRING_AS_STRING,
1911 DBUS_TYPE_UINT32_AS_STRING,
1912 bus_driver_handle_release_service },
1913 { "StartServiceByName",
1914 DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_UINT32_AS_STRING,
1915 DBUS_TYPE_UINT32_AS_STRING,
1916 bus_driver_handle_activate_service },
1917 { "UpdateActivationEnvironment",
1918 DBUS_TYPE_ARRAY_AS_STRING DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
1920 bus_driver_handle_update_activation_environment },
1922 DBUS_TYPE_STRING_AS_STRING,
1923 DBUS_TYPE_BOOLEAN_AS_STRING,
1924 bus_driver_handle_service_exists },
1927 DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING,
1928 bus_driver_handle_list_services },
1929 { "ListActivatableNames",
1931 DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING,
1932 bus_driver_handle_list_activatable_services },
1934 DBUS_TYPE_STRING_AS_STRING,
1936 bus_driver_handle_add_match },
1938 DBUS_TYPE_STRING_AS_STRING,
1940 bus_driver_handle_remove_match },
1942 DBUS_TYPE_STRING_AS_STRING,
1943 DBUS_TYPE_STRING_AS_STRING,
1944 bus_driver_handle_get_service_owner },
1945 { "ListQueuedOwners",
1946 DBUS_TYPE_STRING_AS_STRING,
1947 DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING,
1948 bus_driver_handle_list_queued_owners },
1949 { "GetConnectionUnixUser",
1950 DBUS_TYPE_STRING_AS_STRING,
1951 DBUS_TYPE_UINT32_AS_STRING,
1952 bus_driver_handle_get_connection_unix_user },
1953 { "GetConnectionUnixProcessID",
1954 DBUS_TYPE_STRING_AS_STRING,
1955 DBUS_TYPE_UINT32_AS_STRING,
1956 bus_driver_handle_get_connection_unix_process_id },
1957 { "GetAdtAuditSessionData",
1958 DBUS_TYPE_STRING_AS_STRING,
1959 DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_BYTE_AS_STRING,
1960 bus_driver_handle_get_adt_audit_session_data },
1961 { "GetConnectionSELinuxSecurityContext",
1962 DBUS_TYPE_STRING_AS_STRING,
1963 DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_BYTE_AS_STRING,
1964 bus_driver_handle_get_connection_selinux_security_context },
1968 bus_driver_handle_reload_config },
1971 DBUS_TYPE_STRING_AS_STRING,
1972 bus_driver_handle_get_id },
1973 { "GetConnectionCredentials", "s", "a{sv}",
1974 bus_driver_handle_get_connection_credentials },
1975 { NULL, NULL, NULL, NULL }
1978 static dbus_bool_t bus_driver_handle_introspect (DBusConnection *,
1979 BusTransaction *, DBusMessage *, DBusError *);
1981 static const MessageHandler introspectable_message_handlers[] = {
1982 { "Introspect", "", DBUS_TYPE_STRING_AS_STRING, bus_driver_handle_introspect },
1983 { NULL, NULL, NULL, NULL }
1986 #ifdef DBUS_ENABLE_STATS
1987 static const MessageHandler stats_message_handlers[] = {
1988 { "GetStats", "", "a{sv}", bus_stats_handle_get_stats },
1989 { "GetConnectionStats", "s", "a{sv}", bus_stats_handle_get_connection_stats },
1990 { NULL, NULL, NULL, NULL }
1996 const MessageHandler *message_handlers;
1997 const char *extra_introspection;
2000 /* These should ideally be sorted by frequency of use, although it
2001 * probably doesn't matter with this few items */
2002 static InterfaceHandler interface_handlers[] = {
2003 { DBUS_INTERFACE_DBUS, dbus_message_handlers,
2004 " <signal name=\"NameOwnerChanged\">\n"
2005 " <arg type=\"s\"/>\n"
2006 " <arg type=\"s\"/>\n"
2007 " <arg type=\"s\"/>\n"
2009 " <signal name=\"NameLost\">\n"
2010 " <arg type=\"s\"/>\n"
2012 " <signal name=\"NameAcquired\">\n"
2013 " <arg type=\"s\"/>\n"
2015 { DBUS_INTERFACE_INTROSPECTABLE, introspectable_message_handlers, NULL },
2016 #ifdef DBUS_ENABLE_STATS
2017 { BUS_INTERFACE_STATS, stats_message_handlers, NULL },
2019 { NULL, NULL, NULL }
2023 write_args_for_direction (DBusString *xml,
2024 const char *signature,
2027 DBusTypeReader typereader;
2031 _dbus_string_init_const (&sigstr, signature);
2032 _dbus_type_reader_init_types_only (&typereader, &sigstr, 0);
2034 while ((current_type = _dbus_type_reader_get_current_type (&typereader)) != DBUS_TYPE_INVALID)
2036 const DBusString *subsig;
2039 _dbus_type_reader_get_signature (&typereader, &subsig, &start, &len);
2040 if (!_dbus_string_append_printf (xml, " <arg direction=\"%s\" type=\"",
2043 if (!_dbus_string_append_len (xml,
2044 _dbus_string_get_const_data (subsig) + start,
2047 if (!_dbus_string_append (xml, "\"/>\n"))
2050 _dbus_type_reader_next (&typereader);
2058 bus_driver_generate_introspect_string (DBusString *xml)
2060 const InterfaceHandler *ih;
2061 const MessageHandler *mh;
2063 if (!_dbus_string_append (xml, DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE))
2065 if (!_dbus_string_append (xml, "<node>\n"))
2068 for (ih = interface_handlers; ih->name != NULL; ih++)
2070 if (!_dbus_string_append_printf (xml, " <interface name=\"%s\">\n",
2074 for (mh = ih->message_handlers; mh->name != NULL; mh++)
2076 if (!_dbus_string_append_printf (xml, " <method name=\"%s\">\n",
2080 if (!write_args_for_direction (xml, mh->in_args, TRUE))
2083 if (!write_args_for_direction (xml, mh->out_args, FALSE))
2086 if (!_dbus_string_append (xml, " </method>\n"))
2090 if (ih->extra_introspection != NULL &&
2091 !_dbus_string_append (xml, ih->extra_introspection))
2094 if (!_dbus_string_append (xml, " </interface>\n"))
2098 if (!_dbus_string_append (xml, "</node>\n"))
2105 bus_driver_handle_introspect (DBusConnection *connection,
2106 BusTransaction *transaction,
2107 DBusMessage *message,
2112 const char *v_STRING;
2114 _dbus_verbose ("Introspect() on bus driver\n");
2116 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2120 if (! dbus_message_get_args (message, error,
2123 _DBUS_ASSERT_ERROR_IS_SET (error);
2127 if (!_dbus_string_init (&xml))
2129 BUS_SET_OOM (error);
2133 if (!bus_driver_generate_introspect_string (&xml))
2136 v_STRING = _dbus_string_get_const_data (&xml);
2138 reply = dbus_message_new_method_return (message);
2142 if (! dbus_message_append_args (reply,
2143 DBUS_TYPE_STRING, &v_STRING,
2147 if (! bus_transaction_send_from_driver (transaction, connection, reply))
2150 dbus_message_unref (reply);
2151 _dbus_string_free (&xml);
2156 BUS_SET_OOM (error);
2159 dbus_message_unref (reply);
2161 _dbus_string_free (&xml);
2167 bus_driver_handle_message (DBusConnection *connection,
2168 BusTransaction *transaction,
2169 DBusMessage *message,
2172 const char *name, *interface;
2173 const InterfaceHandler *ih;
2174 const MessageHandler *mh;
2175 dbus_bool_t found_interface = FALSE;
2177 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2179 if (dbus_message_is_signal (message, "org.freedesktop.systemd1.Activator", "ActivationFailure"))
2181 BusContext *context;
2183 context = bus_connection_get_context (connection);
2184 return dbus_activation_systemd_failure(bus_context_get_activation(context), message);
2187 if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_METHOD_CALL)
2189 _dbus_verbose ("Driver got a non-method-call message, ignoring\n");
2190 return TRUE; /* we just ignore this */
2193 /* may be NULL, which means "any interface will do" */
2194 interface = dbus_message_get_interface (message);
2196 _dbus_assert (dbus_message_get_member (message) != NULL);
2198 name = dbus_message_get_member (message);
2200 _dbus_verbose ("Driver got a method call: %s\n", name);
2202 /* security checks should have kept this from getting here */
2203 _dbus_assert (dbus_message_get_sender (message) != NULL ||
2204 strcmp (name, "Hello") == 0);
2206 for (ih = interface_handlers; ih->name != NULL; ih++)
2208 if (interface != NULL && strcmp (interface, ih->name) != 0)
2211 found_interface = TRUE;
2213 for (mh = ih->message_handlers; mh->name != NULL; mh++)
2215 if (strcmp (mh->name, name) != 0)
2218 _dbus_verbose ("Found driver handler for %s\n", name);
2220 if (!dbus_message_has_signature (message, mh->in_args))
2222 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2223 _dbus_verbose ("Call to %s has wrong args (%s, expected %s)\n",
2224 name, dbus_message_get_signature (message),
2227 dbus_set_error (error, DBUS_ERROR_INVALID_ARGS,
2228 "Call to %s has wrong args (%s, expected %s)\n",
2229 name, dbus_message_get_signature (message),
2231 _DBUS_ASSERT_ERROR_IS_SET (error);
2235 if ((* mh->handler) (connection, transaction, message, error))
2237 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2238 _dbus_verbose ("Driver handler succeeded\n");
2243 _DBUS_ASSERT_ERROR_IS_SET (error);
2244 _dbus_verbose ("Driver handler returned failure\n");
2250 _dbus_verbose ("No driver handler for message \"%s\"\n",
2253 dbus_set_error (error, found_interface ? DBUS_ERROR_UNKNOWN_METHOD : DBUS_ERROR_UNKNOWN_INTERFACE,
2254 "%s does not understand message %s",
2255 DBUS_SERVICE_DBUS, name);
2261 bus_driver_remove_connection (DBusConnection *connection)
2263 /* FIXME 1.0 Does nothing for now, should unregister the connection
2264 * with the bus driver.