[projects/pld-ftp-admin] ftptree: report an rpm file that cannot be opened, as one rpm cannot read

arekm arekm at pld-linux.org
Sat Nov 21 10:43:12 CET 2026


commit 557c2b2bec8a493bcbe153ec52d4d771e6c318a8
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sat Nov 21 01:44:53 2026 +0100

    ftptree: report an rpm file that cannot be opened, as one rpm cannot read
    
    A file without read permission raised out of the header pool, so
    pfa-checksign, pfa-signpkg and the move checks stopped with a traceback.
    pfa-checksign now names such a file and exits with 1.

 bin/pfa-checksign  | 9 ++++++---
 modules/ftptree.py | 7 +++++--
 2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/bin/pfa-checksign b/bin/pfa-checksign
index faf0006..352b7bb 100755
--- a/bin/pfa-checksign
+++ b/bin/pfa-checksign
@@ -46,9 +46,12 @@ finally:
 
 print(f"Checking signatures of {len(tree.loadedpkgs)} packages")
 files = [file for pkg in pkgs for file in pkg.rpmfiles()]
+infos = dict(zip(files, ftptree.read_rpms(files), strict=True))
+errors = [info.error for info in infos.values() if info is not None and info.error]
+for error in errors:
+    print(f'ERR: {error}', file=sys.stderr)
 # a missing file counts as not signed
-signed = {file: info is not None and bool(info.signed)
-          for file, info in zip(files, ftptree.read_rpms(files), strict=True)}
+signed = {file: info is not None and bool(info.signed) for file, info in infos.items()}
 for pkg in pkgs:
     unsigned = sum(not signed[file] for file in pkg.rpmfiles())
 
@@ -57,4 +60,4 @@ for pkg in pkgs:
     else:
         print(f'{pkg.nvr} signed')
 
-sys.exit(0)
+sys.exit(1 if errors else 0)
diff --git a/modules/ftptree.py b/modules/ftptree.py
index d05cf42..2e0fd1d 100644
--- a/modules/ftptree.py
+++ b/modules/ftptree.py
@@ -17,7 +17,7 @@ from sign import signed_by_key
 errnum = 0
 quietmode = False
 
-# what the move checks take from an rpm header; error is set when rpm refused to read it
+# what the move checks take from an rpm header; error is set when the file or its header cannot be read
 RpmInfo = collections.namedtuple('RpmInfo', 'signed name obsoletes error')
 # files a process of the header pool reads per task
 READ_CHUNK = 16
@@ -35,7 +35,10 @@ def _read_rpm(path):
     """RpmInfo of the rpm file at path, or None when there is no such file"""
     if not os.path.exists(path):
         return None
-    fdno = os.open(path, os.O_RDONLY)
+    try:
+        fdno = os.open(path, os.O_RDONLY)
+    except OSError as e:
+        return RpmInfo(signed_by_key(None), None, [], f"{path}: {e.strerror}")
     try:
         hdr = _ts.hdrFromFdno(fdno)
     except rpm.error as e:
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-ftp-admin.git/commitdiff/a049a512859eaede288d71649a2320e16c959476



More information about the pld-cvs-commit mailing list