From 457c0a246f7934f7d380ca62cdb841acdf9870e2 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 22 Nov 2022 08:10:49 +0100 Subject: [PATCH] Fix #320: close API/IPC socket immediately in shutdown/reboot This protects against any hook scripts or services calling initctl when we're going down. There's no way to service these requests anyway, so no point in keeping the socket open. This way initctl can check for the existence of the socket before attempting any IPC command. Signed-off-by: Joachim Wiberg --- src/sig.c | 3 +-- src/sm.c | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sig.c b/src/sig.c index e71c87dd..b532fcf4 100644 --- a/src/sig.c +++ b/src/sig.c @@ -318,9 +318,8 @@ void do_shutdown(shutop_t op) do_iterate_proc(kill_cb, &signo); } - /* Exit plugins and API gracefully */ + /* Exit plugins gracefully */ plugin_exit(); - api_exit(); /* We can no longer act on conditions, activate script runner */ cond_exit(); diff --git a/src/sm.c b/src/sm.c index 1e6cabe6..1effeb38 100644 --- a/src/sm.c +++ b/src/sm.c @@ -150,6 +150,7 @@ restart: /* Restore terse mode and run hooks before shutdown */ if (runlevel == 0 || runlevel == 6) { + api_exit(); log_exit(); plugin_run_hooks(HOOK_SHUTDOWN); }