diff options
-rw-r--r-- | configs/mingw32_defconfig | 3 | ||||
-rw-r--r-- | configs/mingw64_defconfig | 3 | ||||
-rw-r--r-- | loginutils/su.c | 1 | ||||
-rw-r--r-- | loginutils/suw32.c | 50 |
4 files changed, 55 insertions, 2 deletions
diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig index a29cc164a..571aa112c 100644 --- a/configs/mingw32_defconfig +++ b/configs/mingw32_defconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Busybox version: 1.31.0.git | 3 | # Busybox version: 1.31.0.git |
4 | # Wed Mar 6 09:32:59 2019 | 4 | # Thu Mar 7 14:31:51 2019 |
5 | # | 5 | # |
6 | CONFIG_HAVE_DOT_CONFIG=y | 6 | CONFIG_HAVE_DOT_CONFIG=y |
7 | # CONFIG_PLATFORM_POSIX is not set | 7 | # CONFIG_PLATFORM_POSIX is not set |
@@ -550,6 +550,7 @@ CONFIG_FEATURE_DEFAULT_PASSWD_ALGO="" | |||
550 | # CONFIG_FEATURE_SU_CHECKS_SHELLS is not set | 550 | # CONFIG_FEATURE_SU_CHECKS_SHELLS is not set |
551 | # CONFIG_FEATURE_SU_BLANK_PW_NEEDS_SECURE_TTY is not set | 551 | # CONFIG_FEATURE_SU_BLANK_PW_NEEDS_SECURE_TTY is not set |
552 | # CONFIG_SULOGIN is not set | 552 | # CONFIG_SULOGIN is not set |
553 | CONFIG_SUW32=y | ||
553 | # CONFIG_VLOCK is not set | 554 | # CONFIG_VLOCK is not set |
554 | 555 | ||
555 | # | 556 | # |
diff --git a/configs/mingw64_defconfig b/configs/mingw64_defconfig index 3d6102f0a..47bfc994a 100644 --- a/configs/mingw64_defconfig +++ b/configs/mingw64_defconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Busybox version: 1.31.0.git | 3 | # Busybox version: 1.31.0.git |
4 | # Wed Mar 6 09:32:59 2019 | 4 | # Thu Mar 7 14:31:51 2019 |
5 | # | 5 | # |
6 | CONFIG_HAVE_DOT_CONFIG=y | 6 | CONFIG_HAVE_DOT_CONFIG=y |
7 | # CONFIG_PLATFORM_POSIX is not set | 7 | # CONFIG_PLATFORM_POSIX is not set |
@@ -550,6 +550,7 @@ CONFIG_FEATURE_DEFAULT_PASSWD_ALGO="" | |||
550 | # CONFIG_FEATURE_SU_CHECKS_SHELLS is not set | 550 | # CONFIG_FEATURE_SU_CHECKS_SHELLS is not set |
551 | # CONFIG_FEATURE_SU_BLANK_PW_NEEDS_SECURE_TTY is not set | 551 | # CONFIG_FEATURE_SU_BLANK_PW_NEEDS_SECURE_TTY is not set |
552 | # CONFIG_SULOGIN is not set | 552 | # CONFIG_SULOGIN is not set |
553 | CONFIG_SUW32=y | ||
553 | # CONFIG_VLOCK is not set | 554 | # CONFIG_VLOCK is not set |
554 | 555 | ||
555 | # | 556 | # |
diff --git a/loginutils/su.c b/loginutils/su.c index 41291ea8f..2e1b309b0 100644 --- a/loginutils/su.c +++ b/loginutils/su.c | |||
@@ -8,6 +8,7 @@ | |||
8 | //config: bool "su (19 kb)" | 8 | //config: bool "su (19 kb)" |
9 | //config: default y | 9 | //config: default y |
10 | //config: select FEATURE_SYSLOG | 10 | //config: select FEATURE_SYSLOG |
11 | //config: depends on PLATFORM_POSIX | ||
11 | //config: help | 12 | //config: help |
12 | //config: su is used to become another user during a login session. | 13 | //config: su is used to become another user during a login session. |
13 | //config: Invoked without a username, su defaults to becoming the super user. | 14 | //config: Invoked without a username, su defaults to becoming the super user. |
diff --git a/loginutils/suw32.c b/loginutils/suw32.c new file mode 100644 index 000000000..3aa478f33 --- /dev/null +++ b/loginutils/suw32.c | |||
@@ -0,0 +1,50 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Mini su implementation for busybox-w32 | ||
4 | * | ||
5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | ||
6 | */ | ||
7 | //config:config SUW32 | ||
8 | //config: bool "su for Microsoft Windows" | ||
9 | //config: default y | ||
10 | //config: depends on PLATFORM_MINGW32 && ASH | ||
11 | //config: help | ||
12 | //config: su runs a shell with elevated privileges. | ||
13 | |||
14 | //applet:IF_SUW32(APPLET_ODDNAME(su, suw32, BB_DIR_BIN, BB_SUID_DROP, suw32)) | ||
15 | |||
16 | //kbuild:lib-$(CONFIG_SUW32) += suw32.o | ||
17 | |||
18 | //usage:#define suw32_trivial_usage | ||
19 | //usage: "[-c \"CMD\"]" | ||
20 | //usage:#define suw32_full_usage "\n\n" | ||
21 | //usage: "Run shell with elevated privileges\n" | ||
22 | //usage: "\n -c CMD Command to pass to 'sh -c'" | ||
23 | |||
24 | #include "libbb.h" | ||
25 | |||
26 | int suw32_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
27 | int suw32_main(int argc UNUSED_PARAM, char **argv) | ||
28 | { | ||
29 | char *opt_command = NULL; | ||
30 | SHELLEXECUTEINFO info; | ||
31 | |||
32 | getopt32(argv, "c:", &opt_command); | ||
33 | if (argv[optind]) | ||
34 | bb_show_usage(); | ||
35 | |||
36 | memset(&info, 0, sizeof(SHELLEXECUTEINFO)); | ||
37 | info.cbSize = sizeof(SHELLEXECUTEINFO); | ||
38 | /* info.fMask = SEE_MASK_DEFAULT; */ | ||
39 | /* info.hwnd = NULL; */ | ||
40 | info.lpVerb = "runas"; | ||
41 | info.lpFile = bb_busybox_exec_path; | ||
42 | if (opt_command) | ||
43 | info.lpParameters = xasprintf("ash -s -c \"%s\"", opt_command); | ||
44 | else | ||
45 | info.lpParameters = "ash"; | ||
46 | /* info.lpDirectory = NULL; */ | ||
47 | info.nShow = SW_SHOWNORMAL; | ||
48 | |||
49 | return !ShellExecuteEx(&info); | ||
50 | } | ||