[projects/pld-ftp-admin] sign: check the signature of a header already read

arekm arekm at pld-linux.org
Tue Oct 27 23:50:29 CET 2026


commit 01cd9609dbc7037ab9216608338f5d6f76050b7c
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Tue Oct 27 14:28:59 2026 +0100

    sign: check the signature of a header already read
    
    is_signed() reads the rpm header itself.  Its check of the header moves
    to signed_by_key(), so code that reads the header for other data too
    needs to read it only once.  is_signed() gives the same answers.

 modules/sign.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/modules/sign.py b/modules/sign.py
index bbda74d..9142721 100644
--- a/modules/sign.py
+++ b/modules/sign.py
@@ -37,11 +37,21 @@ def is_signed(rpm_file):
     try:
         hdr = ts.hdrFromFdno(fdno)
     except rpm.error:
+        hdr = None
+    finally:
+        os.close(fdno)
+
+    return signed_by_key(hdr)
+
+def signed_by_key(hdr):
+    """is_signed() of a header already read, given as None when rpm refused to read it"""
+    if sign_key == None:
+        return None
+
+    if hdr == None:
         # a bad signature, or one by a key missing from the rpm database:
         # either way not a valid signature by sign_key
         return False
-    finally:
-        os.close(fdno)
 
     sigid = getSigInfo(hdr)
     if sigid == None:
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list