- if (!(f = fopen(rvalue, "re"))) {
- if (!ignore)
- log_error("[%s:%u] Failed to open environment file '%s', ignoring: %m", filename, line, rvalue);
- return 0;
- }
-
- while (!feof(f)) {
- char l[LINE_MAX], *p, *u;
- char **t;
-
- if (!fgets(l, sizeof(l), f)) {
- if (feof(f))
- break;
-
- r = -errno;
- log_error("[%s:%u] Failed to read environment file '%s', ignoring: %m", filename, line, rvalue);
- r = 0;
- goto finish;
- }
-
- p = strstrip(l);
-
- if (!*p)
- continue;
-
- if (strchr(COMMENTS, *p))
- continue;
-
- 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;
- }
-
- r = 0;