chiark / gitweb /
core: ensure LSB Provides are handled correctly
authorFrederic Crozat <fcrozat@suse.com>
Thu, 21 Mar 2013 14:40:45 +0000 (15:40 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 25 Mar 2013 16:26:15 +0000 (17:26 +0100)
Let's say you have two initscripts, A and B:

A contains in its LSB header:
Required-Start: C

and B contains in its LSB header:
Provides: C

When systemd is parsing /etc/rc.d/, depending on the file order, you
can end up with either:
- B is parsed first. An unit "C.service" will be "created" and will be
added as additional name to B.service, with unit_add_name. No bug.
- A is parsed first. An unit "C.service" is created for the
"Required-Start" dependency (it will have no file attached, since
nothing provides this dependency yet). Then B is parsed and when trying
to handle "Provides: C", unit_add_name is called but will fail, because
"C.service" already exists in manager->units. Therefore, a merge should
occur for that case.

src/core/service.c

index 4451d38eefdbd103b9d54712e902ec4b51fa64f4..fa8a1cb0390a79a1ff07551cee6c9fa4043d038e 100644 (file)
@@ -762,7 +762,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
                                                 continue;
 
                                         if (unit_name_to_type(m) == UNIT_SERVICE)
-                                                r = unit_add_name(u, m);
+                                                r = unit_merge_by_name(u, m);
                                         else
                                                 /* NB: SysV targets
                                                  * which are provided