Hi all,

in https://bugzilla.novell.com/show_bug.cgi?id=809646 we noticed LSB
Provides can sometime be incorrectly handled (resulting in "Failed to
add LSB Provides name XXXX.service, ignoring: File exists" errors),
depending on initscript parsing order (if a provides is required by
another initscript and this initscript is parsed before the one with the
provides).

Attached patch fixes this issue.
-- 
Frederic Crozat <fcro...@suse.com>
SUSE
>From 4e7c74b96a2c154cfb3e60fc14c8b50070808758 Mon Sep 17 00:00:00 2001
From: Frederic Crozat <fcro...@suse.com>
Date: Thu, 21 Mar 2013 15:40:45 +0100
Subject: [PATCH] core: ensure LSB Provides are handled correctly

Depending on initscript reading order, one initscript might
reference as a Required-Start/Should-Start dependency another
initscript provides, before initscript containing provides has been
parsed and the corresponding in-memory unit has been created. This
change ensure the unit created for the dependency is merged with the
one containing the provides.
---
 src/core/service.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/core/service.c b/src/core/service.c
index 080d583..efbc94c 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -764,8 +764,15 @@ static int service_load_sysv_path(Service *s, const char *path) {
                                         if (r == 0)
                                                 continue;
 
-                                        if (unit_name_to_type(m) == UNIT_SERVICE)
-                                                r = unit_add_name(u, m);
+                                        if (unit_name_to_type(m) == UNIT_SERVICE) {
+                                                Unit *existing_unit;
+
+                                                existing_unit=manager_get_unit(UNIT(s)->manager, m);
+                                                if (existing_unit)
+                                                        r = unit_merge (u, existing_unit);
+                                                else
+                                                        r = unit_add_name(u, m);
+                                        }
                                         else
                                                 /* NB: SysV targets
                                                  * which are provided
-- 
1.8.1.4

_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to