From 21f40fb95ea1caf120d4f7f29d796f8f2395de09 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 27 Nov 2025 11:31:33 +0100 Subject: [PATCH] Allow more initctl commands in runlevels S/0/6 Relax the constraints introduced in a39ee0b, for issue #342, a bit on when start/stop/restart/reload service can be called. Also, allow 'initctl reload', but ignore it when the system is in runlevels S/0/6. This makes it possible to start manual:yes type services at botostrap, for example, which has been a common feature request. Signed-off-by: Joachim Wiberg --- src/api.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/api.c b/src/api.c index 63d92762..87e29fdb 100644 --- a/src/api.c +++ b/src/api.c @@ -68,7 +68,8 @@ static int stop(svc_t *svc, void *user_data) service_timeout_cancel(svc); svc_stop(svc); service_step(svc); - service_step_all(SVC_TYPE_ANY); + if (!IS_RESERVED_RUNLEVEL(runlevel)) + service_step_all(SVC_TYPE_ANY); return 0; } @@ -83,7 +84,8 @@ static int start(svc_t *svc, void *user_data) service_timeout_cancel(svc); svc_start(svc); service_step(svc); - service_step_all(SVC_TYPE_ANY); + if (!IS_RESERVED_RUNLEVEL(runlevel)) + service_step_all(SVC_TYPE_ANY); return 0; } @@ -391,11 +393,6 @@ static void api_cb(uev_t *w, void *arg, int events) } switch (rq.cmd) { - case INIT_CMD_RELOAD: - case INIT_CMD_START_SVC: - case INIT_CMD_RESTART_SVC: - case INIT_CMD_STOP_SVC: - case INIT_CMD_RELOAD_SVC: case INIT_CMD_REBOOT: case INIT_CMD_HALT: case INIT_CMD_POWEROFF: @@ -453,6 +450,10 @@ static void api_cb(uev_t *w, void *arg, int events) break; case INIT_CMD_RELOAD: /* 'init q' and 'initctl reload' */ + if (IS_RESERVED_RUNLEVEL(runlevel)) { + warnx("Ignoring reload in runlevel S and 6/0."); + goto done; + } dbg("reload"); sm_reload(); break; @@ -576,7 +577,7 @@ static void api_cb(uev_t *w, void *arg, int events) dbg("Unsupported cmd: %d", rq.cmd); break; } - + done: if (result) rq.cmd = INIT_CMD_NACK; else