diff options
-rw-r--r-- | Makefile.am | 40 | ||||
-rw-r--r-- | src/bus-driverd/bus-driverd.c | 8 | ||||
-rw-r--r-- | units/user/.gitignore | 1 | ||||
-rw-r--r-- | units/user/systemd-bus-driverd.service.in | 14 |
4 files changed, 47 insertions, 16 deletions
diff --git a/Makefile.am b/Makefile.am index 2d299d4183..7a159429e8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -221,6 +221,8 @@ SYSINIT_TARGET_WANTS = SOCKETS_TARGET_WANTS = BUSNAMES_TARGET_WANTS = TIMERS_TARGET_WANTS = +USER_SOCKETS_TARGET_WANTS = +USER_BUSNAMES_TARGET_WANTS = SYSTEM_UNIT_ALIASES = USER_UNIT_ALIASES = @@ -228,23 +230,25 @@ USER_UNIT_ALIASES = GENERAL_ALIASES = install-target-wants-hook: - what="$(RUNLEVEL1_TARGET_WANTS)" && wants=runlevel1.target && $(add-wants) - what="$(RUNLEVEL2_TARGET_WANTS)" && wants=runlevel2.target && $(add-wants) - what="$(RUNLEVEL3_TARGET_WANTS)" && wants=runlevel3.target && $(add-wants) - what="$(RUNLEVEL4_TARGET_WANTS)" && wants=runlevel4.target && $(add-wants) - what="$(RUNLEVEL5_TARGET_WANTS)" && wants=runlevel5.target && $(add-wants) - what="$(SHUTDOWN_TARGET_WANTS)" && wants=shutdown.target && $(add-wants) - what="$(LOCAL_FS_TARGET_WANTS)" && wants=local-fs.target && $(add-wants) - what="$(MULTI_USER_TARGET_WANTS)" && wants=multi-user.target && $(add-wants) - what="$(SYSINIT_TARGET_WANTS)" && wants=sysinit.target && $(add-wants) - what="$(SOCKETS_TARGET_WANTS)" && wants=sockets.target && $(add-wants) - what="$(BUSNAMES_TARGET_WANTS)" && wants=busnames.target && $(add-wants) - what="$(TIMERS_TARGET_WANTS)" && wants=timers.target && $(add-wants) - what="$(SLICES_TARGET_WANTS)" && wants=slices.target && $(add-wants) + what="$(RUNLEVEL1_TARGET_WANTS)" && wants=runlevel1.target && dir=$(systemunitdir) && $(add-wants) + what="$(RUNLEVEL2_TARGET_WANTS)" && wants=runlevel2.target && dir=$(systemunitdir) && $(add-wants) + what="$(RUNLEVEL3_TARGET_WANTS)" && wants=runlevel3.target && dir=$(systemunitdir) && $(add-wants) + what="$(RUNLEVEL4_TARGET_WANTS)" && wants=runlevel4.target && dir=$(systemunitdir) && $(add-wants) + what="$(RUNLEVEL5_TARGET_WANTS)" && wants=runlevel5.target && dir=$(systemunitdir) && $(add-wants) + what="$(SHUTDOWN_TARGET_WANTS)" && wants=shutdown.target && dir=$(systemunitdir) && $(add-wants) + what="$(LOCAL_FS_TARGET_WANTS)" && wants=local-fs.target && dir=$(systemunitdir) && $(add-wants) + what="$(MULTI_USER_TARGET_WANTS)" && wants=multi-user.target && dir=$(systemunitdir) && $(add-wants) + what="$(SYSINIT_TARGET_WANTS)" && wants=sysinit.target && dir=$(systemunitdir) && $(add-wants) + what="$(SOCKETS_TARGET_WANTS)" && wants=sockets.target && dir=$(systemunitdir) && $(add-wants) + what="$(BUSNAMES_TARGET_WANTS)" && wants=busnames.target && dir=$(systemunitdir) && $(add-wants) + what="$(TIMERS_TARGET_WANTS)" && wants=timers.target && dir=$(systemunitdir) && $(add-wants) + what="$(SLICES_TARGET_WANTS)" && wants=slices.target && dir=$(systemunitdir) && $(add-wants) + what="$(USER_SOCKETS_TARGET_WANTS)" && wants=sockets.target && dir=$(userunitdir) && $(add-wants) + what="$(USER_BUSNAMES_TARGET_WANTS)" && wants=busnames.target && dir=$(userunitdir) && $(add-wants) define add-wants [ -z "$$what" ] || ( \ - dir=$(DESTDIR)$(systemunitdir)/$$wants.wants && \ + dir=$(DESTDIR)$$dir/$$wants.wants && \ $(MKDIR_P) -m 0755 $$dir && \ cd $$dir && \ rm -f $$what && \ @@ -3752,6 +3756,14 @@ dist_systemunit_DATA += \ BUSNAMES_TARGET_WANTS += \ org.freedesktop.DBus.busname +nodist_userunit_DATA += \ + units/user/systemd-bus-driverd.service + +USER_BUSNAMES_TARGET_WANTS += \ + org.freedesktop.DBus.busname + +USER_UNIT_ALIASES += \ + $(systemunitdir)/org.freedesktop.DBus.busname org.freedesktop.DBus.busname endif EXTRA_DIST += \ diff --git a/src/bus-driverd/bus-driverd.c b/src/bus-driverd/bus-driverd.c index 44172c4ed6..172ad68c43 100644 --- a/src/bus-driverd/bus-driverd.c +++ b/src/bus-driverd/bus-driverd.c @@ -51,6 +51,7 @@ #include "def.h" #include "unit-name.h" #include "bus-control.h" +#include "cgroup-util.h" #define CLIENTS_MAX 1024 #define MATCHES_MAX 1024 @@ -748,7 +749,11 @@ static int connect_bus(Context *c) { assert(c); - r = sd_bus_default_system(&c->bus); + r = cg_pid_get_owner_uid(0, NULL); + if (r < 0) + r = sd_bus_default_system(&c->bus); + else + r = sd_bus_default_user(&c->bus); if (r < 0) { log_error("Failed to create bus: %s", strerror(-r)); return r; @@ -828,5 +833,4 @@ finish: sd_event_unref(context.event); return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; - } diff --git a/units/user/.gitignore b/units/user/.gitignore index 6aa54754cb..825102c41e 100644 --- a/units/user/.gitignore +++ b/units/user/.gitignore @@ -1,2 +1,3 @@ /systemd-exit.service /systemd-bus-proxyd@.service +/systemd-bus-driverd.service diff --git a/units/user/systemd-bus-driverd.service.in b/units/user/systemd-bus-driverd.service.in new file mode 100644 index 0000000000..575bddc699 --- /dev/null +++ b/units/user/systemd-bus-driverd.service.in @@ -0,0 +1,14 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=Bus Driver Service + +[Service] +ExecStart=@rootlibexecdir@/systemd-bus-driverd +BusName=org.freedesktop.DBus +WatchdogSec=1min |