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