Browse code

Make '--win-sys env' default

Without this patch, the default path used by OpenVPN is hard coded
to C:\WINDOWS. As users might install Windows in a different directory,
this approach will cause OpenVPN to malfunction in some configurations.

OpenVPN have supported using the system path, by adding --win-sys env.
This patch removes the hard coded approach and uses the --win-sys env
approach by default instead.

Trac-ticket: 66
URL: http://thread.gmane.org/gmane.network.openvpn.user/32508
Signed-off-by: David Sommerseth <davids@redhat.com>
Tested-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>

David Sommerseth authored on 2011/11/18 21:21:43
Showing 5 changed files
... ...
@@ -4769,20 +4769,23 @@ Optional group to be owner of this tunnel.
4769 4769
 .SS Windows-Specific Options:
4770 4770
 .\"*********************************************************
4771 4771
 .TP
4772
-.B \-\-win-sys path|'env'
4772
+.B \-\-win-sys path
4773 4773
 Set the Windows system directory pathname to use when looking for system
4774 4774
 executables such as
4775 4775
 .B route.exe
4776 4776
 and
4777 4777
 .B netsh.exe.
4778 4778
 By default, if this directive is
4779
-not specified, the pathname will be set to "C:\\WINDOWS"
4780
-
4781
-The special string
4782
-.B 'env'
4783
-indicates that the pathname should be read from the
4784
-.B SystemRoot
4785
-environmental variable.
4779
+not specified, OpenVPN will use the SystemRoot environment variable.
4780
+
4781
+This option have changed behaviour in OpenVPN 2.3.  Earlier you had to
4782
+define
4783
+.B --win-sys env
4784
+to use the SystemRoot environment variable, otherwise it defaulted to C:\\WINDOWS.
4785
+It is not needed to use the
4786
+.B env
4787
+keyword any more, and it will just be ignored. A warning is logged when this
4788
+is found in the configuration file.
4786 4789
 .\"*********************************************************
4787 4790
 .TP
4788 4791
 .B \-\-ip-win32 method
... ...
@@ -162,7 +162,7 @@ main (int argc, char *argv[])
162 162
 	  /* initialize environmental variable store */
163 163
 	  c.es = env_set_create (NULL);
164 164
 #ifdef WIN32
165
-	  env_set_add_win32 (c.es);
165
+	  set_win_sys_path_via_env (c.es);
166 166
 #endif
167 167
 
168 168
 #ifdef ENABLE_MANAGEMENT
... ...
@@ -652,8 +652,8 @@ static const char usage_message[] =
652 652
 #ifdef WIN32
653 653
   "\n"
654 654
   "Windows Specific:\n"
655
-  "--win-sys path|'env' : Pathname of Windows system directory, C:\\WINDOWS by default.\n"
656
-  "                       If specified as 'env', read the pathname from SystemRoot env var.\n"
655
+  "--win-sys path    : Pathname of Windows system directory. Default is the pathname\n"
656
+  "                    from SystemRoot environment variable.\n"
657 657
   "--ip-win32 method : When using --ifconfig on Windows, set TAP-Win32 adapter\n"
658 658
   "                    IP address using method = manual, netsh, ipapi,\n"
659 659
   "                    dynamic, or adaptive (default = adaptive).\n"
... ...
@@ -5687,7 +5687,9 @@ add_option (struct options *options,
5687 5687
     {
5688 5688
       VERIFY_PERMISSION (OPT_P_GENERAL);
5689 5689
       if (streq (p[1], "env"))
5690
-	set_win_sys_path_via_env (es);
5690
+	msg (M_INFO, "NOTE: --win-sys env is default from OpenVPN v2.3.	 "
5691
+	     "This entry will now be ignored.  "
5692
+	     "Please remove this entry from your configuration file.");
5691 5693
       else
5692 5694
 	set_win_sys_path (p[1], es);
5693 5695
     }
... ...
@@ -1103,12 +1103,6 @@ set_win_sys_path_via_env (struct env_set *es)
1103 1103
   set_win_sys_path (buf, es);
1104 1104
 }
1105 1105
 
1106
-void
1107
-env_set_add_win32 (struct env_set *es)
1108
-{
1109
-  set_win_sys_path (DEFAULT_WIN_SYS_PATH, es);
1110
-}
1111
-
1112 1106
 
1113 1107
 const char *
1114 1108
 win_get_tempdir()
... ...
@@ -30,7 +30,6 @@
30 30
 
31 31
 /* location of executables */
32 32
 #define SYS_PATH_ENV_VAR_NAME "SystemRoot"  /* environmental variable name that normally contains the system path */
33
-#define DEFAULT_WIN_SYS_PATH  "C:\\WINDOWS" /* --win-sys default value */
34 33
 #define NETSH_PATH_SUFFIX     "\\system32\\netsh.exe"
35 34
 #define WIN_ROUTE_PATH_SUFFIX "\\system32\\route.exe"
36 35
 #define WIN_IPCONFIG_PATH_SUFFIX "\\system32\\ipconfig.exe"
... ...
@@ -269,7 +268,6 @@ bool win_safe_filename (const char *fn);
269 269
 
270 270
 /* add constant environmental variables needed by Windows */
271 271
 struct env_set;
272
-void env_set_add_win32 (struct env_set *es);
273 272
 
274 273
 /* get and set the current windows system path */
275 274
 void set_win_sys_path (const char *newpath, struct env_set *es);