From d9f2f2c8f961a0b8e39c7dde4fe9a45f351715a7 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 13 Feb 2025 07:16:02 +0100 Subject: [PATCH 1/2] confd: refactor core_post_hook() - Reduce complexity - Change type, simplify - Allow errors from initctl Signed-off-by: Joachim Wiberg --- src/confd/src/core.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/confd/src/core.c b/src/confd/src/core.c index ccd2d681..c2c98865 100644 --- a/src/confd/src/core.c +++ b/src/confd/src/core.c @@ -56,7 +56,7 @@ int core_pre_hook(sr_session_ctx_t *session, uint32_t sub_id, const char *module int core_post_hook(sr_session_ctx_t *session, uint32_t sub_id, const char *module, const char *xpath, sr_event_t event, unsigned request_id, void *priv) { - static int num_changes = 0; + static size_t num_changes = 0; switch (event) { case SR_EV_CHANGE: @@ -66,15 +66,10 @@ int core_post_hook(sr_session_ctx_t *session, uint32_t sub_id, const char *modul num_changes = 0; return SR_ERR_OK; case SR_EV_DONE: - if (num_changes <= 0) { - ERROR("BUG in core_post_hook(): callback tracking out of sync"); - abort(); - } - - if (--num_changes == 0) - break; - - return SR_ERR_OK; + num_changes--; + if (num_changes > 0) + return SR_ERR_OK; + break; default: ERROR("core_post_hook() should not be called with event %s", ev2str(event)); return SR_ERR_SYS; @@ -87,7 +82,7 @@ int core_post_hook(sr_session_ctx_t *session, uint32_t sub_id, const char *modul if (systemf("runlevel >/dev/null 2>&1")) return SR_ERR_OK; - if (systemf("initctl -nbq reload")) + if (systemf("initctl -b reload")) return SR_ERR_SYS; return SR_ERR_OK; From 6f99a9c2dce5ce8d1518d5a6a209c86fff4accb8 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 14 Feb 2025 13:47:41 +0100 Subject: [PATCH 2/2] package/finit: bump to v4.9 Primarily fixes issue with DHCP server multiple subnets test, which triggers an ordering issue between reconfiguration of dnsmasq and the `initctl reload` command. For the full ChangeLog, please see: https://github.com/troglobit/finit/releases/tag/4.9 Signed-off-by: Joachim Wiberg --- ...rdeps-dirty-if-main-service-is-nohup.patch | 67 ----- ...ibutes-and-clear-screen-when-startin.patch | 33 --- .../finit/0003-plugins-refactor-rtc.so.patch | 196 -------------- ...18-support-systems-with-a-broken-RTC.patch | 239 ------------------ ...tc-date-DATE-introduced-in-Finit-v4..patch | 73 ------ ...reduce-log-level-LOG_ERR-LOG_WARNING.patch | 85 ------- ...ntended-restart-of-template-siblings.patch | 57 ----- package/finit/finit.hash | 2 +- package/finit/finit.mk | 2 +- 9 files changed, 2 insertions(+), 752 deletions(-) delete mode 100644 package/finit/0001-Only-mark-rdeps-dirty-if-main-service-is-nohup.patch delete mode 100644 package/finit/0002-Reset-color-attributes-and-clear-screen-when-startin.patch delete mode 100644 package/finit/0003-plugins-refactor-rtc.so.patch delete mode 100644 package/finit/0004-Fix-418-support-systems-with-a-broken-RTC.patch delete mode 100644 package/finit/0005-Fix-buggy-with-rtc-date-DATE-introduced-in-Finit-v4..patch delete mode 100644 package/finit/0006-plugins-reduce-log-level-LOG_ERR-LOG_WARNING.patch delete mode 100644 package/finit/0007-Fix-unintended-restart-of-template-siblings.patch diff --git a/package/finit/0001-Only-mark-rdeps-dirty-if-main-service-is-nohup.patch b/package/finit/0001-Only-mark-rdeps-dirty-if-main-service-is-nohup.patch deleted file mode 100644 index 13e58c4c..00000000 --- a/package/finit/0001-Only-mark-rdeps-dirty-if-main-service-is-nohup.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 46ffa81f5c88ce95db011369d8bfb802313e4217 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Thu, 17 Oct 2024 14:23:24 +0200 -Subject: [PATCH 1/7] Only mark rdeps dirty if main service is nohup -Organization: Addiva Elektronik - -This patch changes a behavior that's been default since Finit 4.0, -introduced in 4d05bf9 with 4.0-rc2. - -If service B depends on A and A needs to be reloaded, then B may be -affected. If A is declared as NOHUP , then A will be stopped and -restarted, during which time the condition it provides is removed, -and B will also be stopped. - -However, and as of this patch, if A is declared supporting HUP, then the -condition A provides will only go into flux, during which time B will be -SIGSTOPed instead of needing to be reloaded. - -Fix #415 - -Signed-off-by: Joachim Wiberg ---- - src/service.c | 8 ++++++++ - src/svc.h | 1 + - 2 files changed, 9 insertions(+) - -diff --git a/src/service.c b/src/service.c -index 61be85c..b995ff4 100644 ---- a/src/service.c -+++ b/src/service.c -@@ -2001,6 +2001,10 @@ static void svc_mark_affected(char *cond) - * Called on conf_reload() to update service reverse dependencies. - * E.g., if ospfd depends on zebra and the zebra Finit conf has - * changed, we need to mark the ospfd Finit conf as changed too. -+ * -+ * However, a daemon that depends on syslogd (sysklogd project), need -+ * not be reloeaded (SIGHUP'ed or stop/started) because syslogd support -+ * reloading its configuration file on SIGHUP. - */ - void service_update_rdeps(void) - { -@@ -2012,6 +2016,10 @@ void service_update_rdeps(void) - if (!svc_is_changed(svc)) - continue; - -+ /* Service supports reloading conf without stop/start */ -+ if (!svc_is_nohup(svc)) -+ continue; /* Yup, no need to stop start rdeps */ -+ - svc_mark_affected(mkcond(svc, cond, sizeof(cond))); - } - } -diff --git a/src/svc.h b/src/svc.h -index d00ac14..e2f6bd8 100644 ---- a/src/svc.h -+++ b/src/svc.h -@@ -259,6 +259,7 @@ static inline int svc_is_tty (svc_t *svc) { return svc && SVC_TYPE_TTY - static inline int svc_is_runtask (svc_t *svc) { return svc && (SVC_TYPE_RUNTASK & svc->type);} - static inline int svc_is_forking (svc_t *svc) { return svc && svc->forking; } - static inline int svc_is_manual (svc_t *svc) { return svc && svc->manual; } -+static inline int svc_is_nohup (svc_t *svc) { return svc && (0 == svc->sighup); } - - static inline int svc_in_runlevel (svc_t *svc, int runlevel) { return svc && ISSET(svc->runlevels, runlevel); } - static inline int svc_nohup (svc_t *svc) { return svc && (0 == svc->sighup || 0 != svc->args_dirty); } --- -2.43.0 - diff --git a/package/finit/0002-Reset-color-attributes-and-clear-screen-when-startin.patch b/package/finit/0002-Reset-color-attributes-and-clear-screen-when-startin.patch deleted file mode 100644 index 3deb81f2..00000000 --- a/package/finit/0002-Reset-color-attributes-and-clear-screen-when-startin.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 119e66a7e9c95283918639b51dd03a3d666955f8 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Mon, 28 Oct 2024 10:58:04 +0100 -Subject: [PATCH 2/7] Reset color attributes and clear screen when starting up -Organization: Addiva Elektronik - -Some boot loaders, like GRUB, leave background color artifacts from -their boot menu. This patch resets the foreground and background -color attributes, and then clears the screen, without clearing the -scrollback buffer. - -Signed-off-by: Joachim Wiberg ---- - src/helpers.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/src/helpers.c b/src/helpers.c -index 8768de8..99c4557 100644 ---- a/src/helpers.c -+++ b/src/helpers.c -@@ -87,6 +87,9 @@ void console_init(void) - /* Enable line wrap, if disabled previously, e.g., qemu */ - dprint(STDOUT_FILENO, "\033[?7h", 5); - -+ /* Reset atttributes, background and foreground color */ -+ dprint(STDOUT_FILENO, "\033[49m\033[39m\e[2J", 14); -+ - log_init(); - } - --- -2.43.0 - diff --git a/package/finit/0003-plugins-refactor-rtc.so.patch b/package/finit/0003-plugins-refactor-rtc.so.patch deleted file mode 100644 index 6d9cdfb2..00000000 --- a/package/finit/0003-plugins-refactor-rtc.so.patch +++ /dev/null @@ -1,196 +0,0 @@ -From 0c0e880f3fdd38f7bbde618408378dc0a19ff005 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Sun, 3 Nov 2024 09:39:46 +0100 -Subject: [PATCH 3/7] plugins: refactor rtc.so -Organization: Addiva Elektronik - -Factor out time_set() and time_get() for readability and reuse. - -Signed-off-by: Joachim Wiberg ---- - plugins/rtc.c | 116 +++++++++++++++++++++++++++++--------------------- - 1 file changed, 68 insertions(+), 48 deletions(-) - -diff --git a/plugins/rtc.c b/plugins/rtc.c -index 238791f..9520c7d 100644 ---- a/plugins/rtc.c -+++ b/plugins/rtc.c -@@ -68,6 +68,60 @@ static void tz_restore(char *tz) - tzset(); - } - -+static int time_set(struct tm *tm) -+{ -+ struct tm fallback = { 0 }; -+ struct timeval tv = { 0 }; -+ char tz[128]; -+ int rc = 0; -+ -+ tz_set(tz, sizeof(tz)); -+ -+ if (!tm) { -+ logit(LOG_NOTICE, "Resetting system clock to kernel default, %s.", rtc_timestamp); -+ tm = &fallback; -+ -+ /* Attempt to set RTC to a sane value ... */ -+ tv.tv_sec = rtc_date_fallback; -+ if (!gmtime_r(&tv.tv_sec, tm)) { -+ rc = 1; -+ goto out; -+ } -+ } -+ -+ 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) { -+ errno = EINVAL; -+ rc = 2; -+ } else { -+ if (settimeofday(&tv, NULL) == -1) -+ rc = 1; -+ } -+out: -+ tz_restore(tz); -+ return rc; -+} -+ -+static int time_get(struct tm *tm) -+{ -+ struct timeval tv = { 0 }; -+ char tz[128]; -+ int rc = 0; -+ -+ tz_set(tz, sizeof(tz)); -+ -+ rc = gettimeofday(&tv, NULL); -+ if (rc < 0 || tv.tv_sec < rtc_date_fallback) -+ rc = 2; -+ else -+ gmtime_r(&tv.tv_sec, tm); -+ -+ tz_restore(tz); -+ -+ return rc; -+} -+ - static int rtc_open(void) - { - char *alt[] = { -@@ -91,10 +145,8 @@ static int rtc_open(void) - - static void rtc_save(void *arg) - { -- struct timeval tv = { 0 }; - struct tm tm = { 0 }; - int fd, rc = 0; -- char tz[128]; - - if (rescue) { - dbg("Skipping %s plugin in rescue mode.", __FILE__); -@@ -105,38 +157,26 @@ static void rtc_save(void *arg) - if (fd < 0) - return; - -- tz_set(tz, sizeof(tz)); -- rc = gettimeofday(&tv, NULL); -- if (rc < 0 || tv.tv_sec < rtc_date_fallback) { -+ if ((rc = time_get(&tm))) { - print_desc(NULL, "System clock invalid, not saving to RTC"); -- invalid: -- logit(LOG_ERR, "System clock invalid, before %s, not saving to RTC", rtc_timestamp); -- rc = 2; -- goto out; -+ } else { -+ print_desc(NULL, "Saving system clock (UTC) to RTC"); -+ rc = ioctl(fd, RTC_SET_TIME, &tm); - } - -- print_desc(NULL, "Saving system time (UTC) to RTC"); -- -- gmtime_r(&tv.tv_sec, &tm); -- if (ioctl(fd, RTC_SET_TIME, &tm) < 0) { -- if (EINVAL == errno) -- goto invalid; -- rc = 1; -- goto out; -+ if (rc && errno == EINVAL) { -+ logit(LOG_ERR, "System clock invalid, before %s, not saving to RTC", rtc_timestamp); -+ rc = 2; - } - --out: -- tz_restore(tz); - print(rc, NULL); - close(fd); - } - - static void rtc_restore(void *arg) - { -- struct timeval tv = { 0 }; - struct tm tm = { 0 }; - int fd, rc = 0; -- char tz[128]; - - if (rescue) { - dbg("Skipping %s plugin in rescue mode.", __FILE__); -@@ -149,16 +189,19 @@ static void rtc_restore(void *arg) - return; - } - -- tz_set(tz, sizeof(tz)); -- if (ioctl(fd, RTC_RD_TIME, &tm) < 0) { -+ if ((rc = ioctl(fd, RTC_RD_TIME, &tm)) < 0) { - char msg[120]; - - snprintf(msg, sizeof(msg), "Failed restoring system clock, %s", - EINVAL == errno ? "RTC time is too old" : - ENOENT == errno ? "RTC has no saved time" : "see log for details"); - print_desc(NULL, msg); -+ } else { -+ print_desc(NULL, "Restoring system clock (UTC) from RTC"); -+ rc = time_set(&tm); -+ } - -- invalid: -+ if (rc) { - logit(LOG_ERR, "Failed restoring system clock from RTC."); - if (EINVAL == errno) - logit(LOG_ERR, "RTC time is too old (before %s)", rtc_timestamp); -@@ -167,33 +210,10 @@ static void rtc_restore(void *arg) - else - logit(LOG_ERR, "RTC error code %d: %s", errno, strerror(errno)); - -- /* Been here already? */ -- if (rc) -- goto out; -- -- /* Attempt to set RTC to a sane value ... */ -- tv.tv_sec = rtc_date_fallback; -- if (!gmtime_r(&tv.tv_sec, &tm)) -- goto out; -- -- logit(LOG_NOTICE, "Resetting RTC to kernel default, %s.", rtc_timestamp); -+ time_set(NULL); - rc = 2; - } - -- 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) { -- errno = EINVAL; -- goto invalid; -- } -- -- if (settimeofday(&tv, NULL) == -1) -- rc = 1; -- --out: -- tz_restore(tz); - print(rc, NULL); - close(fd); - } --- -2.43.0 - diff --git a/package/finit/0004-Fix-418-support-systems-with-a-broken-RTC.patch b/package/finit/0004-Fix-418-support-systems-with-a-broken-RTC.patch deleted file mode 100644 index ff03acbb..00000000 --- a/package/finit/0004-Fix-418-support-systems-with-a-broken-RTC.patch +++ /dev/null @@ -1,239 +0,0 @@ -From bc8118d515839dc598f437aa01f07a771646968d Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Sun, 3 Nov 2024 09:47:16 +0100 -Subject: [PATCH 4/7] Fix #418: support systems with a broken RTC -Organization: Addiva Elektronik - -This patch introduces a new configure option --with-rtc-file=FILE. When -enabled the RTC plugin detects missing RTC device and falls back to save -and restore system time from a file instead. When --with-rtc-file is -used without an argument the default file is /var/lib/misc/rtc, but the -feature itself is disabled by default. - -The usefulness of this feature may not be obvious at first, but some -systems are equipped with an RTC that resets to a random date at power -on. This can be really bad in the case the date is far in the future, -because an NTP sync would then cause time skips backwards, which shows -up in logs and causes a whole lot of pain in alarm systems. - -The solution is to disable the RTC driver or device tree node, and when -Finit starts up, the RTC plugin detects a the device node and instead -restores time from the last save game. Meaning time will always only -move forwards. - -NOTE: when Finit is built --with-rtc-file we always save to disk, but - only restore from the "save game" if restoring from RTC fails. - If the system has no RTC we always restore from disk. - - As an added bonus, this change also makes sure to periodically - sync also the RTC with the system clock. Useful for systems - that do not run an NTP client. - -Signed-off-by: Joachim Wiberg ---- - configure.ac | 12 ++++++ - plugins/rtc.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++---- - 2 files changed, 110 insertions(+), 7 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 483457f..ae7cd23 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -180,6 +180,10 @@ AC_ARG_WITH(rtc-date, - AS_HELP_STRING([--with-rtc-date=DATE], [If RTC date/time is too old, restore to DATE, format "YYYY-MM-DD HH:MM", default "2000-01-01 00:00"]), - [rtc_date=$withval], [rtc_date=no]) - -+AC_ARG_WITH(rtc-file, -+ AS_HELP_STRING([--with-rtc-file=FILE], [If RTC is missing, save and restore system clock from this file, default: no]), -+ [rtc_file=$withval], [rtc_file=no]) -+ - ### Enable features ########################################################################### - - # Create config.h from selected features and fallback defaults -@@ -281,6 +285,13 @@ AS_IF([test "x$rtc_date" != "xno"], [ - AC_DEFINE(RTC_TIMESTAMP_CUSTOM, "$rtc_date", [Custom RTC restore date, default: 2000-01-01 00:00])], [ - rtc_date=""]) - -+AS_IF([test "x$rtc_file" != "xno"], [ -+ AS_IF([test "x$rtc_file" = "xyes"], [ -+ rtc_file=/var/lib/misc/rtc]) -+ AC_EXPAND_DIR(rtcfile_path, "$rtc_file") -+ AC_DEFINE_UNQUOTED(RTC_FILE, "$rtcfile_path", [Save and restore system time from this file if /dev/rtc is missing.])],[ -+ AC_DEFINE_UNQUOTED(RTC_FILE, NULL)]) -+ - AS_IF([test "x$with_keventd" != "xno"], [with_keventd=yes]) - - AS_IF([test "x$with_sulogin" != "xno"], [ -@@ -387,6 +398,7 @@ Behavior: - Boot heading..........: $heading - Plugins...............: $plugins - RTC restore date......: $RTC_DATE -+ RTC fallback file.....: $rtc_file - - Optional features: - Install doc/..........: $enable_doc -diff --git a/plugins/rtc.c b/plugins/rtc.c -index 9520c7d..9b4eeae 100644 ---- a/plugins/rtc.c -+++ b/plugins/rtc.c -@@ -36,8 +36,15 @@ - #include "helpers.h" - #include "plugin.h" - --/* Kernel RTC driver validates against this date for sanity check */ -+/* -+ * Kernel RTC driver validates against this date for sanity check. The -+ * on NTP sync the driver can also update the RTC every 11 mins. We use -+ * the same update interval to handle manual time set and file save. -+ */ - #define RTC_TIMESTAMP_BEGIN_2000 "2000-01-01 00:00:00" -+#define RTC_FMT "%Y-%m-%d %H:%M:%S" -+#define RTC_PERIOD (11 * 60 * 1000) -+ - #ifdef RTC_TIMESTAMP_CUSTOM - static char *rtc_timestamp = RTC_TIMESTAMP_CUSTOM; - #else -@@ -45,6 +52,10 @@ static char *rtc_timestamp = RTC_TIMESTAMP_BEGIN_2000; - #endif - static time_t rtc_date_fallback = 946684800LL; - -+static char *rtc_file = RTC_FILE; -+static uev_t rtc_timer; -+ -+ - static void tz_set(char *tz, size_t len) - { - char *ptr; -@@ -122,6 +133,68 @@ static int time_get(struct tm *tm) - return rc; - } - -+static void file_save(void *arg) -+{ -+ struct tm tm = { 0 }; -+ int rc = 0; -+ FILE *fp; -+ -+ fp = fopen(rtc_file, "w"); -+ if (!fp) { -+ logit(LOG_WARNING, "Failed saving system clock to %s, code %d: %s", -+ rtc_file, errno, strerror(errno)); -+ return; -+ } -+ -+ if ((rc = time_get(&tm))) { -+ logit(LOG_ERR, "System clock invalid, before %s, not saving", rtc_timestamp); -+ print_desc(NULL, "System clock invalid, skipping"); -+ } else { -+ char buf[32] = { 0 }; -+ -+ print_desc(NULL, "Saving system clock to file"); -+ strftime(buf, sizeof(buf), RTC_FMT, &tm); -+ fprintf(fp, "%s\n", buf); -+ } -+ -+ print(rc, NULL); -+ fclose(fp); -+} -+ -+static void file_restore(void *arg) -+{ -+ struct tm tm = { 0 }; -+ int rc = 1; -+ FILE *fp; -+ -+ if (!rtc_file) { -+ logit(LOG_NOTICE, "System has no RTC (missing driver?), skipping restore."); -+ return; -+ } -+ -+ print_desc(NULL, "Restoring system clock from backup"); -+ -+ fp = fopen(rtc_file, "r"); -+ if (fp) { -+ char buf[32]; -+ -+ if (fgets(buf, sizeof(buf), fp)) { -+ chomp(buf); -+ strptime(buf, RTC_FMT, &tm); -+ rc = time_set(&tm); -+ } -+ fclose(fp); -+ } else -+ logit(LOG_WARNING, "Missing %s", rtc_file); -+ -+ if (rc) { -+ time_set(NULL); -+ rc = 2; -+ } -+ -+ print(rc, NULL); -+} -+ - static int rtc_open(void) - { - char *alt[] = { -@@ -185,7 +258,7 @@ static void rtc_restore(void *arg) - - fd = rtc_open(); - if (fd < 0) { -- logit(LOG_NOTICE, "System has no RTC (missing driver?), skipping restore."); -+ file_restore(arg); - return; - } - -@@ -210,21 +283,37 @@ static void rtc_restore(void *arg) - else - logit(LOG_ERR, "RTC error code %d: %s", errno, strerror(errno)); - -- time_set(NULL); -- rc = 2; -- } -+ print(2, NULL); -+ -+ /* Try restoring from last save game */ -+ if (rtc_file) -+ file_restore(arg); -+ } else -+ print(0, NULL); - -- print(rc, NULL); - close(fd); - } - -+ -+static void save(void *arg) -+{ -+ rtc_save(arg); -+ file_save(arg); -+} -+ -+static void update(uev_t *w, void *arg, int events) -+{ -+ save(arg); -+} -+ -+ - static plugin_t plugin = { - .name = __FILE__, - .hook[HOOK_BASEFS_UP] = { - .cb = rtc_restore - }, - .hook[HOOK_SHUTDOWN] = { -- .cb = rtc_save -+ .cb = save - } - }; - -@@ -237,6 +326,8 @@ PLUGIN_INIT(plugin_init) - else - rtc_timestamp = RTC_TIMESTAMP_BEGIN_2000; - -+ uev_timer_init(ctx, &rtc_timer, update, NULL, RTC_PERIOD, RTC_PERIOD); -+ - plugin_register(&plugin); - } - --- -2.43.0 - diff --git a/package/finit/0005-Fix-buggy-with-rtc-date-DATE-introduced-in-Finit-v4..patch b/package/finit/0005-Fix-buggy-with-rtc-date-DATE-introduced-in-Finit-v4..patch deleted file mode 100644 index 7da579d5..00000000 --- a/package/finit/0005-Fix-buggy-with-rtc-date-DATE-introduced-in-Finit-v4..patch +++ /dev/null @@ -1,73 +0,0 @@ -From 6be16f2f6d093ef495d0fe4313f7b05b4ba3e08f Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Sun, 3 Nov 2024 10:38:38 +0100 -Subject: [PATCH 5/7] Fix buggy --with-rtc-date=DATE, introduced in Finit v4.4 -Organization: Addiva Elektronik - -In 42ef3d3c, for v4.4-rc1, support for setting a custom RTC restore date -was introduced. Unfortunately the configure script was wrong and caused -config.h to contain - - #define RTC_TIMESTAMP_CUSTOM "$rtc_date" - -instead of - - #define RTC_TIMESTAMP_CUSTOM "2023-04-10 14:35:42" - -Furthermore, the error handling for strptime() was wrong, so the restore -date was always reverted to the default. - -This patch fixes both issues and extends the DATE of --with-rtc-date to -also include seconds. - -Signed-off-by: Joachim Wiberg ---- - configure.ac | 4 ++-- - plugins/rtc.c | 8 +++++--- - 2 files changed, 7 insertions(+), 5 deletions(-) - -diff --git a/configure.ac b/configure.ac -index ae7cd23..58b78ac 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -177,7 +177,7 @@ AC_ARG_WITH(plugin-path, - [plugin_path=$withval], [plugin_path=yes]) - - AC_ARG_WITH(rtc-date, -- AS_HELP_STRING([--with-rtc-date=DATE], [If RTC date/time is too old, restore to DATE, format "YYYY-MM-DD HH:MM", default "2000-01-01 00:00"]), -+ AS_HELP_STRING([--with-rtc-date=DATE], [If RTC date/time is too old, restore to DATE, format "YYYY-MM-DD HH:MM:SS", default "2000-01-01 00:00:00"]), - [rtc_date=$withval], [rtc_date=no]) - - AC_ARG_WITH(rtc-file, -@@ -282,7 +282,7 @@ AS_IF([test "x$with_random_seed" != "xno"], [ - AC_DEFINE_UNQUOTED(RANDOMSEED, "$random_path", [Improve random at boot by seeding it with sth from before.])]) - - AS_IF([test "x$rtc_date" != "xno"], [ -- AC_DEFINE(RTC_TIMESTAMP_CUSTOM, "$rtc_date", [Custom RTC restore date, default: 2000-01-01 00:00])], [ -+ AC_DEFINE_UNQUOTED(RTC_TIMESTAMP_CUSTOM, "$rtc_date", [Custom RTC restore date, default: 2000-01-01 00:00])], [ - rtc_date=""]) - - AS_IF([test "x$rtc_file" != "xno"], [ -diff --git a/plugins/rtc.c b/plugins/rtc.c -index 9b4eeae..a733f75 100644 ---- a/plugins/rtc.c -+++ b/plugins/rtc.c -@@ -321,10 +321,12 @@ PLUGIN_INIT(plugin_init) - { - struct tm tm = { 0 }; - -- if (!strptime(rtc_timestamp, "%Y-%m-%d %H:%M", &tm)) -- rtc_date_fallback = mktime(&tm); -- else -+ if (!strptime(rtc_timestamp, RTC_FMT, &tm)) { -+ logit(LOG_ERR, "Invalid restore date '%s', reverting to '%s'", -+ rtc_timestamp, RTC_TIMESTAMP_BEGIN_2000); - rtc_timestamp = RTC_TIMESTAMP_BEGIN_2000; -+ } else -+ rtc_date_fallback = mktime(&tm); - - uev_timer_init(ctx, &rtc_timer, update, NULL, RTC_PERIOD, RTC_PERIOD); - --- -2.43.0 - diff --git a/package/finit/0006-plugins-reduce-log-level-LOG_ERR-LOG_WARNING.patch b/package/finit/0006-plugins-reduce-log-level-LOG_ERR-LOG_WARNING.patch deleted file mode 100644 index e8dca597..00000000 --- a/package/finit/0006-plugins-reduce-log-level-LOG_ERR-LOG_WARNING.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 49c0557cedd8d3c1a2f74d27fa7db83dd529914a Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Sun, 3 Nov 2024 20:49:04 +0100 -Subject: [PATCH 6/7] plugins: reduce log level LOG_ERR -> LOG_WARNING -Organization: Addiva Elektronik - -These plugins signal success and failure directly to the console, the -user should inspect syslog for more information. - -This change is a follow-up to 340cae4, where kernel logs of LOG_ERR and -higher are allowed to log directly to the console. Since syslogd has -not been started before these plugins, the log messages would otherwise -leak to the console. - -Signed-off-by: Joachim Wiberg ---- - plugins/rtc.c | 14 +++++++------- - plugins/urandom.c | 2 +- - 2 files changed, 8 insertions(+), 8 deletions(-) - -diff --git a/plugins/rtc.c b/plugins/rtc.c -index a733f75..96203a0 100644 ---- a/plugins/rtc.c -+++ b/plugins/rtc.c -@@ -147,7 +147,7 @@ static void file_save(void *arg) - } - - if ((rc = time_get(&tm))) { -- logit(LOG_ERR, "System clock invalid, before %s, not saving", rtc_timestamp); -+ logit(LOG_WARNING, "System clock invalid, before %s, not saving", rtc_timestamp); - print_desc(NULL, "System clock invalid, skipping"); - } else { - char buf[32] = { 0 }; -@@ -238,7 +238,7 @@ static void rtc_save(void *arg) - } - - if (rc && errno == EINVAL) { -- logit(LOG_ERR, "System clock invalid, before %s, not saving to RTC", rtc_timestamp); -+ logit(LOG_WARNING, "System clock invalid, before %s, not saving to RTC", rtc_timestamp); - rc = 2; - } - -@@ -275,13 +275,13 @@ static void rtc_restore(void *arg) - } - - if (rc) { -- logit(LOG_ERR, "Failed restoring system clock from RTC."); -+ logit(LOG_WARNING, "Failed restoring system clock from RTC."); - if (EINVAL == errno) -- logit(LOG_ERR, "RTC time is too old (before %s)", rtc_timestamp); -+ logit(LOG_WARNING, "RTC time is too old (before %s)", rtc_timestamp); - else if (ENOENT == errno) -- logit(LOG_ERR, "RTC has no previously saved (valid) time."); -+ logit(LOG_WARNING, "RTC has no previously saved (valid) time."); - else -- logit(LOG_ERR, "RTC error code %d: %s", errno, strerror(errno)); -+ logit(LOG_WARNING, "RTC error code %d: %s", errno, strerror(errno)); - - print(2, NULL); - -@@ -322,7 +322,7 @@ PLUGIN_INIT(plugin_init) - struct tm tm = { 0 }; - - if (!strptime(rtc_timestamp, RTC_FMT, &tm)) { -- logit(LOG_ERR, "Invalid restore date '%s', reverting to '%s'", -+ logit(LOG_WARNING, "Invalid restore date '%s', reverting to '%s'", - rtc_timestamp, RTC_TIMESTAMP_BEGIN_2000); - rtc_timestamp = RTC_TIMESTAMP_BEGIN_2000; - } else -diff --git a/plugins/urandom.c b/plugins/urandom.c -index b9f6039..6f82779 100644 ---- a/plugins/urandom.c -+++ b/plugins/urandom.c -@@ -154,7 +154,7 @@ static void setup(void *arg) - close(fd); - free(rpi); - if (rc < 0) -- logit(LOG_ERR, "Failed adding entropy to kernel random pool: %s", strerror(err)); -+ logit(LOG_WARNING, "Failed adding entropy to kernel random pool: %s", strerror(err)); - print_result(rc < 0); - return; - fallback: --- -2.43.0 - diff --git a/package/finit/0007-Fix-unintended-restart-of-template-siblings.patch b/package/finit/0007-Fix-unintended-restart-of-template-siblings.patch deleted file mode 100644 index 96233b37..00000000 --- a/package/finit/0007-Fix-unintended-restart-of-template-siblings.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 465bc17ca4b131f8c1ef27ff8279f4ea13745a78 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Thu, 28 Nov 2024 11:06:57 +0100 -Subject: [PATCH 7/7] Fix unintended restart of template siblings -Organization: Addiva Elektronik - -Consider the case where container@.conf is an available template. When -creating a container@foo.conf it will share the same base .conf as an -existing container@bar.conf, but we do not expect to restart bar just -because foo is instantiated. - -Up until this change, all template siblings were considered "dirty" if a -new one was created or updated. Skipping realpath() for all files that -have a '@' works around the problem. - -Signed-off-by: Joachim Wiberg ---- - src/conf.c | 20 +++++++++++++------- - 1 file changed, 13 insertions(+), 7 deletions(-) - -diff --git a/src/conf.c b/src/conf.c -index 1cfcd87..531923c 100644 ---- a/src/conf.c -+++ b/src/conf.c -@@ -1432,16 +1432,22 @@ static int conf_change_act(char *dir, char *name, uint32_t mask) - strlcpy(fn, dir, sizeof(fn)); - dbg("path: %s mask: %08x", fn, mask); - -- /* Handle disabling/removal of service */ -- rp = realpath(fn, NULL); -- if (!rp) { -- if (errno != ENOENT) -- goto fail; -+ if (strchr(name, '@')) { -+ /* Skip realpath for templates */ - rp = strdup(fn); -- if (!rp) -- goto fail; -+ } else { -+ /* Handle disabling/removal of service */ -+ rp = realpath(fn, NULL); -+ if (!rp) { -+ if (errno != ENOENT) -+ goto fail; -+ rp = strdup(fn); -+ } - } - -+ if (!rp) -+ goto fail; -+ - node = conf_find(rp); - if (node) { - dbg("event already registered for %s ...", name); --- -2.43.0 - diff --git a/package/finit/finit.hash b/package/finit/finit.hash index 13ecb597..1a545235 100644 --- a/package/finit/finit.hash +++ b/package/finit/finit.hash @@ -1,5 +1,5 @@ # From https://github.com/troglobit/finit/releases/ -sha256 5026965e33f31b8fa4e2e465b9521e805fa01c31cade884c07d0fcff97cd0ddf finit-4.8.tar.gz +sha256 7e4efaa4c165aabaf145ac3e6ae2ac907209e69758f4892c83cfccc579876c27 finit-4.9.tar.gz # Locally calculated sha256 2fd62c0fe6ea6d1861669f4c87bda83a0b5ceca64f4baa4d16dd078fbd218c14 LICENSE diff --git a/package/finit/finit.mk b/package/finit/finit.mk index ee828a44..987c1945 100644 --- a/package/finit/finit.mk +++ b/package/finit/finit.mk @@ -4,7 +4,7 @@ # ################################################################################ -FINIT_VERSION = 4.8 +FINIT_VERSION = 4.9 FINIT_SITE = https://github.com/troglobit/finit/releases/download/$(FINIT_VERSION) FINIT_LICENSE = MIT FINIT_LICENSE_FILES = LICENSE