]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
condition: allow overriding of ConditionNeedsUpdate= on the kernel command line
authorLennart Poettering <lennart@poettering.net>
Thu, 14 May 2020 07:55:57 +0000 (09:55 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 18 May 2020 18:17:57 +0000 (20:17 +0200)
This should be useful for addressing #15724.

man/kernel-command-line.xml
man/systemd-update-done.service.xml
man/systemd.unit.xml
src/shared/condition.c

index 4aac14ea180c8bf39961b3dc231ea6606888350b..b0cc3fea01c65fdf5c9b9078f03e0f4dec3dc9d5 100644 (file)
         will not query the user for basic system settings, even if the system boots up for the first time and the
         relevant settings are not initialized yet.</para></listitem>
       </varlistentry>
+
+      <varlistentry>
+        <term><varname>systemd.condition-needs-update=</varname></term>
+
+        <listitem><para>Takes a boolean argument. If specified, overrides the result of
+        <varname>ConditionNeedsUpdate=</varname> unit condition checks. See
+        <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
+        details.</para></listitem>
+      </varlistentry>
     </variablelist>
 
   </refsect1>
index ad412691a946847c39d1ae09cc501969aed5d3be..91196dff301fb92ce9cab3b2a82ac8a627b82495 100644 (file)
     <citerefentry project='man-pages'><refentrytitle>touch</refentrytitle><manvolnum>1</manvolnum></citerefentry>
     on it.</para>
 
+    <para>Note that if the <varname>systemd.condition-needs-update=</varname> kernel command line option is
+    used it overrides the <varname>ConditionNeedsUpdate=</varname> unit condition checks. In that case
+    <filename>systemd-update-done.service</filename> will not reset the condition state until a follow-up
+    reboot where the kernel switch is not specified anymore.</para>
   </refsect1>
 
   <refsect1>
index b91c1ad0ecca64919166fbe93562f9befdaa23cc..e8563bcc0a08e59d285f459702d90b6355814192 100644 (file)
           <citerefentry><refentrytitle>systemd-update-done.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
           to make sure they run before the stamp file's modification time gets reset indicating a completed
           update.</para>
+
+          <para>If the <varname>systemd.condition-needs-update=</varname> option is specified on the kernel
+          command line (taking a boolean), it will override the result of this condition check, taking
+          precedence over any file modification time checks. If it is used
+          <filename>systemd-update-done.service</filename> will not have immediate effect on any following
+          <varname>ConditionNeedsUpdate=</varname> checks, until the system is rebooted where the kernel
+          command line option is not specified anymore.</para>
           </listitem>
         </varlistentry>
 
index 2d9702d87320617c335920d84d72a1ce08b6b9c9..2e29d4cca7055008b4cd7253507b6dca90528814 100644 (file)
@@ -548,12 +548,19 @@ static int condition_test_capability(Condition *c, char **env) {
 static int condition_test_needs_update(Condition *c, char **env) {
         struct stat usr, other;
         const char *p;
+        bool b;
         int r;
 
         assert(c);
         assert(c->parameter);
         assert(c->type == CONDITION_NEEDS_UPDATE);
 
+        r = proc_cmdline_get_bool("systemd.condition-needs-update", &b);
+        if (r < 0)
+                log_debug_errno(r, "Failed to parse systemd.condition-needs-update= kernel command line argument, ignoring: %m");
+        if (r > 0)
+                return b;
+
         if (!path_is_absolute(c->parameter)) {
                 log_debug("Specified condition parameter '%s' is not absolute, assuming an update is needed.", c->parameter);
                 return true;