1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 10:25:37 +03:00

systemctl: append .service to unit names lacking suffix

https://bugs.freedesktop.org/show_bug.cgi?id=39386
This commit is contained in:
Lennart Poettering 2012-07-28 13:20:35 +02:00
parent 47ae7201b1
commit 56d4fbf92e
2 changed files with 9 additions and 6 deletions

4
TODO
View File

@ -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

View File

@ -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;
}