summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2011-07-17 07:18:59 +0000
committerjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2011-07-17 07:18:59 +0000
commit14589b1ba9103e2d5c2e08e1514690f957a43513 (patch)
treeea7b6b1032255132da787fd77a868a33d5724ae9
parent5bd5ac9cb24a46487a99738aa280373e36b0b723 (diff)
downloaduhttpd-14589b1ba9103e2d5c2e08e1514690f957a43513.tar.gz
[package] uhttpd: unblock signals in CGI childs, solves hanging ssh logout after server restart from within LuCI and similar problems
git-svn-id: svn://svn.openwrt.org/openwrt/trunk/package/uhttpd/src@27628 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--uhttpd-cgi.c10
-rw-r--r--uhttpd.c2
2 files changed, 11 insertions, 1 deletions
diff --git a/uhttpd-cgi.c b/uhttpd-cgi.c
index 8c17251..ed68851 100644
--- a/uhttpd-cgi.c
+++ b/uhttpd-cgi.c
@@ -157,6 +157,8 @@ void uh_cgi_request(
fd_set reader;
fd_set writer;
+ sigset_t ss;
+
struct sigaction sa;
struct timeval timeout;
struct http_response *res;
@@ -187,6 +189,10 @@ void uh_cgi_request(
/* exec child */
case 0:
+ /* unblock signals */
+ sigemptyset(&ss);
+ sigprocmask(SIG_SETMASK, &ss, NULL);
+
/* restore SIGTERM */
sa.sa_flags = 0;
sa.sa_handler = SIG_DFL;
@@ -201,6 +207,10 @@ void uh_cgi_request(
dup2(rfd[1], 1);
dup2(wfd[0], 0);
+ /* avoid leaking our pipe into child-child processes */
+ fd_cloexec(rfd[1]);
+ fd_cloexec(wfd[0]);
+
/* check for regular, world-executable file _or_ interpreter */
if( ((pi->stat.st_mode & S_IFREG) &&
(pi->stat.st_mode & S_IXOTH)) || (ip != NULL)
diff --git a/uhttpd.c b/uhttpd.c
index 50c3b32..4a3bced 100644
--- a/uhttpd.c
+++ b/uhttpd.c
@@ -621,7 +621,7 @@ static void uh_mainloop(struct config *conf, fd_set serv_fds, int max_fd)
}
#ifdef HAVE_TLS
-static inline uh_inittls(struct config *conf)
+static inline int uh_inittls(struct config *conf)
{
/* library handle */
void *lib;