Compare commits

...
3 Commits
Author SHA1 Message Date
Joachim Wiberg 185a72bd14 Bump version for v4.11 GA release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-03-27 19:29:48 +01:00
Joachim Wiberg cd32c623cf plugins: ignore PID file events for svc_t in setup/teardown/cleanup
An svc_t (service/sysv) that is in setup, teardown, or cleanup state
must be ignored by the pidfile plugin for any events regarding PID
files.  E.g., a setup script for a sysv service may create a PID file
to alert the system that a setup process for the service is running.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-03-27 19:17:04 +01:00
Joachim Wiberg ac4b9c2f93 Unblock signals for pre/post/ready/cleanup scripts
The service_fork() function blocks all signals for the new process, it
is up to the callee to call sig_unblock() before calling exec().

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-03-27 19:10:56 +01:00
4 changed files with 30 additions and 1 deletions
+5
View File
@@ -20,6 +20,11 @@ All relevant changes are documented in this file.
the default `SIGTERM`
- Fix pre/post/ready/cleanup script execution if service has an
optional `env:file` (leading `-`)
- Fix blocked signals for pre/post/ready/cleanup scripts preventing
normal shutdown when a service/sysv is stopped in its setup state
- Fix issue where a pre:script creates a PID file in `/run` cause the
service to move from setup state to running. Any `svc_t` in setup,
teardown, or cleanup state should be ignored in the pidfile plugin
[4.10][] - 2025-03-03
+1 -1
View File
@@ -1,4 +1,4 @@
AC_INIT([Finit], [4.11-rc2], [https://github.com/troglobit/finit/issues],
AC_INIT([Finit], [4.11], [https://github.com/troglobit/finit/issues],
[finit], [https://troglobit.com/projects/finit/])
AC_CONFIG_AUX_DIR(aux)
AM_INIT_AUTOMAKE([1.11 foreign dist-xz subdir-objects])
+17
View File
@@ -80,6 +80,23 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask)
return;
}
switch (svc->state) {
case SVC_TEARDOWN_STATE:
case SVC_CLEANUP_STATE:
case SVC_SETUP_STATE:
/*
* E.g., a setup script for a container may run in lieu
* of crun, trying to fetch a container image from the
* network. This script may want to advertise its PID
* to the system for clean and swift reboots.
*/
dbg("%s[%d]: ignoring any PID file changes in CLEANUP/TEARDOWN/SETUP",
svc_ident(svc, NULL, 0), svc->pid);
return;
default:
break;
}
/* Service condistion to set/clear */
mkcond(svc, cond, sizeof(cond));
+7
View File
@@ -2155,6 +2155,8 @@ static void service_pre_script(svc_t *svc)
strlcpy(buf, svc->pre_script, sizeof(buf));
set_pre_post_envs(svc, "pre");
sig_unblock();
execvp(_PATH_BSHELL, argv);
_exit(EX_OSERR);
}
@@ -2192,6 +2194,7 @@ static void service_post_script(svc_t *svc)
else
strlcpy(buf, svc->post_script, sizeof(buf));
set_pre_post_envs(svc, "post");
sig_unblock();
if (WIFEXITED(svc->status)) {
char val[4];
@@ -2253,6 +2256,8 @@ void service_ready_script(svc_t *svc)
strlcpy(buf, svc->ready_script, sizeof(buf));
set_pre_post_envs(svc, "ready");
sig_unblock();
execvp(_PATH_BSHELL, argv);
_exit(EX_OSERR);
}
@@ -2289,6 +2294,8 @@ static void service_cleanup_script(svc_t *svc)
strlcpy(buf, svc->cleanup_script, sizeof(buf));
set_pre_post_envs(svc, "cleanup");
sig_unblock();
execvp(_PATH_BSHELL, argv);
_exit(EX_OSERR);
}