From 244db223638a3d69f7e33d67878c4f3aa8ea490b Mon Sep 17 00:00:00 2001 From: Peter Woxblom Date: Fri, 14 Aug 2026 18:15:44 +0200 Subject: [PATCH] confd: set IITO startup/failure conditions (fixes status LEDs) The product and common iitod.json configurations reference finit conditions /run/finit/cond/run/startup/success and /run/finit/cond/run/failure/{success,failure} to drive status LEDs, but nothing ever creates them, so the LEDs stay dark on every boot. confd already signals usr/bootstrap when startup applies; add the matching conditions for a clean startup and for the failure paths (fail-secure fallback and the fatal runlevel 9 case), which fixes LED behaviour on all boards. Co-authored-by: Jarvis (Hermes Agent) --- src/confd/src/main.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/confd/src/main.c b/src/confd/src/main.c index f679d9df6..f646a8ee7 100644 --- a/src/confd/src/main.c +++ b/src/confd/src/main.c @@ -49,6 +49,31 @@ */ #define SENTINEL_PATH "/run/confd.boot" +/* + * Set a finit condition, e.g. "run/startup/success", creating parent + * directories as needed. Used to signal IITO (and finit services) about + * the outcome of the bootstrap/startup sequence. + */ +static void set_finit_cond(const char *cond) +{ + char path[128]; + char *p; + + snprintf(path, sizeof(path), "/run/finit/cond/%s", cond); + + /* mkdir -p parent directories (e.g. /run/finit/cond/run/startup) */ + for (p = path + strlen("/run/finit/cond/"); *p; p++) { + if (*p == '/') { + *p = '\0'; + mkdir(path, 0755); + *p = '/'; + } + } + + if (symlink("/run/finit/cond/reconf", path) && errno != EEXIST) + WARN("Failed to set finit condition %s: %m", path); +} + /* Callback type names from sysrepo plugin API */ #define SRP_INIT_CB "sr_plugin_init_cb" #define SRP_CLEANUP_CB "sr_plugin_cleanup_cb" @@ -512,6 +537,7 @@ static void handle_startup_failure(sr_session_ctx_t *sess, const char *failure_p ERROR("sr_copy_config(factory-default) failed: %s", sr_strerror(r)); /* Nuclear option: wipe everything */ systemf("rm -f /etc/sysrepo/data/*startup* /etc/sysrepo/data/*running* /dev/shm/sr_*"); + set_finit_cond("run/failure/failure"); return; } @@ -521,11 +547,13 @@ static void handle_startup_failure(sr_session_ctx_t *sess, const char *failure_p ERROR("Failed loading failure-config, aborting!"); banner_append("CRITICAL ERROR: Logins are disabled, no credentials available"); systemf("initctl -nbq runlevel 9"); + set_finit_cond("run/failure/failure"); return; } } banner_append("ERROR: Corrupt startup-config, system has reverted to default login credentials"); + set_finit_cond("run/failure/success"); } /* @@ -843,6 +871,9 @@ int main(int argc, char **argv) /* Signal that bootstrap is complete (dbus, resolvconf depend on this) */ symlink("/run/finit/cond/reconf", "/run/finit/cond/usr/bootstrap"); + /* Signal IITO that startup applied cleanly (status LEDs) */ + set_finit_cond("run/startup/success"); + /* * Write restart sentinel. From this point on, sysrepo and the system * are in a consistent state. If confd exits for any reason (crash or