]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
env_block(): if PATH is not set, add standard PATH setting to env so that
authorGert Doering <gert@greenie.muc.de>
Sun, 28 Feb 2010 21:48:48 +0000 (22:48 +0100)
committerGert Doering <gert@greenie.muc.de>
Sun, 24 Apr 2011 15:22:39 +0000 (17:22 +0200)
             "netsh.exe" can find "framedyn.dll" (needs work)

win32.c

diff --git a/win32.c b/win32.c
index 2b7bf7b3c4d9ba8787c6cd09cfdb9d31d0461c82..cf6cc2d98aaf6952645a582a84bd26710ec414bf 100644 (file)
--- a/win32.c
+++ b/win32.c
@@ -874,16 +874,21 @@ win_safe_filename (const char *fn)
 static char *
 env_block (const struct env_set *es)
 {
+  char * force_path = "PATH=C:\\Windows\\System32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem";
+
   if (es)
     {
       struct env_item *e;
       char *ret;
       char *p;
       size_t nchars = 1;
+      bool path_seen = false;
       
       for (e = es->list; e != NULL; e = e->next)
        nchars += strlen (e->string) + 1;
 
+      nchars += strlen(force_path)+1;
+
       ret = (char *) malloc (nchars);
       check_malloc_return (ret);
 
@@ -895,7 +900,18 @@ env_block (const struct env_set *es)
              strcpy (p, e->string);
              p += strlen (e->string) + 1;
            }
+         if ( strncmp(e->string, "PATH=", 5 ) == 0 )
+           path_seen = true;
+       }
+
+      /* make sure PATH is set */
+      if ( !path_seen )
+       {
+         msg( M_INFO, "env_block: add %s", force_path );
+         strcpy( p, force_path );
+         p += strlen(force_path) + 1;
        }
+
       *p = '\0';
       return ret;
     }