mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-02 13:53:01 +02:00
Merge pull request #707 from kernelkit/misc
Bump Finit and add support for dummy interfaces
This commit is contained in:
@@ -1,70 +0,0 @@
|
||||
From c2218236546908ecab5eab4b32e698d7bb3d984a Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Sat, 3 Feb 2024 17:30:30 +0100
|
||||
Subject: [PATCH] shutdown: use cond_clear_noupdate() to prevent nested
|
||||
service_stop()
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
When the system shuts down, or user changes runlevels, we don't have to
|
||||
call cond_clear_update(), because this can lead to nested service_stop()
|
||||
calls, which in turn lead to out of sync progress updates:
|
||||
|
||||
[ .. ] Stopping Foo
|
||||
[ OK ] Stopping Bar
|
||||
[ OK ]
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
src/cond-w.c | 6 +++++-
|
||||
src/service.c | 4 +++-
|
||||
2 files changed, 8 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/cond-w.c b/src/cond-w.c
|
||||
index 2502264..0546282 100644
|
||||
--- a/src/cond-w.c
|
||||
+++ b/src/cond-w.c
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "cond.h"
|
||||
#include "pid.h"
|
||||
#include "service.h"
|
||||
+#include "sm.h"
|
||||
|
||||
struct cond_boot {
|
||||
TAILQ_ENTRY(cond_boot) link;
|
||||
@@ -214,7 +215,10 @@ static int do_delete(const char *fpath, const struct stat *sb, int tflag, struct
|
||||
err(1, "Failed removing condition %s", fpath);
|
||||
|
||||
cond = ptr + strlen(COND_BASE) + 1;
|
||||
- cond_update(cond);
|
||||
+ if (sm_is_in_teardown(&sm))
|
||||
+ cond_clear_noupdate(cond);
|
||||
+ else
|
||||
+ cond_update(cond);
|
||||
|
||||
return 0;
|
||||
}
|
||||
diff --git a/src/service.c b/src/service.c
|
||||
index 8175757..eca9ed0 100644
|
||||
--- a/src/service.c
|
||||
+++ b/src/service.c
|
||||
@@ -2261,7 +2261,7 @@ static void svc_set_state(svc_t *svc, svc_state_t new_state)
|
||||
/* if PID isn't collected within SVC_TERM_TIMEOUT msec, kill it! */
|
||||
if (new_state == SVC_STOPPING_STATE) {
|
||||
dbg("%s is stopping, wait %d sec before sending SIGKILL ...",
|
||||
- svc_ident(svc, NULL, 0), svc->killdelay / 1000);
|
||||
+ svc_ident(svc, NULL, 0), svc->killdelay / 1000);
|
||||
service_timeout_cancel(svc);
|
||||
service_timeout_after(svc, svc->killdelay, service_kill);
|
||||
}
|
||||
@@ -2299,6 +2299,8 @@ static void svc_set_state(svc_t *svc, svc_state_t new_state)
|
||||
if ((old_state == SVC_RUNNING_STATE && new_state == SVC_PAUSED_STATE) ||
|
||||
(old_state == SVC_PAUSED_STATE && new_state == SVC_RUNNING_STATE))
|
||||
; /* only paused during reload, don't clear conds. */
|
||||
+ else if (sm_is_in_teardown(&sm))
|
||||
+ cond_clear_noupdate(cond);
|
||||
else
|
||||
cond_clear(cond);
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
From 5998342b3e55638b0f7248383e939a64f53fa8ff Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Mon, 26 Feb 2024 08:41:14 +0100
|
||||
Subject: [PATCH] system: drop debug mode from udevd
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
system/10-hotplug.conf.in | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/system/10-hotplug.conf.in b/system/10-hotplug.conf.in
|
||||
index 49ea081..a4f64b5 100644
|
||||
--- a/system/10-hotplug.conf.in
|
||||
+++ b/system/10-hotplug.conf.in
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
# Check for systemd-udevd and eudev, if we find both, we opt for the latter.
|
||||
service nowarn [S12345789] cgroup.system name:udevd notify:none pid:udevd log /lib/systemd/systemd-udevd -- Device event daemon (udev)
|
||||
-service nowarn [S12345789] cgroup.system name:udevd notify:none pid:udevd log udevd -D -- Device event daemon (udev)
|
||||
+service nowarn [S12345789] cgroup.system name:udevd notify:none pid:udevd log udevd -- Device event daemon (udev)
|
||||
|
||||
# Wait for udevd to start, then trigger coldplug events and module loading.
|
||||
# The last 'settle' call waits for it to finalize processing all uevents.
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
From c1ed3733986486f3255e77dec47ae1d4b2836e2f Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Mon, 11 Mar 2024 15:46:38 +0100
|
||||
Subject: [PATCH 3/4] Fix #397: drop ttinit() for PID 1
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
After reports from the field, see issue #397, of lockups at reboot,
|
||||
we've decided to drop this code from PID 1. It was added before the 4.x
|
||||
series, when the current progress output was introduced. For the older
|
||||
style progress it served a purpose since the placement of [OK]/[FAIL]
|
||||
was on the right hand side.
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
src/log.c | 9 ---------
|
||||
1 file changed, 9 deletions(-)
|
||||
|
||||
diff --git a/src/log.c b/src/log.c
|
||||
index ea49705..b776525 100644
|
||||
--- a/src/log.c
|
||||
+++ b/src/log.c
|
||||
@@ -42,8 +42,6 @@ static int loglevel = LOG_INFO;
|
||||
|
||||
void log_init(void)
|
||||
{
|
||||
- ttinit();
|
||||
-
|
||||
if (debug)
|
||||
loglevel = LOG_DEBUG;
|
||||
else
|
||||
@@ -53,13 +51,6 @@ void log_init(void)
|
||||
/* If we enabled terse mode at boot, restore to previous setting at shutdown */
|
||||
void log_exit(void)
|
||||
{
|
||||
- /*
|
||||
- * Unless in debug mode at shutdown, Reinitialize screen,
|
||||
- * terminal may have been resized at runtime
|
||||
- */
|
||||
- if (!debug)
|
||||
- ttinit();
|
||||
-
|
||||
enable_progress(1);
|
||||
}
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
From 146bf5512208cb906edddb3f0108cf6f7c525044 Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Mon, 11 Mar 2024 15:55:39 +0100
|
||||
Subject: [PATCH 4/4] Fix #398: display unsupported initctl command (number) in
|
||||
log
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
src/api.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/api.c b/src/api.c
|
||||
index c19c0d8..8d29a23 100644
|
||||
--- a/src/api.c
|
||||
+++ b/src/api.c
|
||||
@@ -377,7 +377,9 @@ static void api_cb(uev_t *w, void *arg, int events)
|
||||
case INIT_CMD_POWEROFF:
|
||||
case INIT_CMD_SUSPEND:
|
||||
if (IS_RESERVED_RUNLEVEL(runlevel)) {
|
||||
- warnx("Unsupported command in runlevel S and 6/0.");
|
||||
+ strterm(rq.data, sizeof(rq.data));
|
||||
+ warnx("Unsupported command (cmd: %d, data: %s) in runlevel S and 6/0.",
|
||||
+ rq.cmd, rq.data);
|
||||
goto leave;
|
||||
}
|
||||
default:
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
From 90a4df8d1281fd64d048ec1bc91e8cec5f96df06 Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Mon, 11 Mar 2024 18:53:22 +0100
|
||||
Subject: [PATCH 5/6] plugins: on error-retry, don't print "Restoring RTC"
|
||||
twice
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
plugins/rtc.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/plugins/rtc.c b/plugins/rtc.c
|
||||
index 31c99e0..238791f 100644
|
||||
--- a/plugins/rtc.c
|
||||
+++ b/plugins/rtc.c
|
||||
@@ -180,7 +180,8 @@ static void rtc_restore(void *arg)
|
||||
rc = 2;
|
||||
}
|
||||
|
||||
- print_desc(NULL, "Restoring system clock (UTC) from RTC");
|
||||
+ if (!rc)
|
||||
+ print_desc(NULL, "Restoring system clock (UTC) from RTC");
|
||||
tm.tm_isdst = -1; /* Use tzdata to figure it out, please. */
|
||||
tv.tv_sec = mktime(&tm);
|
||||
if (tv.tv_sec == (time_t)-1 || tv.tv_sec < rtc_date_fallback) {
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
From bf4a584e2ebfa512a2d6cfe5e43a81ee741e3296 Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Tue, 12 Mar 2024 05:18:35 +0100
|
||||
Subject: [PATCH 6/7] plugins: add support for hwrng and check if seed file is
|
||||
empty
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
plugins/urandom.c | 41 ++++++++++++++++++++++++++++++-----------
|
||||
1 file changed, 30 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/plugins/urandom.c b/plugins/urandom.c
|
||||
index 64a3fa7..2da8035 100644
|
||||
--- a/plugins/urandom.c
|
||||
+++ b/plugins/urandom.c
|
||||
@@ -47,6 +47,7 @@ static void setup(void *arg)
|
||||
#ifdef RANDOMSEED
|
||||
struct rand_pool_info *rpi;
|
||||
ssize_t len = 0;
|
||||
+ struct stat st;
|
||||
int rc = -1;
|
||||
int fd, err;
|
||||
|
||||
@@ -55,7 +56,7 @@ static void setup(void *arg)
|
||||
return;
|
||||
}
|
||||
|
||||
- if (!fexist(RANDOMSEED)) {
|
||||
+ if (stat(RANDOMSEED, &st) || st.st_size < 512) {
|
||||
int ret = 1;
|
||||
mode_t prev;
|
||||
FILE *fp;
|
||||
@@ -64,16 +65,34 @@ static void setup(void *arg)
|
||||
prev = umask(077);
|
||||
fp = fopen(RANDOMSEED, "w");
|
||||
if (fp) {
|
||||
- int iter = 128;
|
||||
- struct timeval tv;
|
||||
-
|
||||
- gettimeofday(&tv, NULL);
|
||||
- srandom(tv.tv_sec % 3600);
|
||||
- while (iter--) {
|
||||
- uint32_t i, prng = random();
|
||||
-
|
||||
- for (i = 0; i < sizeof(prng); i++)
|
||||
- fputc((prng >> (i * CHAR_BIT)) & UCHAR_MAX, fp);
|
||||
+ const char *hwrng = "/dev/hwrng";
|
||||
+ FILE *hw;
|
||||
+
|
||||
+ hw = fopen(hwrng, "r");
|
||||
+ if (hw) {
|
||||
+ char buf[512];
|
||||
+ size_t len;
|
||||
+
|
||||
+ len = fread(buf, sizeof(buf[0]), sizeof(buf), hw);
|
||||
+ if (len == 0) {
|
||||
+ fclose(hw);
|
||||
+ goto no_hwrng;
|
||||
+ }
|
||||
+
|
||||
+ len = fwrite(buf, sizeof(buf[0]), len, fp);
|
||||
+ fclose(hw);
|
||||
+ } else {
|
||||
+ struct timeval tv;
|
||||
+ int iter = 128;
|
||||
+no_hwrng:
|
||||
+ gettimeofday(&tv, NULL);
|
||||
+ srandom(tv.tv_sec % 3600);
|
||||
+ while (iter--) {
|
||||
+ uint32_t i, prng = random();
|
||||
+
|
||||
+ for (i = 0; i < sizeof(prng); i++)
|
||||
+ fputc((prng >> (i * CHAR_BIT)) & UCHAR_MAX, fp);
|
||||
+ }
|
||||
}
|
||||
ret = fclose(fp);
|
||||
}
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
From b49f55ab3d1aec48bbfdf2106fd8f500406a5348 Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Wed, 13 Mar 2024 11:48:47 +0100
|
||||
Subject: [PATCH 7/7] tmpfiles.d: ignore x/X command, no cleanup at runtime
|
||||
with Finit
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
Silence log warnings for command x/X (ignore clean for path), because
|
||||
Finit does not do tmpfiles cleaning at runtime.
|
||||
|
||||
x /tmp/podman-run-*
|
||||
x /tmp/containers-user-*
|
||||
x /tmp/run-*/libpod
|
||||
D! /var/lib/containers/storage/tmp 0700 root root
|
||||
D! /run/podman 0700 root root
|
||||
D! /var/lib/cni/networks
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
src/tmpfiles.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/tmpfiles.c b/src/tmpfiles.c
|
||||
index d62b09f..15b463c 100644
|
||||
--- a/src/tmpfiles.c
|
||||
+++ b/src/tmpfiles.c
|
||||
@@ -434,6 +434,10 @@ static void tmpfiles(char *line)
|
||||
}
|
||||
}
|
||||
break;
|
||||
+ case 'X':
|
||||
+ case 'x':
|
||||
+ dbg("Unsupported x/X command, ignoring %s, no support for clean at runtime.", path);
|
||||
+ break;
|
||||
case 'Z':
|
||||
opts = "-R";
|
||||
/* fallthrough */
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
From 052136cb9927379e75bc346d46c86d728f1e33ef Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Tue, 2 Apr 2024 16:03:31 +0200
|
||||
Subject: [PATCH 08/12] initctl: touch does not respect -n switch
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
Fixes #402
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
src/serv.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/serv.c b/src/serv.c
|
||||
index e14d5ec..1cace46 100644
|
||||
--- a/src/serv.c
|
||||
+++ b/src/serv.c
|
||||
@@ -377,9 +377,9 @@ int serv_touch(char *arg)
|
||||
fn = conf(path, sizeof(path), arg, 0);
|
||||
if (!fexist(fn)) {
|
||||
if (!strstr(arg, "finit.conf"))
|
||||
- ERRX(72, "%s not available.", arg);
|
||||
+ ERRX(noerr ? 0 : 72, "%s not available.", arg);
|
||||
if (is_builtin(arg))
|
||||
- ERRX(4, "%s is a built-in service.", arg);
|
||||
+ ERRX(noerr ? 0 : 4, "%s is a built-in service.", arg);
|
||||
|
||||
strlcpy(path, finit_conf, sizeof(path));
|
||||
fn = path;
|
||||
@@ -387,7 +387,7 @@ int serv_touch(char *arg)
|
||||
|
||||
/* libite:touch() follows symlinks */
|
||||
if (utimensat(AT_FDCWD, fn, NULL, AT_SYMLINK_NOFOLLOW))
|
||||
- ERR(71, "failed marking %s for reload", fn);
|
||||
+ ERR(noerr ? 0 : 71, "failed marking %s for reload", fn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
From 7b501f255b5730ce9da5c72aa6abd87bbf20ba11 Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Wed, 3 Apr 2024 06:46:18 +0200
|
||||
Subject: [PATCH 09/12] initctl: touch does not support template services
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
Fixes #403
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
src/serv.c | 10 ++++++++++
|
||||
src/util.h | 20 ++++++++++++++++++++
|
||||
2 files changed, 30 insertions(+)
|
||||
|
||||
diff --git a/src/serv.c b/src/serv.c
|
||||
index 1cace46..6344ce3 100644
|
||||
--- a/src/serv.c
|
||||
+++ b/src/serv.c
|
||||
@@ -374,6 +374,15 @@ int serv_touch(char *arg)
|
||||
return serv_list("enabled");
|
||||
}
|
||||
|
||||
+ /* 1. Try /etc/finit.d/enabled/$arg.conf to handle template@.conf */
|
||||
+ paste(path, sizeof(path), finit_rcsd, "enabled/");
|
||||
+ strlcat(path, arg, sizeof(path));
|
||||
+ if (!suffix(path, sizeof(path), ".conf") && fexist(path)) {
|
||||
+ fn = path;
|
||||
+ goto touchit;
|
||||
+ }
|
||||
+
|
||||
+ /* 2. Try /etc/finit.d/available/$arg.conf and other combos (legacy) */
|
||||
fn = conf(path, sizeof(path), arg, 0);
|
||||
if (!fexist(fn)) {
|
||||
if (!strstr(arg, "finit.conf"))
|
||||
@@ -385,6 +394,7 @@ int serv_touch(char *arg)
|
||||
fn = path;
|
||||
}
|
||||
|
||||
+touchit:
|
||||
/* libite:touch() follows symlinks */
|
||||
if (utimensat(AT_FDCWD, fn, NULL, AT_SYMLINK_NOFOLLOW))
|
||||
ERR(noerr ? 0 : 71, "failed marking %s for reload", fn);
|
||||
diff --git a/src/util.h b/src/util.h
|
||||
index 9f0cbf0..80e1c51 100644
|
||||
--- a/src/util.h
|
||||
+++ b/src/util.h
|
||||
@@ -109,6 +109,26 @@ static inline int paste(char *buf, size_t len, const char *dir, const char *file
|
||||
fisslashdir(dir) ? "" : file[0] == '/' ? "" : "/", file);
|
||||
}
|
||||
|
||||
+/* ensure path has suffix */
|
||||
+static inline int suffix(char *path, size_t len, const char *sfx)
|
||||
+{
|
||||
+ size_t slen = strlen(sfx);
|
||||
+ size_t plen = strlen(path);
|
||||
+
|
||||
+ if (plen < slen)
|
||||
+ slen = strlcat(path, sfx, len);
|
||||
+ else {
|
||||
+ plen -= slen;
|
||||
+ if (strcmp(&path[plen], sfx))
|
||||
+ slen = strlcat(path, sfx, len);
|
||||
+ }
|
||||
+
|
||||
+ if (slen >= len)
|
||||
+ return -1;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
#endif /* FINIT_UTIL_H_ */
|
||||
|
||||
/**
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
From 6a89e60fc84b90e5f09f61d37892f3b17bd14631 Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Wed, 24 Apr 2024 11:33:35 +0200
|
||||
Subject: [PATCH 10/11] Fix #405: parsing >1 active consoles in tty @console
|
||||
setups
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
Systems that have the following tty setup and multiple consoles listed
|
||||
in /sys/class/tty/console/active misbehave:
|
||||
|
||||
tty [12345789] @console 0 xterm noclear passenv
|
||||
|
||||
Only the first listed console is started properly, the remaining ones
|
||||
were registered using the wrong :ID and no arguments to getty.
|
||||
|
||||
This patch fixes the parsing and re-use of the base paramenters for
|
||||
all consoles listed in the active file.
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
src/service.c | 45 +++++++++++++++++++++++----------------------
|
||||
1 file changed, 23 insertions(+), 22 deletions(-)
|
||||
|
||||
diff --git a/src/service.c b/src/service.c
|
||||
index eca9ed0..95a04b8 100644
|
||||
--- a/src/service.c
|
||||
+++ b/src/service.c
|
||||
@@ -1633,10 +1633,16 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
|
||||
|
||||
if (type == SVC_TYPE_TTY) {
|
||||
size_t i, len = 0;
|
||||
+ char *ptr;
|
||||
|
||||
if (tty_parse_args(&tty, cmd, &args))
|
||||
return errno;
|
||||
|
||||
+ if (tty_isatcon(tty.dev))
|
||||
+ dev = tty_atcon();
|
||||
+ else
|
||||
+ dev = tty.dev;
|
||||
+ next:
|
||||
if (tty.cmd)
|
||||
len += strlen(tty.cmd);
|
||||
else
|
||||
@@ -1659,14 +1665,22 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
|
||||
if (!cmd)
|
||||
return errno;
|
||||
|
||||
- if (tty_isatcon(tty.dev))
|
||||
- dev = tty_atcon();
|
||||
- else
|
||||
- dev = tty.dev;
|
||||
-
|
||||
/* tty's always respawn, never incr. restart_cnt */
|
||||
respawn = 1;
|
||||
- next:
|
||||
+
|
||||
+ /* Create name:id tuple for identity, e.g., tty:S0 */
|
||||
+ ptr = strrchr(dev, '/');
|
||||
+ if (ptr)
|
||||
+ ptr++;
|
||||
+ else
|
||||
+ ptr = dev;
|
||||
+ if (!strncmp(ptr, "tty", 3))
|
||||
+ ptr += 3;
|
||||
+
|
||||
+ name = "tty";
|
||||
+ if (!id || id[0] == 0)
|
||||
+ id = ptr;
|
||||
+
|
||||
svc = svc_find_by_tty(dev);
|
||||
} else
|
||||
svc = svc_find(name, id);
|
||||
@@ -1722,8 +1736,6 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
|
||||
conf_parse_cond(svc, cond);
|
||||
|
||||
if (type == SVC_TYPE_TTY) {
|
||||
- char *ptr;
|
||||
-
|
||||
if (dev)
|
||||
strlcpy(svc->dev, dev, sizeof(svc->dev));
|
||||
if (tty.baud)
|
||||
@@ -1738,19 +1750,6 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
|
||||
|
||||
/* TTYs cannot be redirected */
|
||||
log = NULL;
|
||||
-
|
||||
- /* Create name:id tuple for identity, e.g., tty:S0 */
|
||||
- ptr = strrchr(svc->dev, '/');
|
||||
- if (ptr)
|
||||
- ptr++;
|
||||
- else
|
||||
- ptr = svc->dev;
|
||||
- if (!strncmp(ptr, "tty", 3))
|
||||
- ptr += 3;
|
||||
- if (!id || id[0] == 0)
|
||||
- id = ptr;
|
||||
- strlcpy(svc->name, "tty", sizeof(svc->name));
|
||||
- strlcpy(svc->id, id, sizeof(svc->id));
|
||||
}
|
||||
|
||||
parse_cmdline_args(svc, cmd, &args);
|
||||
@@ -1870,8 +1869,10 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
|
||||
/* continue expanding any 'tty @console ...' */
|
||||
if (tty_isatcon(tty.dev)) {
|
||||
dev = tty_atcon();
|
||||
- if (dev)
|
||||
+ if (dev) {
|
||||
+ id = NULL; /* reset for next tty:ID */
|
||||
goto next;
|
||||
+ }
|
||||
}
|
||||
|
||||
return 0;
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
From 340cae4afd0d11979322a6c2f4d40a12ea59817b Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Wed, 24 Apr 2024 12:46:59 +0200
|
||||
Subject: [PATCH 11/11] Change default behavior, allow kernel logs to console
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
A Linux system booted with the kernel command line option 'quiet' only
|
||||
logs error (and above) severity messages to the console. For embedded
|
||||
systems, which is the primary target for Finit, this is what you want
|
||||
to see.
|
||||
|
||||
Hence, and after careful consideration, this patch changes the default
|
||||
behavior of Finit to allow kernel logs to the console. A build-time
|
||||
configure flags, --disable-kernel-logging, has been added to restore
|
||||
legacy behavior.
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
configure.ac | 9 +++++++++
|
||||
src/finit.c | 14 +++++++++++---
|
||||
2 files changed, 20 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index a4470d0..31f4cff 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -71,6 +71,10 @@ AC_ARG_ENABLE(redirect,
|
||||
AS_HELP_STRING([--disable-redirect], [Disable redirection of service output to /dev/null]),,[
|
||||
enable_redirect=yes])
|
||||
|
||||
+AC_ARG_ENABLE(kernel_logging,
|
||||
+ AS_HELP_STRING([--disable-kernel-logging], [Disable kernel logging to console (use 'quiet' instead!]),,[
|
||||
+ enable_kernel_logging=yes])
|
||||
+
|
||||
AC_ARG_ENABLE(logrotate,
|
||||
AS_HELP_STRING([--disable-logrotate], [Disable built-in rotation of /var/log/wtmp]),,[
|
||||
enable_logrotate=yes])
|
||||
@@ -181,6 +185,9 @@ AS_IF([test "x$enable_auto_reload" = "xyes"], [
|
||||
AS_IF([test "x$enable_kernel_cmdline" = "xyes"], [
|
||||
AC_DEFINE(KERNEL_CMDLINE, 1, [Dumpster diving after init args from /proc/cmdline])])
|
||||
|
||||
+AS_IF([test "x$enable_kernel_logging" = "xyes"], [
|
||||
+ AC_DEFINE(KERNEL_LOGGING, 1, [Keep kernel warn/err logs to console])])
|
||||
+
|
||||
AS_IF([test "x$enable_fastboot" = "xyes"], [
|
||||
AC_DEFINE(FAST_BOOT, 1, [Skip fsck check on filesystems listed in /etc/fstab])])
|
||||
|
||||
@@ -382,6 +389,8 @@ Optional features:
|
||||
Built-in sulogin......: $with_sulogin $sulogin
|
||||
Built-in watchdogd....: $with_watchdog $watchdog
|
||||
Built-in logrotate....: $enable_logrotate
|
||||
+ Parse kernel cmdline..: $enable_kernel_cmdline
|
||||
+ Keep kernel logging...: $enable_kernel_logging
|
||||
Skip fsck check.......: $enable_fastboot
|
||||
Run fsck fix mode.....: $enable_fsckfix
|
||||
Redirect output.......: $enable_redirect
|
||||
diff --git a/src/finit.c b/src/finit.c
|
||||
index 27b81e9..38b1278 100644
|
||||
--- a/src/finit.c
|
||||
+++ b/src/finit.c
|
||||
@@ -87,14 +87,22 @@ svc_t *wdog = NULL; /* No watchdog by default */
|
||||
*/
|
||||
static void banner(void)
|
||||
{
|
||||
+#ifndef KERNEL_LOGGING
|
||||
/*
|
||||
* Silence kernel logs, assuming users have sysklogd or
|
||||
- * similar enabled to start emptying /dev/kmsg, but for
|
||||
- * our progress we want to own the console.
|
||||
+ * similar enabled to start emptying /dev/kmsg.
|
||||
+ *
|
||||
+ * Instead of using `configure --disable-kernel-logging`, we
|
||||
+ * recommend adjusting the kernel log level in the kernel's
|
||||
+ * menuconfig, or using sysctl kernel.printk, or setting the
|
||||
+ * desired log level, on the kernel cmdline, e.g. 'quiet'.
|
||||
+ *
|
||||
+ * By default KERNEL_LOGGING is enabled so you can see any
|
||||
+ * warnings/errors or higher on your system console.
|
||||
*/
|
||||
if (!debug && !kerndebug)
|
||||
klogctl(6, NULL, 0);
|
||||
-
|
||||
+#endif
|
||||
/*
|
||||
* First level hooks, if you want to run here, you're
|
||||
* pretty much on your own. Nothing's up yet ...
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
From 13b107b7b15e6d4823627ea4707a12108fd5a1c7 Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Fri, 21 Jun 2024 10:24:35 +0200
|
||||
Subject: [PATCH] Fix #407: extend initctl poll timeout
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
src/client.c | 6 ++++--
|
||||
2 files changed, 8 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/client.c b/src/client.c
|
||||
index c3fd3aef..a8c06ac4 100644
|
||||
--- a/src/client.c
|
||||
+++ b/src/client.c
|
||||
@@ -29,6 +29,8 @@
|
||||
#include "client.h"
|
||||
#include "log.h"
|
||||
|
||||
+#define REQUEST_TIMEOUT 15000
|
||||
+
|
||||
static int sd = -1;
|
||||
|
||||
int client_connect(void)
|
||||
@@ -85,7 +87,7 @@ int client_request(struct init_request *rq, ssize_t len)
|
||||
|
||||
pfd.fd = sd;
|
||||
pfd.events = POLLOUT;
|
||||
- if (poll(&pfd, 1, 2000) <= 0) {
|
||||
+ if (poll(&pfd, 1, REQUEST_TIMEOUT) <= 0) {
|
||||
warn("Timed out waiting for Finit, errno %d", errno);
|
||||
return -1;
|
||||
}
|
||||
@@ -107,7 +109,7 @@ int client_request(struct init_request *rq, ssize_t len)
|
||||
|
||||
pfd.fd = sd;
|
||||
pfd.events = POLLIN | POLLERR | POLLHUP;
|
||||
- if ((rc = poll(&pfd, 1, 2000)) <= 0) {
|
||||
+ if ((rc = poll(&pfd, 1, REQUEST_TIMEOUT)) <= 0) {
|
||||
if (rc) {
|
||||
if (errno == EINTR) /* shutdown/reboot */
|
||||
return -1;
|
||||
@@ -1,64 +0,0 @@
|
||||
From ab62b5282b0461b14464a4a5de49f3b1fa0604fe Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Sat, 25 May 2024 19:33:21 +0200
|
||||
Subject: [PATCH 12/12] runparts: add -b (batch) mode for syslog output
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
src/runparts.c | 24 ++++++++++++++++++------
|
||||
1 file changed, 18 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/runparts.c b/src/runparts.c
|
||||
index 5af2c2d..c4225ce 100644
|
||||
--- a/src/runparts.c
|
||||
+++ b/src/runparts.c
|
||||
@@ -26,18 +26,27 @@
|
||||
#else
|
||||
#include <sys/prctl.h>
|
||||
|
||||
+const char *active_msg = NULL;
|
||||
+int interactive = 1;
|
||||
int debug;
|
||||
|
||||
static void print_desc(const char *prefix, const char *msg)
|
||||
{
|
||||
- fprintf(stderr, "\e[1m[\e[0m\e[1;33m ⋯ \e[0m\e[1m]\e[0m %s %s", prefix, msg);
|
||||
+ if (interactive)
|
||||
+ fprintf(stderr, "\e[1m[\e[0m\e[1;33m ⋯ \e[0m\e[1m]\e[0m %s %s", prefix, msg);
|
||||
+ else
|
||||
+ fprintf(stderr, "%s %s ...\n", prefix, msg);
|
||||
+ active_msg = msg;
|
||||
}
|
||||
static void print_result(int rc)
|
||||
{
|
||||
- if (rc)
|
||||
- fputs("\r\e[1m[\e[0m\e[1;31mFAIL\e[0m\e[1m]\e[0m\n", stderr);
|
||||
- else
|
||||
- fputs("\r\e[1m[\e[0m\e[1;32m OK \e[0m\e[1m]\e[0m\n", stderr);
|
||||
+ if (interactive) {
|
||||
+ if (rc)
|
||||
+ fputs("\r\e[1m[\e[0m\e[1;31mFAIL\e[0m\e[1m]\e[0m\n", stderr);
|
||||
+ else
|
||||
+ fputs("\r\e[1m[\e[0m\e[1;32m OK \e[0m\e[1m]\e[0m\n", stderr);
|
||||
+ } else
|
||||
+ fprintf(stderr, "[%s] %s\n", rc ? "FAIL" : " OK ", active_msg ?: "");
|
||||
}
|
||||
|
||||
void sig_unblock(void)
|
||||
@@ -193,8 +202,11 @@ int main(int argc, char *argv[])
|
||||
int rc, c, progress = 0, sysv = 0;
|
||||
char *dir;
|
||||
|
||||
- while ((c = getopt(argc, argv, "dh?ps")) != EOF) {
|
||||
+ while ((c = getopt(argc, argv, "bdh?ps")) != EOF) {
|
||||
switch(c) {
|
||||
+ case 'b': /* batch mode */
|
||||
+ interactive = 0;
|
||||
+ break;
|
||||
case 'd':
|
||||
debug = 1;
|
||||
break;
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# From https://github.com/troglobit/finit/releases/
|
||||
sha256 139adcb81ec8a5bb628249f92e2144b20f7e14c53aa56bb86a2fd42c5e7dca11 finit-4.7.tar.gz
|
||||
sha256 5026965e33f31b8fa4e2e465b9521e805fa01c31cade884c07d0fcff97cd0ddf finit-4.8.tar.gz
|
||||
|
||||
# Locally calculated
|
||||
sha256 2fd62c0fe6ea6d1861669f4c87bda83a0b5ceca64f4baa4d16dd078fbd218c14 LICENSE
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
################################################################################
|
||||
|
||||
FINIT_VERSION = 4.7
|
||||
FINIT_VERSION = 4.8
|
||||
FINIT_SITE = https://github.com/troglobit/finit/releases/download/$(FINIT_VERSION)
|
||||
FINIT_LICENSE = MIT
|
||||
FINIT_LICENSE_FILES = LICENSE
|
||||
|
||||
@@ -227,6 +227,8 @@ static int ifchange_cand_infer_type(sr_session_ctx_t *session, const char *path)
|
||||
inferred.data.string_val = "infix-if-type:bridge";
|
||||
else if (!fnmatch("docker+([0-9])", ifname, FNM_EXTMATCH))
|
||||
inferred.data.string_val = "infix-if-type:bridge";
|
||||
else if (!fnmatch("dummy+([0-9])", ifname, FNM_EXTMATCH))
|
||||
inferred.data.string_val = "infix-if-type:dummy";
|
||||
else if (!fnmatch("podman+([0-9])", ifname, FNM_EXTMATCH))
|
||||
inferred.data.string_val = "infix-if-type:bridge";
|
||||
else if (!fnmatch("lag+([0-9])", ifname, FNM_EXTMATCH))
|
||||
@@ -1522,6 +1524,16 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int netdag_gen_dummy(struct dagger *net, struct lyd_node *dif,
|
||||
struct lyd_node *cif, FILE *ip)
|
||||
{
|
||||
const char *ifname = lydx_get_cattr(cif, "name");
|
||||
|
||||
fprintf(ip, "link add dev %s type dummy\n", ifname);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int netdag_gen_veth(struct dagger *net, struct lyd_node *dif,
|
||||
struct lyd_node *cif, FILE *ip)
|
||||
{
|
||||
@@ -1665,6 +1677,8 @@ static int netdag_gen_afspec_add(sr_session_ctx_t *session, struct dagger *net,
|
||||
|
||||
if (!strcmp(iftype, "infix-if-type:bridge")) {
|
||||
err = netdag_gen_bridge(session, net, dif, cif, ip, 1);
|
||||
} else if (!strcmp(iftype, "infix-if-type:dummy")) {
|
||||
err = netdag_gen_dummy(net, NULL, cif, ip);
|
||||
} else if (!strcmp(iftype, "infix-if-type:veth")) {
|
||||
err = netdag_gen_veth(net, NULL, cif, ip);
|
||||
} else if (!strcmp(iftype, "infix-if-type:vlan")) {
|
||||
|
||||
@@ -26,7 +26,7 @@ MODULES=(
|
||||
"infix-hardware@2024-04-25.yang"
|
||||
"ieee802-dot1q-types@2022-10-29.yang"
|
||||
"infix-ip@2024-09-16.yang"
|
||||
"infix-if-type@2024-01-29.yang"
|
||||
"infix-if-type@2024-10-13.yang"
|
||||
"infix-routing@2024-10-01.yang"
|
||||
"ieee802-dot1ab-lldp@2022-03-15.yang"
|
||||
"infix-lldp@2023-08-23.yang"
|
||||
|
||||
@@ -11,15 +11,20 @@ module infix-if-type {
|
||||
contact "kernelkit@googlegroups.com";
|
||||
description "Infix extensions to IANA interfaces types";
|
||||
|
||||
revision 2023-08-21 {
|
||||
description "Add infix-inteface-type to reduce number of supported
|
||||
interfaces. The derived identities are based on both
|
||||
this new identity and their parent iana-if-type.";
|
||||
revision 2024-10-13 {
|
||||
description "Add new interface type dummy.";
|
||||
reference "internal";
|
||||
}
|
||||
|
||||
revision 2024-01-29 {
|
||||
description "Add new interface type etherlike";
|
||||
description "Add new interface type etherlike.";
|
||||
reference "internal";
|
||||
}
|
||||
|
||||
revision 2023-08-21 {
|
||||
description "Add infix-inteface-type to reduce number of supported
|
||||
interfaces. The derived identities are based on both
|
||||
this new identity and their parent iana-if-type.";
|
||||
reference "internal";
|
||||
}
|
||||
|
||||
@@ -42,6 +47,11 @@ module infix-if-type {
|
||||
base ianaift:bridge;
|
||||
description "IEEE bridge interface.";
|
||||
}
|
||||
identity dummy {
|
||||
base infix-interface-type;
|
||||
base ianaift:other;
|
||||
description "Linux dummy interface. Useful mostly for testing.";
|
||||
}
|
||||
identity ethernet {
|
||||
base infix-interface-type;
|
||||
base ianaift:ethernetCsmacd;
|
||||
|
||||
@@ -45,6 +45,9 @@ def json_get_yang_type(iface_in):
|
||||
if iface_in['linkinfo']['info_kind'] == "dsa":
|
||||
return "infix-if-type:ethernet"
|
||||
|
||||
if iface_in['linkinfo']['info_kind'] == "dummy":
|
||||
return "infix-if-type:dummy"
|
||||
|
||||
# Fallback
|
||||
return "infix-if-type:ethernet"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user