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
This commit is contained in:
Lennart Poettering
2015-05-05 15:06:42 -07:00
parent 6442185ab6
commit 7410616cd9
34 changed files with 1066 additions and 867 deletions
+2 -14
View File
@@ -29,30 +29,18 @@
static int specifier_prefix_and_instance(char specifier, void *data, void *userdata, char **ret) {
InstallInfo *i = userdata;
char *n;
assert(i);
n = unit_name_to_prefix_and_instance(i->name);
if (!n)
return -ENOMEM;
*ret = n;
return 0;
return unit_name_to_prefix_and_instance(i->name, ret);
}
static int specifier_prefix(char specifier, void *data, void *userdata, char **ret) {
InstallInfo *i = userdata;
char *n;
assert(i);
n = unit_name_to_prefix(i->name);
if (!n)
return -ENOMEM;
*ret = n;
return 0;
return unit_name_to_prefix(i->name, ret);
}
static int specifier_instance(char specifier, void *data, void *userdata, char **ret) {