summaryrefslogtreecommitdiff
path: root/src/core/load-fragment.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-04-30 20:21:00 +0200
committerLennart Poettering <lennart@poettering.net>2015-05-05 15:06:42 -0700
commit7410616cd9dbbec97cf98d75324da5cda2b2f7a2 (patch)
tree6d968995b3bdf961603ab4853bf078c0dbdce27c /src/core/load-fragment.c
parent6442185ab674cc202d63c18605057b9a51ca2722 (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/core/load-fragment.c')
-rw-r--r--src/core/load-fragment.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index b76656b931..970120ab70 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -3394,7 +3394,7 @@ static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
* unit name. */
name = basename(*filename);
- if (unit_name_is_valid(name, TEMPLATE_VALID)) {
+ if (unit_name_is_valid(name, UNIT_NAME_ANY)) {
id = set_get(names, name);
if (!id) {
@@ -3642,11 +3642,11 @@ int unit_load_fragment(Unit *u) {
/* Look for a template */
if (u->load_state == UNIT_STUB && u->instance) {
- _cleanup_free_ char *k;
+ _cleanup_free_ char *k = NULL;
- k = unit_name_template(u->id);
- if (!k)
- return -ENOMEM;
+ r = unit_name_template(u->id, &k);
+ if (r < 0)
+ return r;
r = load_from_path(u, k);
if (r < 0)
@@ -3659,9 +3659,9 @@ int unit_load_fragment(Unit *u) {
if (t == u->id)
continue;
- z = unit_name_template(t);
- if (!z)
- return -ENOMEM;
+ r = unit_name_template(t, &z);
+ if (r < 0)
+ return r;
r = load_from_path(u, z);
if (r < 0)