fragment: allow prefixing of the EnvironmentFile= path with - to ignore errors

This commit is contained in:
Lennart Poettering
2011-01-06 01:39:08 +01:00
parent 06ac173943
commit afe4bfe2c1
3 changed files with 22 additions and 5 deletions
+13 -1
View File
@@ -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;
}