chiark / gitweb /
systemctl: append .service when unit does not have valid suffix
authorLukas Nykryn <lnykryn@redhat.com>
Tue, 16 Oct 2012 09:01:29 +0000 (11:01 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 16 Oct 2012 14:07:37 +0000 (16:07 +0200)
systemctl status a and systemctl status a.service lead to same output but
systemctl status a.b and systemctl status a.b.service do not.

src/shared/unit-name.c

index cfe3133..50031e6 100644 (file)
@@ -470,7 +470,6 @@ char *unit_dbus_path_from_name(const char *name) {
 char *unit_name_mangle(const char *name) {
         char *r, *t;
         const char *f;
-        bool dot = false;
 
         assert(name);
 
@@ -491,10 +490,6 @@ char *unit_name_mangle(const char *name) {
                 return NULL;
 
         for (f = name, t = r; *f; f++) {
-
-                if (*f == '.')
-                        dot = true;
-
                 if (*f == '/')
                         *(t++) = '-';
                 else if (!strchr("@" VALID_CHARS, *f))
@@ -503,7 +498,7 @@ char *unit_name_mangle(const char *name) {
                         *(t++) = *f;
         }
 
-        if (!dot)
+        if (unit_name_to_type(name) < 0)
                 strcpy(t, ".service");
         else
                 *t = 0;