aboutsummaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2005-10-31 03:01:17 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2005-10-31 03:01:17 +0000
commitc67d59cd5c30534a4108945294284f29df7a6c84 (patch)
tree00f4471a4eba2fdb39f1c0b4a0021d6824eb2abb /misc.c
parentChanges to Windows build configuration to (diff)
downloadopenvpn-c67d59cd5c30534a4108945294284f29df7a6c84.tar.xz
Windows reliability changes:
* Added code to make sure that the local PATH environmental variable points to the Windows system32 directory. * Added new --ip-win32 adaptive mode which tries 'dynamic' and then fails over to 'netsh' if the DHCP negotiation fails. * Made --ip-win32 adaptive the default. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@739 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/misc.c b/misc.c
index df40ace..278e8d7 100644
--- a/misc.c
+++ b/misc.c
@@ -1372,3 +1372,33 @@ openvpn_sleep (const int n)
#endif
sleep (n);
}
+
+/*
+ * Configure PATH. On Windows, sometimes PATH is not set correctly
+ * by default.
+ */
+void
+configure_path (void)
+{
+#ifdef WIN32
+ FILE *fp;
+ fp = fopen ("c:\\windows\\system32\\route.exe", "rb");
+ if (fp)
+ {
+ const int bufsiz = 512;
+ struct gc_arena gc = gc_new ();
+ struct buffer oldpath = alloc_buf_gc (bufsiz, &gc);
+ struct buffer newpath = alloc_buf_gc (bufsiz, &gc);
+ DWORD status;
+ fclose (fp);
+ status = GetEnvironmentVariable ("PATH", BPTR(&oldpath), (DWORD)BCAP(&oldpath));
+ if (status > 0)
+ {
+ buf_printf (&newpath, "C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;%s", BSTR(&oldpath));
+ SetEnvironmentVariable ("PATH", BSTR(&newpath));
+ /*printf ("PATH: %s\n", BSTR(&newpath));*/
+ }
+ gc_free (&gc);
+ }
+#endif
+}