Bug 1913765

Summary: Signal delivery within scriptlets is blocked
Product: Red Hat Enterprise Linux 8 Reporter: Welterlen Benoit <bwelterl>
Component: rpmAssignee: Michal Domonkos <mdomonko>
Status: CLOSED ERRATA QA Contact: Eva Mrakova <emrakova>
Severity: high Docs Contact:
Priority: high    
Version: 8.3CC: jkalliya, kwalker, mdomonko, mmatsuya, pmatilai
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rpm-4.14.3-11.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-18 14:49:53 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:
Attachments:
Description Flags
Patch that add SIGALRM from the excluded blocked signals none

Description Welterlen Benoit 2021-01-07 14:38:01 UTC
Created attachment 1745317 [details]
Patch that add SIGALRM from the excluded blocked signals

Created attachment 1745317 [details]
Patch that add SIGALRM from the excluded blocked signals

Created attachment 1745317 [details]
Patch that add SIGALRM from the excluded blocked signals

Created attachment 1745317 [details]
Patch that add SIGALRM from the excluded blocked signals

Description of problem:
If an alarm is needed in one of the script in the RPM, it will be ignored because of the blocked signals.
For example, if you use flock with -w, the alarm after the timeout will never be received:
%pre
flock -x -w 19 /tmp/lock sleep 99

Version-Release number of selected component (if applicable):
rpm-4.14.3-4

How reproducible:
always

Steps to Reproduce:
1. add a script that needs an alarm, example flock -w <timeout>
2. 
3.

Actual results:
- the alarm from the timeout is not received

Expected results:
- flock interrupted

Additional info:
- I already opened a pull request upstream: https://github.com/rpm-software-management/rpm/pull/1479
- attached patch, tested on RHEL8.3
- http://brew-task-repos.usersys.redhat.com/repos/scratch/bwelterl/rpm/4.14.3/4.el8/

Acceptance criteria:

Signals within scriptlets (e.g. %pre) work as expected - that is, signals like SIGALRM or SIGINT are received by the scriptlets (or the subprocesses they run).

As a (manual) reproducer, one can use the %pre example from above, while running flock on the same file but from a different shell.

With the fixed RPM version, the %pre script would unblock after -w seconds and make RPM fail with exit code 1 and an error message saying the %pre scriptlet failed.  With the current (unfixed) RPM version, the %pre script should eventually finish, install the package and exit with code 0.

Note that this is subject to race conditions, though, so could be hard to automate reliably...

You can also test this with SIGINT instead, e.g. make the %pre scriptlet block and then try pressing CTRL-C.  With the fix, it should receive the signal and interrupt the RPM transaction.

Comment 2 Panu Matilainen 2021-01-12 12:10:03 UTC
Upstream fix proposal: https://github.com/rpm-software-management/rpm/pull/1486

Comment 13 errata-xmlrpc 2021-05-18 14:49:53 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 (rpm bug fix and enhancement update), 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/RHBA-2021:1606