summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/sd-bus.c
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2015-08-11 20:46:05 +0200
committerKay Sievers <kay@vrfy.org>2015-08-11 20:49:36 +0200
commitd4d00020d6ad855d65d31020fefa5003e1bb477f (patch)
tree312c253adaf27c87c111d20a116df40a6496e468 /src/libsystemd/sd-bus/sd-bus.c
parent3f1818cf70ac34cf93f1f033b4f1bbb7a89b3dff (diff)
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/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;