diff options
author | Ron Yorston <rmy@pobox.com> | 2019-03-09 07:53:03 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2019-03-09 07:53:03 +0000 |
commit | 0f9bc90f097e2d3d4162757cd42941afb9358552 (patch) | |
tree | f0f2ac50d5ce916e5e1dc9041eb34a5f92f13b49 | |
parent | 9da32114e4779619b3cbbb4e3d795a5247e964d9 (diff) | |
download | busybox-w32-0f9bc90f097e2d3d4162757cd42941afb9358552.tar.gz busybox-w32-0f9bc90f097e2d3d4162757cd42941afb9358552.tar.bz2 busybox-w32-0f9bc90f097e2d3d4162757cd42941afb9358552.zip |
su: work when binary has a UNC path
ShellExecuteEx() requires backslashes as the file separator if
the binary to be executed has a UNC path. Convert separators
unconditionally.
-rw-r--r-- | loginutils/suw32.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/loginutils/suw32.c b/loginutils/suw32.c index d51a7f58c..93fd145f1 100644 --- a/loginutils/suw32.c +++ b/loginutils/suw32.c | |||
@@ -28,17 +28,27 @@ 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 | 32 | ||
32 | getopt32(argv, "c:", &opt_command); | 33 | getopt32(argv, "c:", &opt_command); |
33 | if (argv[optind]) | 34 | if (argv[optind]) |
34 | bb_show_usage(); | 35 | bb_show_usage(); |
35 | 36 | ||
37 | /* ShellExecuteEx() needs backslash as separator in UNC paths. */ | ||
38 | bb_path = s = xstrdup(bb_busybox_exec_path); | ||
39 | for ( ; *s; ++s) { | ||
40 | if (*s == '/') | ||
41 | *s = '\\'; | ||
42 | } | ||
43 | |||
36 | memset(&info, 0, sizeof(SHELLEXECUTEINFO)); | 44 | memset(&info, 0, sizeof(SHELLEXECUTEINFO)); |
37 | info.cbSize = sizeof(SHELLEXECUTEINFO); | 45 | info.cbSize = sizeof(SHELLEXECUTEINFO); |
38 | /* info.fMask = SEE_MASK_DEFAULT; */ | 46 | /* info.fMask = SEE_MASK_DEFAULT; */ |
39 | /* info.hwnd = NULL; */ | 47 | /* info.hwnd = NULL; */ |
40 | info.lpVerb = "runas"; | 48 | info.lpVerb = "runas"; |
41 | info.lpFile = bb_busybox_exec_path; | 49 | info.lpFile = bb_path; |
50 | /* ShellExecuteEx() always runs system binaries in C:\Windows\System32. | ||
51 | * Pass the directory we want to the shell. */ | ||
42 | info.lpParameters = xasprintf("--busybox ash -d \"%s\"", getcwd(NULL, 0)); | 52 | info.lpParameters = xasprintf("--busybox ash -d \"%s\"", getcwd(NULL, 0)); |
43 | if (opt_command) | 53 | if (opt_command) |
44 | info.lpParameters = | 54 | info.lpParameters = |