From 7410616cd9dbbec97cf98d75324da5cda2b2f7a2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 30 Apr 2015 20:21:00 +0200 Subject: 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 --- src/sysv-generator/sysv-generator.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/sysv-generator') 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; -- cgit v1.2.3-54-g00ecf