Package: webfs / 1.21+ds1-12

32_no_cloexec.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Description: Erase FD_CLOEXEC flag.
 In recent Glibc and kernels, the default action is to set FD_CLOEXEC
 when duplicating a descriptor. The CGI routine uses an execve() call
 and the parent starts listening to stdout of the child. Therefore
 the closing of STDOUT_FILENO must be prevented nowadays.
Author: Mats Erik Andersson <mats.andersson@gisladisker.se>
Forwarded: no
Last-Update: 2010-01-29
--- webfs-1.21/cgi.c~	2010-01-26 13:29:23.000000000 +0100
+++ webfs-1.21/cgi.c	2010-01-29 00:11:30.000000000 +0100
@@ -130,6 +130,9 @@
     close_on_exec(p[0]);
     close_on_exec(p[1]);
 
+    /* Rescue stdout from being closed. CLOEXEC is default nowadays. */
+    fcntl(STDOUT_FILENO, F_SETFD, ~FD_CLOEXEC);
+
     /* setup environment */
     env_copy(&env);