From 9defc474741af7c2c37aae2d082dec06917e57c2 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 27 Aug 2025 12:29:19 -0400 Subject: [PATCH] Give pycdlib a duped filehandle Attempts to share the filehandle resulted in race conditions around closing, dedicate a dupe filehandle to pycdlib to avoid the conflict. --- confluent_server/confluent/osimage.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/confluent_server/confluent/osimage.py b/confluent_server/confluent/osimage.py index 2501b62b..89c94d08 100644 --- a/confluent_server/confluent/osimage.py +++ b/confluent_server/confluent/osimage.py @@ -790,7 +790,9 @@ def scan_iso(archive): for block in ent.get_blocks(): filecontents[str(ent)] += bytes(block) if scanudf: - return scan_udf(dfd) + ndfd = os.dup(archive.fileno()) + os.lseek(ndfd, 0, 0) + return scan_udf(ndfd) finally: os.close(dfd) return filesizes, filecontents @@ -799,14 +801,18 @@ def scan_udf(dfd): fp = os.fdopen(dfd, 'rb') iso = pycdlib.PyCdlib() iso.open_fp(fp) + imginfo = {} try: extracted = BytesIO() iso.get_file_from_iso_fp(extracted, udf_path='/sources/idwbinfo.txt') idwbinfo = extracted.getvalue() - return {}, {'sources/idwbinfo.txt': idwbinfo} + imginfo = {'sources/idwbinfo.txt': idwbinfo} except Exception: - return {}, {} - + pass + finally: + iso.close() + fp.close() + return {}, imginfo def fingerprint(archive):