summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-07-21 03:13:15 +0200
committerLennart Poettering <lennart@poettering.net>2010-07-21 03:13:15 +0200
commit8f05424d50045ffd85912e4df36618e8aabd8988 (patch)
tree7b6d38e8666b284d6c13313bf74dc12b12873cab /src
parentc24eb49e6aecd6de2ad450083e826d4c9d9c75b6 (diff)
unit: allow symlinking unit files to /dev/null
Diffstat (limited to 'src')
-rw-r--r--src/load-fragment.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/load-fragment.c b/src/load-fragment.c
index 50008101a1..cd66b2dd14 100644
--- a/src/load-fragment.c
+++ b/src/load-fragment.c
@@ -1312,16 +1312,20 @@ static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
path_kill_slashes(*filename);
/* Add the file name we are currently looking at to
- * the names of this unit */
+ * the names of this unit, but only if it is a valid
+ * unit name. */
name = file_name_from_path(*filename);
- if (!(id = set_get(names, name))) {
- if (!(id = strdup(name)))
- return -ENOMEM;
+ if (unit_name_is_valid(name)) {
+ if (!(id = set_get(names, name))) {
- if ((r = set_put(names, id)) < 0) {
- free(id);
- return r;
+ if (!(id = strdup(name)))
+ return -ENOMEM;
+
+ if ((r = set_put(names, id)) < 0) {
+ free(id);
+ return r;
+ }
}
}
@@ -1340,7 +1344,7 @@ static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
*filename = target;
}
- if (!(f = fdopen(fd, "r"))) {
+ if (!(f = fdopen(fd, "re"))) {
r = -errno;
close_nointr_nofail(fd);
return r;
@@ -1730,6 +1734,7 @@ static int load_from_path(Unit *u, const char *path) {
}
if (!filename) {
+ /* Hmm, no suitable file found? */
r = 0;
goto finish;
}
@@ -1750,11 +1755,6 @@ static int load_from_path(Unit *u, const char *path) {
goto finish;
}
- if (!S_ISREG(st.st_mode)) {
- r = -ENOENT;
- goto finish;
- }
-
/* Now, parse the file contents */
if ((r = config_parse(filename, f, sections, items, false, u)) < 0)
goto finish;