load: make sure that unit files in /etc/ always take precedence, even over link targets, to make them easily overrdiable

This commit is contained in:
Lennart Poettering 2010-07-21 03:28:10 +02:00
parent 8f05424d50
commit 294d81f124
2 changed files with 42 additions and 43 deletions

2
fixme
View file

@ -37,8 +37,6 @@
* place /etc/inittab with explaining blurb.
* /etc must always take precedence even if we follow symlinks!
* vielleicht implizit immer auf syslog dependen?
* debian deadlock when partition auf noauto is.

View file

@ -1780,19 +1780,16 @@ finish:
int unit_load_fragment(Unit *u) {
int r;
assert(u);
if (u->meta.fragment_path) {
if ((r = load_from_path(u, u->meta.fragment_path)) < 0)
return r;
} else {
Iterator i;
const char *t;
/* Try to find the unit under its id */
assert(u);
assert(u->meta.load_state == UNIT_STUB);
assert(u->meta.id);
/* 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;
@ -1810,7 +1807,12 @@ int unit_load_fragment(Unit *u) {
break;
}
/* Now, follow the same logic, but look for a template */
/* 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;
/* Look for a template */
if (u->meta.load_state == UNIT_STUB && u->meta.instance) {
char *k;
@ -1842,7 +1844,6 @@ int unit_load_fragment(Unit *u) {
break;
}
}
}
return 0;
}