diff options
author | Kay Sievers <kay@vrfy.org> | 2015-08-11 20:46:05 +0200 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2015-08-11 20:49:36 +0200 |
commit | d4d00020d6ad855d65d31020fefa5003e1bb477f (patch) | |
tree | 312c253adaf27c87c111d20a116df40a6496e468 /src/shared | |
parent | 3f1818cf70ac34cf93f1f033b4f1bbb7a89b3dff (diff) | |
download | systemd-d4d00020d6ad855d65d31020fefa5003e1bb477f.tar.gz systemd-d4d00020d6ad855d65d31020fefa5003e1bb477f.tar.bz2 systemd-d4d00020d6ad855d65d31020fefa5003e1bb477f.zip |
sd-bus: do not connect to dbus-1 socket when kdbus is available
We should not fall back to dbus-1 and connect to the proxy when kdbus
returns an error that indicates that kdbus is running but just does not
accept new connections because of quota limits or something similar.
Using is_kdbus_available() in libsystemd/ requires it to move from
shared/ to libsystemd/.
Based on a patch from David Herrmann:
https://github.com/systemd/systemd/pull/886
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/bus-util.c | 34 | ||||
-rw-r--r-- | src/shared/bus-util.h | 28 |
2 files changed, 2 insertions, 60 deletions
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index aa87cd0910..0df0594ea3 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -2027,37 +2027,3 @@ 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; -} diff --git a/src/shared/bus-util.h b/src/shared/bus-util.h index 4ae216b7d9..0c683c0713 100644 --- a/src/shared/bus-util.h +++ b/src/shared/bus-util.h @@ -23,18 +23,12 @@ #include "sd-event.h" #include "sd-bus.h" +#include "bus-error.h" +#include "bus-internal.h" #include "hashmap.h" #include "install.h" #include "time-util.h" -typedef enum BusTransport { - BUS_TRANSPORT_LOCAL, - BUS_TRANSPORT_REMOTE, - BUS_TRANSPORT_MACHINE, - _BUS_TRANSPORT_MAX, - _BUS_TRANSPORT_INVALID = -1 -} BusTransport; - typedef int (*bus_property_set_t) (sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata); struct bus_properties_map { @@ -135,21 +129,6 @@ typedef struct UnitInfo { int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u); -DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus*, sd_bus_unref); -DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus*, sd_bus_flush_close_unref); -DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_slot*, sd_bus_slot_unref); -DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_message*, sd_bus_message_unref); -DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_creds*, sd_bus_creds_unref); -DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_track*, sd_bus_track_unref); - -#define _cleanup_bus_unref_ _cleanup_(sd_bus_unrefp) -#define _cleanup_bus_flush_close_unref_ _cleanup_(sd_bus_flush_close_unrefp) -#define _cleanup_bus_slot_unref_ _cleanup_(sd_bus_slot_unrefp) -#define _cleanup_bus_message_unref_ _cleanup_(sd_bus_message_unrefp) -#define _cleanup_bus_creds_unref_ _cleanup_(sd_bus_creds_unrefp) -#define _cleanup_bus_track_unref_ _cleanup_(sd_bus_slot_unrefp) -#define _cleanup_bus_error_free_ _cleanup_(sd_bus_error_free) - #define BUS_DEFINE_PROPERTY_GET_ENUM(function, name, type) \ int function(sd_bus *bus, \ const char *path, \ @@ -197,6 +176,3 @@ int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, Un int bus_path_encode_unique(sd_bus *b, const char *prefix, const char *sender_id, const char *external_id, char **ret_path); int bus_path_decode_unique(const char *path, const char *prefix, char **ret_sender, char **ret_external); - -bool is_kdbus_wanted(void); -bool is_kdbus_available(void); |