From e7cca05fe3dd2b90d7e6eebdca7a857e6bd9e568 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 20 Dec 2017 09:16:55 +0100 Subject: [PATCH] Reserve certain configuration directives for bootstrap only The following configuration directives, previously only allowed in /etc/finit.conf, are now also only allowed in runlevel S, i.e. at bootstrap: - host - mknod - network - runparts - runlevel This change is in preparation for allowing reload of finit.conf as well as /etc/finit.d/*.conf, which we already support. Signed-off-by: Joachim Nilsson --- src/conf.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/conf.c b/src/conf.c index 946c1440..4431a46e 100644 --- a/src/conf.c +++ b/src/conf.c @@ -35,6 +35,7 @@ #include "tty.h" #include "helpers.h" +#define BOOTSTRAP (runlevel == 0) #define MATCH_CMD(l, c, x) \ (!strncasecmp(l, c, strlen(c)) && (x = (l) + strlen(c))) @@ -242,13 +243,13 @@ static void parse_static(char *line) char *x; char cmd[CMD_SIZE]; - if (MATCH_CMD(line, "host ", x)) { + if (BOOTSTRAP && MATCH_CMD(line, "host ", x)) { if (hostname) free(hostname); hostname = strdup(strip_line(x)); return; } - if (MATCH_CMD(line, "mknod ", x)) { + if (BOOTSTRAP && MATCH_CMD(line, "mknod ", x)) { char *dev = strip_line(x); strcpy(cmd, "mknod "); @@ -258,13 +259,13 @@ static void parse_static(char *line) return; } - if (MATCH_CMD(line, "network ", x)) { + if (BOOTSTRAP && MATCH_CMD(line, "network ", x)) { if (network) free(network); network = strdup(strip_line(x)); return; } - if (MATCH_CMD(line, "runparts ", x)) { + if (BOOTSTRAP && MATCH_CMD(line, "runparts ", x)) { if (runparts) free(runparts); runparts = strdup(strip_line(x)); return; @@ -289,10 +290,12 @@ static void parse_static(char *line) return; } - /* The desired runlevel to start when leaving bootstrap (S). + /* + * The desired runlevel to start when leaving bootstrap (S). * Finit supports 1-9, but most systems only use 1-6, where - * 6 is reserved for reboot */ - if (MATCH_CMD(line, "runlevel ", x)) { + * 6 is reserved for reboot and 0 for halt/poweroff. + */ + if (BOOTSTRAP && MATCH_CMD(line, "runlevel ", x)) { char *token = strip_line(x); const char *err = NULL;