aboutsummaryrefslogtreecommitdiff
path: root/loginutils/suw32.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* sush: new appletsu_cmd2Ron Yorston2023-04-231-1/+29
| | | | | | | Introduce the new applet sush. It's like su but it permits additional arguments on the command line which are passed to the elevated shell. Adds 144-168 bytes. (O bytes if it's not enabled.)
* su: properly quote commandRon Yorston2023-04-231-8/+15
| | | | | | | | | | Previously the command passed to the elevated shell was placed in literal double quotes on the command line. Instead it should be subject to full quoting by the quote_arg() function. Tweak command line processing. Costs 24-32 bytes.
* win32: use lazy loading for certain DLLsRon Yorston2020-06-021-1/+6
| | | | | | | | | Only a handful of functions are used from shell32.dll, userenv.dll and psapi.dll. Mostly these functions are in out of the way places. By loading the functions only when required we can avoid the startup cost of linking the three DLLs in the common case that they aren't needed.
* win32: add function to convert slashes to backslashesRon Yorston2019-03-151-6/+3
| | | | | | | | | There are now two places where slashes are converted to backslashes throughout a string so it makes sense to create a function to do this. To avoid confusion rename convert_slashes() to bs_to_slash() and call the new function slash_to_bs().
* su: canonicalise directory before elevating privilegesRon Yorston2019-03-141-5/+11
| | | | | | If the current directory is in a drive mapped to a network share we may not be able to access it once we have elevated privileges. Avoid this by canonicalising the path before calling ShellExecuteEx().
* win32: changes to user idsRon Yorston2019-03-101-3/+5
| | | | | | | | | | | | | | | | Formalise the use of 0 as the uid of a process running with elevated privileges: - Rewrite getuid(2) to return DEFAULT_UID by default and 0 if the process has elevated privileges. - geteuid(2) and the corresponding functions for groups are aliases for getuid(2). - Change root's home directory to be whatever GetSystemDirectory() returns, probably C:/Windows/System32 in most cases. - Remove the special handling of geteuid(2) in the line editing code. With these changes the shell started by 'su' is a lot more like a *nix root shell.
* su: change title of console windowRon Yorston2019-03-091-1/+3
|
* su: work when binary has a UNC pathRon Yorston2019-03-091-1/+11
| | | | | | ShellExecuteEx() requires backslashes as the file separator if the binary to be executed has a UNC path. Convert separators unconditionally.
* su, wget: use magic '--busybox' flagRon Yorston2019-03-081-5/+2
| | | | | | I've been a bit lax about ensuring the --busybox flag is passed in command lines. It's needed to avoid problems if the binary is called something like sh.exe.
* ash, su: add -d flag to set directory in ash, use it in suRon Yorston2019-03-081-2/+5
| | | | | | | | When busybox-w32 is installed in C:/Windows/System32 su doesn't run in the same directory as its parent as intended. Work around this by adding a flag to the shell to set the working directory.
* su: add a basic implementation for WIN32Ron Yorston2019-03-071-0/+50
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"""'