richardphibel / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
Michal Domonkos df2666
commit cb6aa82dbc10d554f8d234e934ae7c77e39a3ce2
Michal Domonkos df2666
Author: Panu Matilainen <pmatilai@redhat.com>
Michal Domonkos df2666
Date:   Tue Jan 12 13:35:23 2021 +0200
Michal Domonkos df2666
Michal Domonkos df2666
    Unblock signals in forked scriptlets
Michal Domonkos df2666
    
Michal Domonkos df2666
    Since commit c5f82d3f6223ebd0c5cc0a07ea60393ae7284929 we've blocked
Michal Domonkos df2666
    most signals during transactions, which makes sense to rpm itself but
Michal Domonkos df2666
    the signal mask is inherited to childs and carried even across exec(),
Michal Domonkos df2666
    so all scriptlets are executing with those signals blocked as well.
Michal Domonkos df2666
    Which in turn does not make sense, the scriptlets could run stuff that
Michal Domonkos df2666
    actually depends on signal delivery (such as SIGALARM in RhBug:1913765).
Michal Domonkos df2666
    
Michal Domonkos df2666
    Unblock all signals for forked scriptlet execution (Lua scriptlets are
Michal Domonkos df2666
    totally different as they execute in-process for now)
Michal Domonkos df2666
Michal Domonkos df2666
diff --git a/lib/rpmscript.c b/lib/rpmscript.c
Michal Domonkos df2666
index 2ae3378f7..c69d29554 100644
Michal Domonkos df2666
--- a/lib/rpmscript.c
Michal Domonkos df2666
+++ b/lib/rpmscript.c
Michal Domonkos df2666
@@ -152,6 +152,11 @@ static void doScriptExec(ARGV_const_t argv, ARGV_const_t prefixes,
Michal Domonkos df2666
 			FD_t scriptFd, FD_t out)
Michal Domonkos df2666
 {
Michal Domonkos df2666
     int xx;
Michal Domonkos df2666
+    sigset_t set;
Michal Domonkos df2666
+
Michal Domonkos df2666
+    /* Unmask all signals, the scripts may need them */
Michal Domonkos df2666
+    sigfillset(&set);
Michal Domonkos df2666
+    sigprocmask(SIG_UNBLOCK, &set, NULL);
Michal Domonkos df2666
 
Michal Domonkos df2666
     /* SIGPIPE is ignored in rpm, reset to default for the scriptlet */
Michal Domonkos df2666
     (void) signal(SIGPIPE, SIG_DFL);