chiark / gitweb /
bus-driverd: support user mode
authorKay Sievers <kay@vrfy.org>
Tue, 7 Jan 2014 12:20:22 +0000 (20:20 +0800)
committerKay Sievers <kay@vrfy.org>
Wed, 8 Jan 2014 00:38:39 +0000 (08:38 +0800)
Makefile.am
src/bus-driverd/bus-driverd.c
units/user/.gitignore
units/user/systemd-bus-driverd.service.in [new file with mode: 0644]

index 2d299d4..7a15942 100644 (file)
@@ -221,6 +221,8 @@ SYSINIT_TARGET_WANTS =
 SOCKETS_TARGET_WANTS =
 BUSNAMES_TARGET_WANTS =
 TIMERS_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 =
 
 SYSTEM_UNIT_ALIASES =
 USER_UNIT_ALIASES =
@@ -228,23 +230,25 @@ USER_UNIT_ALIASES =
 GENERAL_ALIASES =
 
 install-target-wants-hook:
 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" ] || ( \
 
 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 && \
          $(MKDIR_P) -m 0755 $$dir && \
          cd $$dir && \
          rm -f $$what && \
@@ -3752,6 +3756,14 @@ dist_systemunit_DATA += \
 BUSNAMES_TARGET_WANTS += \
        org.freedesktop.DBus.busname
 
 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 += \
 endif
 
 EXTRA_DIST += \
index 44172c4..172ad68 100644 (file)
@@ -51,6 +51,7 @@
 #include "def.h"
 #include "unit-name.h"
 #include "bus-control.h"
 #include "def.h"
 #include "unit-name.h"
 #include "bus-control.h"
+#include "cgroup-util.h"
 
 #define CLIENTS_MAX 1024
 #define MATCHES_MAX 1024
 
 #define CLIENTS_MAX 1024
 #define MATCHES_MAX 1024
@@ -748,7 +749,11 @@ static int connect_bus(Context *c) {
 
         assert(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;
         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;
         sd_event_unref(context.event);
 
         return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
-
 }
 }
index 6aa5475..825102c 100644 (file)
@@ -1,2 +1,3 @@
 /systemd-exit.service
 /systemd-bus-proxyd@.service
 /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 (file)
index 0000000..575bddc
--- /dev/null
@@ -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