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.
This commit is contained in:
Mike Yuan 2024-09-28 15:54:42 +02:00
parent de41622bf3
commit 86eb3a8fdd
No known key found for this signature in database
GPG Key ID: 417471C0A40F58B3
2 changed files with 15 additions and 0 deletions

View File

@ -163,6 +163,15 @@
<xi:include href="version-info.xml" xpointer="v251"/></listitem>
</varlistentry>
<varlistentry>
<term><varname>$SYSTEMD_SOFT_REBOOTS_COUNT</varname></term>
<listitem><para>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.</para>
<xi:include href="version-info.xml" xpointer="v257"/></listitem>
</varlistentry>
<varlistentry>
<term><varname>$SYSTEMD_FIRST_BOOT</varname></term>

View File

@ -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)