diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-04-30 20:21:00 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-05-05 15:06:42 -0700 |
commit | 7410616cd9dbbec97cf98d75324da5cda2b2f7a2 (patch) | |
tree | 6d968995b3bdf961603ab4853bf078c0dbdce27c /src/sysv-generator | |
parent | 6442185ab674cc202d63c18605057b9a51ca2722 (diff) |
core: rework unit name validation and manipulation logic
A variety of changes:
- Make sure all our calls distuingish OOM from other errors if OOM is
not the only error possible.
- Be much stricter when parsing escaped paths, do not accept trailing or
leading escaped slashes.
- Change unit validation to take a bit mask for allowing plain names,
instance names or template names or an combination thereof.
- Refuse manipulating invalid unit name
Diffstat (limited to 'src/sysv-generator')
-rw-r--r-- | src/sysv-generator/sysv-generator.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c index 714ce8f6cb..0c839c2c53 100644 --- a/src/sysv-generator/sysv-generator.c +++ b/src/sysv-generator/sysv-generator.c @@ -310,11 +310,13 @@ static int sysv_translate_facility(const char *name, const char *filename, char * out whether something is a target or a service alias. */ if (*name == '$') { - if (!unit_prefix_is_valid(n)) - return -EINVAL; + int k; /* Facilities starting with $ are most likely targets */ - r = unit_name_build(n, NULL, ".target"); + k = unit_name_build(n, NULL, ".target", &r); + if (k < 0) + return k; + } else if (streq_ptr(n, filename)) /* Names equaling the file name of the services are redundant */ return 0; |