summaryrefslogtreecommitdiff
path: root/debian/patches/Optionally-install-systemd-user-units-for-a-per-user.patch
blob: 30dc3203c90d22a1f54c8b124771aaeac082e278 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
From: Simon McVittie <simon.mcvittie@collabora.co.uk>
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
---
 bus/Makefile.am                  | 16 +++++++++++++++-
 bus/systemd-user/dbus.service.in | 11 +++++++++++
 bus/systemd-user/dbus.socket.in  |  9 +++++++++
 configure.ac                     | 19 +++++++++++++++++++
 4 files changed, 54 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 c0bc154..178606f 100644
--- a/bus/Makefile.am
+++ b/bus/Makefile.am
@@ -233,6 +233,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:
@@ -284,13 +288,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 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 b765b72..e1127e8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1509,6 +1509,16 @@ 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='${libdir}/systemd/user'])
+    ])
+AC_SUBST([systemduserunitdir], [$with_systemduserunitdir])
+
 ##### Set up location for system bus socket
 if ! test -z "$with_system_socket"; then
    DBUS_SYSTEM_SOCKET=$with_system_socket
@@ -1762,6 +1772,13 @@ if test "x$enable_stats" = xyes; then
     [Define to enable bus daemon usage statistics])
 fi
 
+AC_ARG_ENABLE([user-session],
+  [AS_HELP_STRING([--enable-user-session],
+    [enable user-session semantics for session bus under systemd])],
+  [], [enable_user_session=no])
+AM_CONDITIONAL([DBUS_ENABLE_USER_SESSION],
+  [test "x$enable_user_session" = xyes])
+
 AC_CONFIG_FILES([
 Doxyfile
 dbus/versioninfo.rc
@@ -1776,6 +1793,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