Commit Graph

13927 Commits

Author SHA1 Message Date
Denys Vlasenko 68c048fb23 modprobe-small: fix and simplify rmmod
"rmmod OUT_OF_TREE_MODULE" was not working, because module is not in depmod file.

In general, rmmod doesn't need scanning, it simply unloads every argv[i].

function                                             old     new   delta
rmmod                                                  -      63     +63
modprobe_main                                        449     465     +16
process_module                                       705     667     -38
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 79/-38)             Total: 41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-07 20:44:46 +01:00
Kevin Wallace 782ee2aa0e libbb/loop: don't try to re-use existing loop device
loopinfo.lo_file_name is not enough to uniquely identify a file on a system with
multiple mount namespaces.  We could conceivably change this to dedup on
(lo_rdevice, lo_inode), but, as the comment above the deleted code notes, this
whole approach of reusing devices is racy anyway, so it seems better to stop
doing it entirely.

Signed-off-by: Kevin Wallace <k@igneous.io>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-07 19:13:57 +01:00
Stephen Heumann 46abe82986 Add support for displaying prefixes as well as setting them with prefix builtin 2015-02-07 11:26:54 -06:00
Denys Vlasenko a03195941b examples/mdev_fat.conf: document that newer mdev exposes path
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-07 18:14:39 +01:00
Ari Sundholm f22a838aed dd: add optional support for status=noxfer/none
While at it, added 'B' number suffixes, upstream compat

function                                             old     new   delta
dd_main                                             1469    1543     +74
dd_suffixes                                           88     112     +24
packed_usage                                       30156   30176     +20
dd_output_status                                     372     388     +16
static.status_words                                    -      13     +13
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/0 up/down: 147/0)             Total: 147 bytes

Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-07 01:41:22 +01:00
Denys Vlasenko 7e66102f76 ash: fix a SEGV case in an invalid heredoc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-05 21:00:17 +01:00
Denys Vlasenko a14fa79592 deluser: implement --remove-home
function                                             old     new   delta
deluser_main                                         308     355     +47
packed_usage                                       30149   30156      +7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 54/0)               Total: 54 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-05 18:35:52 +01:00
Denys Vlasenko 3c5d133c7d fstrim: fix help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-04 15:19:38 +01:00
Denys Vlasenko a75dcd4353 route: fix bogus read error when route table is empty
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-04 10:40:10 +01:00
Stephen Heumann 0d0ec552b5 Properly support running programs using relative pathnames.
Previously, relative pathnames other than those starting with "." or ".." wouldn't be recognized.
2015-02-03 21:24:10 -06:00
Denys Vlasenko 09020b1aa8 route: improve -A inet6
Upstream route command shows non-up routes, it shows reject and nonexthop flags.
And we had "ref" and "use" values mixed up...

function                                             old     new   delta
flagvals                                              32      44     +12
flagchars                                              9      12      +3
INET_setroute                                        767     768      +1
INET6_setroute                                       495     496      +1
set_flags                                             43      39      -4
flags_ipvx                                            16       8      -8
route_main                                           632     623      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/3 up/down: 17/-21)             Total: -4 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-03 19:32:44 +01:00
Denys Vlasenko b62d4d9d57 gzip: trivial code shrink -5 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-03 15:25:17 +01:00
Denys Vlasenko a977778893 ifconfig: fix double free fatal error in INET_sprint
Based on the patch by Zheng Junling <zhengjunling@huawei.com>
and Chen Gang <cg.chen@huawei.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-03 12:11:30 +01:00
Denys Vlasenko 8e74adab01 libbb: make INET[6]_rresolve use sockaddr2{host,dotted}_noport
function                                             old     new   delta
INET_rresolve                                        274     214     -60
INET6_rresolve                                       168      85     -83

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-03 12:07:40 +01:00
Denys Vlasenko f7f70bf1b3 gzip: speed up and shrink put_16bit()
function                                             old     new   delta
put_16bit                                            104      98      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-02 16:07:07 +01:00
Rich Felker 7f7ade1964 gzip: do not store timestamp in gzip header
Storing the original file's modification time in the output file is
harmful (precludes deterministic results) and unlike official gzip,
the busybox version provides no way to suppress this behavior; the -n
option is silently ignored. Rather than trying to make -n work, this
patch just removes the timestamp-storing functionality. It should be
considered deprecated anyway; it's not Y2038-safe and gunzip ignores
it by default.

Per RFC 1952, 0 is the correct value to store to indicate that there
is no timestamp.

