fragment: allow prefixing of the EnvironmentFile= path with - to ignore errors
This commit is contained in:
+13
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user