From 949f43853dcddf7491e1e990b306c6bca72904f8 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 24 Feb 2026 05:52:30 +0100 Subject: [PATCH] package/finit: bump to 4.16-rc1 Drop backported fixes. Details at https://github.com/finit-project/finit/releases/tag/4.16-rc1 Signed-off-by: Joachim Wiberg --- ...NAME-environment-variables-when-drop.patch | 48 ------- ...ices-stuck-in-restart-state-after-no.patch | 86 ------------ ...pe-special-characters-in-JSON-output.patch | 131 ------------------ ...Don-t-hide-cursor-when-shutting-down.patch | 31 ----- ...ad-NAME-not-updating-conditions-for-.patch | 61 -------- package/finit/finit.hash | 2 +- package/finit/finit.mk | 2 +- 7 files changed, 2 insertions(+), 359 deletions(-) delete mode 100644 package/finit/0001-Set-USER-and-LOGNAME-environment-variables-when-drop.patch delete mode 100644 package/finit/0002-Fix-467-TTY-services-stuck-in-restart-state-after-no.patch delete mode 100644 package/finit/0003-initctl-escape-special-characters-in-JSON-output.patch delete mode 100644 package/finit/0004-Don-t-hide-cursor-when-shutting-down.patch delete mode 100644 package/finit/0005-Fix-initctl-reload-NAME-not-updating-conditions-for-.patch diff --git a/package/finit/0001-Set-USER-and-LOGNAME-environment-variables-when-drop.patch b/package/finit/0001-Set-USER-and-LOGNAME-environment-variables-when-drop.patch deleted file mode 100644 index 8cc5b67a..00000000 --- a/package/finit/0001-Set-USER-and-LOGNAME-environment-variables-when-drop.patch +++ /dev/null @@ -1,48 +0,0 @@ -From abaad560f0bf1f7de832a55222e20e2a9a61986f Mon Sep 17 00:00:00 2001 -From: Aaron Andersen -Date: Sat, 10 Jan 2026 18:57:52 -0500 -Subject: [PATCH 1/2] Set USER and LOGNAME environment variables when dropping - privileges -Organization: Wires - -When a service is configured to run as a non-root user (@user), finit -correctly drops privileges via setuid() and sets HOME and PATH, but -does not set the USER and LOGNAME environment variables. They remain -set to "root" from boot time. - -This causes problems for software that determines its identity from -the environment rather than getuid(). For example, rootless Podman -checks os.Getenv("USER") first when looking up subordinate UID/GID -ranges in /etc/subuid and /etc/subgid. - -With USER=root but UID=1000, Podman looks up root's subuid entry -instead of the actual user's, causing applications like newuidmap -to fail. Setting USER and LOGNAME to match the actual user identity -follows POSIX conventions and matches the behavior of su, sudo, and -login. - -Signed-off-by: Joachim Wiberg ---- - src/service.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/src/service.c b/src/service.c -index 2c8fb6e..d45db40 100644 ---- a/src/service.c -+++ b/src/service.c -@@ -627,8 +627,11 @@ static pid_t service_fork(svc_t *svc) - set_uid(uid, svc); - - /* Set default path for regular users */ -- if (uid > 0) -+ if (uid > 0) { - setenv("PATH", _PATH_DEFPATH, 1); -+ setenv("USER", svc->username, 1); -+ setenv("LOGNAME", svc->username, 1); -+ } - if (home) { - setenv("HOME", home, 1); - if (chdir(home)) { --- -2.43.0 - diff --git a/package/finit/0002-Fix-467-TTY-services-stuck-in-restart-state-after-no.patch b/package/finit/0002-Fix-467-TTY-services-stuck-in-restart-state-after-no.patch deleted file mode 100644 index 88c8e936..00000000 --- a/package/finit/0002-Fix-467-TTY-services-stuck-in-restart-state-after-no.patch +++ /dev/null @@ -1,86 +0,0 @@ -From 34bf9a77765db4d963fc66dde29b415ecc8ab611 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Mon, 12 Jan 2026 19:31:39 +0100 -Subject: [PATCH 2/2] Fix #467: TTY services stuck in restart state after - non-zero exit -Organization: Wires - -When a TTY exited with non-zero code (e.g., user with shell=/sbin/false), -it would enter restart state but never recover, requiring manual restart. - -The throttling logic from commit f0032ab had two issues: - - 1. Duplicate exit code check in service_retry() created infinite timer loop - 2. TTYs lacked default restart_tmo, causing timer to never start - -Fix by removing duplicate check and ensuring TTYs get a 2-second default -restart_tmo for proper throttling. - -Signed-off-by: Joachim Wiberg ---- - src/service.c | 31 ++++++++++++++----------------- - 1 file changed, 14 insertions(+), 17 deletions(-) - -diff --git a/src/service.c b/src/service.c -index d45db40..ff8e180 100644 ---- a/src/service.c -+++ b/src/service.c -@@ -2194,15 +2194,20 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file) - /* only set forking based on pidfile if user supplied pid: option */ - if (pid && svc->pidfile[0] == '!') - svc->forking = 1; -+ } - -- if (svc->restart_tmo == 0) { -- if (svc_is_forking(svc)) -- svc->restart_tmo = 2000; -- else -- svc->restart_tmo = 1; -- } -+ /* Set default restart_tmo for services and TTYs that can restart */ -+ if (svc_is_daemon(svc) && svc->restart_tmo == 0) { -+ if (svc_is_forking(svc)) -+ svc->restart_tmo = 2000; -+ else -+ svc->restart_tmo = 1; - } - -+ /* TTYs need a longer default to throttle errors (e.g., missing device) */ -+ if (svc_is_tty(svc) && svc->restart_tmo == 0) -+ svc->restart_tmo = 2000; -+ - /* Set configured limits */ - memcpy(svc->rlimit, rlimit, sizeof(svc->rlimit)); - -@@ -2631,7 +2636,6 @@ static void service_cleanup_script(svc_t *svc) - static void service_retry(svc_t *svc) - { - char *restart_cnt = (char *)&svc->restart_cnt; -- int rc = WEXITSTATUS(svc->status); - int timeout; - - service_timeout_cancel(svc); -@@ -2641,17 +2645,10 @@ static void service_retry(svc_t *svc) - - if (svc->respawn) { - /* -- * Non-zero exit indicates an error that may not be resolved -- * by immediate retry. Add delay to prevent busy-loop and to -- * rate-limit retries, e.g. when TTY device doesn't exist. -+ * Respawn services (TTYs) that exited with non-zero status -+ * have already been delayed in the SVC_RUNNING_STATE handler. -+ * Just restart now. - */ -- if (WIFEXITED(svc->status) && rc != 0) { -- dbg("%s exited with error %d, delaying respawn ...", -- svc_ident(svc, NULL, 0), rc); -- service_timeout_after(svc, svc->restart_tmo, service_retry); -- return; -- } -- - dbg("%s crashed/exited, respawning ...", svc_ident(svc, NULL, 0)); - svc_unblock(svc); - service_step(svc); --- -2.43.0 - diff --git a/package/finit/0003-initctl-escape-special-characters-in-JSON-output.patch b/package/finit/0003-initctl-escape-special-characters-in-JSON-output.patch deleted file mode 100644 index e0ce598e..00000000 --- a/package/finit/0003-initctl-escape-special-characters-in-JSON-output.patch +++ /dev/null @@ -1,131 +0,0 @@ -From c4463ec64f9732bd67b8cfd2b73adc10e50d1178 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Sun, 18 Jan 2026 23:26:37 +0100 -Subject: [PATCH] initctl: escape special characters in JSON output -Organization: Wires - -Strings like command, description, and environment may contain characters -that need escaping for valid JSON, e.g., embedded quotes in command line -arguments like -V "NanoPi R2S". - -Add json_escape() helper to handle quotes, backslashes, and control chars. - -Signed-off-by: Joachim Wiberg ---- - src/initctl.c | 78 +++++++++++++++++++++++++++++++++++++++++++++------ - 1 file changed, 69 insertions(+), 9 deletions(-) - -diff --git a/src/initctl.c b/src/initctl.c -index 25c52cf..435e2da 100644 ---- a/src/initctl.c -+++ b/src/initctl.c -@@ -1036,6 +1036,62 @@ static int svc_compare(svc_t *svc, char *arg) - return 0; - } - -+/* -+ * Escape a string for safe JSON output. Handles quotes, backslashes, -+ * and control characters. Returns pointer to static buffer. -+ */ -+static char *json_escape(const char *str) -+{ -+ static char buf[1024]; -+ char *ptr = buf; -+ size_t left = sizeof(buf) - 1; -+ -+ if (!str) -+ return ""; -+ -+ while (*str && left > 1) { -+ char c = *str++; -+ -+ switch (c) { -+ case '"': -+ case '\\': -+ *ptr++ = '\\'; -+ *ptr++ = c; -+ left -= 2; -+ break; -+ case '\n': -+ *ptr++ = '\\'; -+ *ptr++ = 'n'; -+ left -= 2; -+ break; -+ case '\r': -+ *ptr++ = '\\'; -+ *ptr++ = 'r'; -+ left -= 2; -+ break; -+ case '\t': -+ *ptr++ = '\\'; -+ *ptr++ = 't'; -+ left -= 2; -+ break; -+ default: -+ if ((unsigned char)c < 0x20) { -+ /* Other control chars: use \uXXXX */ -+ int n = snprintf(ptr, left, "\\u%04x", (unsigned char)c); -+ ptr += n; -+ left -= n; -+ } else { -+ *ptr++ = c; -+ left--; -+ } -+ break; -+ } -+ } -+ *ptr = '\0'; -+ -+ return buf; -+} -+ - static int json_status_one(FILE *fp, svc_t *svc, char *indent, int prev) - { - long now = jiffies(); -@@ -1051,14 +1107,16 @@ static int json_status_one(FILE *fp, svc_t *svc, char *indent, int prev) - fprintf(fp, - "%s" - "%s{\n" -- "%s \"identity\": \"%s\",\n" -- "%s \"description\": \"%s\",\n" -+ "%s \"identity\": \"%s\",\n", -+ prev ? ",\n" : indent, prev ? indent : "", -+ indent, svc_ident(svc, NULL, 0)); -+ fprintf(fp, -+ "%s \"description\": \"%s\",\n", -+ indent, json_escape(svc->desc)); -+ fprintf(fp, - "%s \"type\": \"%s\",\n" - "%s \"forking\": %s,\n" - "%s \"status\": \"%s\",\n", -- prev ? ",\n" : indent, prev ? indent : "", -- indent, svc_ident(svc, NULL, 0), -- indent, svc->desc, - indent, svc_typestr(svc), - indent, svc->forking ? "true" : "false", - indent, svc_status(svc)); -@@ -1080,15 +1138,17 @@ static int json_status_one(FILE *fp, svc_t *svc, char *indent, int prev) - } - - fprintf(fp, -- "%s \"origin\": \"%s\",\n" -+ "%s \"origin\": \"%s\",\n", -+ indent, svc->file[0] ? svc->file : "built-in"); -+ svc_command(svc, buf, sizeof(buf), 0); -+ fprintf(fp, - "%s \"command\": \"%s\",\n", -- indent, svc->file[0] ? svc->file : "built-in", -- indent, svc_command(svc, buf, sizeof(buf), 0)); -+ indent, json_escape(buf)); - - svc_environ(svc, buf, sizeof(buf), 0); - if (buf[0]) - fprintf(fp, -- "%s \"environment\": \"%s\",\n", indent, buf); -+ "%s \"environment\": \"%s\",\n", indent, json_escape(buf)); - - svc_cond(svc, buf, sizeof(buf), 0); - if (buf[0]) --- -2.43.0 - diff --git a/package/finit/0004-Don-t-hide-cursor-when-shutting-down.patch b/package/finit/0004-Don-t-hide-cursor-when-shutting-down.patch deleted file mode 100644 index 4c6086db..00000000 --- a/package/finit/0004-Don-t-hide-cursor-when-shutting-down.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 7090321ff3c812644507d43e1ddea25de8cff93a Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Tue, 10 Feb 2026 15:58:46 +0100 -Subject: [PATCH 4/5] Don't hide cursor when shutting down -Organization: Wires - -Users starting Finit based systems using U-Boot or Barebox may otherwise -not get a visible cursor at their prompt. - -Signed-off-by: Joachim Wiberg ---- - src/sm.c | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/src/sm.c b/src/sm.c -index a1e982b..f23fa65 100644 ---- a/src/sm.c -+++ b/src/sm.c -@@ -361,9 +361,6 @@ restart: - - /* Restore terse mode and run hooks before shutdown */ - if (runlevel == 0 || runlevel == 6) { -- /* Hide cursor, we're going down ... */ -- dprint(STDOUT_FILENO, "\033[?25l", 6); -- - api_exit(); - log_exit(); - plugin_run_hooks(HOOK_SHUTDOWN); --- -2.43.0 - diff --git a/package/finit/0005-Fix-initctl-reload-NAME-not-updating-conditions-for-.patch b/package/finit/0005-Fix-initctl-reload-NAME-not-updating-conditions-for-.patch deleted file mode 100644 index b51d47ed..00000000 --- a/package/finit/0005-Fix-initctl-reload-NAME-not-updating-conditions-for-.patch +++ /dev/null @@ -1,61 +0,0 @@ -From f0914f6d32b9cd055a888cf0a1c7e45dec871824 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Tue, 10 Feb 2026 15:59:49 +0100 -Subject: [PATCH 5/5] Fix 'initctl reload NAME' not updating conditions for - dependents -Organization: Wires - -When reloading a specific service with 'initctl reload foo', the -pid/foo and service/foo/ready conditions were never cleared, so -dependent services were not notified of the reload. - -Clear the service's pid condition and, for pid/none notify types, -the ready condition before reloading. The conditions are then -reasserted by the pidfile inotify handler when the service touches -its PID file after processing SIGHUP. - -For s6/systemd services the ready condition is left intact since -their readiness notification may not re-trigger on SIGHUP. - -Signed-off-by: Joachim Wiberg ---- - src/api.c | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -diff --git a/src/api.c b/src/api.c -index 381c219..8537335 100644 ---- a/src/api.c -+++ b/src/api.c -@@ -112,6 +112,8 @@ static int restart(svc_t *svc, void *user_data) - - static int reload(svc_t *svc, void *user_data) - { -+ char cond[MAX_COND_LEN]; -+ - (void)user_data; - - if (!svc) -@@ -122,6 +124,20 @@ static int reload(svc_t *svc, void *user_data) - else - service_timeout_cancel(svc); - -+ /* -+ * Clear conditions before reload to ensure dependent services -+ * are properly updated. The conditions are reasserted when -+ * the service touches its PID file after processing SIGHUP. -+ * -+ * Note: only clear 'ready' for services where the pidfile -+ * inotify handler reasserts it (pid/none). For s6/systemd -+ * services readiness relies on their respective notification -+ * mechanism which may not re-trigger on SIGHUP. -+ */ -+ cond_clear(mkcond(svc, cond, sizeof(cond))); -+ if (svc->notify == SVC_NOTIFY_PID || svc->notify == SVC_NOTIFY_NONE) -+ service_ready(svc, 0); -+ - svc_mark_dirty(svc); - service_step(svc); - --- -2.43.0 - diff --git a/package/finit/finit.hash b/package/finit/finit.hash index eb1240f1..9a066cb6 100644 --- a/package/finit/finit.hash +++ b/package/finit/finit.hash @@ -1,5 +1,5 @@ # From https://github.com/troglobit/finit/releases/ -sha256 0e4774ccb8933ed92287e6c18d27cb463222dcc1f50a3607e27bbe5fd150ece0 finit-4.15.tar.gz +sha256 7f8b5a49149b17670d93e41a9b146c5633e035aa00087b8c945def8387cdecbd finit-4.16-rc1.tar.gz # Locally calculated sha256 868cb6c5414933a48db11186042cfe65c87480d326734bc6cf0e4b19b4a2e52a LICENSE diff --git a/package/finit/finit.mk b/package/finit/finit.mk index 890dc069..87b907d2 100644 --- a/package/finit/finit.mk +++ b/package/finit/finit.mk @@ -4,7 +4,7 @@ # ################################################################################ -FINIT_VERSION = 4.15 +FINIT_VERSION = 4.16-rc1 FINIT_SITE = https://github.com/troglobit/finit/releases/download/$(FINIT_VERSION) FINIT_LICENSE = MIT FINIT_LICENSE_FILES = LICENSE