summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO4
-rw-r--r--src/shared/unit-name.c11
2 files changed, 9 insertions, 6 deletions
diff --git a/TODO b/TODO
index d4f350292d..59ba7a2e14 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 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;
}