From febccf4d5e882e4a166de42e06fc09cf72a5c82b Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 6 May 2025 08:39:53 -0400 Subject: [PATCH] Fix imgutil with el8 diskless --- imgutil/imgutil | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/imgutil/imgutil b/imgutil/imgutil index b1698c79..019cfa4f 100644 --- a/imgutil/imgutil +++ b/imgutil/imgutil @@ -752,10 +752,13 @@ class ElHandler(OsHandler): subprocess.check_call(['yum'] + self.yumargs) else: subprocess.check_call(['yum', '-y'] + self.yumargs) - with open(os.path.join(self.targpath, 'etc/selinux/config'), 'r') as seconfigin: - seconfig = seconfigin.read().replace('SELINUX=enforcing', 'SELINUX=disabled') - with open(os.path.join(self.targpath, 'etc/selinux/config'), 'w') as seconfigout: - seconfigout.write(seconfig) + try: + with open(os.path.join(self.targpath, 'etc/selinux/config'), 'r') as seconfigin: + seconfig = seconfigin.read().replace('SELINUX=enforcing', 'SELINUX=disabled') + with open(os.path.join(self.targpath, 'etc/selinux/config'), 'w') as seconfigout: + seconfigout.write(seconfig) + except Exception: # this might not exist in all images + pass with open('/proc/mounts') as mountinfo: for line in mountinfo.readlines(): if line.startswith('selinuxfs '):