1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-25 06:03:40 +03:00

unit: allow symlinking unit files to /dev/null

This commit is contained in:
Lennart Poettering 2010-07-21 03:13:15 +02:00
parent c24eb49e6a
commit 8f05424d50
2 changed files with 13 additions and 15 deletions

2
fixme
View File

@ -35,8 +35,6 @@
* systemctl status $PID, systemctl stop $PID! * systemctl status $PID, systemctl stop $PID!
/dev/null symlinks supporten
* place /etc/inittab with explaining blurb. * place /etc/inittab with explaining blurb.
* /etc must always take precedence even if we follow symlinks! * /etc must always take precedence even if we follow symlinks!

View File

@ -1312,8 +1312,11 @@ static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
path_kill_slashes(*filename); path_kill_slashes(*filename);
/* Add the file name we are currently looking at to /* 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); name = file_name_from_path(*filename);
if (unit_name_is_valid(name)) {
if (!(id = set_get(names, name))) { if (!(id = set_get(names, name))) {
if (!(id = strdup(name))) if (!(id = strdup(name)))
@ -1324,6 +1327,7 @@ static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
return r; return r;
} }
} }
}
/* Try to open the file name, but don't if its a symlink */ /* Try to open the file name, but don't if its a symlink */
if ((fd = open(*filename, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW)) >= 0) if ((fd = open(*filename, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW)) >= 0)
@ -1340,7 +1344,7 @@ static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
*filename = target; *filename = target;
} }
if (!(f = fdopen(fd, "r"))) { if (!(f = fdopen(fd, "re"))) {
r = -errno; r = -errno;
close_nointr_nofail(fd); close_nointr_nofail(fd);
return r; return r;
@ -1730,6 +1734,7 @@ static int load_from_path(Unit *u, const char *path) {
} }
if (!filename) { if (!filename) {
/* Hmm, no suitable file found? */
r = 0; r = 0;
goto finish; goto finish;
} }
@ -1750,11 +1755,6 @@ static int load_from_path(Unit *u, const char *path) {
goto finish; goto finish;
} }
if (!S_ISREG(st.st_mode)) {
r = -ENOENT;
goto finish;
}
/* Now, parse the file contents */ /* Now, parse the file contents */
if ((r = config_parse(filename, f, sections, items, false, u)) < 0) if ((r = config_parse(filename, f, sections, items, false, u)) < 0)
goto finish; goto finish;