From 06219747f5368909e8006c7b6138aca671a3b9d7 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 29 Aug 2022 13:27:11 +0200 Subject: [PATCH] condition: change ConditionKernelVersion= so that =/!= mean literal string comparison, and ==/<> version comparison 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 | 6 +++--- src/shared/condition.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml index 9dd02c30604..16aa8303e79 100644 --- a/man/systemd.unit.xml +++ b/man/systemd.unit.xml @@ -1334,9 +1334,9 @@ ConditionKernelVersion= may be used to check whether the kernel version (as reported by uname -r) 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 <, <=, - = (or ==), != (or - <>), >=, > for a relative + expressions. Each expression starts with one of = or != for + string comparisons, <, <=, ==, + <>, >=, > for a relative version comparison, or =$, !=$ for a shell-style glob match. If no operator is specified =$ is implied. diff --git a/src/shared/condition.c b/src/shared/condition.c index 6c8023143b8..ffca2006c07 100644 --- a/src/shared/condition.c +++ b/src/shared/condition.c @@ -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;