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:


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.