Signed-off-by: Rich Felker <dalias@libc.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-02 16:01:16 +01:00
Denys Vlasenko 5104645cf8 platform.h: enable mempcpy for FreeBSD
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-02 03:51:47 +01:00
Micke Prag 07fa09a952 ubiattach: add option -O
Some images do not have the default VID offset. The option -O must
be used to attach such images.

Signed-off-by: Micke Prag <micke.prag@telldus.se>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-30 18:33:24 +01:00
Martin Kaiser 1cbe93cf4e telnetd: we only need CONFIG_UNIX98_PTYS from the Linux kernel
(re-sending this as it got ignored completey and the format of the
previous mail was probably not correct - please let me know if there's
anything else I can do to get this trivial fix applied)

for telnetd to work, we only need CONFIG_UNIX98_PTYS to be enabled
in the Linux kernel - DEVPTS_FS has been obsolete for some time

Signed-off-by: Martin Kaiser <lists@kaiser.cx>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-30 17:12:38 +01:00
Denys Vlasenko 08f9ffc3f7 dpkg: update supported compression methods
Based on a patch by Ron Yorston <rmy@tigress.co.uk>

function                                             old     new   delta
get_header_tar_xz                                      -      60     +60
filter_accept_list_reassign                          128     188     +60
unpack_package                                       585     621     +36
init_archive_deb_control                              52      76     +24
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 3/0 up/down: 180/0)             Total: 180 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-30 15:15:38 +01:00
Denys Vlasenko 8c05a74f7e platform.h: mempcpy needs <string.h>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-29 16:41:48 +01:00
Denys Vlasenko ff3f3accc6 ntpd: get rid of G.initial_poll_complete
This speeds up syncing - now happens only just
two replies from a peer. Especially useful for "ntpd -q".
Shouldn't have ill effects: if we chose a bad peer,
we will discover it later and switch to another one.

The code is even smaller this way.

Suggested by Miroslav Lichvar <mlichvar@redhat.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-29 16:31:36 +01:00
Denys Vlasenko 936c401077 dhcpd: fix an improper widening conversion
We wanted to detect when tv_sec = unsigned1 - unsigned2
underflows by looking at tv_sec's sign. But if tv_sec
is long and it is wider than unsigned, we get unsigned -> long
conversion which is in this case never negative.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-27 21:59:40 +01:00
Denys Vlasenko 64b744997e ftpd: prevent zombies. closes 7832
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-26 15:45:48 +01:00
Stephen Heumann ad96f52394 Bump version to 1.0. 2015-01-25 16:11:15 -06:00
Denys Vlasenko 50a6d86520 platform.h: add compat mempcpy
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-25 22:08:46 +01:00
Stephen Heumann 8ab8709e6b Add code to kill stopped (or partially stopped) jobs with SIGHUP on exit.
POSIX says that _exit() should do this, but on GNO it doesn't. This implementation should match the POSIX behavior in most cases, although it's not exactly the same.

Gsh also kills jobs on exit, but does so whether they're stopped or not and uses SIGKILL.
2015-01-24 21:32:57 -06:00
Stephen Heumann b2161dc4e1 Disable a bit of useless code.
Also, add a copyright notice for me in hush.c.
2015-01-24 18:56:25 -06:00
Denys Vlasenko cc70b6f8b6 depmod: simple memory optimization
function                                             old     new   delta
filename2modname                                      67      86     +19
parse_module                                         374     351     -23

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-24 22:30:30 +01:00
Denys Vlasenko 86031a5ffd trim extra newlines in help texts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-24 19:46:45 +01:00
Stephen Heumann acab757b9a Don't try to block SIGCHLD in the system() implementation.
The logic for this was broken (giving a signal number rather than a mask to sigblock), and if it wasn't broken then it would have caused the wait call to hang.

Blocking SIGCHLD is required by POSIX, but gsh doesn't do it, so existing GNO code shouldn't be relying on it.
2015-01-22 20:57:21 -06:00
Stephen Heumann 445a03527d Fix to make ^Z work for suspending processes when hush is the login shell.
The issue is that GNO's login (and other BSD-derived versions) start up the login shell with SIGTSTP ignored. Hush was recording this configuration and propagating it to its child processes, causing ^Z not to work. The fix is to not do that (for login shells only).

