| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
|
|
|
|
|
|
| |
Allow either ISAAC or the shell's built-in pseudo-random number
generator to be used for /dev/urandom. The latter is smaller so
it's the default.
|
| |
|
|
|
|
|
|
|
|
| |
Reduce the size of the binary by about 32 bytes:
- use xzalloc to allocate static buffers so we don't have to
initialise them;
- avoid duplicated code in spawnveq.
|
|
|
|
|
|
|
|
|
|
|
| |
Moving detection of file formats from access(2) to stat(2) in
commit 650f67507 was acknowledged to slow down stat. One
problematic case is c:/windows/system32 which contains about
2000 DLLs and was found to slow 'ls' unacceptably.
Treat DLLs as a special case in has_exec_format.
See GitHub issue #101.
|
| |
|
|
|
|
|
|
|
|
|
| |
Reading the attributes of files like c:/pagefile.sys fails with
error code ERROR_SHARING_VIOLATION, which breaks 'ls'.
If this happens try an alternative API call to get the attributes.
See GitHub issue #101.
|
|
|
|
|
|
|
|
|
| |
Make mingw_popen_fd sufficiently general that it can be used to
implement the other two popen routines.
mingw_popen now just creates a command line and passes it to
mingw_popen_fd. The one call to mingw_popen2 has been replaced
by a call to mingw_popen_fd.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Allow wget to support https URLs. Changes are:
- Add mingw_popen2 which uses a named pipe to allow bidirectional
communication with a child process;
- Modify ssl_client to accept a WIN32 handle instead of a file
descriptor as an argument;
- Allow tls_get_random to open /dev/urandom;
- Using the above changes implement a WIN32 version of spawn_ssl_client
in wget.
This closes GitHub issue #75.
Also, enable authentication in wget.
|
|
|
|
|
| |
Since device files are now handled in mingw_open there's no need
for any special treatment in ash redirection.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Handling of the special devices /dev/zero and /dev/urandom was
inconsistent:
- they could be used as arguments to 'cat' but not 'od';
- they could not be used in shell redirection.
Restrict the use of these devices to two places:
- as input files to 'dd' with the 'if=' argument;
- internally within 'shred'.
See GitHub issue #98.
|
|
|
|
|
|
|
| |
write(2) is commonly used in applets like cat and tr so we should
check for broken pipes there too.
See issue #99.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Microsoft Windows doesn't support SIGPIPE and its support for the
EPIPE error is somewhat inadequate. Most of the time a broken pipe
leads to an EINVAL error which is misleading:
$ yes hello | head -1
hello
yes: Invalid argument
Add a function to test for the underlying Windows error that indicates
a broken pipe and set errno to EPIPE. Call this function in a few
strategic places.
|
|
|
|
|
|
|
| |
Rewrite winansi_puts using winansi_fputs and putchar. There's no
need to use winansi_putchar.
Improve error return values from winansi_fputs and winansi_fwrite.
|
|
|
|
| |
Also tighten up the code slightly.
|
| |
|
| |
|
|
|
|
|
|
| |
BusyBox ensures that strchrnul is always available, either from the
target platform or by including its own version. Therefore it isn't
necessary for fnmatch to use its equivalent.
|
|
|
|
|
|
|
| |
It appears that uninitialised static variables are placed in the
data section rather than bss, increasing the size of the binary.
Rewrite some code to reduce the amount of static data.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Exclude source files in libbb that aren't used by busybox-w32. This
speeds up the build marginally. They can always be reinstated if
necessary.
Provide fake routines for everything in inode_hash.c so that it
can be excluded. inode_hash.c is now unchanged from upstream.
Use last_char_is in has_exe_suffix_or_dot. It doesn't save any
bytes but it makes the code neater.
|
|
|
|
| |
The only other caller (in spawnveq) has been removed.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Consistent processing of file extensions, as described in the previous
commit, has been applied to the 'which' applet and the functions
find_executable and mingw_spawn_interpreter.
In spawnveq check that the file to be executed exists and is executable,
and ensure that it won't have any extensions added by spawnve.
It's intended that all files passed to spawnve should have their names
fully specified. If this isn't the case the tests here will cause errors
which will need to be fixed.
|
|
|
|
|
|
|
| |
A filename ending with a dot is a signal to spawnve not to try
adding extensions but to use the name unmodified.
The add_win32_extension function should follow the same rule.
|
|
|
|
|
| |
The has_win_suffix function didn't check that the extension started
with a '.'. As a result the shell was unable to execute cmd.exe.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Move the code to detect shell scripts and binary executables from
mingw_access to a separate function, has_exec_format. Call this function
in do_lstat to decide whether to set the executable bits in the file mode.
This will slow down stat but has a couple of advantages:
- shell scripts are highlighted in ls output
- the test applet can use stat(2) to detect executable files
The new function is used to handle another corner case in spawnveq:
binary executables without the usual .exe extension are only run by
spawnve if the file name ends with '.'.
Two minor changes:
- file_is_win32_executable has been renamed add_win32_extension to
clarify what it does
- a call to file_is_executable has been removed from find_command
in ash as it resulted in unhelpful error messages.
|
|
|
|
|
|
|
| |
Set all mode bits rather than just setting user modes and then
extending them to group and other.
Combine common code in mingw_fstat.
|
|
|
|
|
|
|
|
| |
Support batch files with .bat and .cmd extensions, similar to
what's done for .exe and .com.
Check extensions in the same order as Windows' spawn function:
.com, .exe, .bat, .cmd.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently /dev/zero is handled as a special case in dd. Add hacks
to the open and read functions in mingw.c to handle the zero and
urandom devices.
- Opening /dev/zero or /dev/urandom actually opens the special
Windows file 'nul' which behaves like /dev/null. This allows
manipulation of the file descriptor with things like seek and
close
- When /dev/zero or /dev/urandom is opened the resulting file
descriptor is stored and used to override the behaviour of read.
- No attempt is made to track duplicated file descriptors, so using
these devices for redirections in the shell isn't going to work
and won't be permitted. (Could be, but won't.)
- Limited control of the special file descriptors is provided by
allowing the internal variables to be changed.
- The numbers from /dev/urandom aren't very random.
|
| |
|
|
|
|
|
|
|
|
| |
The copy of inet_pton.c imported from gnulib was licensed under
GPL3 which is incompatible with the GPL2-only licence of BusyBox.
Import an MPL2-licensed version of this file from ISC BIND git
master as of this date.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
popen uses the shell to run the command provided. If BusyBox has
been configured appropriately use the built-in shell for this.
- Currently the only user of popen in busybox-w32 is awk, which
uses it when piping to or from commands.
- If the command is available as an applet the shell will use it.
If a different version of the program is required the command
will need to specify the full path.
- This change means that popen will work even if no shell is
present on the path.
- Since the binary may have been run as sh.exe or awk.exe it's
necessary to use the magic --busybox option.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
It turns out that with the new toolchain safe API calls work on all
all platforms. Even the original code from commit fa147bd7e works
on Windows XP when built with the new tools.
- Remove the unsafe environment manipulation via the environ array
- Microsoft's putenv takes a copy of its argument so the string
can be freed
- Rewrite some routines and add more error checking
|
|
|
|
|
|
|
| |
The strftime provided by the Microsoft C runtime uses '#' as the
format string flag to remove zero padding; glibc uses '-'.
Support the use of the '-' flag for improved compatibility.
|
|
|
|
|
|
| |
df now uses statvfs instead of statfs. Support this by pretending
that statfs *is* statvfs. Not really true but good enough for the
present purpose.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When passing -1 as pid to the waitpid() function, it is supposed to wait
for *any* child to exit. That is a bit tough to emulate on Windows given
that waitpid() returns only one pid, and if multiple children have exited,
subsequent calls to waitpid() should produce all of their pids
subsequently. Oh, and we would have to figure out which processes were
spawned and remember that list. And then, it would still be possible for
the children to exit in the meantime and for *another* process using the
pid, as Windows reuses pids very, very quickly.
So let's punt and simply state that we do not support that
functionality.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
|
|
|
|
|
|
| |
According to the man page:
If sig is 0, then no signal is sent, but existence and permission
checks are still performed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Extend the implementation of kill(2) so that:
- Sending the TERM signal asks the target process to exit. As on
Unix it may not comply.
- Sending the KILL signal forcibly terminates the target process.
- Using a negative pid treats the target process as a process
group leader and signals it and all of its descendants.
- Using a pid of zero treats the current process as a process
group leader and signals it and all of its descendants.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As Git for Windows' source code recently learned, let's also avoid using
TerminateProcess() in BusyBox-w32: it does not allow the killed
processes' atexit() handlers to run.
Instead, jump through a couple of hoops by injecting a remote thread
that executes the ExitProcess() function.
This allows the atexit() handlers to run, at which point the exit code
of the process can already be queried via GetExitCodeProcess(), and
appropriate action can be taken, such as killing child processes.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
|
|
|
|
|
|
|
| |
It may be necessary to run ps as administrator to get information
about processes belonging to other users.
The code to detect GetTickCount64 at run-time was imported from
Git for Windows.
|
| |
|
|
|
|
|
|
|
|
|
| |
This is a companion patch to 4319368c6 (Use gnulib poll, importing the
version from git, 2012-03-30) (Git's implementation of IsConsoleHandle()
was adjusted in the meantime).
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
|
|
|
|
| |
Remove the check for argv being NULL in spawnveq. It shouldn't
ever succeed.
|
|
|
|
|
|
| |
The function find_executable is more generic than needed here: it
can search for all matches on PATH whereas we only want the first.
Implement find_first_executable to do that.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Simplify how scripts are detected by parse_interpreter. It now:
- uses strtok to parse the line buffer;
- returns any options as a single string, not an array of separate options;
- returns both the full path of the interpreter and its name.
When a script is detected the sequence is now:
- if the path to the interpreter refers to an executable run that;
- else look up the interpreter name as a applet (if so configured) and
run the applet found;
- else search for the interpreter name on PATH.
|
|
|
|
|
|
|
|
| |
Add a function (has_exe_suffix) to replace explicit code to check
if a filename ends with '.exe. or '.com'.
Also shrink code that checks for '.exe' or '.com' on PATH in shell's
find_command function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
On Windows, isatty(fd) determines whether the file descriptor refers to
a character device.
The thing is: even NUL or a printer is a character device. BusyBox
thinks, however, that isatty() only returns non-zero for an interactive
terminal.
So let's shadow isatty() by a version that answers the question BusyBox
wants to have answered.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ron Yorston <rmy@pobox.com>
|