diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-07-21 03:28:10 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-07-21 03:28:10 +0200 |
commit | 294d81f124568983323a53f40bfbaa371f0da077 (patch) | |
tree | 83d9f2827efbaf3733c4eec5fce1cd42f8dacc48 /src/load-fragment.c | |
parent | 8f05424d50045ffd85912e4df36618e8aabd8988 (diff) |
load: make sure that unit files in /etc/ always take precedence, even over link targets, to make them easily overrdiable
Diffstat (limited to 'src/load-fragment.c')
-rw-r--r-- | src/load-fragment.c | 83 |
1 files changed, 42 insertions, 41 deletions
diff --git a/src/load-fragment.c b/src/load-fragment.c index cd66b2dd14..98f16f9a23 100644 --- a/src/load-fragment.c +++ b/src/load-fragment.c @@ -1780,68 +1780,69 @@ finish: int unit_load_fragment(Unit *u) { int r; + Iterator i; + const char *t; assert(u); + assert(u->meta.load_state == UNIT_STUB); + assert(u->meta.id); - if (u->meta.fragment_path) { + /* First, try to find the unit under its id. We always look + * for unit files in the default directories, to make it easy + * to override things by placing things in /etc/systemd/system */ + if ((r = load_from_path(u, u->meta.id)) < 0) + return r; + + /* Try to find an alias we can load this with */ + if (u->meta.load_state == UNIT_STUB) + SET_FOREACH(t, u->meta.names, i) { + + if (t == u->meta.id) + continue; + + if ((r = load_from_path(u, t)) < 0) + return r; + + if (u->meta.load_state != UNIT_STUB) + break; + } + /* And now, try looking for it under the suggested (originally linked) path */ + if (u->meta.load_state == UNIT_STUB && u->meta.fragment_path) if ((r = load_from_path(u, u->meta.fragment_path)) < 0) return r; - } else { - Iterator i; - const char *t; + /* Look for a template */ + if (u->meta.load_state == UNIT_STUB && u->meta.instance) { + char *k; + + if (!(k = unit_name_template(u->meta.id))) + return -ENOMEM; + + r = load_from_path(u, k); + free(k); - /* Try to find the unit under its id */ - if ((r = load_from_path(u, u->meta.id)) < 0) + if (r < 0) return r; - /* Try to find an alias we can load this with */ if (u->meta.load_state == UNIT_STUB) SET_FOREACH(t, u->meta.names, i) { if (t == u->meta.id) continue; - if ((r = load_from_path(u, t)) < 0) + if (!(k = unit_name_template(t))) + return -ENOMEM; + + r = load_from_path(u, k); + free(k); + + if (r < 0) return r; if (u->meta.load_state != UNIT_STUB) break; } - - /* Now, follow the same logic, but look for a template */ - if (u->meta.load_state == UNIT_STUB && u->meta.instance) { - char *k; - - if (!(k = unit_name_template(u->meta.id))) - return -ENOMEM; - - r = load_from_path(u, k); - free(k); - - if (r < 0) - return r; - - if (u->meta.load_state == UNIT_STUB) - SET_FOREACH(t, u->meta.names, i) { - - if (t == u->meta.id) - continue; - - if (!(k = unit_name_template(t))) - return -ENOMEM; - - r = load_from_path(u, k); - free(k); - - if (r < 0) - return r; - - if (u->meta.load_state != UNIT_STUB) - break; - } - } } return 0; |