mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
systemctl: append .service to unit names lacking suffix
https://bugs.freedesktop.org/show_bug.cgi?id=39386
This commit is contained in:
parent
47ae7201b1
commit
56d4fbf92e
4
TODO
4
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
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user