| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
| |
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>
|
|
|
|
|
| |
mingw-w64 has its own mempcpy. And even if it didn't upstream
BusyBox has one too. So we definitely don't need our own.
|
|
|
|
|
|
|
| |
I bet this has been fixed in gnulib, too.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
|
|
|
|
|
|
|
| |
The libbb.h header implicitly includes mingw.h, which has the
declaration of that function.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
It would be more straight-forward to simply #include "libbb.h" which
includes a #define getenv mingw_getenv, but that header also defines
isprint() to a function that is nowhere to be found, leading to link
problems.
So let's go the easy route.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
|
|
|
|
| |
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
|
|
|
|
|
|
|
| |
This was inherited from gnulib. While at it, get rid of the ugly (and
unneeded) LOCALE constants.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
|
|
|
|
|
|
|
|
|
| |
When `#include`ing libbb.h, it implicitly includes mingw.h (with a
prototype for strptime()) and it also defines
_POSIX_THREAD_SAFE_FUNCTIONS so that the time.h header declares
localtime_r().
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
|
|
|
|
|
|
|
|
|
|
| |
The `tend` variable is only ever initialized and used if the timeout is
*not* infinite.
However, GCC is not smart enough to figure that out. So just initialize
the variable to 0 and be done with it already.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
|
|
|
|
|
|
|
|
|
| |
The function signatures were inherited from Git's source code, but are
inconsistent with the declarations in the POSIX standard.
This requires quite a few changes in quite a few callers, unfortunately.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
|
|
|
|
| |
The functions copy_environ and free_environ became unused following
commit ac181bf54 "win32: simplify spawning applets".
|
|
|
|
| |
Rewrite mingw_system using mingw_spawn_proc. Also fix return values.
|
|
|
|
|
|
| |
When spawning a process the file should be executed directly if its
filename contains any path separator, not just if it's an absolute
path.
|
| |
|
|
|
|
|
| |
Upstream BusyBox allows PREFER_APPLETS and SH_STANDALONE to be set
independently. Allow such configurations to work in busybox-w32.
|
|
|
|
|
|
|
| |
The original WIN32 code used the BUSYBOX_APPLET_NAME environment variable
to pass the applet name to the spawned process. This was based on the
(apparently) mistaken idea that WIN32 would replace argv[0] with the
path to the executable.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There are plenty of warnings that were not detected in Git's source
code, due to some warnings being turned off in Git's build by default
(even with DEVELOPER=1).
The warnings fall into three categories:
- constants being tested via `#if <name>` instead of `#ifdef <name>`
- unused function parameters
- one instance of an unnecessarily-shadowing variable
This patch fixes all of them.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In 909696f13 (win32: Import regex source, 2010-04-14), Git's
compat/regex/ was imported wholesale, with one change (to avoid
redefining _GNU_SOURCE).
For the record, the git.git commit mentioned in that commit message
refers to a transient commit made to git.git's `next` branch which is
rewound with every major Git version, therefore it is long gone. Also
for the record, the correct reference would be: 3632cfc2487 (Use
compatibility regex library for OSX/Darwin, 2008-09-07), i.e. the
compat/regex/ source code as of Git v1.6.0.2.
This commit updates the regex source code to that of Git v2.13.2, or
bd8f0055836 (regex: fix a SIZE_MAX macro redefinition warning,
2016-06-07) in git.git.
Instead of the original fixup to avoid redefining _GNU_SOURCE, we now
require these changes relative to Git's source code:
> diff --git a/win32/regex.c b/win32/regex.c
> index 5cb23e5d5..95e5d757a 100644
> --- a/win32/regex.c
> +++ b/win32/regex.c
> @@ -18,9 +18,11 @@
> Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA. */
>
> -#ifdef HAVE_CONFIG_H
> -#include "config.h"
> -#endif
> +#define HAVE_LIBINTL_H 0
> +#define ENABLE_NLS 0
> +#define HAVE_ALLOCA 0
> +#define NO_MBSUPPORT 1
> +#define GAWK 1
>
> /* Make sure no one compiles this code with a C++ compiler. */
> #ifdef __cplusplus
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
|
|
|
|
| |
vfprintf is used in ash_vmsg. It should be passed through the
codepage conversion in winansi.c.
|
|
|
|
| |
Don't expect sleeping for fractions of a second to be very accurate.
|
|
|
|
|
| |
If the environment variable BB_SKIP_ANSI_EMULATION is set (the value
doesn't matter) escape sequences are passed through to the terminal.
|