[systemd-commits] TODO src/shared

Lennart Poettering lennart at kemper.freedesktop.org
Sat Jul 28 04:21:53 PDT 2012


 TODO                   |    4 ----
 src/shared/unit-name.c |   11 +++++++++--
 2 files changed, 9 insertions(+), 6 deletions(-)

New commits:
commit 56d4fbf92eb6d8eb31c910e137224308c40dd909
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Jul 28 13:20:35 2012 +0200

    systemctl: append .service to unit names lacking suffix
    
    https://bugs.freedesktop.org/show_bug.cgi?id=39386

diff --git a/TODO b/TODO
index d4f3502..59ba7a2 100644
--- a/TODO
+++ b/TODO
@@ -49,10 +49,6 @@ Features:
 
 * rename "userspace" to "core-os"
 
-* append ".service" to unit names without any suffix (https://bugs.freedesktop.org/show_bug.cgi?id=39386)
-
-* journalctl: add --priority switch
-
 * systemctl: "Journal has been rotated since unit was started." message is misleading
 
 * syscall filter: add knowledge about compat syscalls
diff --git a/src/shared/unit-name.c b/src/shared/unit-name.c
index e84d995..7193718 100644
--- a/src/shared/unit-name.c
+++ b/src/shared/unit-name.c
@@ -477,6 +477,7 @@ 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);
 
@@ -493,12 +494,15 @@ char *unit_name_mangle(const char *name) {
         /* We'll only escape the obvious characters here, to play
          * safe. */
 
-        r = new(char, strlen(name) * 4 + 1);
+        r = new(char, strlen(name) * 4 + 1 + sizeof(".service")-1);
         if (!r)
                 return NULL;
 
         for (f = name, t = r; *f; f++) {
 
+                if (*f == '.')
+                        dot = true;
+
                 if (*f == '/')
                         *(t++) = '-';
                 else if (!strchr("@" VALID_CHARS, *f))
@@ -507,7 +511,10 @@ char *unit_name_mangle(const char *name) {
                         *(t++) = *f;
         }
 
-        *t = 0;
+        if (!dot)
+                strcpy(t, ".service");
+        else
+                *t = 0;
 
         return r;
 }



More information about the systemd-commits mailing list