| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The syntax becomes:
su [-c CMD [ARG...]]
This makes it a lot easier to use values from the current shell,
instead of shell-quoting them for re-input and embedding at CMD.
Also, previously -c expected an option-argument, and now it's a flag
which requires a CMD operand, just like 'sh', so that both these
forms now error the same way (as they should):
sh -c --
su -c --
(previously su -c -- did not error because '--' was assumed CMD)
Adds 64 bytes.
(Based on GitHub PR #317)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In 'su -c "CMD"' CMD should become a single argument to busybox
sh -c ...
But previously, the parameter string to ShellExecute was constructed
by placing the literal value of CMD inside double quotes, which could
result in incorrect and/or more than one parameter seen by the
program, because double-quotes and (some) backslashes in CMD should
be escaped while constructing the string, but they weren't.
Now they're escaped so that the WIN32 CommandLineToArgv[W] parses it
into a single argument with value identical to the original CMD.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
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().
|
|
|
|
|
|
| |
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().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
| |
ShellExecuteEx() requires backslashes as the file separator if
the binary to be executed has a UNC path. Convert separators
unconditionally.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
|
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"""'
|