naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
803fb7
From 33cca921994d30abfb03ce0f681c6fc58f5c0703 Mon Sep 17 00:00:00 2001
803fb7
From: Lennart Poettering <lennart@poettering.net>
803fb7
Date: Fri, 24 Apr 2015 17:28:06 +0200
803fb7
Subject: [PATCH] unit: don't add automatic dependencies on device units if
803fb7
 they aren't supported
803fb7
803fb7
http://lists.freedesktop.org/archives/systemd-devel/2015-April/031187.html
803fb7
(cherry picked from commit 47bc12e1ba35d38edda737dae232088d6d3ae688)
803fb7
803fb7
Cherry-picked from: c20cdaa
803fb7
Resolves: #1222517
803fb7
---
803fb7
 src/core/unit.c | 10 +++++++---
803fb7
 1 file changed, 7 insertions(+), 3 deletions(-)
803fb7
803fb7
diff --git a/src/core/unit.c b/src/core/unit.c
803fb7
index 565455bd6..b9e1f13ea 100644
803fb7
--- a/src/core/unit.c
803fb7
+++ b/src/core/unit.c
803fb7
@@ -2830,14 +2830,18 @@ int unit_add_node_link(Unit *u, const char *what, bool wants) {
803fb7
 
803fb7
         assert(u);
803fb7
 
803fb7
-        if (!what)
803fb7
-                return 0;
803fb7
-
803fb7
         /* Adds in links to the device node that this unit is based on */
803fb7
+        if (isempty(what))
803fb7
+                return 0;
803fb7
 
803fb7
         if (!is_device_path(what))
803fb7
                 return 0;
803fb7
 
803fb7
+        /* When device units aren't supported (such as in a
803fb7
+         * container), don't create dependencies on them. */
803fb7
+        if (unit_vtable[UNIT_DEVICE]->supported && !unit_vtable[UNIT_DEVICE]->supported(u->manager))
803fb7
+                return 0;
803fb7
+
803fb7
         e = unit_name_from_path(what, ".device");
803fb7
         if (!e)
803fb7
                 return -ENOMEM;