From d06868415419c212c0cfc70161c10da3cb73eec3 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 9 Feb 2021 15:09:59 +0100 Subject: [PATCH] plugins: fix possible ordering bug; pidfile --> bootmisc The recently updated pidfile plugin now also watches the subdirectories in /var/run, but for that to work it must witness the creation of these subdirectories. The bootmisc plugin creates several, e.g., /run/quagga/ in which PID files like zebra.pid are created. Signed-off-by: Joachim Wiberg --- plugins/bootmisc.c | 5 ++++- plugins/pidfile.c | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/plugins/bootmisc.c b/plugins/bootmisc.c index 737c5080..e476ef40 100644 --- a/plugins/bootmisc.c +++ b/plugins/bootmisc.c @@ -116,8 +116,10 @@ static void setup(void *arg) _d("System with new /run tmpfs ..."); makedir("/run/lock", 1777); symlink("/run/lock", "/var/lock"); - symlink("/run", "/var/run"); symlink("/dev/shm", "/run/shm"); + + /* compat only, should really be set up by OS/dist */ + symlink("/run", "/var/run"); } else { makedir("/var/lock", 1777); makedir("/var/run", 0755); @@ -191,6 +193,7 @@ static plugin_t plugin = { .hook[HOOK_BASEFS_UP] = { .cb = setup }, + .depends = { "pidfile" }, }; PLUGIN_INIT(plugin_init) diff --git a/plugins/pidfile.c b/plugins/pidfile.c index a8f9dab2..3a1a0d21 100644 --- a/plugins/pidfile.c +++ b/plugins/pidfile.c @@ -314,8 +314,18 @@ static void pidfile_init(void *arg) static struct context pidfile_ctx; /* - * We require /var/run to be set up before calling pidfile_init(), - * so the bootmisc plugin must run first. + * When performing an `initctl reload` with one (unchanged) service + * depending on, e.g. `net/iface/lo`, its condition will not be set + * to ON by the pidfile plugin unless the netlink plugin hook runs + * first. + * + * Example: + * + * service /sbin/dropbear ... + * + * Which provides the condition, will not be + * set by pidfile.so during `initctl reload` because dropbear is + * still SIGSTP:ed waiting for . */ static plugin_t plugin = { .name = __FILE__, @@ -325,7 +335,7 @@ static plugin_t plugin = { .cb = pidfile_callback, .flags = PLUGIN_IO_READ, }, - .depends = { "bootmisc", "netlink" }, + .depends = { "netlink" }, }; PLUGIN_INIT(plugin_init)