From 263aca37ecf5f977f68d87b54f2fb30584725781 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 9 Feb 2015 19:02:43 +0000 Subject: Optionally install systemd user units for a per-user bus The socket path used here, $XDG_RUNTIME_DIR/bus, does not match what was used in user-session-units, but is what Lennart recommended on fd.o #61303, and is also what kdbus will use for its bus proxy. Installation of these units switches D-Bus to a different model of the system: instead of considering each login session (approximately, each password typed in) to be its own session, the user-session model is that all concurrent logins by the same user form one large session. This allows the same bus to be shared by a graphical session, cron jobs, tty/ssh sessions, screen/tmux sessions and so on. Because this is a different world-view, it is compile-time optional: OS builders can choose which world their OS will live in. The default is still the login-session model used in earlier D-Bus releases, but might change to the user-session model in future. Explicit configuration is recommended. In OSs that support both models (either for sysadmin flexibility or as a transitional measure), the OS builder should enable the user bus units, but split them off into a dpkg binary package, RPM subpackage etc.; the sysadmin can choose whether to enable the user-session model by choosing whether to install that package. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61301 Reviewed-by: Philip Withnall --- bus/Makefile.am | 16 +++++++++++++++- bus/systemd-user/dbus.service.in | 11 +++++++++++ bus/systemd-user/dbus.socket.in | 9 +++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 bus/systemd-user/dbus.service.in create mode 100644 bus/systemd-user/dbus.socket.in (limited to 'bus') diff --git a/bus/Makefile.am b/bus/Makefile.am index 1db7c9e1..ac2b4fce 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -250,6 +250,10 @@ if HAVE_SYSTEMD $(mkinstalldirs) $(DESTDIR)$(systemdsystemunitdir)/multi-user.target.wants ln -fs ../dbus.service $(DESTDIR)$(systemdsystemunitdir)/multi-user.target.wants/dbus.service endif +if DBUS_ENABLE_USER_SESSION + $(mkinstalldirs) $(DESTDIR)$(systemduserunitdir)/sockets.target.wants + ln -fs ../dbus.socket $(DESTDIR)$(systemduserunitdir)/sockets.target.wants/dbus.socket +endif if DBUS_UNIX install-exec-hook: @@ -301,13 +305,23 @@ endif if HAVE_SYSTEMD SCRIPT_IN_FILES += \ dbus.service.in \ - dbus.socket.in + dbus.socket.in \ + systemd-user/dbus.service.in \ + systemd-user/dbus.socket.in \ + $(NULL) systemdsystemunit_DATA = \ dbus.service \ dbus.socket endif +if DBUS_ENABLE_USER_SESSION +systemduserunit_DATA = \ + systemd-user/dbus.service \ + systemd-user/dbus.socket \ + $(NULL) +endif + #### Extra dist EXTRA_DIST=$(CONFIG_IN_FILES) $(SCRIPT_IN_FILES) diff --git a/bus/systemd-user/dbus.service.in b/bus/systemd-user/dbus.service.in new file mode 100644 index 00000000..b41f522b --- /dev/null +++ b/bus/systemd-user/dbus.service.in @@ -0,0 +1,11 @@ +[Unit] +Description=D-Bus User Message Bus +Documentation=man:dbus-daemon(1) +Requires=dbus.socket + +[Service] +ExecStart=@EXPANDED_BINDIR@/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation +ExecReload=@EXPANDED_BINDIR@/dbus-send --print-reply --session --type=method_call --dest=org.freedesktop.DBus / org.freedesktop.DBus.ReloadConfig + +[Install] +Also=dbus.socket diff --git a/bus/systemd-user/dbus.socket.in b/bus/systemd-user/dbus.socket.in new file mode 100644 index 00000000..77958f7c --- /dev/null +++ b/bus/systemd-user/dbus.socket.in @@ -0,0 +1,9 @@ +[Unit] +Description=D-Bus User Message Bus Socket + +[Socket] +ListenStream=%t/bus + +[Install] +WantedBy=sockets.target +Also=dbus.service -- cgit v1.2.1