[systemd-commits] src/service.c

Michael Biebl mbiebl at kemper.freedesktop.org
Mon Dec 27 09:46:34 PST 2010


 src/service.c |   30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

New commits:
commit 5b8191986c5e00323315e61a53efadbf64de8161
Author: Michael Biebl <biebl at debian.org>
Date:   Mon Dec 27 18:41:54 2010 +0100

    service: ifdef (more) distro-specific compat logic
    
    This should make it easier to get rid of that compat code later and
    avoids problems like stripping of rc. from /etc/init.d/rc.local on
    Debian.

diff --git a/src/service.c b/src/service.c
index ca0db8e..9f2ee41 100644
--- a/src/service.c
+++ b/src/service.c
@@ -237,19 +237,23 @@ static char *sysv_translate_name(const char *name) {
         if (!(r = new(char, strlen(name) + sizeof(".service"))))
                 return NULL;
 
+#if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU)
+        if (endswith(name, ".sh"))
+                /* Drop Debian-style .sh suffix */
+                strcpy(stpcpy(r, name) - 3, ".service");
+#endif
+#ifdef TARGET_SUSE
         if (startswith(name, "boot."))
                 /* Drop SuSE-style boot. prefix */
                 strcpy(stpcpy(r, name + 5), ".service");
-        else if (endswith(name, ".sh"))
-                /* Drop Debian-style .sh suffix */
-                strcpy(stpcpy(r, name) - 3, ".service");
+#endif
 #ifdef TARGET_ARCH
-        else if (startswith(name, "@"))
+        if (startswith(name, "@"))
                 /* Drop Arch-style background prefix */
                 strcpy(stpcpy(r, name + 1), ".service");
 #endif
 #ifdef TARGET_FRUGALWARE
-        else if (startswith(name, "rc."))
+        if (startswith(name, "rc."))
                 /* Drop Frugalware-style rc. prefix */
                 strcpy(stpcpy(r, name + 3), ".service");
 #endif
@@ -857,10 +861,20 @@ static int service_load_sysv_name(Service *s, const char *name) {
 
         /* For SysV services we strip the boot.*, rc.* and *.sh
          * prefixes/suffixes. */
-        if (startswith(name, "boot.") ||
-            startswith(name, "rc.") ||
-            endswith(name, ".sh.service"))
+#if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU)
+        if (endswith(name, ".sh.service"))
                 return -ENOENT;
+#endif
+
+#ifdef TARGET_SUSE
+        if (startswith(name, "boot."))
+                return -ENOENT;
+#endif
+
+#ifdef TARGET_FRUGALWARE
+        if (startswith(name, "rc."))
+                return -ENOENT;
+#endif
 
         STRV_FOREACH(p, s->meta.manager->lookup_paths.sysvinit_path) {
                 char *path;



More information about the systemd-commits mailing list