Browse Source

Reset ignored signals to SIG_DFL before exec() in fastcgi/scgi (fixes #2029)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2582 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.24
Stefan Bühler 13 years ago
parent
commit
839aa7dbd9
  1. 1
      NEWS
  2. 16
      src/mod_fastcgi.c
  3. 17
      src/mod_scgi.c

1
NEWS

@ -17,6 +17,7 @@ NEWS
* cmake: Fix crypt lib check
* cmake: Add -export-dynamic to link flags, fixes build on FreeBSD
* Set FD_CLOEXEC for bound sockets before pipe-logger forks (fixes #2026)
* Reset ignored signals to SIG_DFL before exec() in fastcgi/scgi (fixes #2029)
- 1.4.23 - 2009-06-19
* Added some extra warning options in cmake and fix the resulting warnings (unused/static functions)

16
src/mod_fastcgi.c

@ -384,6 +384,21 @@ typedef struct {
/* ok, we need a prototype */
static handler_t fcgi_handle_fdevent(void *s, void *ctx, int revents);
static void reset_signals(void) {
#ifdef SIGTTOU
signal(SIGTTOU, SIG_DFL);
#endif
#ifdef SIGTTIN
signal(SIGTTIN, SIG_DFL);
#endif
#ifdef SIGTSTP
signal(SIGTSTP, SIG_DFL);
#endif
signal(SIGHUP, SIG_DFL);
signal(SIGPIPE, SIG_DFL);
signal(SIGUSR1, SIG_DFL);
}
static void fastcgi_status_copy_procname(buffer *b, fcgi_extension_host *host, fcgi_proc *proc) {
buffer_copy_string_len(b, CONST_STR_LEN("fastcgi.backend."));
buffer_append_string_buffer(b, host->id);
@ -1052,6 +1067,7 @@ static int fcgi_spawn_connection(server *srv,
*c = '/';
}
reset_signals();
/* exec the cgi */
execve(arg.ptr[0], arg.ptr, env.ptr);

17
src/mod_scgi.c

@ -331,7 +331,20 @@ static handler_t scgi_handle_fdevent(void *s, void *ctx, int revents);
int scgi_proclist_sort_down(server *srv, scgi_extension_host *host, scgi_proc *proc);
static void reset_signals(void) {
#ifdef SIGTTOU
signal(SIGTTOU, SIG_DFL);
#endif
#ifdef SIGTTIN
signal(SIGTTIN, SIG_DFL);
#endif
#ifdef SIGTSTP
signal(SIGTSTP, SIG_DFL);
#endif
signal(SIGHUP, SIG_DFL);
signal(SIGPIPE, SIG_DFL);
signal(SIGUSR1, SIG_DFL);
}
static handler_ctx * handler_ctx_init() {
handler_ctx * hctx;
@ -826,6 +839,8 @@ static int scgi_spawn_connection(server *srv,
buffer_copy_string_len(b, CONST_STR_LEN("exec "));
buffer_append_string_buffer(b, host->bin_path);
reset_signals();
/* exec the cgi */
execle("/bin/sh", "sh", "-c", b->ptr, (char *)NULL, env.ptr);

Loading…
Cancel
Save