1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2010 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 #include <sys/socket.h>
28 #include <dbus/dbus.h>
30 #include <sys/epoll.h>
33 #include "dbus-common.h"
38 int bus_check_peercred(DBusConnection *c) {
45 assert_se(dbus_connection_get_unix_fd(c, &fd));
47 l = sizeof(struct ucred);
48 if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &l) < 0) {
49 log_error("SO_PEERCRED failed: %m");
53 if (l != sizeof(struct ucred)) {
54 log_error("SO_PEERCRED returned wrong size.");
58 if (ucred.uid != 0 && ucred.uid != geteuid())
64 static int sync_auth(DBusConnection *bus, DBusError *error) {
69 /* This complexity should probably move into D-Bus itself:
71 * https://bugs.freedesktop.org/show_bug.cgi?id=35189 */
73 begin = tstamp = now(CLOCK_MONOTONIC);
76 if (tstamp > begin + DEFAULT_TIMEOUT_USEC)
79 if (dbus_connection_get_is_authenticated(bus))
82 if (!dbus_connection_read_write_dispatch(bus, ((begin + DEFAULT_TIMEOUT_USEC - tstamp) + USEC_PER_MSEC - 1) / USEC_PER_MSEC))
85 tstamp = now(CLOCK_MONOTONIC);
88 if (!dbus_connection_get_is_connected(bus)) {
89 dbus_set_error_const(error, DBUS_ERROR_NO_SERVER, "Connection terminated during authentication.");
93 if (!dbus_connection_get_is_authenticated(bus)) {
94 dbus_set_error_const(error, DBUS_ERROR_TIMEOUT, "Failed to authenticate in time.");
101 int bus_connect(DBusBusType t, DBusConnection **_bus, bool *_private, DBusError *error) {
102 DBusConnection *bus = NULL;
108 if (geteuid() == 0 && t == DBUS_BUS_SYSTEM) {
109 /* If we are root, then let's talk directly to the
110 * system instance, instead of going via the bus */
112 bus = dbus_connection_open_private("unix:path=/run/systemd/private", error);
117 if (t == DBUS_BUS_SESSION) {
120 /* If we are supposed to talk to the instance,
121 * try via XDG_RUNTIME_DIR first, then
122 * fallback to normal bus access */
124 e = getenv("XDG_RUNTIME_DIR");
128 if (asprintf(&p, "unix:path=%s/systemd/private", e) < 0)
131 bus = dbus_connection_open_private(p, NULL);
137 bus = dbus_bus_get_private(t, error);
145 dbus_connection_set_exit_on_disconnect(bus, FALSE);
148 if (bus_check_peercred(bus) < 0) {
149 dbus_connection_close(bus);
150 dbus_connection_unref(bus);
152 dbus_set_error_const(error, DBUS_ERROR_ACCESS_DENIED, "Failed to verify owner of bus.");
157 r = sync_auth(bus, error);
159 dbus_connection_close(bus);
160 dbus_connection_unref(bus);
171 int bus_connect_system_ssh(const char *user, const char *host, DBusConnection **_bus, DBusError *error) {
177 assert(user || host);
180 asprintf(&p, "exec:path=ssh,argv1=-xT,argv2=%s@%s,argv3=systemd-stdio-bridge", user, host);
182 asprintf(&p, "exec:path=ssh,argv1=-xT,argv2=%s@localhost,argv3=systemd-stdio-bridge", user);
184 asprintf(&p, "exec:path=ssh,argv1=-xT,argv2=%s,argv3=systemd-stdio-bridge", host);
187 dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, NULL);
191 bus = dbus_connection_open_private(p, error);
197 dbus_connection_set_exit_on_disconnect(bus, FALSE);
199 if ((r = sync_auth(bus, error)) < 0) {
200 dbus_connection_close(bus);
201 dbus_connection_unref(bus);
205 if (!dbus_bus_register(bus, error)) {
206 dbus_connection_close(bus);
207 dbus_connection_unref(bus);
215 int bus_connect_system_polkit(DBusConnection **_bus, DBusError *error) {
221 /* Don't bother with PolicyKit if we are root */
223 return bus_connect(DBUS_BUS_SYSTEM, _bus, NULL, error);
225 if (!(bus = dbus_connection_open_private("exec:path=pkexec,argv1=" SYSTEMD_STDIO_BRIDGE_BINARY_PATH, error)))
228 dbus_connection_set_exit_on_disconnect(bus, FALSE);
230 if ((r = sync_auth(bus, error)) < 0) {
231 dbus_connection_close(bus);
232 dbus_connection_unref(bus);
236 if (!dbus_bus_register(bus, error)) {
237 dbus_connection_close(bus);
238 dbus_connection_unref(bus);
246 const char *bus_error_message(const DBusError *error) {
249 /* Sometimes the D-Bus server is a little bit too verbose with
250 * its error messages, so let's override them here */
251 if (dbus_error_has_name(error, DBUS_ERROR_ACCESS_DENIED))
252 return "Access denied";
254 return error->message;
257 DBusHandlerResult bus_default_message_handler(
259 DBusMessage *message,
260 const char *introspection,
261 const char *interfaces,
262 const BusBoundProperties *bound_properties) {
265 DBusMessage *reply = NULL;
271 dbus_error_init(&error);
273 if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Introspectable", "Introspect") && introspection) {
275 if (!(reply = dbus_message_new_method_return(message)))
278 if (!dbus_message_append_args(reply, DBUS_TYPE_STRING, &introspection, DBUS_TYPE_INVALID))
281 } else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Properties", "Get") && bound_properties) {
282 const char *interface, *property;
283 const BusBoundProperties *bp;
284 const BusProperty *p;
286 DBusMessageIter iter, sub;
288 if (!dbus_message_get_args(
291 DBUS_TYPE_STRING, &interface,
292 DBUS_TYPE_STRING, &property,
294 return bus_send_error_reply(c, message, &error, -EINVAL);
296 for (bp = bound_properties; bp->interface; bp++) {
297 if (!streq(bp->interface, interface))
300 for (p = bp->properties; p->property; p++)
301 if (streq(p->property, property))
306 if (!nulstr_contains(interfaces, interface))
307 dbus_set_error_const(&error, DBUS_ERROR_UNKNOWN_INTERFACE, "Unknown interface");
309 dbus_set_error_const(&error, DBUS_ERROR_UNKNOWN_PROPERTY, "Unknown property");
311 return bus_send_error_reply(c, message, &error, -EINVAL);
314 reply = dbus_message_new_method_return(message);
318 dbus_message_iter_init_append(reply, &iter);
320 if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, p->signature, &sub))
323 data = (char*)bp->base + p->offset;
325 data = *(void**)data;
326 r = p->append(&sub, property, data);
331 dbus_message_unref(reply);
332 return bus_send_error_reply(c, message, NULL, r);
335 if (!dbus_message_iter_close_container(&iter, &sub))
338 } else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Properties", "GetAll") && bound_properties) {
339 const char *interface;
340 const BusBoundProperties *bp;
341 const BusProperty *p;
342 DBusMessageIter iter, sub, sub2, sub3;
344 if (!dbus_message_get_args(
347 DBUS_TYPE_STRING, &interface,
349 return bus_send_error_reply(c, message, &error, -EINVAL);
351 if (interface[0] && !nulstr_contains(interfaces, interface)) {
352 dbus_set_error_const(&error, DBUS_ERROR_UNKNOWN_INTERFACE, "Unknown interface");
353 return bus_send_error_reply(c, message, &error, -EINVAL);
356 if (!(reply = dbus_message_new_method_return(message)))
359 dbus_message_iter_init_append(reply, &iter);
361 if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &sub))
364 for (bp = bound_properties; bp->interface; bp++) {
365 if (interface[0] && !streq(bp->interface, interface))
368 for (p = bp->properties; p->property; p++) {
371 if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_DICT_ENTRY, NULL, &sub2) ||
372 !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &p->property) ||
373 !dbus_message_iter_open_container(&sub2, DBUS_TYPE_VARIANT, p->signature, &sub3))
376 data = (char*)bp->base + p->offset;
378 data = *(void**)data;
379 r = p->append(&sub3, p->property, data);
384 dbus_message_unref(reply);
385 return bus_send_error_reply(c, message, NULL, r);
388 if (!dbus_message_iter_close_container(&sub2, &sub3) ||
389 !dbus_message_iter_close_container(&sub, &sub2))
394 if (!dbus_message_iter_close_container(&iter, &sub))
397 } else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Properties", "Set") && bound_properties) {
398 const char *interface, *property;
399 DBusMessageIter iter;
400 const BusBoundProperties *bp;
401 const BusProperty *p;
405 if (!dbus_message_iter_init(message, &iter) ||
406 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
407 return bus_send_error_reply(c, message, NULL, -EINVAL);
409 dbus_message_iter_get_basic(&iter, &interface);
411 if (!dbus_message_iter_next(&iter) ||
412 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
413 return bus_send_error_reply(c, message, NULL, -EINVAL);
415 dbus_message_iter_get_basic(&iter, &property);
417 if (!dbus_message_iter_next(&iter) ||
418 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT ||
419 dbus_message_iter_has_next(&iter))
420 return bus_send_error_reply(c, message, NULL, -EINVAL);
422 for (bp = bound_properties; bp->interface; bp++) {
423 if (!streq(bp->interface, interface))
426 for (p = bp->properties; p->property; p++)
427 if (streq(p->property, property))
432 if (!nulstr_contains(interfaces, interface))
433 dbus_set_error_const(&error, DBUS_ERROR_UNKNOWN_INTERFACE, "Unknown interface");
435 dbus_set_error_const(&error, DBUS_ERROR_UNKNOWN_PROPERTY, "Unknown property");
437 return bus_send_error_reply(c, message, &error, -EINVAL);
441 dbus_set_error_const(&error, DBUS_ERROR_PROPERTY_READ_ONLY, "Property read-only");
442 return bus_send_error_reply(c, message, &error, -EINVAL);
445 dbus_message_iter_recurse(&iter, &sub);
447 sig = dbus_message_iter_get_signature(&sub);
451 if (!streq(sig, p->signature)) {
453 return bus_send_error_reply(c, message, NULL, -EINVAL);
458 r = p->set(&sub, property);
462 return bus_send_error_reply(c, message, NULL, r);
465 reply = dbus_message_new_method_return(message);
469 const char *interface = dbus_message_get_interface(message);
471 if (!interface || !nulstr_contains(interfaces, interface)) {
472 dbus_set_error_const(&error, DBUS_ERROR_UNKNOWN_INTERFACE, "Unknown interface");
473 return bus_send_error_reply(c, message, &error, -EINVAL);
478 if (!dbus_connection_send(c, reply, NULL))
481 dbus_message_unref(reply);
482 return DBUS_HANDLER_RESULT_HANDLED;
485 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
489 dbus_message_unref(reply);
491 dbus_error_free(&error);
493 return DBUS_HANDLER_RESULT_NEED_MEMORY;
496 int bus_property_append_string(DBusMessageIter *i, const char *property, void *data) {
497 const char *t = data;
505 if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t))
511 int bus_property_append_strv(DBusMessageIter *i, const char *property, void *data) {
517 return bus_append_strv_iter(i, t);
520 int bus_property_append_bool(DBusMessageIter *i, const char *property, void *data) {
530 if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &db))
536 int bus_property_append_uint64(DBusMessageIter *i, const char *property, void *data) {
541 /* Let's ensure that usec_t is actually 64bit, and hence this
542 * function can be used for usec_t */
543 assert_cc(sizeof(uint64_t) == sizeof(usec_t));
545 if (!dbus_message_iter_append_basic(i, DBUS_TYPE_UINT64, data))
551 int bus_property_append_uint32(DBusMessageIter *i, const char *property, void *data) {
556 /* Let's ensure that pid_t, mode_t, uid_t, gid_t are actually
557 * 32bit, and hence this function can be used for
558 * pid_t/mode_t/uid_t/gid_t */
559 assert_cc(sizeof(uint32_t) == sizeof(pid_t));
560 assert_cc(sizeof(uint32_t) == sizeof(mode_t));
561 assert_cc(sizeof(uint32_t) == sizeof(unsigned));
562 assert_cc(sizeof(uint32_t) == sizeof(uid_t));
563 assert_cc(sizeof(uint32_t) == sizeof(gid_t));
565 if (!dbus_message_iter_append_basic(i, DBUS_TYPE_UINT32, data))
571 int bus_property_append_int32(DBusMessageIter *i, const char *property, void *data) {
576 assert_cc(sizeof(int32_t) == sizeof(int));
578 if (!dbus_message_iter_append_basic(i, DBUS_TYPE_INT32, data))
584 int bus_property_append_size(DBusMessageIter *i, const char *property, void *data) {
591 u = (uint64_t) *(size_t*) data;
593 if (!dbus_message_iter_append_basic(i, DBUS_TYPE_UINT64, &u))
599 int bus_property_append_ul(DBusMessageIter *i, const char *property, void *data) {
606 u = (uint64_t) *(unsigned long*) data;
608 if (!dbus_message_iter_append_basic(i, DBUS_TYPE_UINT64, &u))
614 int bus_property_append_long(DBusMessageIter *i, const char *property, void *data) {
621 l = (int64_t) *(long*) data;
623 if (!dbus_message_iter_append_basic(i, DBUS_TYPE_INT64, &l))
629 const char *bus_errno_to_dbus(int error) {
634 return DBUS_ERROR_INVALID_ARGS;
637 return DBUS_ERROR_NO_MEMORY;
641 return DBUS_ERROR_ACCESS_DENIED;
644 return DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN;
647 return DBUS_ERROR_FILE_NOT_FOUND;
650 return DBUS_ERROR_FILE_EXISTS;
654 return DBUS_ERROR_TIMEOUT;
657 return DBUS_ERROR_IO_ERROR;
662 return DBUS_ERROR_DISCONNECTED;
665 return DBUS_ERROR_FAILED;
668 DBusHandlerResult bus_send_error_reply(DBusConnection *c, DBusMessage *message, DBusError *berror, int error) {
669 DBusMessage *reply = NULL;
670 const char *name, *text;
672 if (berror && dbus_error_is_set(berror)) {
674 text = berror->message;
676 name = bus_errno_to_dbus(error);
677 text = strerror(-error);
680 if (!(reply = dbus_message_new_error(message, name, text)))
683 if (!dbus_connection_send(c, reply, NULL))
686 dbus_message_unref(reply);
689 dbus_error_free(berror);
691 return DBUS_HANDLER_RESULT_HANDLED;
695 dbus_message_unref(reply);
698 dbus_error_free(berror);
700 return DBUS_HANDLER_RESULT_NEED_MEMORY;
703 DBusMessage* bus_properties_changed_new(const char *path, const char *interface, const char *properties) {
705 DBusMessageIter iter, sub;
711 if (!(m = dbus_message_new_signal(path, "org.freedesktop.DBus.Properties", "PropertiesChanged")))
714 dbus_message_iter_init_append(m, &iter);
716 /* We won't send any property values, since they might be
717 * large and sometimes not cheap to generated */
719 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &interface) ||
720 !dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &sub) ||
721 !dbus_message_iter_close_container(&iter, &sub) ||
722 !dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub))
725 NULSTR_FOREACH(i, properties)
726 if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &i))
729 if (!dbus_message_iter_close_container(&iter, &sub))
736 dbus_message_unref(m);
741 uint32_t bus_flags_to_events(DBusWatch *bus_watch) {
747 /* no watch flags for disabled watches */
748 if (!dbus_watch_get_enabled(bus_watch))
751 flags = dbus_watch_get_flags(bus_watch);
753 if (flags & DBUS_WATCH_READABLE)
755 if (flags & DBUS_WATCH_WRITABLE)
758 return events | EPOLLHUP | EPOLLERR;
761 unsigned bus_events_to_flags(uint32_t events) {
764 if (events & EPOLLIN)
765 flags |= DBUS_WATCH_READABLE;
766 if (events & EPOLLOUT)
767 flags |= DBUS_WATCH_WRITABLE;
768 if (events & EPOLLHUP)
769 flags |= DBUS_WATCH_HANGUP;
770 if (events & EPOLLERR)
771 flags |= DBUS_WATCH_ERROR;
776 int bus_parse_strv(DBusMessage *m, char ***_l) {
777 DBusMessageIter iter;
782 if (!dbus_message_iter_init(m, &iter))
785 return bus_parse_strv_iter(&iter, _l);
788 int bus_parse_strv_iter(DBusMessageIter *iter, char ***_l) {
790 unsigned n = 0, i = 0;
796 if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY ||
797 dbus_message_iter_get_element_type(iter) != DBUS_TYPE_STRING)
800 dbus_message_iter_recurse(iter, &sub);
802 while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) {
804 dbus_message_iter_next(&sub);
807 if (!(l = new(char*, n+1)))
810 dbus_message_iter_recurse(iter, &sub);
812 while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) {
815 assert_se(dbus_message_iter_get_arg_type(&sub) == DBUS_TYPE_STRING);
816 dbus_message_iter_get_basic(&sub, &s);
818 if (!(l[i++] = strdup(s))) {
823 dbus_message_iter_next(&sub);
835 int bus_append_strv_iter(DBusMessageIter *iter, char **l) {
840 if (!dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "s", &sub))
844 if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, l))
847 if (!dbus_message_iter_close_container(iter, &sub))
853 int bus_iter_get_basic_and_next(DBusMessageIter *iter, int type, void *data, bool next) {
858 if (dbus_message_iter_get_arg_type(iter) != type)
861 dbus_message_iter_get_basic(iter, data);
863 if (!dbus_message_iter_next(iter) != !next)
869 int generic_print_property(const char *name, DBusMessageIter *iter, bool all) {
873 switch (dbus_message_iter_get_arg_type(iter)) {
875 case DBUS_TYPE_STRING: {
877 dbus_message_iter_get_basic(iter, &s);
879 if (all || !isempty(s))
880 printf("%s=%s\n", name, s);
885 case DBUS_TYPE_BOOLEAN: {
888 dbus_message_iter_get_basic(iter, &b);
889 printf("%s=%s\n", name, yes_no(b));
894 case DBUS_TYPE_UINT64: {
896 dbus_message_iter_get_basic(iter, &u);
898 /* Yes, heuristics! But we can change this check
899 * should it turn out to not be sufficient */
901 if (endswith(name, "Timestamp")) {
902 char timestamp[FORMAT_TIMESTAMP_MAX], *t;
904 t = format_timestamp(timestamp, sizeof(timestamp), u);
906 printf("%s=%s\n", name, strempty(t));
908 } else if (strstr(name, "USec")) {
909 char timespan[FORMAT_TIMESPAN_MAX];
911 printf("%s=%s\n", name, format_timespan(timespan, sizeof(timespan), u));
913 printf("%s=%llu\n", name, (unsigned long long) u);
918 case DBUS_TYPE_UINT32: {
920 dbus_message_iter_get_basic(iter, &u);
922 if (strstr(name, "UMask") || strstr(name, "Mode"))
923 printf("%s=%04o\n", name, u);
925 printf("%s=%u\n", name, (unsigned) u);
930 case DBUS_TYPE_INT32: {
932 dbus_message_iter_get_basic(iter, &i);
934 printf("%s=%i\n", name, (int) i);
938 case DBUS_TYPE_DOUBLE: {
940 dbus_message_iter_get_basic(iter, &d);
942 printf("%s=%g\n", name, d);
946 case DBUS_TYPE_ARRAY:
948 if (dbus_message_iter_get_element_type(iter) == DBUS_TYPE_STRING) {
952 dbus_message_iter_recurse(iter, &sub);
954 dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) {
957 while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) {
960 assert(dbus_message_iter_get_arg_type(&sub) == DBUS_TYPE_STRING);
961 dbus_message_iter_get_basic(&sub, &s);
962 printf("%s%s", space ? " " : "", s);
965 dbus_message_iter_next(&sub);
973 } else if (dbus_message_iter_get_element_type(iter) == DBUS_TYPE_BYTE) {
976 dbus_message_iter_recurse(iter, &sub);
978 dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) {
981 while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) {
984 assert(dbus_message_iter_get_arg_type(&sub) == DBUS_TYPE_BYTE);
985 dbus_message_iter_get_basic(&sub, &u);
988 dbus_message_iter_next(&sub);
1003 static void release_name_pending_cb(DBusPendingCall *pending, void *userdata) {
1005 DBusConnection *bus = userdata;
1007 assert_se(reply = dbus_pending_call_steal_reply(pending));
1008 dbus_message_unref(reply);
1010 dbus_connection_close(bus);
1013 void bus_async_unregister_and_exit(DBusConnection *bus, const char *name) {
1014 DBusMessage *m = NULL;
1015 DBusPendingCall *pending = NULL;
1019 /* We unregister the name here, but we continue to process
1020 * requests, until we get the response for it, so that all
1021 * requests are guaranteed to be processed. */
1023 m = dbus_message_new_method_call(
1026 DBUS_INTERFACE_DBUS,
1031 if (!dbus_message_append_args(
1038 if (!dbus_connection_send_with_reply(bus, m, &pending, -1))
1041 if (!dbus_pending_call_set_notify(pending, release_name_pending_cb, bus, NULL))
1044 dbus_message_unref(m);
1045 dbus_pending_call_unref(pending);
1050 log_error("Out of memory");
1053 dbus_pending_call_cancel(pending);
1054 dbus_pending_call_unref(pending);
1058 dbus_message_unref(m);
1061 DBusHandlerResult bus_exit_idle_filter(DBusConnection *bus, DBusMessage *m, void *userdata) {
1062 usec_t *remain_until = userdata;
1066 assert(remain_until);
1068 /* Everytime we get a new message we reset out timeout */
1069 *remain_until = now(CLOCK_MONOTONIC) + DEFAULT_EXIT_USEC;
1071 if (dbus_message_is_signal(m, DBUS_INTERFACE_LOCAL, "Disconnected"))
1072 dbus_connection_close(bus);
1074 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;