From afe4bfe2c1ed28a3e75c627edf458d2f40ff16f8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 6 Jan 2011 01:39:08 +0100 Subject: fragment: allow prefixing of the EnvironmentFile= path with - to ignore errors --- src/load-fragment.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') 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; } -- cgit v1.2.3-54-g00ecf