diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-01-06 01:39:08 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-01-06 01:39:08 +0100 |
commit | afe4bfe2c1ed28a3e75c627edf458d2f40ff16f8 (patch) | |
tree | 836b7cef1b8562a7a36a5ed91444b7cd84fa7ef7 | |
parent | 06ac173943858b37980bee645329d4bb18dea47c (diff) |
fragment: allow prefixing of the EnvironmentFile= path with - to ignore errors
-rw-r--r-- | TODO | 4 | ||||
-rw-r--r-- | man/systemd.exec.xml | 9 | ||||
-rw-r--r-- | src/load-fragment.c | 14 |
3 files changed, 22 insertions, 5 deletions
@@ -1,3 +1,5 @@ +* dbus should run with oom adjust set + * support caching password questions in plymouth and on the console https://bugzilla.redhat.com/show_bug.cgi?id=655538 @@ -119,8 +121,6 @@ * global defaults for StandardOuput=xxx -* Make EnvironmentFile=-/fooobar/waldo ingnore errors while reading /foobar/waldo - * mkswap/mke2fs is called on wrong devices in crypto devices. Fedora: diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml index b24792b0a0..d6ac5aed89 100644 --- a/man/systemd.exec.xml +++ b/man/systemd.exec.xml @@ -275,8 +275,13 @@ contain new-line separated variable assignments. Empty lines and lines starting with ; or # will be ignored, - which may be used for - commenting.</para></listitem> + which may be used for commenting. The + argument passed should be an absolute + file name, optionally prefixed with + "-", which indicates that if the file + does not exist it won't be read and no + error or warning message is + logged.</para></listitem> </varlistentry> <varlistentry> diff --git a/src/load-fragment.c b/src/load-fragment.c index 281863264e..334dd68146 100644 --- a/src/load-fragment.c +++ b/src/load-fragment.c @@ -1348,14 +1348,26 @@ static int config_parse_env_file( FILE *f; int r; char ***env = data; + bool ignore = false; assert(filename); assert(lvalue); assert(rvalue); assert(data); + if (rvalue[0] == '-') { + ignore = true; + rvalue++; + } + + if (!path_is_absolute(rvalue)) { + log_error("[%s:%u] Path '%s' is not absolute, ignoring.", filename, line, rvalue); + return 0; + } + if (!(f = fopen(rvalue, "re"))) { - log_error("[%s:%u] Failed to open environment file '%s', ignoring: %m", filename, line, rvalue); + if (!ignore) + log_error("[%s:%u] Failed to open environment file '%s', ignoring: %m", filename, line, rvalue); return 0; } |