Stop NSPR from messing with our signals

For NSPR, (which NSS uses internally) being portable to Windows and
whatnot and centered around apps like Firefox, simply ignoring
SIGPIPE is probably a reasonable choice. Rpm however is an old school
unix cli piece where SIGPIPE is very much relevant and handled where
necessary. Besides we now have not just one but two other, less obnoxious
crypto backends which exhibit different core rpm behavior due to the
difference, not good.

Save and restore the SIGPIPE handler across NSS initialization,
and remove all the now redundant calls to reset it after forking.
Should've done this ages ago but better late than never, no?

Note that the install-time scriptlet thing is different since we set
SIGPIPE to SIG_IGN by ourselves there, add a comment.
This commit is contained in:
Panu Matilainen 2017-05-10 12:39:28 +03:00
parent 5e51d2bf70
commit 585be2acf0
5 changed files with 5 additions and 5 deletions

View File

@ -157,8 +157,6 @@ rpmRC doScript(rpmSpec spec, rpmBuildFlags what, const char *name,
rpmlog(RPMLOG_NOTICE, _("Executing(%s): %s\n"), name, buildCmd);
if (!(child = fork())) {
/* NSPR messes with SIGPIPE, reset to default for the kids */
signal(SIGPIPE, SIG_DFL);
errno = 0;
(void) execvp(argv[0], (char *const *)argv);

View File

@ -269,8 +269,6 @@ static StringBuf getOutputFrom(ARGV_t argv,
child = fork();
if (child == 0) {
/* NSPR messes with SIGPIPE, reset to default for the kids */
signal(SIGPIPE, SIG_DFL);
close(toProg[1]);
close(fromProg[0]);

View File

@ -55,7 +55,6 @@ int initPipe(void)
}
if (!(pipeChild = fork())) {
(void) signal(SIGPIPE, SIG_DFL);
(void) close(p[1]);
(void) dup2(p[0], STDIN_FILENO);
(void) close(p[0]);

View File

@ -162,6 +162,7 @@ static void doScriptExec(ARGV_const_t argv, ARGV_const_t prefixes,
int xx;
int open_max;
/* SIGPIPE is ignored in rpm, reset to default for the scriptlet */
(void) signal(SIGPIPE, SIG_DFL);
/* XXX Force FD_CLOEXEC on all inherited fdno's. */

View File

@ -53,6 +53,9 @@ int rpmInitCrypto(void)
* a private context if possible.
*/
if (!_crypto_initialized) {
/* NSPR sets SIGPIPE to ignore behind our back, save and restore */
struct sigaction oact;
sigaction(SIGPIPE, NULL, &oact);
#if HAVE_NSS_INITCONTEXT
PRUint32 flags = (NSS_INIT_READONLY|NSS_INIT_NOCERTDB|
NSS_INIT_NOMODDB|NSS_INIT_FORCEOPEN|
@ -67,6 +70,7 @@ int rpmInitCrypto(void)
} else {
_crypto_initialized = 1;
}
sigaction(SIGPIPE, &oact, NULL);
}
/* Register one post-fork handler per process */