]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
condition: change ConditionKernelVersion= so that =/!= mean literal string comparison...
authorLennart Poettering <lennart@poettering.net>
Mon, 29 Aug 2022 11:27:11 +0000 (13:27 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 1 Sep 2022 21:16:13 +0000 (23:16 +0200)
The only reason to do this is to ensure uniformity with the other
options, that work like this, i.e. ConditionOSRelease= or
ConditionSecurity=.

This is a compatibility break, but a minor one, given that string
comparison and version comparison is mostly the same for equality and
inequality.

man/systemd.unit.xml
src/shared/condition.c

index 9dd02c3060413a8b84137f0df2fedbd315892776..16aa8303e799dcf27b68d091eb4c2450ebd31c17 100644 (file)
           <listitem><para><varname>ConditionKernelVersion=</varname> may be used to check whether the kernel
           version (as reported by <command>uname -r</command>) matches a certain expression (or if prefixed
           with the exclamation mark does not match it). The argument must be a list of (potentially quoted)
-          expressions.  Each expression starts with one of <literal>&lt;</literal>, <literal>&lt;=</literal>,
-          <literal>=</literal> (or <literal>==</literal>), <literal>!=</literal> (or
-          <literal>&lt;&gt;</literal>), <literal>&gt;=</literal>, <literal>&gt;</literal> for a relative
+          expressions.  Each expression starts with one of <literal>=</literal> or <literal>!=</literal> for
+          string comparisons, <literal>&lt;</literal>, <literal>&lt;=</literal>, <literal>==</literal>,
+          <literal>&lt;&gt;</literal>, <literal>&gt;=</literal>, <literal>&gt;</literal> for a relative
           version comparison, or <literal>=$</literal>, <literal>!=$</literal> for a shell-style glob
           match. If no operator is specified <literal>=$</literal> is implied.</para>
 
index 6c8023143b821ecf37dae7e087feb78a36868af7..ffca2006c0757560537a4780528ee158c7ed7c62 100644 (file)
@@ -206,7 +206,7 @@ static int condition_test_kernel_version(Condition *c, char **env) {
                         break;
 
                 s = strstrip(word);
-                operator = parse_compare_operator(&s, COMPARE_ALLOW_FNMATCH);
+                operator = parse_compare_operator(&s, COMPARE_ALLOW_FNMATCH|COMPARE_EQUAL_BY_STRING);
                 if (operator < 0) /* No prefix? Then treat as glob string */
                         operator = COMPARE_FNMATCH_EQUAL;