dcavalca / rpms / rpm

Forked from rpms/rpm a year ago
Clone
629b27
From dc53b002bd3d03a21e9af406a9aff5e588710b5b Mon Sep 17 00:00:00 2001
629b27
From: chantra <chantr4@gmail.com>
629b27
Date: Mon, 28 Mar 2022 19:42:39 -0700
629b27
Subject: [PATCH 30/30] [rpmcow] Make rpm -i install package without the need
629b27
 of --nodigest
629b27
629b27
When using transcoded files, the logic to check signature is different
629b27
and was done while the file was transcoded. This change the code path
629b27
used by `rpm -{i,U}` to check if the file is transcoded, and in such
629b27
cases, assume it was already verified.
629b27
---
629b27
 lib/transaction.c    | 29 ++++++++++++++++++-----------
629b27
 tests/rpm2extents.at |  6 +++---
629b27
 2 files changed, 21 insertions(+), 14 deletions(-)
629b27
629b27
diff --git a/lib/transaction.c b/lib/transaction.c
629b27
index 36c2a7a64..703e4140c 100644
629b27
--- a/lib/transaction.c
629b27
+++ b/lib/transaction.c
629b27
@@ -37,6 +37,7 @@
629b27
 #include "lib/rpmfi_internal.h"	/* only internal apis */
629b27
 #include "lib/rpmte_internal.h"	/* only internal apis */
629b27
 #include "lib/rpmts_internal.h"
629b27
+#include "lib/rpmextents_internal.h"
629b27
 #include "lib/rpmvs.h"
629b27
 #include "rpmio/rpmhook.h"
629b27
 #include "lib/rpmtriggers.h"
629b27
@@ -1255,10 +1256,16 @@ static int verifyPackageFiles(rpmts ts, rpm_loff_t total)
629b27
 	    .signature = RPMRC_NOTFOUND,
629b27
 	    .vfylevel = vfylevel,
629b27
 	};
629b27
+	int verified = 0;
629b27
 	rpmRC prc = RPMRC_FAIL;
629b27
 
629b27
 	rpmtsNotify(ts, p, RPMCALLBACK_VERIFY_PROGRESS, oc++, total);
629b27
 	FD_t fd = rpmtsNotify(ts, p, RPMCALLBACK_INST_OPEN_FILE, 0, 0);
629b27
+	if (fd != NULL && isTranscodedRpm(fd) == RPMRC_OK) {
629b27
+	    /* Transcoded RPMs are validated at transcoding time */
629b27
+	    prc = RPMRC_OK;
629b27
+	    verified = 1;
629b27
+	} else {
629b27
 	if (fd != NULL) {
629b27
 	    prc = rpmpkgRead(vs, fd, NULL, NULL, &vd.msg);
629b27
 	    rpmtsNotify(ts, p, RPMCALLBACK_INST_CLOSE_FILE, 0, 0);
629b27
@@ -1267,8 +1274,11 @@ static int verifyPackageFiles(rpmts ts, rpm_loff_t total)
629b27
 	if (prc == RPMRC_OK)
629b27
 	    prc = rpmvsVerify(vs, RPMSIG_VERIFIABLE_TYPE, vfyCb, &vd);
629b27
 
629b27
+	    verified = vd.signature == RPMRC_OK;
629b27
+	}
629b27
+
629b27
 	/* Record verify result, signatures only for now */
629b27
-	rpmteSetVerified(p, vd.signature == RPMRC_OK);
629b27
+	rpmteSetVerified(p, verified);
629b27
 
629b27
 	if (prc)
629b27
 	    rpmteAddProblem(p, RPMPROB_VERIFY, NULL, vd.msg, 0);
629b27
diff --git a/tests/rpm2extents.at b/tests/rpm2extents.at
629b27
index 5c66de7f6..5135c9cf8 100644
629b27
--- a/tests/rpm2extents.at
629b27
+++ b/tests/rpm2extents.at
629b27
@@ -102,7 +102,7 @@ AT_CHECK([
629b27
 RPMDB_INIT
629b27
 
629b27
 runroot_other cat /data/RPMS/hello-2.0-1.x86_64.rpm | runroot_other rpm2extents SHA256 > ${RPMTEST}/tmp/hello-2.0-1.x86_64.rpm 2> /dev/null
629b27
-runroot_plugins rpm -i --nodigest --nodeps --undefine=%__transaction_dbus_announce /tmp/hello-2.0-1.x86_64.rpm
629b27
+runroot_plugins rpm -i --nodeps --undefine=%__transaction_dbus_announce /tmp/hello-2.0-1.x86_64.rpm
629b27
 test -f ${RPMTEST}/usr/bin/hello
629b27
 ],
629b27
 [0],
629b27
@@ -115,7 +115,7 @@ AT_KEYWORDS([reflink])
629b27
 AT_CHECK([
629b27
 RPMDB_INIT
629b27
 
629b27
-runroot_plugins rpm -i --nodigest --nodeps --undefine=%__transaction_dbus_announce /data/RPMS/hello-2.0-1.x86_64.rpm && exit $?
629b27
+runroot_plugins rpm -i --nodeps --undefine=%__transaction_dbus_announce /data/RPMS/hello-2.0-1.x86_64.rpm && exit $?
629b27
 # Check that the file is properly installed in chroot
629b27
 test -f ${RPMTEST}/usr/bin/hello
629b27
 ],
629b27
@@ -132,7 +132,7 @@ RPMDB_INIT
629b27
 
629b27
 PKG=hlinktest-1.0-1.noarch.rpm
629b27
 runroot_other cat /data/RPMS/${PKG} | runroot_other rpm2extents SHA256 > ${RPMTEST}/tmp/${PKG} 2> /dev/null
629b27
-runroot_plugins rpm -i --nodigest --nodeps --undefine=%__transaction_dbus_announce /tmp/${PKG}
629b27
+runroot_plugins rpm -i --nodeps --undefine=%__transaction_dbus_announce /tmp/${PKG}
629b27
 ],
629b27
 [0],
629b27
 [],
629b27
-- 
629b27
2.35.1
629b27