From 7aabb625005c642d6a30d6d97b51bf183429152e Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 30 Jul 2015 13:34:07 +0100 Subject: ash: don't convert path delimiters for certain environment variables The SYSTEMROOT and COMSPEC environment variables are known to cause problems for Windows applications if they contain forward slashes rather than backslashes. So don't convert them, even if the -X flag isn't present. --- README.md | 2 +- shell/ash.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 69c991ae9..d9988c45e 100644 --- a/README.md +++ b/README.md @@ -18,5 +18,5 @@ Then just `make`. - Don't do wild things with Windows drive or UNC notation. - Wildcard expansion is disabled by default, though it can be turned on at compile time. This only affects command line arguments to the binary: the BusyBox shell has full support for wildcards. - Handling of users, groups and permissions is totally bogus. The system only admits to knowing about the current user and always returns the same hardcoded uid, gid and permission values. - - Windows XP and Windows Server 2003 sometimes have trouble with forward slashes in environment variables. The -X shell option (which must be the first argument) prevents busybox-w32 from changing backslashes to forward slashes. + - Some crufty old Windows code (Windows XP, cmd.exe) doesn't like forward slashes in environment variables. The -X shell option (which must be the first argument) prevents busybox-w32 from changing backslashes to forward slashes. If Windows programs don't run from the shell it's worth trying it. - Currently only 32-bit builds of BusyBox work. If you want to install 32-bit BusyBox in a system directory on a 64-bit version of Windows you should put it in `C:\Windows\SysWOW64`, not `C:\Windows\System32`. On 64-bit systems the latter is for 64-bit binaries. diff --git a/shell/ash.c b/shell/ash.c index ef3f7933a..349e9deb8 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -13475,6 +13475,12 @@ init(void) for (start = *envp;start < end;start++) *start = toupper(*start); + /* skip conversion of variables known to cause problems */ + if ( strncmp(*envp, "SYSTEMROOT=", 11) == 0 || + strncmp(*envp, "COMSPEC=", 8) == 0 ) { + continue; + } + /* convert backslashes to forward slashes */ if (!xp) { for ( ++end; *end; ++end ) { -- cgit v1.2.3-55-g6feb