Francois Gouget : testbot/testagentd: Child processes should not inherit the server's sockets ( and other file descriptors).

Alexandre Julliard julliard at winehq.org
Mon Apr 14 12:10:15 CDT 2014


Module: tools
Branch: master
Commit: 1ed804c36b35bf4fd51876b4d02e92f64afb0fb5
URL:    http://source.winehq.org/git/tools.git/?a=commit;h=1ed804c36b35bf4fd51876b4d02e92f64afb0fb5

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Mon Apr 14 15:45:24 2014 +0200

testbot/testagentd: Child processes should not inherit the server's sockets (and other file descriptors).

---

 testbot/src/testagentd/platform_windows.c |    2 +-
 testbot/src/testagentd/testagentd.c       |   13 +++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/testbot/src/testagentd/platform_windows.c b/testbot/src/testagentd/platform_windows.c
index 9dda56a..89e435d 100644
--- a/testbot/src/testagentd/platform_windows.c
+++ b/testbot/src/testagentd/platform_windows.c
@@ -126,7 +126,7 @@ uint64_t platform_run(char** argv, uint32_t flags, char** redirects)
     si.hStdInput = fhs[0];
     si.hStdOutput = fhs[1];
     si.hStdError = fhs[2];
-    if (!CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS,
+    if (!CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS,
                         NULL, NULL, &si, &pi))
     {
         set_status(ST_ERROR, "could not run '%s': %lu", cmdline, GetLastError());
diff --git a/testbot/src/testagentd/testagentd.c b/testbot/src/testagentd/testagentd.c
index b8f9c57..230683a 100644
--- a/testbot/src/testagentd/testagentd.c
+++ b/testbot/src/testagentd/testagentd.c
@@ -1067,7 +1067,7 @@ int main(int argc, char** argv)
     char* opt_port = NULL;
     char* opt_srchost = NULL;
     struct addrinfo *addresses, *addrp;
-    int rc, addrlen;
+    int rc, sockflags, addrlen;
     int opt_usage = 0;
     SOCKET master;
     int on = 1;
@@ -1171,6 +1171,11 @@ int main(int argc, char** argv)
     }
 
     /* Bind to the host in a protocol neutral way */
+#ifdef SOCK_CLOEXEC
+    sockflags = SOCK_CLOEXEC;
+#else
+    sockflags = 0;
+#endif
     rc = ta_getaddrinfo(NULL, opt_port, &addresses);
     if (rc)
     {
@@ -1182,7 +1187,8 @@ int main(int argc, char** argv)
         debug("trying family=%d\n", addrp->ai_family);
         if (addrp->ai_family != PF_INET)
             continue;
-        master = socket(addrp->ai_family, addrp->ai_socktype, addrp->ai_protocol);
+        master = socket(addrp->ai_family, addrp->ai_socktype | sockflags,
+                        addrp->ai_protocol);
         if (master < 0)
             continue;
         setsockopt(master, SOL_SOCKET, SO_REUSEADDR, (void*)&on, sizeof(on));
@@ -1212,6 +1218,9 @@ int main(int argc, char** argv)
         SOCKET client;
         debug("Waiting in accept()\n");
         client = accept(master, NULL, NULL);
+#ifdef O_CLOEXEC
+        fcntl(client, F_SETFL, fcntl(client, F_GETFL, 0) | O_CLOEXEC);
+#endif
         if (client >= 0)
         {
             if (is_host_allowed(client, opt_srchost, addrlen))




More information about the wine-cvs mailing list