#include <unistd.h>
#include "alloc-util.h"
+#include "def.h"
#include "dirent-util.h"
#include "exit-status.h"
#include "fd-util.h"
_cleanup_free_ char *short_description = NULL, *long_description = NULL, *chkconfig_description = NULL;
char *description;
bool supports_reload = false;
- char l[LINE_MAX];
assert(s);
log_debug("Loading SysV script %s", s->path);
- FOREACH_LINE(l, f, goto fail) {
+ for (;;) {
+ _cleanup_free_ char *l = NULL;
char *t;
+ r = read_line(f, LONG_LINE_MAX, &l);
+ if (r < 0)
+ return log_error_errno(r, "Failed to read configuration file '%s': %m", s->path);
+ if (r == 0)
+ break;
+
line++;
t = strstrip(l);
/* Try to figure out whether this init script supports
* the reload operation. This heuristic looks for
* "Usage" lines which include the reload option. */
- if ( state == USAGE_CONTINUATION ||
+ if (state == USAGE_CONTINUATION ||
(state == NORMAL && strcasestr(t, "usage"))) {
if (usage_contains_reload(t)) {
supports_reload = true;
s->loaded = true;
return 0;
-
-fail:
- return log_error_errno(errno, "Failed to read configuration file '%s': %m", s->path);
}
static int fix_order(SysvStub *s, Hashmap *all_services) {