Browse files

sd-bus: drop references to legacy /var/run D-Bus socket

Let's directly reference /run instead, so that we can work without /var
being around, or with /var/run being incorrectly set up.

Note that we keep the old socket path in place when referencing the
system bus of containers, as they might be foreign operating systems,
that still don't have adopted /run, and where it makes sense to use the
standardized name instead. On local systems, we insist on /run being set
up properly however, hence this limitation does not apply.

Also, get rid of the UNIX_SYSTEM_BUS_ADDRESS and
UNIX_USER_BUS_ADDRESS_FMT defines. They had a purpose when we still did
kdbus, as we then had to support two different backends. But since
that's gone, we don't need this indirection anymore, hence settle on a
one define only.
  • Loading branch information...
poettering committed Dec 19, 2017
1 parent 8c095a0 commit 15ca0a42c7db49146a7169dbcb0683f0836cf8c2
Showing with 7 additions and 5 deletions.
  1. +4 −3 src/basic/def.h
  2. +2 −1 src/libsystemd/sd-bus/sd-bus.c
  3. +1 −1 src/login/pam_systemd.c
@@ -53,9 +53,10 @@

#define UNIX_SYSTEM_BUS_ADDRESS "unix:path=/var/run/dbus/system_bus_socket"
#define UNIX_USER_BUS_ADDRESS_FMT "unix:path=%s/bus"
/* Note that we use the new /run prefix here (instead of /var/run) since we require them to be aliases and that way we
* become independent of /var being mounted */
#define DEFAULT_SYSTEM_BUS_ADDRESS "unix:path=/run/dbus/system_bus_socket"
#define DEFAULT_USER_BUS_ADDRESS_FMT "unix:path=%s/bus"

.un.sun_family = AF_UNIX, \
@@ -832,6 +832,7 @@ static int parse_container_unix_address(sd_bus *b, const char **p, char **guid)
b->nspid = 0;

b->sockaddr.un.sun_family = AF_UNIX;
/* Note that we use the old /var/run prefix here, to increase compatibility with really old containers */
strncpy(b->sockaddr.un.sun_path, "/var/run/dbus/system_bus_socket", sizeof(b->sockaddr.un.sun_path));
b->sockaddr_size = SOCKADDR_UN_LEN(b->sockaddr.un);
b->is_local = false;
@@ -1157,7 +1158,7 @@ int bus_set_address_user(sd_bus *b) {
if (!ee)
return -ENOMEM;

if (asprintf(&s, UNIX_USER_BUS_ADDRESS_FMT, ee) < 0)
if (asprintf(&s, DEFAULT_USER_BUS_ADDRESS_FMT, ee) < 0)
return -ENOMEM;

b->address = s;
@@ -197,7 +197,7 @@ static int export_legacy_dbus_address(

s = mfree(s);
if (asprintf(&s, UNIX_USER_BUS_ADDRESS_FMT, runtime) < 0)
if (asprintf(&s, DEFAULT_USER_BUS_ADDRESS_FMT, runtime) < 0)
goto error;

r = pam_misc_setenv(handle, "DBUS_SESSION_BUS_ADDRESS", s, 0);

0 comments on commit 15ca0a4

Please sign in to comment.