From 14f0443bd7e08720d16ccd92814fe200eb0770ea Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Wed, 24 Feb 2021 22:04:46 +0100 Subject: [PATCH] Allow services to be added *and removed* from /etc/finit.conf This patch fixes a long standing issue where removing a service from /etc/finit.conf does not stop and unregister it. The issue was caused by the Finit support for "protected" services, e.g. services created by plugins like hotplug.so To reproduce issue before this fix: cat /etc/finit.d/available/ntpd.conf >> /etc/finit.conf initctl reload The NTP service now runs smoothly, as expected. Later on, we decide to drop it from our system: sed -i 1,2d /etc/finit.conf initctl reload ... and the NTP service continues to run unaffected. Not what most sane users expect. Signed-off-by: Joachim Wiberg --- src/conf.c | 2 +- src/service.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/conf.c b/src/conf.c index 0b68aa7f..8cec98d7 100644 --- a/src/conf.c +++ b/src/conf.c @@ -626,7 +626,7 @@ static int parse_conf(char *file) _d("%s", line); parse_static(line); - parse_dynamic(line, global_rlimit, NULL); + parse_dynamic(line, global_rlimit, file); } fclose(fp); diff --git a/src/service.c b/src/service.c index 25452d60..eaa3d551 100644 --- a/src/service.c +++ b/src/service.c @@ -1107,6 +1107,7 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file) else svc_mark_clean(svc); + /* for finit native services only, e.g. plugins/hotplug.c */ if (!file) svc->protect = 1;