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