sysv-generator: FOREACH_LINE excorcism
This commit is contained in:
parent
050ca29963
commit
e393eff622
|
@ -5,6 +5,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "def.h"
|
||||
#include "dirent-util.h"
|
||||
#include "exit-status.h"
|
||||
#include "fd-util.h"
|
||||
|
@ -432,7 +433,6 @@ static int load_sysv(SysvStub *s) {
|
|||
_cleanup_free_ char *short_description = NULL, *long_description = NULL, *chkconfig_description = NULL;
|
||||
char *description;
|
||||
bool supports_reload = false;
|
||||
char l[LINE_MAX];
|
||||
|
||||
assert(s);
|
||||
|
||||
|
@ -446,9 +446,16 @@ static int load_sysv(SysvStub *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);
|
||||
|
@ -456,7 +463,7 @@ static int load_sysv(SysvStub *s) {
|
|||
/* 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;
|
||||
|
@ -644,9 +651,6 @@ static int load_sysv(SysvStub *s) {
|
|||
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue