Add check to make sure /run/initctl is open before we try to close

it when receiving SIGUSR1. Avoids crashing upon receiving signal.
This commit is contained in:
Jesse Smith 2018-04-15 14:09:33 -03:00
parent aee28b3292
commit f09da9cb55
2 changed files with 11 additions and 7 deletions

View File

@ -12,6 +12,12 @@ sysvinit (2.90) UNRELEASED; urgency=low
longer waits if we slept past the time we should have shutdown.
Accurate to the nearest minute.
Closes Savannah bug #36279.
* Added document article and manual page for the initctl (/run/initctl)
named pipe. Makes it easier for people to communicate with and
extend communication to init.
* Added check that named pipe is open before trying to close it
when something goes wrong or we receive SIGUSER1. Avoids potential
crash if we receive SIGUSR1 while pipe is not open.
sysvinit (2.89) world; urgency=low

View File

@ -2165,13 +2165,10 @@ void re_exec(void)
initlog(L_CO, "Attempt to re-exec failed");
}
/*
* It's a backup day today, so I'm pissed off. Being a BOFH, however,
* does have it's advantages...
*/
fail_cancel();
close(pipe_fd);
pipe_fd = -1;
if (pipe_fd >= 0)
close(pipe_fd);
pipe_fd = -1;
DELSET(got_signals, SIGCHLD);
DELSET(got_signals, SIGHUP);
DELSET(got_signals, SIGUSR1);
@ -2680,7 +2677,8 @@ void process_signals()
* SIGUSR1 means close and reopen /run/initctl
*/
INITDBG(L_VB, "got SIGUSR1");
close(pipe_fd);
if (pipe_fd)
close(pipe_fd);
pipe_fd = -1;
DELSET(got_signals, SIGUSR1);
}