if (ignore_enoent && r == -ENOENT)
return 0;
- return log_error_errno(r, "Failed to open file '%s', ignoring: %m", path);
+ return log_error_errno(r, "Failed to open file '%s': %m", path);
}
log_debug("apply: %s", path);
for (;;) {
- char l[LINE_MAX], *p;
+ _cleanup_free_ char *line = NULL;
+ char *p;
int k;
- if (!fgets(l, sizeof(l), f)) {
- if (feof(f))
- break;
-
- return log_error_errno(errno, "Failed to read file '%s', ignoring: %m", path);
- }
+ k = read_line(f, LONG_LINE_MAX, &line);
+ if (k < 0)
+ return log_error_errno(k, "Failed to read file '%s': %m", path);
+ if (k == 0)
+ break;
- p = strstrip(l);
- if (!*p)
+ p = strstrip(line);
+ if (isempty(p))
continue;
- if (strchr(COMMENTS "\n", *p))
+ if (strchr(COMMENTS, p[0]))
continue;
k = apply_rule(p);