[Tools] testbot/testagentd: Fix handling the --run in/out/err redirection options.

Francois Gouget fgouget at codeweavers.com
Tue Jul 11 05:35:22 CDT 2017


Preventing handle inheritance at the CreateProcess() level also
prevents us from redirecting the child processes stdin/out/err. So
instead disable handle inheritance directly on the TestAgentd sockets.

TestAgentd also opens file descriptors for the sendfile, getfile and 
upgrade operations but those are closed before handling any other 
operation. So we only have to prevent the sockets from being inherited.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/src/testagentd/platform_windows.c | 2 +-
 testbot/src/testagentd/testagentd.c       | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/testbot/src/testagentd/platform_windows.c b/testbot/src/testagentd/platform_windows.c
index c72cf252..70272a65 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, FALSE, NORMAL_PRIORITY_CLASS,
+    if (!CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, 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 bc3d32b4..fce28b27 100644
--- a/testbot/src/testagentd/testagentd.c
+++ b/testbot/src/testagentd/testagentd.c
@@ -1347,6 +1347,9 @@ int main(int argc, char** argv)
         if (master < 0)
             continue;
         setsockopt(master, SOL_SOCKET, SO_REUSEADDR, (void*)&on, sizeof(on));
+#ifdef HANDLE_FLAG_INHERIT
+        SetHandleInformation((HANDLE)master, HANDLE_FLAG_INHERIT, 0);
+#endif
 
         debug("Trying to bind to %s\n", sockaddr_to_string(addrp->ai_addr, addrp->ai_addrlen));
         if (bind(master, addrp->ai_addr, addrp->ai_addrlen) == 0)
@@ -1376,6 +1379,9 @@ int main(int argc, char** argv)
 #ifdef O_CLOEXEC
         fcntl(client, F_SETFL, fcntl(client, F_GETFL, 0) | O_CLOEXEC);
 #endif
+#ifdef HANDLE_FLAG_INHERIT
+        SetHandleInformation((HANDLE)client, HANDLE_FLAG_INHERIT, 0);
+#endif
         if (client >= 0)
         {
             if (is_host_allowed(client, opt_srchost, addrlen))
-- 
2.13.2



More information about the wine-patches mailing list