chiark / gitweb /
sd-bus: drop references to legacy /var/run D-Bus socket
authorLennart Poettering <lennart@poettering.net>
Tue, 19 Dec 2017 14:41:58 +0000 (15:41 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:49:59 +0000 (07:49 +0200)
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.

src/basic/def.h
src/libelogind/sd-bus/sd-bus.c
src/login/pam_elogind.c

index fdc2026211955a354afc8b608f08e416a2f90486..11b9a7ccaaa287c090a8af5b0ffced4d012deec9 100644 (file)
         "/usr/lib/kbd/keymaps/\0"
 #endif
 
-#define UNIX_SYSTEM_BUS_ADDRESS "unix:path=/var/run/dbus/system_bus_socket"
-#define DEFAULT_SYSTEM_BUS_ADDRESS UNIX_SYSTEM_BUS_ADDRESS
-#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"
 
 #define PLYMOUTH_SOCKET {                                       \
                 .un.sun_family = AF_UNIX,                       \
index 5f99d0f8a3965233c9f320bb5f879e0cc86e36df..5976e6d28962afd5e8435776efd0309a92fa603c 100644 (file)
@@ -837,6 +837,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;
@@ -1167,7 +1168,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;
index 80b73769407c729d5f82c7eb074efe0de75d5ae7..b1e678d2b256aa13d20ef653f41adacbe9daf763 100644 (file)
@@ -197,7 +197,7 @@ static int export_legacy_dbus_address(
                 return PAM_SUCCESS;
 
         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);