]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: complain if Before= dep on .device is declared
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 25 Sep 2016 12:34:30 +0000 (08:34 -0400)
committerMartin Pitt <martin.pitt@ubuntu.com>
Sat, 1 Oct 2016 20:53:17 +0000 (22:53 +0200)
[Unit]
Before=foobar.device

[Service]
ExecStart=/bin/true
Type=oneshot

$ systemd-analyze verify before-device.service
before-device.service: Dependency Before=foobar.device ignored (.device units cannot be delayed)

TODO
src/core/unit.c

diff --git a/TODO b/TODO
index 64d530b7d712b354e49beb1529d89690cff55ed0..ff9e9be9fb6db0dfa66ec64a054572cbebea8435 100644 (file)
--- a/TODO
+++ b/TODO
@@ -139,8 +139,6 @@ Features:
 
 * PID 1 should send out sd_notify("WATCHDOG=1") messages (for usage in the --user mode, and when run via nspawn)
 
-* consider throwing a warning if a service declares it wants to be "Before=" a .device unit.
-
 * there's probably something wrong with having user mounts below /sys,
   as we have for debugfs. for exmaple, src/core/mount.c handles mounts
   prefixed with /sys generally special.
index 5d284a359d81f17449d8de0757e014a1cea56a62..693f75c92832f23c0305b608b4d6daa0f56b6aaa 100644 (file)
@@ -2225,6 +2225,11 @@ int unit_add_dependency(Unit *u, UnitDependency d, Unit *other, bool add_referen
                 return 0;
         }
 
+        if (d == UNIT_BEFORE && other->type == UNIT_DEVICE) {
+                log_unit_warning(u, "Dependency Before=%s ignored (.device units cannot be delayed)", other->id);
+                return 0;
+        }
+
         r = set_ensure_allocated(&u->dependencies[d], NULL);
         if (r < 0)
                 return r;