summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/sd-bus.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd/sd-bus/sd-bus.c')
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 0f075907d5..763f830e2d 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -43,7 +43,6 @@
#include "bus-kernel.h"
#include "bus-control.h"
#include "bus-objects.h"
-#include "bus-util.h"
#include "bus-container.h"
#include "bus-protocol.h"
#include "bus-track.h"
@@ -1173,7 +1172,10 @@ int bus_set_address_system(sd_bus *b) {
if (e)
return sd_bus_set_address(b, e);
- return sd_bus_set_address(b, DEFAULT_SYSTEM_BUS_ADDRESS);
+ if (is_kdbus_available())
+ return sd_bus_set_address(b, KERNEL_SYSTEM_BUS_ADDRESS);
+
+ return sd_bus_set_address(b, UNIX_SYSTEM_BUS_ADDRESS);
}
_public_ int sd_bus_open_system(sd_bus **ret) {
@@ -1221,16 +1223,17 @@ int bus_set_address_user(sd_bus *b) {
return sd_bus_set_address(b, e);
e = secure_getenv("XDG_RUNTIME_DIR");
- if (e) {
+ if (is_kdbus_available())
+ (void) asprintf(&b->address, KERNEL_USER_BUS_ADDRESS_FMT, getuid());
+ else if (e) {
_cleanup_free_ char *ee = NULL;
ee = bus_address_escape(e);
if (!ee)
return -ENOMEM;
- (void) asprintf(&b->address, KERNEL_USER_BUS_ADDRESS_FMT ";" UNIX_USER_BUS_ADDRESS_FMT, getuid(), ee);
- } else
- (void) asprintf(&b->address, KERNEL_USER_BUS_ADDRESS_FMT, getuid());
+ (void) asprintf(&b->address, UNIX_USER_BUS_ADDRESS_FMT, ee);
+ }
if (!b->address)
return -ENOMEM;