From 057171efc103ac76c60a2a0d277d8bbf25415c21 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 27 Aug 2015 16:32:22 +0200 Subject: Revert "sd-bus: do not connect to dbus-1 socket when kdbus is available" This reverts commit d4d00020d6ad855d65d31020fefa5003e1bb477f. The idea of the commit is broken and needs to be reworked. We really cannot reduce the bus-addresses to a single address. We always will have systemd with native clients and legacy clients at the same time, so we also need both addresses at the same time. --- src/shared/bus-util.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/shared/bus-util.c') diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index 1bcb8903f3..1369a61458 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -2032,3 +2032,37 @@ int bus_path_decode_unique(const char *path, const char *prefix, char **ret_send *ret_external = external; return 1; } + +bool is_kdbus_wanted(void) { + _cleanup_free_ char *value = NULL; +#ifdef ENABLE_KDBUS + const bool configured = true; +#else + const bool configured = false; +#endif + + int r; + + if (get_proc_cmdline_key("kdbus", NULL) > 0) + return true; + + r = get_proc_cmdline_key("kdbus=", &value); + if (r <= 0) + return configured; + + return parse_boolean(value) == 1; +} + +bool is_kdbus_available(void) { + _cleanup_close_ int fd = -1; + struct kdbus_cmd cmd = { .size = sizeof(cmd), .flags = KDBUS_FLAG_NEGOTIATE }; + + if (!is_kdbus_wanted()) + return false; + + fd = open("/sys/fs/kdbus/control", O_RDWR | O_CLOEXEC | O_NONBLOCK | O_NOCTTY); + if (fd < 0) + return false; + + return ioctl(fd, KDBUS_CMD_BUS_MAKE, &cmd) >= 0; +} -- cgit v1.2.3-54-g00ecf