diff options
author | Ron Yorston <rmy@pobox.com> | 2024-08-05 14:32:44 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-08-05 14:32:44 +0100 |
commit | e5244175baa5c94726670a6aeb8645428306011a (patch) | |
tree | e86a863bf8717b982a848e1badf4dc059771c9ea /loginutils/suw32.c | |
parent | 2a09008c8eab35b5cc0422fab333ca657877256c (diff) | |
download | busybox-w32-e5244175baa5c94726670a6aeb8645428306011a.tar.gz busybox-w32-e5244175baa5c94726670a6aeb8645428306011a.tar.bz2 busybox-w32-e5244175baa5c94726670a6aeb8645428306011a.zip |
su: use correct option when cmd.exe is used as shell
Most Unix shells (and PowerShell) use the '-c' option to specify
commands to execute. cmd.exe uses '/c' instead.
Detect when cmd.exe is the 'shell' being used with 'su -s' and
adjust the command option to suit.
Adds 48-56 bytes.
(GitHub issue #438)
Diffstat (limited to 'loginutils/suw32.c')
-rw-r--r-- | loginutils/suw32.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/loginutils/suw32.c b/loginutils/suw32.c index cbe727969..821071388 100644 --- a/loginutils/suw32.c +++ b/loginutils/suw32.c | |||
@@ -111,7 +111,9 @@ int suw32_main(int argc UNUSED_PARAM, char **argv) | |||
111 | args = xappendword(args, "-N"); | 111 | args = xappendword(args, "-N"); |
112 | 112 | ||
113 | if (opt_command) { | 113 | if (opt_command) { |
114 | args = xappendword(args, "-c"); | 114 | args = xappendword(args, |
115 | (opt_shell && strcasecmp(bb_basename(bb_path), "cmd.exe") == 0) ? | ||
116 | "/c" : "-c"); | ||
115 | q = quote_arg(opt_command); | 117 | q = quote_arg(opt_command); |
116 | args = xappendword(args, q); | 118 | args = xappendword(args, q); |
117 | free(q); | 119 | free(q); |