RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1730266 - Rpm post scriplet failed with exit status 1 but return status of rpm is 0
Summary: Rpm post scriplet failed with exit status 1 but return status of rpm is 0
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: rpm
Version: 7.4
Hardware: x86_64
OS: Linux
unspecified
urgent
Target Milestone: rc
: ---
Assignee: Packaging Maintenance Team
QA Contact: BaseOS QE Security Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-07-16 11:13 UTC by shagun
Modified: 2019-11-01 11:26 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-09-17 07:35:34 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description shagun 2019-07-16 11:13:03 UTC
Hi,

On CentOS 6, when we try to install any rpm it fails with scriplet failed with exit status 1 but return status of rpm is also 1 which is correct.
Example:
But On CentOS 7, we are not getting return status of rpm as 1 it is coming 0, which is installing the RPM.

rpm -Uvh /home/seldridg/rpmbuild/RPMS/noarch/test-1.0-1.el6.noarch.rpm; echo $?
Preparing... ########################################### [100%]
1:test ########################################### [100%]
Test Script called
failure seen while executing test-script
error: %post(test-1.0-1.el6.noarch) scriptlet failed, exit status 1
1 <-- verified this works as expected

I checked the source code of rpm package for CentOS6/7 and found that one patch is applicable in CentOS6 rpm package and because of this any failure is coming during scriplet failure it treats warning as an error and giving rpm status as a 1 and not installing that RPM in your system.

rpm -Uvh /home/seldridg/rpmbuild/RPMS/noarch/test-1.0-1.el7.noarch.rpm; echo $?
Preparing... ########################################### [100%]
1:test ########################################### [100%]
Test Script called
failure seen while executing test-script
error: %post(test-1.0-1.el7.noarch) scriptlet failed, exit status 1
0 <-- verified this works as expected

Below is the patch:
+++ b/rpm-4.8.x-strict-script-errors.patch
@@ -0,0 +1,25 @@
+diff -up rpm-4.8.0/lib/psm.c.strict-script rpm-4.8.0/lib/psm.c
+--- rpm-4.8.0/lib/psm.c.strict-script 2013-08-05 11:09:40.290136043 +0300
++++ rpm-4.8.0/lib/psm.c       2013-08-05 11:12:18.465137945 +0300
+@@ -517,7 +517,9 @@ static rpmRC runLuaScript(rpmpsm psm, He
+     if (rc != RPMRC_OK) {
+       if ((stag != RPMTAG_PREIN && stag != RPMTAG_PREUN &&
+            stag != RPMTAG_VERIFYSCRIPT && stag != RPMTAG_PRETRANS)) {
+-          warn_only = 1;
++          if (!rpmExpandNumeric("%{?_strict_script_errors}")) {
++             warn_only = 1;
++          }
+       }
+     }
+     umask(oldmask);
+@@ -774,7 +776,9 @@ static rpmRC runScript(rpmpsm psm, Heade
+       } else {
+           /* filter out "regular" error exits from non-pre scriptlets */
+           if ((stag != RPMTAG_PREIN && stag != RPMTAG_PREUN && stag != RPMTAG_VERIFYSCRIPT && stag != RPMTAG_PRETRANS)) {
+-             warn_only = 1;
++             if (!rpmExpandNumeric("%{?_strict_script_errors}")) {
++                 warn_only = 1;
++             }
+           }
+           rpmlog(warn_only ? RPMLOG_WARNING : RPMLOG_ERR, 
+                 _("%s scriptlet failed, exit status %d\n"),

I tried to modify the code according to this but not getting success.
Please help me on this. I want the same behavior of CentOS 6 on CentOS 7.

Comment 2 shagun 2019-07-17 09:12:57 UTC
Any update on this issue?

Regards,
Shagun

Comment 4 Panu Matilainen 2019-09-17 07:35:34 UTC
The %_strict_script_mode was only added to rhel-6 as a temporary aid to give people time to transition from the rhel-5 era rpm behavior, and was never intended to be carried into later releases. There are no plans to bring it into rhel-7.


Note You need to log in before you can comment on or make changes to this bug.