summaryrefslogtreecommitdiff
path: root/src/core/unit.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-01-11 00:21:06 +0100
committerLennart Poettering <lennart@poettering.net>2013-01-11 00:21:06 +0100
commit8afbb8e1180dce3cb33a14fc3ec5afcf501104e6 (patch)
tree9b865b95b235337ed4603c5764b9edf5ddbc24b3 /src/core/unit.c
parent5dd9014faf58bf974352043fbddd3a8e9c3cd9d9 (diff)
unit: allow extension of unit files with .d/*.conf drop-ins
For all unit files foobar.service we will now read foobar.service.d/*.conf, too. This may be used to override certain unit settings without having to edit unit files directly. This makes it really easy to change specific settings for services without having to edit any unit file: mkdir /etc/systemd/system/avahi-daemon.service.d/ echo -e '[Service]\nNice=99' > /etc/systemd/system/avahi-daemon.service.d/nice.conf systemctl daemon-reload
Diffstat (limited to 'src/core/unit.c')
-rw-r--r--src/core/unit.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index 45453dce6..f00cfedb8 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1781,6 +1781,7 @@ static const char *resolve_template(Unit *u, const char *name, const char*path,
assert(u);
assert(name || path);
+ assert(p);
if (!name)
name = path_get_file_name(path);
@@ -1795,7 +1796,8 @@ static const char *resolve_template(Unit *u, const char *name, const char*path,
else {
char *i;
- if (!(i = unit_name_to_prefix(u->id)))
+ i = unit_name_to_prefix(u->id);
+ if (!i)
return NULL;
s = unit_name_replace_instance(name, i);
@@ -1812,22 +1814,20 @@ static const char *resolve_template(Unit *u, const char *name, const char*path,
int unit_add_dependency_by_name(Unit *u, UnitDependency d, const char *name, const char *path, bool add_reference) {
Unit *other;
int r;
- char *s;
+ _cleanup_free_ char *s = NULL;
assert(u);
assert(name || path);
- if (!(name = resolve_template(u, name, path, &s)))
+ name = resolve_template(u, name, path, &s);
+ if (!name)
return -ENOMEM;
- if ((r = manager_load_unit(u->manager, name, path, NULL, &other)) < 0)
- goto finish;
-
- r = unit_add_dependency(u, d, other, add_reference);
+ r = manager_load_unit(u->manager, name, path, NULL, &other);
+ if (r < 0)
+ return r;
-finish:
- free(s);
- return r;
+ return unit_add_dependency(u, d, other, add_reference);
}
int unit_add_two_dependencies_by_name(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference) {