| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously busybox-w32 was enhanced so certain Unix-style absolute
paths of the form '/dir/file' were treated as being relative to the
system drive. (Notionally as reported by %SYSTEMDRIVE% but in fact
derived from the API call GetSystemDirectory().)
Make the location of such files configurable by the BB_SYSTEMROOT
environment variable.
- BB_SYSTEMROOT should probably only refer to a Windows-style
absolute path, but this isn't checked.
- Set BB_SYSTEMROOT using the Windows Control Panel or setx, not as
a shell variable: the shell itself won't see the environment
variable.
|
|
|
|
|
|
|
|
|
|
| |
Revert commit 249f68e3c (win32: append '/' to bare drive name in
opendir).
Instead add better handling for paths of the form 'c:path' to ls
and expmeta() in ash.
Adds 64 bytes.
|
|
|
|
|
|
|
|
| |
Replace auto_add_system_drive() with alloc_system_drive() which
leaves space for a possible filename extension. This makes it
possible to drop alloc_win32_extension() and auto_win32_extension().
Saves 144 bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
WIN32 _putenv() can't set an environment variable with an empty
value because 'NAME=' is treated as a request to delete the variable.
Allow mingw_putenv() to set an empty value by first setting a fake
value and then truncating it.
This problem has always been present in mingw_putenv() but it became
particularly pressing when ash started treating all applets as NOEXEC.
The environment of NOEXEC applets is created by clearing the current
environment and using putenv() to set a new one from the shell
variables. Empty variable were not being set.
See GitHub issue #197.
|
|
|
|
|
|
|
|
| |
Use xasprintf() to create string in unsetenv().
Clarify when we're using WIN32 _putenv().
No change in functionality; saves 16 bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Shell scripts moved from Unix may contain hard-coded paths to
binaries such as /bin/sh. A recent commit made it possible to
execute such binaries reliably, but that does require them to be
installed. As an alternative solution: if a binary with a
standard Unix path prefix can't be found but is available as a
built-in applet, run the applet.
Add the function unix_path() to detect paths starting with /bin,
/usr/bin, /sbin or /usr/sbin.
Use this function in:
- the 'which' applet
- shellexec(), describe_command() and find_command() in ash
- mingw_spawn_1()
See GitHub issue #195.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As noted in commit 548ec7045 (win32: interpret absolute paths as
relative to %SYSTEMDRIVE%) a path starting with a '/' in the Unix
world is treated as relative to the current drive by Windows.
To avoid ambiguity that commit considered certain such paths to
be relative to %SYSTEMDRIVE%. Extend this to paths representing
executables.
Add the functions need_system_drive() and auto_add_system_drive()
to detect the need for a system drive prefix and to add it if
necessary. Use these functions in:
- the 'which' applet
- the find_executable() function
- tab-completion code
- PATH look-up, shellexec(), describe_command() and find_command() in ash
- parse_interpreter() and mingw_spawn_1()
With these changes executable paths starting with a slash are
handled consistently, whatever the current drive.
|
|
|
|
|
|
|
| |
Allocate static storage for the system drive string instead of
making a new allocation on every call. This is easier to manage.
Adds 16 bytes.
|
|
|
|
|
|
|
|
|
|
| |
Add a new function, has_path(), to detect that an executable name
doesn't require a path look-up.
Also, since is_absolute_path() is now only used in shell/ash.c move
its definition there from include/mingw.h.
Saves 128 bytes.
|
|
|
|
|
|
|
|
| |
Use a new common function, mingw_fork_compressor(), to implement
fork_transformer() in open_transformer.c and vfork_compressor()
in tar.c.
Saves 160 bytes.
|
|
|
|
|
|
|
|
|
|
| |
Update to latest code from gnulib. This adds a '%q' (quarter) field
descriptor.
Remove the 'neg' variable from the code to handle the '%z' (timezone)
field descriptor. Since our struct tm lacks a tm_gmtoff member '%z' is
only supported "for reasons of symmetry". Since the computed value is
never used there's no need to negate it.
|
|
|
|
|
|
|
|
| |
- Drop exit_code argument from kill_SIGTERM_by_handle()
- Pass signal number rather than exit code to other functions
- Merge kill_SIGKILL() and kill_SIGTEST()
Saves 112 bytes.
|
| |
|
| |
|
|
|
|
|
|
| |
Until now the emulated stat(2) system calls have only returned a
synthesised Unix-style mode value. Also return the raw Windows
file attributes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Be more strict about identifying UNC paths in unc_root_len().
In updatepwd() in ash:
- Skip duplicate leading slashes unless the directory is a UNC path.
- Rewrite detection and handling of the five possible types of path.
This improves cases like 'cd ///' and 'cd /xyz' when the current
directory is a UNC path.
See GitHub issue #192.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Change how busybox.exe expands wildcards on the command line.
When globbing is enabled at compile time provide an implementation
of _setargv(), which is run early during startup of C programs. This:
- enables globbing by setting _dowildcard to -1
- checks for the presence of the environment BB_GLOBBING
- if it exists and is set to 0 disables globbing
- if it doesn't exist sets BB_GLOBBING=0 but continues to apply
Windows' globbing in the current process
The consequences of this are:
- When busybox.exe is initially run from a Command Prompt Windows'
globbing is applied;
- Windows' globbing is turned off for future child processes, thus
allowing the shell re-execute busybox.exe without it interfering
with wildcards;
- this behaviour can be overridden by setting BB_GLOBBING explicitly.
Globbing can still be disabled at compile time if required. In that
case BB_GLOBBING has no effect.
With these changes globbing can be enabled by default and BusyBox
will do the right thing in most circumstances.
(See GitHub issues #172 and #189.)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The function mingw_spawn_forkshell() was introduced to handle
spawning a forkshell process. Since we know that:
- the binary being executed doesn't meet any of the special cases
handled by spawnveq()
- the arguments don't require quoting
we can call spawnve() directly instead of spawnveq().
Also, use xzalloc() to allocate new_argv so we don't need to set
the final NULL pointer explicitly.
|
|
|
|
| |
Modern versions of MinGW-w64 define more console modes.
|
|
|
|
|
|
|
| |
In the 64-bit build the time applet reported garbage when it was
unable to run the program to be timed.
The error return from mingw_spawn_pid() was incorrect.
|
|
|
|
|
|
|
|
|
| |
The subprocess that handles incoming connections for httpd didn't
work. It has an accepted connection on stdin and calls getpeername()
to obtain its details, but getpeername() didn't initialise networking.
ssl_client only seems to deal with file descriptors. Expose
init_winsock() again and call it from ssl_client.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
A call to initialise networking is made during start up even if
the applet doesn't need it. Instead, only initialise networking
when a call is made to a function that definitely requires it.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
spawn_forkshell() uses mingw_spawn_proc() to start the child shell.
mingw_spawn_proc() then calls mingw_spawn_1() which determines
that "sh" is an applet, thus calling mingw_spawn_applet() which
finally calls spawnveq().
Not only is this convoluted it also won't work if PREFER_APPLETS
and SH_STANDALONE aren't enabled.
Simplify matters by adding a new function, mingw_spawn_forkshell(),
which is tailored for just this case.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since the earliest days of busybox-w32 '#!' has searched PATH for
the interpreter. This doesn't seem to be supported by precedent.
In testing I also found that additional code was needed for the case
where PATH has been altered in the current shell or is modified on
the command line: PATH has to be extracted from envp rather than
getenv("PATH"). Drop this non-standard feature.
*NIX implementations disagree on whether the interpreter can itself
be a script. Follow Linux and allow this with a limit of four levels
of nesting.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit e6680912a (dd: create a sparse file when seek=N is used)
broke the use of 'conv=notrunc seek=N' to modify existing files.
Rename seek_sparse() to make_sparse() and:
- add an argument to specify the start of the sparse region;
- call make_sparse() before ftruncate();
- call make_sparse() only if:
* we can determine the size of the file;
* the file is not open in append mode;
* the file is being extended.
This should fix GitHub issue #186.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use ReadDirectoryChangesW to implement inotifyd for WIN32.
There are limitations:
- It's only possible to watch directories, not files.
- The notification doesn't distinguish between different changes to
file state. All changes other than creation, deletion and renaming
are reported as 'c'.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Change the meaning of the BB_SKIP_ANSI_EMULATION variable:
- if it isn't set or if it has any value other than 1 or 2, use
ANSI emulation;
- if it's set to 1, always emit ANSI escape codes;
- if it's set to 2, attempt to enable virtual terminal processing in
the current console. If that works emit ANSI escape codes, if not
revert to ANSI emulation.
On all platforms I've tested (Windows 10, Windows 8.1, ReactOS 0.4.13,
plus ConEmu) BB_SKIP_ANSI_EMULATION=2 does the right thing.
|
|
|
|
|
| |
Update the skip status on the first call to skip_ansi_emulation()
and whenever the BB_SKIP_ANSI_EMULATION variable changes.
|
|
|
|
|
|
|
|
| |
Port the time applet to WIN32. This requires the implemntation of
a replacement for wait3(2).
Only elapsed, user and system times are supported, not the memory
and i/o statistics reported by GNU time.
|
|
|
|
|
|
|
| |
Implement getpeername(2).
Add mingw_spawn_detach() to allow the spawned process to detach from
the console.
|
|
|
|
|
|
|
|
| |
Tab-completion of 'c:file' paths was leaking memory and incorrectly
included BusyBox applets and shell built-ins.
Fix handling of 'c:file' paths used as arguments to spawn functions.
Otherwise things like 'timeout 5 c:busybox sleep 99' don't work.
|
|
|
|
|
|
|
| |
When the seek=N argument is used mark the file as sparse and set
the range that is sparse.
See https://stackoverflow.com/questions/4011508/how-to-create-a-sparse-file-on-ntfs
|
|
|
|
|
|
| |
Use GetCompressedFileSize to obtain the actual number of blocks
for compressed or sparse files. Use this to return a more accurate
value for st_blocks.
|
|
|
|
|
|
|
|
| |
Our implementation of strptime() doesn't support alternative number
formats. Rather than duplicate the code for the affected conversion
specifications just return to the start of the switch statement.
Saves 256 bytes.
|
|
|
|
|
|
|
| |
Replace several explicit string comparisons with a single call
to index_in_strings().
Saves 304 bytes.
|
|
|
|
|
|
|
| |
Define NOT_DEVICE as -1 so the return value of index_in_strings()
when no device name is matched is NOT_DEVICE.
Make the logic in mingw_open() clearer.
|
|
|
|
|
|
|
| |
Use memset() to fill the structure with zeroes, avoiding the need
to set some members explicitly.
Saves 16 bytes.
|
|
|
|
|
|
|
|
| |
Place filesystem names in a single null-separated string and search
it using index_in_strings(). Use the result (offset by 1 to allow
for failure) to index an array of filesytem types.
Saves 112 bytes.
|
|
|
|
|
|
| |
Improve get_dev_type() and use it to dectect /dev/null in mingw_xopen().
Saves 64 bytes.
|
|
|
|
|
| |
Have bs_to_slash() return a pointer to its argument. This allows
some calls to be chained, saving 32 bytes.
|
|
|
|
|
|
|
| |
Since we don't have a working clock_settime(2) there's no point
in claiming to support the '-s' option.
Saves 96 bytes
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Closing 'vi' in Windows 7 resulted in the console window failing to
echo any output correctly until the 'reset' builtin was run. This
didn't happen in Windows XP, 8 or 10.
The problem is fixed by only duplicating the console handle when switching
*to* the alternate screen buffer.
Add sanity checks so that switching to the alternate buffer requires
the cached handled to be invalid, while it must be valid when switching
from the alternate buffer.
|
|
|
|
|
|
|
|
|
|
|
|
| |
When a format specification is replaced the loop variable 't'
should point to the last character of the replacement string in
the new format buffer.
In an extreme case if the original format string is "%z" and
tm->tm_isdst is negative to indicate that no DST information is
available the replacement string will be empty and 't' will point
to the location before the start of the new format buffer. This
is OK.
|
|
|
|
|
| |
The security descriptor was being freed before its contents were
accessed.
|
|
|
|
|
|
| |
- Update configuration files
- Omit unnecessary libraries
- Replace fake stime(2) with fake clock_settime(2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Rework the ANSI emulation code to reduce its size.
- Fetch console attributes when required rather than caching them.
The init() function is no longer required; the only remaining
initialisation is now performed in is_console().
- Turning off inverse video (ESC[27m) didn't work properly. This has
been improved though it still doesn't work in some unlikely cases
(ESC[7;27m).
These changes save 180 bytes.
|
| |
|
|
|
|
|
|
|
|
|
| |
As reported in GitHub issue #178 the last colour set by the ls command
is retained in the console.
This is due to the previous commit reinitialising the stored attributes
more frequently than it should. Attriubutes should only be initialised
once.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As reported in GitHub issue #177, ANSI escape sequences don't work
reliably after shell redirection.
The problem appears to be due to a change in the behaviour of dup2()
in Windows 10 release 1809. The escape handling code kept a copy of
the console handle for internal use. Prior to Windows 10 release 1809
this worked; since then unwinding shell redirections results in the actual
console handle changing from time to time for reasons that are unknowable
without access to the source code.
Fix this by always fetching the console handle instead of caching it.
|