From f8c07e81ffae650aeafd4bcf32f2ffaeb0d47503 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 28 Feb 2021 09:07:34 +0100 Subject: [PATCH] Reclassify `module` as BOOTSTRAP only, including minor refactor The module setting is deprecated, other mechanisms exist. This change is to ensure we don't try to (re)load any modules at runtime, only at bootstrap. Signed-off-by: Joachim Wiberg --- src/conf.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/conf.c b/src/conf.c index d55e8592..0d57cdbd 100644 --- a/src/conf.c +++ b/src/conf.c @@ -419,8 +419,8 @@ error: static void parse_static(char *line, int is_rcsd) { - char *x; char cmd[CMD_SIZE]; + char *x; if (BOOTSTRAP && (MATCH_CMD(line, "host ", x) || MATCH_CMD(line, "hostname ", x))) { if (hostname) free(hostname); @@ -434,7 +434,12 @@ static void parse_static(char *line, int is_rcsd) strcpy(cmd, "mknod "); strlcat(cmd, dev, sizeof(cmd)); run_interactive(cmd, "Creating device node %s", dev); + return; + } + /* Kernel module to load */ + if (BOOTSTRAP && MATCH_CMD(line, "module ", x)) { + kmod_load(x); return; } @@ -511,16 +516,6 @@ static void parse_dynamic(char *line, struct rlimit rlimit[], char *file) { char *x; - /* Skip comments, i.e. lines beginning with # */ - if (MATCH_CMD(line, "#", x)) - return; - - /* Kernel module to load at bootstrap */ - if (MATCH_CMD(line, "module ", x)) { - kmod_load(x); - return; - } - /* Monitored daemon, will be respawned on exit */ if (MATCH_CMD(line, "service ", x)) { service_register(SVC_TYPE_SERVICE, x, rlimit, file); @@ -585,12 +580,18 @@ static int parse_conf(char *file, int is_rcsd) _d("*** Parsing %s", file); while (!feof(fp)) { + char *x; + if (!fgets(line, sizeof(line), fp)) continue; chomp(line); tabstospaces(line); -// _d("%s", line); +//DEV _d("%s", line); + + /* Skip comments, i.e. lines beginning with # */ + if (MATCH_CMD(line, "#", x)) + continue; parse_static(line, is_rcsd); parse_dynamic(line, is_rcsd ? rlimit : global_rlimit, file);