]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fix Windows script execution when called from script hooks
authorJosh Cepek <josh.cepek@usa.net>
Thu, 16 May 2013 14:09:23 +0000 (09:09 -0500)
committerGert Doering <gert@greenie.muc.de>
Sun, 19 May 2013 12:23:30 +0000 (14:23 +0200)
Console applications under Windows, such as batch scripts, require the
CREATE_NO_WINDOW process flag when run without an actual console window
present. This change allows such scripts to execute and impact the hook
status by way of their return code.

Fixes bug #240.

Signed-off-by: Josh Cepek <josh.cepek@usa.net>
Acked-by: Heiko Hund <heiko.hund@sophos.com>
Message-Id: <kn2pao$5sv$1@ger.gmane.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/7594
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/win32.c

index 2db96a8d28361f7f36af3fee28ddd9b64e3f0378..178e2c356007f24ba9c9f7892aa3a4001375f73b 100644 (file)
@@ -879,7 +879,10 @@ openvpn_execve (const struct argv *a, const struct env_set *es, const unsigned i
           start_info.dwFlags = STARTF_USESHOWWINDOW;
           start_info.wShowWindow = SW_HIDE;
 
-          if (CreateProcessW (cmd, cl, NULL, NULL, FALSE, 0, env, NULL, &start_info, &proc_info))
+          /* this allows console programs to run, and is ignored otherwise */
+          DWORD proc_flags = CREATE_NO_WINDOW;
+
+          if (CreateProcessW (cmd, cl, NULL, NULL, FALSE, proc_flags, env, NULL, &start_info, &proc_info))
             {
               DWORD exit_status = 0;
               CloseHandle (proc_info.hThread);