chiark / gitweb /
core: do not add dependencies to self
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 8 Aug 2014 00:42:58 +0000 (20:42 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 8 Aug 2014 00:42:58 +0000 (20:42 -0400)
Adds a pair of files which cause a segfault (also with
systemd-analyze verify).

https://bugzilla.redhat.com/show_bug.cgi?id=1124843

src/core/load-dropin.c
src/core/unit.c
test/loopy.service [new file with mode: 0644]
test/loopy.service.d/compat.conf [new file with mode: 0644]
test/loopy2.service [new symlink]

index 21c9915..ffc68b4 100644 (file)
@@ -181,7 +181,7 @@ int unit_load_dropin(Unit *u) {
         }
 
         u->dropin_paths = unit_find_dropin_paths(u);
-        if (! u->dropin_paths)
+        if (!u->dropin_paths)
                 return 0;
 
         STRV_FOREACH(f, u->dropin_paths) {
index b68796a..0926732 100644 (file)
@@ -597,14 +597,22 @@ static void merge_dependencies(Unit *u, Unit *other, UnitDependency d) {
                 UnitDependency k;
 
                 for (k = 0; k < _UNIT_DEPENDENCY_MAX; k++) {
-                        r = set_remove_and_put(back->dependencies[k], other, u);
-                        if (r == -EEXIST)
+                        /* Do not add dependencies between u and itself */
+                        if (back == u) {
                                 set_remove(back->dependencies[k], other);
-                        else
-                                assert(r >= 0 || r == -ENOENT);
+                        } else {
+                                r = set_remove_and_put(back->dependencies[k], other, u);
+                                if (r == -EEXIST)
+                                        set_remove(back->dependencies[k], other);
+                                else
+                                        assert(r >= 0 || r == -ENOENT);
+                        }
                 }
         }
 
+        /* Also do not move dependencies on u to itself */
+        set_remove(other->dependencies[d], u);
+
         complete_move(&u->dependencies[d], &other->dependencies[d]);
 
         set_free(other->dependencies[d]);
diff --git a/test/loopy.service b/test/loopy.service
new file mode 100644 (file)
index 0000000..9eb6457
--- /dev/null
@@ -0,0 +1,2 @@
+[Service]
+ExecStart=/bin/true
diff --git a/test/loopy.service.d/compat.conf b/test/loopy.service.d/compat.conf
new file mode 100644 (file)
index 0000000..51b84b8
--- /dev/null
@@ -0,0 +1,5 @@
+[Unit]
+BindsTo=loopy2.service
+
+[Install]
+Also=loopy2.service
diff --git a/test/loopy2.service b/test/loopy2.service
new file mode 120000 (symlink)
index 0000000..961b1fe
--- /dev/null
@@ -0,0 +1 @@
+loopy.service
\ No newline at end of file