dcavalca / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone

Blame SOURCES/0029-extentsVerifySigs-Make-it-optional-to-print-the-sign.patch

629b27
From 5753b178a08043316e6f3556754741cdd9cd19c5 Mon Sep 17 00:00:00 2001
629b27
From: chantra <chantr4@gmail.com>
629b27
Date: Mon, 28 Mar 2022 14:00:13 -0700
629b27
Subject: [PATCH 29/30] [extentsVerifySigs] Make it optional to print the
629b27
 signature verification output
629b27
629b27
---
629b27
 lib/rpmchecksig.c         |  2 +-
629b27
 lib/rpmextents.c          | 39 ++++++++++++++++++++-------------------
629b27
 lib/rpmextents_internal.h |  3 ++-
629b27
 3 files changed, 23 insertions(+), 21 deletions(-)
629b27
629b27
diff --git a/lib/rpmchecksig.c b/lib/rpmchecksig.c
629b27
index c9fc3bbc9..7f856154e 100644
629b27
--- a/lib/rpmchecksig.c
629b27
+++ b/lib/rpmchecksig.c
629b27
@@ -229,7 +229,7 @@ static int rpmpkgVerifySigs(rpmKeyring keyring, int vfylevel, rpmVSFlags flags,
629b27
 
629b27
 
629b27
     if(isTranscodedRpm(fd) == RPMRC_OK){
629b27
-	return extentsVerifySigs(fd);
629b27
+	return extentsVerifySigs(fd, 1);
629b27
     }
629b27
 
629b27
     struct rpmvs_s *vs = rpmvsCreate(vfylevel, flags, keyring);
629b27
diff --git a/lib/rpmextents.c b/lib/rpmextents.c
629b27
index 59ba427a4..ac43264af 100644
629b27
--- a/lib/rpmextents.c
629b27
+++ b/lib/rpmextents.c
629b27
@@ -10,7 +10,7 @@
629b27
 #include "lib/rpmextents_internal.h"
629b27
 
629b27
 
629b27
-int extentsVerifySigs(FD_t fd){
629b27
+int extentsVerifySigs(FD_t fd, int print_content){
629b27
     rpm_loff_t current;
629b27
     int32_t rc;
629b27
     size_t len;
629b27
@@ -36,24 +36,26 @@ int extentsVerifySigs(FD_t fd){
629b27
 	goto exit;
629b27
     }
629b27
 
629b27
-    len = sizeof(content_len);
629b27
-    if (Fread(&content_len, len, 1, fd) != len) {
629b27
-	rpmlog(RPMLOG_ERR, _("extentsVerifySigs: Failed to read signature content length\n"));
629b27
-	goto exit;
629b27
-    }
629b27
-
629b27
-    content = rmalloc(content_len + 1);
629b27
-    if(content == NULL) {
629b27
-	rpmlog(RPMLOG_ERR, _("extentsVerifySigs: Failed to allocate memory to read signature content\n"));
629b27
-	goto exit;
629b27
+    if(print_content) {
629b27
+	len = sizeof(content_len);
629b27
+	if (Fread(&content_len, len, 1, fd) != len) {
629b27
+	    rpmlog(RPMLOG_ERR, _("extentsVerifySigs: Failed to read signature content length\n"));
629b27
+	    goto exit;
629b27
+	}
629b27
+
629b27
+	content = rmalloc(content_len + 1);
629b27
+	if(content == NULL) {
629b27
+	    rpmlog(RPMLOG_ERR, _("extentsVerifySigs: Failed to allocate memory to read signature content\n"));
629b27
+	    goto exit;
629b27
+	}
629b27
+	content[content_len] = 0;
629b27
+	if (Fread(content, content_len, 1, fd) != content_len) {
629b27
+	    rpmlog(RPMLOG_ERR, _("extentsVerifySigs: Failed to read signature content\n"));
629b27
+	    goto exit;
629b27
+	}
629b27
+
629b27
+	rpmlog(RPMLOG_NOTICE, "%s", content);
629b27
     }
629b27
-    content[content_len] = 0;
629b27
-    if (Fread(content, content_len, 1, fd) != content_len) {
629b27
-	rpmlog(RPMLOG_ERR, _("extentsVerifySigs: Failed to read signature content\n"));
629b27
-	goto exit;
629b27
-    }
629b27
-
629b27
-    rpmlog(RPMLOG_NOTICE, "%s", content);
629b27
 exit:
629b27
     if(content){
629b27
 	rfree(content);
629b27
@@ -79,7 +81,6 @@ rpmRC extentsFooterFromFD(FD_t fd, struct extents_footer_t *footer) {
629b27
 
629b27
     len = sizeof(struct extents_footer_t);
629b27
     if(Fseek(fd, -len, SEEK_END) < 0) {
629b27
-	rpmlog(RPMLOG_ERR, _("isTranscodedRpm: failed to seek for footer: %s\n"), strerror(errno));
629b27
 	rc = RPMRC_FAIL;
629b27
 	goto exit;
629b27
     }
629b27
diff --git a/lib/rpmextents_internal.h b/lib/rpmextents_internal.h
629b27
index 380c08425..0a3318c8e 100644
629b27
--- a/lib/rpmextents_internal.h
629b27
+++ b/lib/rpmextents_internal.h
629b27
@@ -32,9 +32,10 @@ struct __attribute__ ((__packed__)) extents_footer_t {
629b27
 /** \ingroup rpmextents
629b27
  * Checks the results of the signature verification ran during transcoding.
629b27
  * @param fd	The FD_t of the transcoded RPM
629b27
+ * @param print_content Whether or not to print the result from rpmsig
629b27
  * @return	The number of checks that `rpmvsVerify` failed during transcoding.
629b27
  */
629b27
-int extentsVerifySigs(FD_t fd);
629b27
+int extentsVerifySigs(FD_t fd, int print_content);
629b27
 
629b27
 /** \ingroup rpmextents
629b27
  * Read the RPM Extents footer from a file descriptor.
629b27
-- 
629b27
2.35.1
629b27