summaryrefslogtreecommitdiff
path: root/src/shared/unit-name.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/unit-name.c')
-rw-r--r--src/shared/unit-name.c11
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;
}