Also, set the system vector to run hush before running any of the startup scripts, in case something run in them uses it.
2015-01-22 17:43:45 -06:00
Natanael Copa 9de69c024c modprobe: fix modprobe -r and parsing of /etc/modprobe.d
This fixes a regression introduced with commit 78854520 (modprobe:
revert checking for /, stop doing basename() on modprobe args,
2015-01-01) that broke modprobe options stored in /etc/modprobe.conf and
/etc/modprobe.d/*.conf.

This also fixes modprobe -r

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-19 19:15:24 +01:00
Stephen Heumann 6276d32088 Bump version number 2015-01-17 19:40:20 -06:00
Stephen Heumann f91211baec Add a couple notes to README 2015-01-16 23:16:02 -06:00
Stephen Heumann 2eafa59ebc Better handling of really long commands.
Commands in the range of 16k-32k should now work, and commands longer than that should cause hush to die with an error message instead of corrupting stuff (at least in the simple cases I tested).

It would be possible to eliminate the 32k limit by using a type larger than "int" for lengths, but that would be a more invasive change.
2015-01-16 21:33:13 -06:00
Stephen Heumann 24b49d61e7 Update sample hushenv file, using "$@" so arguments with spaces will be handled properly. 2015-01-16 19:09:50 -06:00
Stephen Heumann 988683c572 Fix "wait" builtin to work correctly in no-parameters case
This was another issue where wait() was being called with SIGCHLD masked, and therefore never returning.
2015-01-16 18:14:55 -06:00
Stephen Heumann d305e3b821 Fix a bug where numbers could be truncated to four decimal digits in certain circumstances.
This affected values from $RANDOM, and could potentially also result in corruption of pid values if they were large enough.
2015-01-15 21:28:35 -06:00
Stephen Heumann bb88e739e5 Fix bug where using a 16-bit signal mask caused some signal handlers not to be installed.
This manifested itself in interactive hush shells getting suspended when ^Z was typed (and maybe also other ways).
2015-01-15 20:34:20 -06:00
Stephen Heumann 3d106c6708 In waitpid emulation, restart waiting after signals.
This matches the semantics the original hush code obtained by using the SA_RESTART flag when installing signal handlers, and avoids error messages about waitpid being interrupted.
2015-01-15 18:45:42 -06:00
Stephen Heumann 656769d136 Work around GNO libc's buggy sigprocmask implementation by defining our own version of it. This should fix issues where hush could hang in wait() calls.
The sigprocmask implementation in GNO 2.0.6 libc has bugs that cause it to never actually unblock signals that have been blocked. This was causing many signals to remain blocked when they shouldn't be, particularly after running signal handlers.

This problem combined with a kernel issue (wait() calls won't recognize that a child has finished if SIGCHLD is blocked) to cause hangs in certain conditions.

This patch works around these issues by defining our own non-buggy version of sigprocmask in place of libc's.
2015-01-15 18:02:33 -06:00
Denys Vlasenko 76b2262b9b modprobe: fix "modprobe devname:snd/timer" case (alias with a slash)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-15 03:04:23 +01:00
Denys Vlasenko e998b08f11 modprobe: fix recent breakage: modules.dep reading code needs to strip dirname
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-15 02:49:59 +01:00
Denys Vlasenko 1b6715345f modprobe-small: code shrink
function                                             old     new   delta
pathname_matches_modname                              80      42     -38

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-11 17:46:56 +01:00
Denys Vlasenko 3c75b1c34e modprobe-small: fix recent breakage: modprobe -r was using full path
"modprobe -r MODNAME", after it found the full module pathname,
should strip dirpath before trying to remove the module.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-11 17:40:30 +01:00
Denys Vlasenko 39f017293a diff: fix a bug in diffing against stdin. Closes 7784
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-11 16:41:54 +01:00
Stephen Heumann f88111e789 Do newline conversion in the "echo" builtin. 2015-01-08 17:23:39 -06:00
Stephen Heumann 01890e4a42 Reset to normal cursor when the command prompt is printed.
This works around problems when programs change the cursor and don't restore it before exiting.
2015-01-08 17:10:46 -06:00
Ron Yorston 70f4320b40 vi: fix reading of file after last line
If the :r command is used to read a file after the last line of the
buffer the last line of the buffer and the first line of the file
are joined.  An extra blank line appears at the end of the buffer.

   file 1
   file 1
   file 1file 2
   file 2
   file 2

	~
	~

The insertion point is normally at the start of the line following the
specified line.  When the specified line is the last one the next_line
function baulks at moving to the non-existent following line.

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-07 18:23:29 +01:00