]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #7572 from poettering/taint-manager
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 7 Dec 2017 20:06:28 +0000 (21:06 +0100)
committerGitHub <noreply@github.com>
Thu, 7 Dec 2017 20:06:28 +0000 (21:06 +0100)
"taint" logic improvements and other minor fixes

NEWS
coccinelle/empty-to-null.cocci [new file with mode: 0644]
coccinelle/run-coccinelle.sh
src/core/manager.c
src/core/unit.c

diff --git a/NEWS b/NEWS
index 3524f145a47aa05a05e9da27970d9863b3942c70..bbb481e922de174210d4e5f05be8e2d599b65f3d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -43,14 +43,21 @@ CHANGES WITH 236 in spe:
           basic.target unit has been reached, instead of when the run queue ran
           empty for the first time.
 
-        * Unit files learnt three new % specifiers that are expanded during
-          loading: %S resolves to the top-level state directory (/var/lib for
-          the system instance, $XDG_CONFIG_HOME for the user instance), %C
-          resolves to the top-level cache directory (/var/cache for the system
-          instance, $XDG_CACHE_HOME for the user instance), %L resolves to the
-          top-level logs directory (/var/log for the system instance,
+        * Tmpfiles.d with user configuration are now also supported.
+          systemd-tmpfiles gained a new --user switch, and snippets placed in
+          ~/.config/user-tmpfiles.d/ and corresponding directories will be
+          executed by systemd-tmpfiles --user running in the new
+          systemd-tmpfiles-setup.service and systemd-tmpfiles-clean.service
+          running in the user session.
+
+        * Unit files and tmpfiles.d snippets learnt three new % specifiers:
+          %S resolves to the top-level state directory (/var/lib for the system
+          instance, $XDG_CONFIG_HOME for the user instance), %C resolves to the
+          top-level cache directory (/var/cache for the system instance,
+          $XDG_CACHE_HOME for the user instance), %L resolves to the top-level
+          logs directory (/var/log for the system instance,
           $XDG_CONFIG_HOME/log/ for the user instance). This matches the
-          existing %t specifier, that resolves to the top-level runtime
+          existing %t specifier, that resolves to the top-level runtime
           directory (/run for the system instance, and $XDG_RUNTIME_DIR for the
           user instance).
 
diff --git a/coccinelle/empty-to-null.cocci b/coccinelle/empty-to-null.cocci
new file mode 100644 (file)
index 0000000..fbc75b9
--- /dev/null
@@ -0,0 +1,5 @@
+@@
+expression s;
+@@
+- isempty(s) ? NULL : s
++ empty_to_null(s)
index fe3aeb68ce9bff3293f32908c72c03d3542206b2..1373b53c5f4a3d00c3ddd216380b97690898917c 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash -e
 
-for SCRIPT in *.cocci ; do
+for SCRIPT in ${@-*.cocci} ; do
         [ "$SCRIPT" = "empty-if.cocci" ] && continue
         echo "--x-- Processing $SCRIPT --x--"
         TMPFILE=`mktemp`
index a773c1e94bae8a9bc49b6bcc1c64e0baaf311b88..6cf7fd3f303a2ba333c7a6f0b6f1a7b74143b018 100644 (file)
@@ -604,6 +604,29 @@ static int manager_setup_prefix(Manager *m) {
         return 0;
 }
 
+static int manager_setup_run_queue(Manager *m) {
+        int r;
+
+        assert(m);
+        assert(!m->run_queue_event_source);
+
+        r = sd_event_add_defer(m->event, &m->run_queue_event_source, manager_dispatch_run_queue, m);
+        if (r < 0)
+                return r;
+
+        r = sd_event_source_set_priority(m->run_queue_event_source, SD_EVENT_PRIORITY_IDLE);
+        if (r < 0)
+                return r;
+
+        r = sd_event_source_set_enabled(m->run_queue_event_source, SD_EVENT_OFF);
+        if (r < 0)
+                return r;
+
+        (void) sd_event_source_set_description(m->run_queue_event_source, "manager-run-queue");
+
+        return 0;
+}
+
 int manager_new(UnitFileScope scope, unsigned test_run_flags, Manager **_m) {
         Manager *m;
         int r;
@@ -688,20 +711,10 @@ int manager_new(UnitFileScope scope, unsigned test_run_flags, Manager **_m) {
         if (r < 0)
                 goto fail;
 
-        r = sd_event_add_defer(m->event, &m->run_queue_event_source, manager_dispatch_run_queue, m);
+        r = manager_setup_run_queue(m);
         if (r < 0)
                 goto fail;
 
-        r = sd_event_source_set_priority(m->run_queue_event_source, SD_EVENT_PRIORITY_IDLE);
-        if (r < 0)
-                goto fail;
-
-        r = sd_event_source_set_enabled(m->run_queue_event_source, SD_EVENT_OFF);
-        if (r < 0)
-                goto fail;
-
-        (void) sd_event_source_set_description(m->run_queue_event_source, "manager-run-queue");
-
         r = manager_setup_signals(m);
         if (r < 0)
                 goto fail;
@@ -720,21 +733,23 @@ int manager_new(UnitFileScope scope, unsigned test_run_flags, Manager **_m) {
                 goto fail;
         }
 
-        if (MANAGER_IS_SYSTEM(m)) {
+        r = manager_setup_prefix(m);
+        if (r < 0)
+                goto fail;
+
+        if (MANAGER_IS_SYSTEM(m) && test_run_flags == 0) {
                 r = mkdir_label("/run/systemd/units", 0755);
                 if (r < 0 && r != -EEXIST)
                         goto fail;
         }
 
+        m->taint_usr =
+                !in_initrd() &&
+                dir_is_empty("/usr") > 0;
+
         /* Note that we do not set up the notify fd here. We do that after deserialization,
          * since they might have gotten serialized across the reexec. */
 
-        m->taint_usr = dir_is_empty("/usr") > 0;
-
-        r = manager_setup_prefix(m);
-        if (r < 0)
-                goto fail;
-
         *_m = m;
         return 0;
 
index ed0cf026785cd2aeab81bc8e89291fe52d270b1e..7af8425707e12c1def98e0afdd5555b573c2d93c 100644 (file)
@@ -3015,8 +3015,8 @@ static int signal_name_owner_changed(sd_bus_message *message, void *userdata, sd
                 return 0;
         }
 
-        old_owner = isempty(old_owner) ? NULL : old_owner;
-        new_owner = isempty(new_owner) ? NULL : new_owner;
+        old_owner = empty_to_null(old_owner);
+        new_owner = empty_to_null(new_owner);
 
         if (UNIT_VTABLE(u)->bus_name_owner_change)
                 UNIT_VTABLE(u)->bus_name_owner_change(u, name, old_owner, new_owner);