diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-07-28 13:20:35 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-07-28 13:20:35 +0200 |
commit | 56d4fbf92eb6d8eb31c910e137224308c40dd909 (patch) | |
tree | 7a1cea09bf208c3c802d591182943ca8b79a5fb7 /src | |
parent | 47ae7201b1df43bd3da83a19e38483b0e5694c99 (diff) |
systemctl: append .service to unit names lacking suffix
https://bugs.freedesktop.org/show_bug.cgi?id=39386
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/unit-name.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/shared/unit-name.c b/src/shared/unit-name.c index e84d995dd7..7193718792 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; } |