aboutsummaryrefslogtreecommitdiff
path: root/loginutils/su.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-03-07 14:54:41 +0000
committerRon Yorston <rmy@pobox.com>2019-03-07 15:34:24 +0000
commit0533794afd81b37684669ee0c5afc7a5e1ff159d (patch)
treea6afcd3e6c5e6430093b5e01111d799ed1a30622 /loginutils/su.c
parent585d17d262efabce4a9a87f33f531ef9ab7c0e36 (diff)
downloadbusybox-w32-0533794afd81b37684669ee0c5afc7a5e1ff159d.tar.gz
busybox-w32-0533794afd81b37684669ee0c5afc7a5e1ff159d.tar.bz2
busybox-w32-0533794afd81b37684669ee0c5afc7a5e1ff159d.zip
su: add a basic implementation for WIN32
Use the undocumented 'runas' verb in a call to ShellExecuteEx() to run a shell with elevated privileges. Because of the way ShellExecuteEx() works this: - requires that you acknowledge a User Account Control prompt (if you're an Administrator); - requires that you enter an Administrator's password (if you aren't an Administrator); - creates a separate console window for the privileged shell. Variables from the parent shell aren't passed to its privileged child, only variables from the environment. It's possible to specify a command to run when the shell starts. This can be used to pass shell variables: su -c "HELLO='hello world'; GOODBYE=$GOODBYE" Or do fancy things like: su -c "ls -l; read -p 'Hit return to exit: '; exit" It's probably best to put double quotes around the command and use single quotes inside it. Apparently ShellExecuteEx() requires double quotes to be entered in triplicate: su -c 'HELLO="""hello world"""'
Diffstat (limited to 'loginutils/su.c')
-rw-r--r--loginutils/su.c1
1 files changed, 1 insertions, 0 deletions
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.