Compare commits

...
14 Commits
Author SHA1 Message Date
Joachim Wiberg 6b7478ff43 Update ChangeLog and bump version for v4.12 release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-04-28 00:23:10 +02:00
Joachim Wiberg 6c4c16cbdb Update ChangeLog for v4.12
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-04-28 00:04:39 +02:00
Joachim Wiberg e539dbfe37 Merge pull request #436 from sirocyl/patch-1
README.md: typo
2025-04-27 09:56:17 +02:00
Tyler True 90c6bcd365 README.md: typo
`intictl` -> `initctl`, also linkified it to the command description
2025-04-26 23:45:19 -04:00
Joachim Wiberg c9c268f218 plugins: fix variable overloading warning in urandom plugin
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-04-07 12:55:01 +02:00
Joachim Wiberg 3feff37ba5 plugins: use byte addressing of rand_pool_info data buffer
Fix out-of-bounds write in urandom plugin.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-04-07 12:52:16 +02:00
Joachim Wiberg c67d15e272 runparts: update usage text, missing '-b' flag for batch mode
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-03-31 14:17:55 +02:00
Joachim Wiberg 8984c655f8 cond_get_agg: minor refactor
- Use stack instead of heap memory
 - constify

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-03-31 14:16:24 +02:00
Joachim Wiberg 1a7b26bac3 Bump version for 4.12 release cycle
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-03-31 07:49:05 +02:00
Joachim Wiberg 1f47718012 Merge pull request #435 from aanderse/master 2025-03-29 13:28:15 +01:00
Aaron Andersen fa13cddc28 improve notify:s6 compatibility 2025-03-29 08:03:43 -04:00
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
8 changed files with 63 additions and 17 deletions
+19
View File
@@ -3,6 +3,19 @@ Change Log
All relevant changes are documented in this file.
[4.12][] - 2025-04-28
---------------------
### Changes
- Improve notify:s6 readiness compatibility, by Aaron Andersen
- Update `runparts` usage text
### Fixes
- Fix variable overloading in urandom plugin
- Fix buffer overwrite in urandom plugin, reported by Aaron Andersen
[4.11][] - 2025-03-27
---------------------
@@ -20,6 +33,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
@@ -1780,6 +1798,7 @@ Major bug fix release.
* Initial release
[UNRELEASED]: https://github.com/troglobit/finit/compare/4.11...HEAD
[4.12]: https://github.com/troglobit/finit/compare/4.11...4.12
[4.11]: https://github.com/troglobit/finit/compare/4.10...4.11
[4.10]: https://github.com/troglobit/finit/compare/4.9...4.10
[4.9]: https://github.com/troglobit/finit/compare/4.8...4.9
+1 -1
View File
@@ -251,7 +251,7 @@ All services in runlevel S) are started first, followed by the desired
run-time runlevel. Run tasks in runlevel S can be started in sequence
by using `run [S] cmd`. Changing runlevels at runtime is done like any
other init, e.g. <kbd>init 4</kbd>, but also using the more advanced
`intictl` tool.
[`initctl`](#commands--status) tool.
**Conditions**
+1 -1
View File
@@ -1,4 +1,4 @@
AC_INIT([Finit], [4.11-rc2], [https://github.com/troglobit/finit/issues],
AC_INIT([Finit], [4.12], [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));
+8 -5
View File
@@ -78,6 +78,7 @@ static void setup(void *arg)
{
#ifdef RANDOMSEED
struct rand_pool_info *rpi;
unsigned char *rpi_buf;
ssize_t len = 0;
struct stat st;
int rc = -1;
@@ -103,13 +104,14 @@ static void setup(void *arg)
hw = fopen(hwrng, "r");
if (hw) {
char buf[512];
size_t len;
size_t num;
len = fread(buf, sizeof(buf[0]), sizeof(buf), hw);
if (len == 0)
num = fread(buf, sizeof(buf[0]), sizeof(buf), hw);
if (num == 0)
fallback(fp);
else
len = fwrite(buf, sizeof(buf[0]), len, fp);
fwrite(buf, sizeof(buf[0]), num, fp);
fclose(hw);
} else {
fallback(fp);
@@ -137,10 +139,11 @@ static void setup(void *arg)
goto fallback;
}
rpi_buf = (unsigned char *)rpi->buf;
do {
ssize_t num;
num = read(fd, &rpi->buf[len], RANDOM_BYTES - len);
num = read(fd, &rpi_buf[len], RANDOM_BYTES - len);
if (num <= 0) {
if (num == -1 && errno == EINTR)
continue;
+7 -7
View File
@@ -96,16 +96,16 @@ enum cond_state cond_get(const char *name)
enum cond_state cond_get_agg(const char *names)
{
static char conds[MAX_COND_LEN];
enum cond_state s = COND_ON;
char *cond;
if (!names)
return COND_ON;
if (names) {
char conds[strlen(names) + 1];
const char *cond;
strlcpy(conds, names, sizeof(conds));
for (cond = strtok(conds, ","); s && cond; cond = strtok(NULL, ","))
s = min(s, cond_get(cond));
strlcpy(conds, names, sizeof(conds));
for (cond = strtok(conds, ","); s && cond; cond = strtok(NULL, ","))
s = min(s, cond_get(cond));
}
return s;
}
+1 -1
View File
@@ -193,7 +193,7 @@ int run_parts(char *dir, char *cmd, const char *env[], int progress, int sysv)
#ifndef __FINIT__
static int usage(int rc)
{
warnx("usage: runparts [-dhps?] DIRECTORY");
warnx("usage: runparts [-bdhps?] DIRECTORY");
return rc;
}
+9 -2
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);
}
@@ -2905,7 +2912,7 @@ void service_notify_cb(uev_t *w, void *arg, int events)
}
len = read(w->fd, buf, sizeof(buf) - 1);
if (len == -1) {
if (len <= 0) {
warn("Failed reading notification from %s", svc_ident(svc, NULL, 0));
return;
}
@@ -2913,7 +2920,7 @@ void service_notify_cb(uev_t *w, void *arg, int events)
buf[len] = 0;
/* systemd and s6, respectively. The latter then closes the socket */
if (!strcmp(buf, "READY=1\n") || !strcmp(buf, "\n")) {
if (!strcmp(buf, "READY=1\n") || buf[len - 1] == '\n') {
/*
* native (pidfile) services are marked as started by
* the pidfile plugin.