gdbusaddress: Use runstatedir rather than localstatedir

This reworks commit 20e1508e6e, for two
reasons:
 - Upstream dbus.git now does the same (although this isn’t yet reflected
   in the online version of the D-Bus Specification); see
   https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/209.
 - It allows local-prefix (e.g. jhbuild) builds of GLib to build in a
   custom prefix while still interacting with system services using the
   system-wide `/run` directory. To do so, pass `-Druntime_dir=/run` to
   meson configure.

As documented in the `NEWS` file in
https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/209, it’s only
valid to use `/run` – rather than `/var/run` – for D-Bus if the two
paths are interoperable. i.e. `/var/run` should be a symlink to `/run`,
and the D-Bus daemon should be configured to put its socket there.

This commit deliberately doesn’t introduce a special `system_socket`
configure option for specifying where the D-Bus system socket lives, as
that would only be useful for a distribution which sets `runstatedir` to
something other than `/var/run` or `/run`, which seems unlikely. We
could add such an option in future, though, if a distribution comes
forward with such a requirement.

See discussion on
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3095#note_1605502.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2022-11-30 13:47:47 +00:00
parent 30995f9dd7
commit b7b9f89417
2 changed files with 16 additions and 2 deletions

12
NEWS
View File

@ -1,3 +1,15 @@
UNRELEASED CHANGES
==================
* Change the default D-Bus system bus socket address from
`/var/run/dbus/system_bus_socket` to `/run/dbus/system_bus_socket`, in line
with changes in dbus.git. This can now be overridden by passing
`-Druntime_dir=/some/path` at configure time — the default is `/run`, which
should work for all users except distributions where `/run` is not equivalent
to `/var/run`. OS distributors should check that this configured path matches
the runtime directory configured for their D-Bus daemon. (!3101)
Overview of changes in GLib 2.75.0, 2022-11-10
==============================================

View File

@ -1339,8 +1339,10 @@ g_dbus_address_get_for_bus_sync (GBusType bus_type,
{
/* While the D-Bus specification says this must be `/var/run/dbus/system_bus_socket`,
* a footnote allows it to use localstatedir:
* https://dbus.freedesktop.org/doc/dbus-specification.html#ftn.id-1.13.6.4.3.3 */
ret = g_strdup ("unix:path=" GLIB_LOCALSTATEDIR "/run/dbus/system_bus_socket");
* https://dbus.freedesktop.org/doc/dbus-specification.html#ftn.id-1.13.6.4.3.3
* or, on systems where /run is the same as /var/run, runstatedir:
* https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/209 */
ret = g_strdup ("unix:path=" GLIB_RUNSTATEDIR "/dbus/system_bus_socket");
}
break;