diff options
-rw-r--r-- | loginutils/suw32.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/loginutils/suw32.c b/loginutils/suw32.c index 6396a7b88..e3c6d8744 100644 --- a/loginutils/suw32.c +++ b/loginutils/suw32.c | |||
@@ -28,7 +28,7 @@ int suw32_main(int argc UNUSED_PARAM, char **argv) | |||
28 | { | 28 | { |
29 | char *opt_command = NULL; | 29 | char *opt_command = NULL; |
30 | SHELLEXECUTEINFO info; | 30 | SHELLEXECUTEINFO info; |
31 | char *bb_path, *s; | 31 | char *bb_path, *cwd, *s; |
32 | 32 | ||
33 | getopt32(argv, "c:", &opt_command); | 33 | getopt32(argv, "c:", &opt_command); |
34 | if (argv[optind]) | 34 | if (argv[optind]) |
@@ -47,13 +47,19 @@ int suw32_main(int argc UNUSED_PARAM, char **argv) | |||
47 | /* info.hwnd = NULL; */ | 47 | /* info.hwnd = NULL; */ |
48 | info.lpVerb = "runas"; | 48 | info.lpVerb = "runas"; |
49 | info.lpFile = bb_path; | 49 | info.lpFile = bb_path; |
50 | /* It seems that when ShellExecuteEx() runs binaries residing in | 50 | /* |
51 | * It seems that when ShellExecuteEx() runs binaries residing in | ||
51 | * certain 'system' directories it sets the current directory of | 52 | * certain 'system' directories it sets the current directory of |
52 | * the process to %SYSTEMROOT%\System32. Override this by passing | 53 | * the process to %SYSTEMROOT%\System32. Override this by passing |
53 | * the directory we want to the shell. */ | 54 | * the directory we want to the shell. |
55 | * | ||
56 | * Canonicalise the directory now: if it's in a drive mapped to | ||
57 | * a network share it may not be available once we have elevated | ||
58 | * privileges. | ||
59 | */ | ||
60 | cwd = xmalloc_realpath(getcwd(NULL, 0)); | ||
54 | info.lpParameters = | 61 | info.lpParameters = |
55 | xasprintf("--busybox ash -d \"%s\" -t \"BusyBox ash (Admin)\" ", | 62 | xasprintf("--busybox ash -d \"%s\" -t \"BusyBox ash (Admin)\" ", cwd); |
56 | getcwd(NULL, 0)); | ||
57 | if (opt_command) | 63 | if (opt_command) |
58 | info.lpParameters = | 64 | info.lpParameters = |
59 | xasprintf("%s -s -c \"%s\"", info.lpParameters, opt_command); | 65 | xasprintf("%s -s -c \"%s\"", info.lpParameters, opt_command); |