Module: tools Branch: master Commit: 14a04dd784e2a593de188be92ad4969da01994cc URL: http://source.winehq.org/git/tools.git/?a=commit;h=14a04dd784e2a593de188be92...
Author: Francois Gouget fgouget@codeweavers.com Date: Tue Jul 11 12:35:22 2017 +0200
testbot/testagentd: Fix handling the --run in/out/err redirection options.
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@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
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 c72cf25..70272a6 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 bc3d32b..fce28b2 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))