| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
| |
Changes to the ls applet upstream assumed that the return value of
isatty() followed the C standard and would be 0 or 1. The wrapper
for Windows' _isatty() didn't allow for it returning a non-zero
value for a tty, not 1. This confused ls.
Fix the wrapper.
(GitHub issue #513)
|
| |
|
|
|
|
|
|
|
|
| |
The ioctl() to get the size of the terminal windows used functions
which weren't available on Windows XP. Load these dynamically to
avoid failure.
Adds 160 bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Implement a minimal stty applet for Windows.
- Display and set terminal rows and columns
- Enable/disable raw/cooked mode
- Enable/disable echo mode
- Implement 'stty sane' to reset raw/cooked/echo
Adds 2120-2304 bytes.
(GitHub issue #58)
|
|
|
|
|
|
|
| |
There were two copies of the static function die_if_error().
Replace these with a single external function.
Saves 16 bytes.
|
|
|
|
|
|
|
|
| |
Apply gnulib commit 034af0e401 (select, pselect: Fix test failure
on native Windows).
* lib/select.c (rpl_select): Fail if nfds is out-of-range.
* lib/pselect.c (pselect): Likewise.
|
|
|
|
| |
Changes are mostly cosmetic.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Apply musl commit 7e13e5ae (inet_pton: fix uninitialized memory
use for IPv4-mapped IPv6 addresses).
When a dot is encountered, the loop counter is incremented before
exiting the loop, but the corresponding ip array element is left
uninitialized, so the subsequent memmove (if "::" was seen) and the
loop copying ip to the output buffer will operate on an uninitialized
uint16_t.
The uninitialized data never directly influences the control flow and
is overwritten on successful return by the second half of the parsed
IPv4 address. But it's better to fix this to avoid unexpected
transformations by a sufficiently smart compiler and reports from
UB-detection tools.
Adds 16 bytes.
|
|
|
|
|
|
|
|
|
|
|
| |
Apply musl commit 79bdacff (glob: fix wrong return code when
aborting before any matches).
when the result count was zero, glob was ignoring a possible
GLOB_ABORTED error code and returning GLOB_NOMATCH. whether this
happened could be nondeterministic and dependent on the order of
dirent enumeration, in cases where multiple matches were present and
only some produced errors.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The emulation of readdir(2) didn't include the '.' and '..'
directories in the root of a logical drive. This resulted in
the 'ls' applet (and others) not matching the expected Unix
behaviour.
Alter the emulation of readdir(2) to include fake '.' and '..'
directories if necessary.
Adds 88-112 bytes.
(GitHub issue #487)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some installer programs have an entry in their manifest to indicate
that they need elevated privileges. The shell in busybox-w32 was
unable to run such programs.
When a program fails to run with ERROR_ELEVATION_REQUIRED, try
again using ShellExecuteEx() with the 'runas' verb to give it
elevated privileges.
Adds 272-288 bytes.
(GitHub issue #481)
|
|
|
|
|
| |
Compiling with FEATURE_SH_NOFORK disabled resulted in an error and
a warning. Fixing these doesn't change the default build.
|
|
|
|
|
|
|
|
| |
Alter quote_arg() to perform a single pass over the string in the
case where no change is required. Based on a proposal by @avih in
GitHub PR #317.
Saves 16 bytes.
|
|
|
|
|
|
|
|
|
|
|
| |
The previous commit removed trailing dots and spaces from the last
component of a pathname when changing directory. If the result has
a trailing slash remove that too. But not if it's a drive root,
to avoid 'cd C:/' showing a current directory of 'C:'.
Adds 48 bytes.
(GitHub issue #478)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The Windows API strips trailing dots and spaces from the last
component of a path. cmd.exe handles this quirk when changing
directory by adjusting its idea of the current directory to match
reality. The shell in busybox-w32 didn't do this, leading to some
confusion.
Fix the shell's cd builtin so it works more like cmd.exe.
Adds 64-80 bytes.
(GitHub issue #478)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A CGI script was found to hang when a large amount of data was
posted:
#!/bin/sh
echo "Content-type: text/plain;"
echo
if [ "$REQUEST_METHOD" = "POST" ]; then
dd of=my.dat bs=1 count=${CONTENT_LENGTH}
echo -n "success."
else
echo -n "error!"
fi
This appears to be due to problems determining whether a pipe is
writable on Windows. The Git for Windows project has a workaround
in their copy of GNUlib's poll(2) implementation. The details are
in the commit message:
https://github.com/git-for-windows/git/commit/94f4d01932279c419844aa708bec31a26056bc6b
Apply the same workaround here.
Saves 220-272 bytes.
(GitHub issue #468)
|
|
|
|
|
|
|
|
|
| |
If a process performing an exec is an orphan there's no reason for
it to wait for its child's exit code. Let it exit immediately.
Adds 16 bytes.
(GitHub issue #461)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
'kill -9' was found to fail with an 'Invalid argument' error.
This is a regression introduced by commit 569de936a (kill: killing
a zombie process should fail).
Use the correct argument to OpenProcess() for SIGKILL so it can
query the exit code of the target process.
Adds 16 bytes.
(GitHub issue #465)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It proved to be almost impossible to interrupt a loop like:
while true; do sleep 1; done
where 'sleep' was an external program, not an applet. The issue
was introduced by commit 0475b7a64 (win32: convert exit codes).
This passed a POSIX error code to the exit() in wait_for_child()
so a parent was unable to detect when its child was interrupted.
Pass the Windows exit code to exit() instead. Work around the
changes introduced by commit 790e377273 (win32: revert 'don't set
error mode').
Adds 16-32 bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When mingw_chdir() was introduced it canonicalised its argument
(585d17d26). This had the side effect of making its case match
that of the directory as stored on disk. Subsequent changes
retained that behaviour for symlinks but not otherwise (69d328022,
b99032390). This was noted to affect the appearance of the
directory specified by the (undocumented) 'sh -d' option.
Fix the case of non-symlink directories too.
Adds 16-32 bytes.
|
|
|
|
|
|
|
|
| |
The bogus user/group ids we use on Windows are very limited.
Make these limitations explicit in the 'id' applet.
Saves 464 bytes.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 1ade2225d2 (winansi: allow alternative screen buffer to be
disabled) added a workaround for the broken alternative screen
buffer in the Wine console.
The problem has been fixed in Wine for well over a year:
https://bugs.winehq.org/show_bug.cgi?id=54287
Remove the workaround.
Saves 80-96 bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The BusyBox shell detects certain cases where forking a command is
unnecessary (last command in a script or subshell, for example) and
calls execve(2) instead. This doesn't help in the Windows port
because execve(2) is implemented by creating a process.
There is one case where it is possible to apply this optimisation:
if the command is a script and the script interpreter is an applet.
- Have evalcommand() pass a flag to indicate this situation to
shellexec(). Also, allocate two spare elements before the start
of the argv array.
- If the flag is TRUE shellexec() passes the shell's PATH variable
down to tryexec() so it can perform a test for applet override.
- If tryexec() finds that all the necessary conditions apply it
can run a script by directly invoking the interpreter's main().
Adds 192-224 bytes.
|
|
|
|
|
| |
Add the FAST_FUNC qualifier to several Windows-specific functions.
This has no effect in 64-bit builds but saves 336 bytes for 32-bit.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The '%s' format of our strftime(3) wrapper (display number of
seconds since the Unix epoch) returned incorrect results on 64-bit
systems for times more than 2^31 seconds after the epoch.
Use the correct format.
Adds 16 bytes.
(GitHub issue #446)
|
|
|
|
|
|
|
|
|
|
|
| |
If we can't open a file to preserve its access time (perhaps
because it doesn't belong to us) just try again without bothering
about the access time. I thought I'd already done that, but
that must have been in an alternative reality.
Adds 16 bytes.
(GitHub issue #443)
|
|
|
|
|
|
|
|
|
|
|
|
| |
When privilege has been dropped by the 'drop' applet, the 'su'
applet is unable to raise it again because ShellExecuteEx()
thinks it unnecessary.
Detect this situation, report an error and return exit code 2.
Costs 72-112 bytes.
(GitHub issue #437)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit f444dc586 (win32: only search PATH for compressor) made
mingw_fork_compressor() perform a PATH lookup for the xz and lzma
compression programs. This avoided relying on CreateProcess() to
perform the search.
Other callers of the pipe creation code should also avoid reliance
on CreateProcess's executable search:
- Move the applet test and PATH lookup into mingw_popen_internal().
The first argument to CreateProcess() will always be a path to
an executable.
- mingw_fork_compressor() uses the new "w+" mode to indicate that
xz and lzma compressors should be found on PATH.
- mingw_popen() no longer needs to check for an applet itself, as
that's now handled in mingw_popen_internal().
- spawn_ssl_client() in 'wget' can rely on the popen code to look
up the 'ssl_client' applet.
- Remove unnecessary argument checks in mingw_popen_internal().
Adds 0-24 bytes.
|
|
|
|
|
|
|
|
|
|
|
| |
- Replace the half-baked code to quote the command passed to
popen(3) with a call to quote_arg().
- Where the command to be run is a non-overridden applet in the
current binary pass the path to the binary to CreateProcess()
instead of adding '--busybox' to the command.
Saves 128-136 bytes.
|
|
|
|
|
|
|
| |
Rewrite mingw_spawn_interpreter() to remove a duplicated recursive
call.
Saves 32-48 bytes.
|
|
|
|
|
|
|
| |
As well as trying to read '/etc/profile' also look for the script
'etc/profile' relative to the location of the running binary.
Adds 64-96 bytes.
|
|
|
|
|
|
| |
Now that get_system_drive() no longer returns a NULL pointer on
error chdir_system_drive() needs to check for an empty string
instead.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A previous commit (e3bfe3695) revised the use of getsysdir() to
obtain the system directory, and hence the system drive. See the
commit message for the history to that point.
Further improvements are possible:
- Remove getsysdir() and push the calls to GetSystemDirectory()
down into get_system_drive() and get_proc_addr().
- Check the return value of GetSystemDirectory(). It's unlikely
to fail, but better safe than sorry.
- Instead of making all callers of get_system_drive() check for a
NULL return value always return a non-NULL pointer. If the drive
can't be found an empty string is returned instead (which is what
the callers were using anyway).
- The function need_system_drive() was only used in one place (in
httpd). Move the code there and remove the function.
- Use concat_path_file() where possible.
Saves 76-144 bytes.
|
|
|
|
|
|
|
|
| |
The BB_TERMINAL_MODE variable is only documented to work for values
between 0 and 5. Due to an oversight it also accepted the value 6.
Like other unsupported values 6 is now replaced with the default
value configured at build time.
|
| |
|
|
|
|
| |
Saves 16 bytes.
|
|
|
|
|
|
| |
Rewrite the test for the value of BB_CRITICAL_ERROR_DIALOGS.
Saves 16-48 bytes.
|
|
|
|
|
|
|
|
|
| |
The wrapper function 'mingw_open()' should only read the optional
third argument if the 'O_CREAT' flag bit is set.
Adds 16 bytes.
(GitHub issue #425)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the environment variable BB_CRITICAL_ERROR_DIALOGS is set to
1 critical error dialogs are enabled. If unset or set to any
other value they aren't. In either case the error messages
introduced by commit 790e37727 (win32: revert 'don't set error
mode') are issued.
The shell exports BB_CRITICAL_ERROR_DIALOGS to the environment
immediately on any change so the setting takes effect at once.
Adds 104-160 bytes.
(GitHub issue #423)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit eb376b5d1 (win32: don't set error mode) removed a call to
SetErrorMode(SEM_FAILCRITICALERRORS).
But the documentation says:
Best practice is that all applications call the process-wide
SetErrorMode function with a parameter of SEM_FAILCRITICALERRORS
at startup. This is to prevent error mode dialogs from hanging
the application.
Doing this prevents the system from displaying useful information,
though. The application should attempt to tell the user what went
wrong.
Reinstate the call to SetErrorMode() and try to provide an error
message, at least for the situation mentioned in issue #423 and
other similar cases.
Adds 360-368 bytes.
(GitHub issue #423)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It was noted that setting HISTFILE=/dev/null in upstream BusyBox
prevented shell history from being saved to a history file. This
failed in busybox-w32 with an error from lseek(2).
The lseek(2) wrapper was rather conservative in the file types it
accepted. Allowing FILE_TYPE_CHAR makes it possible to seek on
/dev/null, thus avoiding the issue with HISTFILE.
In addition, the wrapper for open(2) now converts the Unix-style
mode argument to Windows-style.
(GitHub issue #425)
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Detecting Actually Portable Executable binaries used a longer
signature than seems necessary. Six characters should be enough
for anyone.
When right shifting a byte by 24 bits, cast it to unsigned to avoid
undefined behaviour.
Saves 24-32 bytes.
(GitHub issue #424)
|
|
|
|
|
|
|
|
|
| |
Check for the signature of Actually Portable Executable binaries
and treat them as executable.
Adds 40-64 bytes.
(GitHub issue #424)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In recent versions of Windows the PATH environment variable has
a trailing semicolon. This is insignificant to Windows because
it's ignored. busybox-w32 conforms to the POSIX interpretation
of PATH which treats an empty path element as denoting the current
directory. As result, on these versions of Windows executables
may by default be run from the current directory, contrary to
usual Unix practice.
Attempt to detect and remove the trailing semicolon on applet
start up. If the user insists, they can add a trailing semicolon
to the shell variable PATH and it will be respected in the
conventional manner.
Adds 88-112 bytes.
(GitHub issue #422)
|
|
|
|
|
|
|
|
| |
Merge the kill() and kill_pids() functions.
Allocate an array for the PIDs rather than use a hardcoded one.
Adds 32 bytes to the 32-bit build, none to 64-bit.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
busybox-w32 had a dummy implementation of getppid(2) which always
returned 1. Provide a more realistic version.
The effect is limited:
- The PPID shell variable should report a sensible value.
- The special value to omit the parent PID 'pidof -o %PPID'
should work.
Costs 48 bytes.
|
|
|
|
|
|
|
|
|
|
|
| |
Recent changes to allow orphaned processes to report a parent PID
of 1 rely on the assumption that Process32First/Process32Next
return parents before children. This isn't guaranteed by the API.
Obtain all known PIDs on the first call to procps_scan() so that
dead parents can be detected reliably.
Costs 48 bytes.
|
|
|
|
| |
Saves 16-32 bytes
|