From b84afab0187c2106b85155ecfd101978a7c134ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Zatloukal?= Date: Fri, 22 May 2026 10:45:15 +0200 Subject: [PATCH] Guard chcon call with has_selinux() There was one chcon call missed in the previous has_selinux checking, guard that one too. Fixes https://github.com/teemtee/testcloud/issues/18 --- testcloud/instance.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/testcloud/instance.py b/testcloud/instance.py index 0b60ed8..d629a18 100644 --- a/testcloud/instance.py +++ b/testcloud/instance.py @@ -325,12 +325,14 @@ def prepare(self, data_tpl=None): shutil.copy(self.ign_file, self.config_path) else: self._generate_config_file(coreos_data_tpl=data_tpl) - chcon_command = subprocess.call("chcon -t svirt_home_t %s" % self.config_path, shell=True) - if chcon_command == 0: - log.info("chcon command succeed ") - else: - log.error("chcon command failed") - raise TestcloudInstanceError("Failure during change file SELinux security context") + + if has_selinux(): + chcon_command = subprocess.call("chcon -t svirt_home_t %s" % self.config_path, shell=True) + if chcon_command == 0: + log.info("chcon command succeed ") + else: + log.error("chcon command failed") + raise TestcloudInstanceError("Failure during change file SELinux security context") # deal with backing store self._create_local_disk()