From: Mike Yuan Date: Sat, 28 Sep 2024 13:54:42 +0000 (+0200) Subject: core/manager: pass soft-reboot count to generators X-Git-Tag: v257-rc1~227^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=86eb3a8fdd4d11ddf3155743b05d3b2a2044009d;p=thirdparty%2Fsystemd.git core/manager: pass soft-reboot count to generators soft-reboot allows switching into a different root/installation, i.e. potentially invalidate settings from kernel cmdline and such. Let's hence inform generators about soft-reboots. --- diff --git a/man/systemd.generator.xml b/man/systemd.generator.xml index ae4c2c5c0b3..1a9b5d16530 100644 --- a/man/systemd.generator.xml +++ b/man/systemd.generator.xml @@ -163,6 +163,15 @@ + + $SYSTEMD_SOFT_REBOOTS_COUNT + + If the system has soft-rebooted, this variable is set to the count of soft-reboots. + This environment variable is only set for system generators. + + + + $SYSTEMD_FIRST_BOOT diff --git a/src/core/manager.c b/src/core/manager.c index 373f4d66e7b..b9ea79a7ada 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -4081,6 +4081,12 @@ static int build_generator_environment(Manager *m, char ***ret) { if (r < 0) return r; + if (m->soft_reboots_count > 0) { + r = strv_env_assignf(&nl, "SYSTEMD_SOFT_REBOOTS_COUNT", "%u", m->soft_reboots_count); + if (r < 0) + return r; + } + if (m->first_boot >= 0) { r = strv_env_assign(&nl, "SYSTEMD_FIRST_BOOT", one_zero(m->first_boot)); if (r < 0)