From 3ae1d13339b5b18b3ba10cd00306509621185272 Mon Sep 17 00:00:00 2001 From: Bastian Triller Date: Wed, 28 Oct 2026 11:16:12 +0100 Subject: [PATCH] enterprise/federation: Use Python script for checks Get rid of shells and other commands and use Python itself for version check and installed module. Get major version 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 --- cfe_internal/enterprise/federation/federation.cf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cfe_internal/enterprise/federation/federation.cf b/cfe_internal/enterprise/federation/federation.cf index 7f244f4998..0bf5642b5e 100644 --- a/cfe_internal/enterprise/federation/federation.cf +++ b/cfe_internal/enterprise/federation/federation.cf @@ -256,15 +256,15 @@ bundle agent distributed_cleanup_dependencies (redhat_6|centos_6):: "cfengine_mp_fr_distributed_cleanup_python3_installed" expression => returnszero( - "$(sys.bindir)/cfengine-selected-python --version | grep -q ' 3.'", - "useshell" + "$(sys.bindir)/cfengine-selected-python -c 'import sys; exit(sys.version_info < (3,))'", + noshell ); (redhat_6|centos_6|redhat_7|centos_7):: "cfengine_mp_fr_distributed_cleanup_urllib3_installed" expression => returnszero( - "echo 'import urllib3' | $(sys.bindir)/cfengine-selected-python 2>/dev/null", - "useshell" + "$(sys.bindir)/cfengine-selected-python -c 'try: import urllib3$(const.n)except ModuleNotFoundError: exit(1)'", + noshell ); packages: