Bug 1419590

Summary: rpm-sign exit with 0 if it fails to sign package
Product: Red Hat Enterprise Linux 7 Reporter: Vit Ry <Frodox>
Component: rpmAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED ERRATA QA Contact: Jan Blazek <jblazek>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.3CC: ffesti, Frodox, pmoravco, vmukhame
Target Milestone: rcKeywords: EasyFix
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rpm-4.11.3-33.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 11:34:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vit Ry 2017-02-06 15:04:04 UTC
Description of problem:
rpm --addsign return 0 if it fails to sign rpm-package


Version-Release number of selected component (if applicable):
rpm.ppc64 0:4.11.3-21.el7
rpm-sign.ppc64 0:4.11.3-21.el7


How reproducible:
always


Steps to Reproduce:
1. get any rpm
2. change perms, so user can't write it that dir
3. setup gpg keys under user
4. rpm --addsign <package>.rpm


Actual results:
Error message and exit code 0.

$ rpm --addsign kernel-3.10.0-514.6.1.el7.src.rpm
Enter pass phrase: 
Pass phrase is good.
kernel-3.10.0-514.6.1.el7.src.rpm:
error: rpmMkTemp failed

$ echo $?
0


Expected results:

return code would be non-zero.

Comment 2 Vit Ry 2017-02-08 12:20:18 UTC
Patch:

diff -up rpm-4.11.3/sign/rpmgensig.c.sign-error-propagation rpm-4.11.3/sign/rpmgensig.c
--- rpm-4.11.3/sign/rpmgensig.c.sign-error-propagation
+++ rpm-4.11.3/sign/rpmgensig.c
@@ -495,9 +495,9 @@ static int rpmSign(const char *rpm, int
     if (deleting) {	/* Nuke all the signature tags. */
 	deleteSigs(sigh);
     } else {
-	res = replaceSignature(sigh, sigtarget, passPhrase);
-	if (res != 0) {
-	    if (res == 1) {
+	int temp_res = replaceSignature(sigh, sigtarget, passPhrase);
+	if (temp_res != 0) {
+	    if (temp_res == 1) {
 		rpmlog(RPMLOG_WARNING,
 		   _("%s already contains identical signature, skipping\n"),
 		   rpm);

Comment 3 Pavlina Moravcova Varekova 2018-04-13 13:51:41 UTC
The patch looks OK. The problem is already solved in upstream in patch
https://github.com/rpm-software-management/rpm/commit/e1fd794253588e44226f480c426ba1833295b318
The upstream patch is in rpm-4.12.0 and higher. So it should be used here too.

Comment 7 errata-xmlrpc 2018-10-30 11:34:10 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2018:3250