From 5e47b7fcf663c47f85050603cee5390b4c171a15 Mon Sep 17 00:00:00 2001 From: Bastian Triller Date: Sat, 13 Dec 2025 13:55:38 +0100 Subject: [PATCH] inventory/linux: Use Python script to check version Get rid of shells and other command and use Python itself for version check. Get major/minor via tuple for compatibility with very ancient Python versions (sys.version_info.major etc introduced in 2.7) [1]. [1] https://docs.python.org/2/library/sys.html#sys.version_info --- inventory/linux.cf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inventory/linux.cf b/inventory/linux.cf index c1922666b5..35ef7bd5c6 100644 --- a/inventory/linux.cf +++ b/inventory/linux.cf @@ -75,8 +75,8 @@ bundle common inventory_linux " acceptable ( 3.x or 2.4 or greater ) for package", " modules. We use this guard to prevent errors", " related to missing python modules."), - expression => returnszero("$(sys.bindir)/cfengine-selected-python -V 2>&1 | grep ^Python | cut -d' ' -f 2 | ( IFS=. read v1 v2 v3 ; [ $v1 -ge 3 ] || [ $v1 -eq 2 -a $v2 -ge 4 ] )", - useshell); + expression => returnszero("$(sys.bindir)/cfengine-selected-python -c 'import sys; vi = sys.version_info; exit(not (vi[0] > 2 or (vi[0] == 2 and vi[1] > 3)))'", + noshell); } bundle monitor measure_entropy_available