From 9fbae16af506d4986b50aac9e02c501af8827fef Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 6 Jan 2014 17:03:39 +0000 Subject: [PATCH 2/4] Install systemd user units for a per-user bus When systemd gains support for activating a per-user systemd for each set of overlapping login sessions, this is what it'll use. 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. [Patch v2: replaced XDG_RUNTIME_DIR/dbus/user_bus_socket with XDG_RUNTIME_DIR/bus, added sockets.target.wants/dbus.socket link, added Documentation key.] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61301 --- bus/Makefile.am | 16 +++++++++++++++- bus/systemd-user/dbus.service.in | 11 +++++++++++ bus/systemd-user/dbus.socket.in | 9 +++++++++ configure.ac | 15 +++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 bus/systemd-user/dbus.service.in create mode 100644 bus/systemd-user/dbus.socket.in diff --git a/bus/Makefile.am b/bus/Makefile.am index cd0c67d..b5eab9d 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -220,6 +220,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 HAVE_USER_SYSTEMD + $(mkinstalldirs) $(DESTDIR)$(systemduserunitdir)/sockets.target.wants + ln -fs ../dbus.socket $(DESTDIR)$(systemduserunitdir)/sockets.target.wants/dbus.socket +endif if DBUS_UNIX install-exec-hook: @@ -271,13 +275,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 HAVE_USER_SYSTEMD +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 0000000..b41f522 --- /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 0000000..77958f7 --- /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 diff --git a/configure.ac b/configure.ac index 700821f..974789f 100644 --- a/configure.ac +++ b/configure.ac @@ -1499,6 +1499,19 @@ if test "x$with_systemdsystemunitdir" != xno; then fi AM_CONDITIONAL(HAVE_SYSTEMD, [test "x$have_systemd" != "xno" -a -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ]) +AC_ARG_WITH([systemduserunitdir], +AS_HELP_STRING([--with-systemduserunitdir=DIR], [Directory for systemd user service files]), + [], + [ + PKG_CHECK_EXISTS([systemd], + [with_systemduserunitdir=$($PKG_CONFIG --variable=systemduserunitdir systemd)], + [with_systemduserunitdir=no]) + ]) +AS_IF([test "x$have_systemd" = xno], [with_systemduserunitdir=no]) +AS_IF([test "x$with_systemduserunitdir" = x], [with_systemduserunitdir=no]) +AC_SUBST([systemduserunitdir], [$with_systemduserunitdir]) +AM_CONDITIONAL(HAVE_USER_SYSTEMD, [test "x$with_systemduserunitdir" != xno]) + ##### Set up location for system bus socket if ! test -z "$with_system_socket"; then DBUS_SYSTEM_SOCKET=$with_system_socket @@ -1754,6 +1767,8 @@ bus/org.freedesktop.dbus-session.plist bus/rc.messagebus bus/dbus.service bus/dbus.socket +bus/systemd-user/dbus.service +bus/systemd-user/dbus.socket Makefile dbus/Makefile bus/Makefile -- 1.8.5.2