chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
specifier: at minimal test
[elogind.git]
/
src
/
load-fragment.c
diff --git
a/src/load-fragment.c
b/src/load-fragment.c
index 1b23205a2f7fde8eb66842824678a8219ff05269..261180d1555b6b72761f72505baf19d92856cb07 100644
(file)
--- a/
src/load-fragment.c
+++ b/
src/load-fragment.c
@@
-1348,19
+1348,31
@@
static int config_parse_env_file(
FILE *f;
int r;
char ***env = data;
FILE *f;
int r;
char ***env = data;
+ bool ignore = false;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
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"))) {
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;
}
while (!feof(f)) {
return 0;
}
while (!feof(f)) {
- char l[LINE_MAX], *p;
+ char l[LINE_MAX], *p
, *u
;
char **t;
if (!fgets(l, sizeof(l), f)) {
char **t;
if (!fgets(l, sizeof(l), f)) {
@@
-1381,7
+1393,21
@@
static int config_parse_env_file(
if (strchr(COMMENTS, *p))
continue;
if (strchr(COMMENTS, *p))
continue;
- t = strv_env_set(*env, p);
+ if (!(u = normalize_env_assignment(p))) {
+ log_error("Out of memory");
+ r = -ENOMEM;
+ goto finish;
+ }
+
+ t = strv_append(*env, u);
+ free(u);
+
+ if (!t) {
+ log_error("Out of memory");
+ r = -ENOMEM;
+ goto finish;
+ }
+
strv_free(*env);
*env = t;
}
strv_free(*env);
*env = t;
}