Commit Graph

2159 Commits

Author SHA1 Message Date
Denys Vlasenko
8858a9864e libbb: rearrange NOFORK/NOEXEC code, logic is not changed
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-08 01:21:49 +02:00
Denys Vlasenko
80e8e3cc05 noexec: consolidate code
function                                             old     new   delta
run_noexec_applet_and_exit                             -      61     +61
find_applet_by_name                                  128     124      -4
run_applet_no_and_exit                               441     434      -7
tryexec                                              169     152     -17
pseudo_exec_argv                                     338     321     -17
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/6 up/down: 61/-48)             Total: 13 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-07 19:24:57 +02:00
Denys Vlasenko
c9c1ccc4ed noexec: do GETOPT_RESET() before entering APPLET_main()
hush -c 'yes | head -1' was not happy.

function                                             old     new   delta
tryexec                                              159     169     +10
pseudo_exec_argv                                     328     338     +10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-07 18:59:35 +02:00
Denys Vlasenko
f2cf1cc716 noexec: set comm field for noexecs
function                                             old     new   delta
set_task_comm                                          -      18     +18
tryexec                                              152     159      +7
pseudo_exec_argv                                     321     328      +7
main                                                 106      97      -9
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/2 up/down: 34/-13)             Total: 23 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-07 18:45:33 +02:00
Denys Vlasenko
248a67fb75 free,stat: make NOEXEC
pkill/pgrep/pidof uncovered another quirk: what about noexec's _process names_?

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-07 18:18:09 +02:00
Denys Vlasenko
798b94518e ubi tools: ubiupdatevol supports "-" input and actually respects -s SIZE
Decided to not make any flash applets NOEXEC.
Minor robustifications here and there. Better error messages. Save on strings:

function                                             old     new   delta
ubi_tools_main                                      1235    1288     +53
ubi_get_volid_by_name                                125     133      +8
ubirename_main                                       198     204      +6
get_num_from_file                                     90      94      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 71/0)               Total: 71 bytes
   text	   data	    bss	    dec	    hex	filename
 915696	    485	   6880	 923061	  e15b5	busybox_old
 915670	    485	   6880	 923035	  e159b	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-07 16:00:25 +02:00
Denys Vlasenko
2262746e2b slattach: code shrink, better --help text
function                                             old     new   delta
tcsetattr_serial_or_warn                               -      34     +34
static.int_N_SLIP                                      -       4      +4
restore_state_and_exit                               123     117      -6
packed_usage                                       31774   31747     -27
set_termios_state_or_warn                             42       -     -42
slattach_main                                        673     624     -49
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 0/3 up/down: 38/-124)           Total: -86 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-06 17:14:09 +02:00
Denys Vlasenko
32b60cc0db kbd_mode: try harder to find console device if -C TTY is not given
Was (under X):
	$ ./busybox_old kbd_mode
	kbd_mode: ioctl 0x4b44 failed: Inappropriate ioctl for device
Now:
	$ ./busybox kbd_mode
	The keyboard is in off mode

function                                             old     new   delta
kbd_mode_main                                        166     174      +8
packed_usage                                       31782   31764     -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 8/-18)             Total: -10 bytes
   text	   data	    bss	    dec	    hex	filename
 915757	    485	   6880	 923122	  e15f2	busybox_old
 915747	    485	   6880	 923112	  e15e8	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-06 12:17:46 +02:00
Denys Vlasenko
50db1f29bf sysctl: recognize ";comment" and "<whitespace>#comment" lines
function                                             old     new   delta
config_read                                          639     699     +60

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-05 18:20:34 +02:00
Denys Vlasenko
20077c1429 libbb: make trim() return pointer to terminating NUL
function                                             old     new   delta
trim                                                  80      90     +10
angle_address                                         56      50      -6
sysctl_main                                          282     273      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: +10/-15)           Total:  -5 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-05 17:50:35 +02:00
Denys Vlasenko
9cf89cdf84 sysctl: fix file parsing, do not require -w for VAR=VAL
function                                             old     new   delta
sysctl_act_on_setting                                  -     451    +451
sysctl_main                                          222     282     +60
packed_usage                                       31744   31793     +49
config_read                                          604     639     +35
sysctl_act_recursive                                 612     163    -449
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/1 up/down: 595/-449)          Total: 146 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-05 13:45:22 +02:00
Denys Vlasenko
b182e9ad60 libbb: use _exit, not exit, in bb_daemonize_or_rexec()
By the time we reach exit in parent, child already exited or execed.
We should not re-run libc cleanup code.

While at it, introduce bb_daemon_helper() and add a few comments.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-04 23:04:17 +02:00
Denys Vlasenko
dd5a40246b getopt32: move support for "always treat first arg as option" to users (tar/ar)
Now getopt() never leaks (and never performs) any xmalloc's.

function                                             old     new   delta
ar_main                                              522     556     +34
tar_main                                             986    1014     +28
getopt32                                            1458    1350    -108
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 62/-108)           Total: -46 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-04 16:46:17 +02:00
Denys Vlasenko
727948e585 getopt32: factor out code to treat all args as options
Working towards making getopt32() xmalloc-free

function                                             old     new   delta
make_all_argv_opts                                     -      58     +58
top_main                                             914     912      -2
getopt32                                            1517    1458     -59
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/2 up/down: 58/-61)             Total: -3 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-04 16:33:23 +02:00
Denys Vlasenko
19c9f31af1 nofork: fix a bug uncovered by hush testsuite (forgotten fflush)
function                                             old     new   delta
run_nofork_applet                                    280     287      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-03 19:52:47 +02:00
Denys Vlasenko
39194f0309 new NOFORKs: pwdx,kill[all5],ttysize,realpath,readlink NOEXECs: date,resize
function                                             old     new   delta
run_nofork_applet                                    258     280     +22
readlink_main                                        112     123     +11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 33/0)               Total: 33 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-03 19:03:32 +02:00
Denys Vlasenko
84ea60ed65 line editing: make read_line_input() not take timeout param
It's almost always -1.

function                                             old     new   delta
read_line_input                                     3902    3912     +10
new_line_input_t                                      24      31      +7
pgetc                                                583     585      +2
save_command_ps_at_cur_history                        80      78      -2
read_line                                             76      74      -2
fgetc_interactive                                    246     244      -2
addLines                                              84      82      -2
doCommands                                          2226    2222      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/5 up/down: 19/-12)              Total: 7 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-02 17:27:28 +02:00
Denys Vlasenko
95f7953f2c do not use `a' quoting style in comments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-02 14:26:33 +02:00
Ron Yorston
008fc9499a libbb: remove vdprintf
Two reasons:

* it's only built for GNU C Library versions < 2 (released 1997)

* it isn't used anywhere in BusyBox

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-29 17:30:21 +02:00
Denys Vlasenko
147d2ce3dd standalone shell / prefer_applets: fix "exe" in comm fields
function                                             old     new   delta
main                                                  92     106     +14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-29 02:19:01 +02:00
Denys Vlasenko
f128bdbbd7 shell: make standalone shell tab-complete "busybox"
function                                             old     new   delta
busybox_main                                           -     624    +624
packed_usage                                       31758   31777     +19
applet_names                                        2638    2646      +8
applet_main                                         1528    1532      +4
applet_install_loc                                   191     192      +1
run_applet_and_exit                                  681      78    -603
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/1 up/down: 656/-603)           Total: 53 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-29 00:59:24 +02:00
Denys Vlasenko
86d5bf4246 config: trim/improve item names and help texts.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-27 02:59:13 +02:00
Denys Vlasenko
86981e3ad2 ash: allow "trap NUM [SIG]..." syntax
While at it, make get_signum() return -1 for numeric strings >= NSIG.

function                                             old     new   delta
trapcmd                                              292     306     +14
get_signum                                           295     300      +5
builtin_trap                                         413     412      -1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 19/-1)              Total: 18 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-25 20:06:17 +02:00
Denys Vlasenko
ef0366eb4f libbb: avoid malloc/free in bb_unsetenv()
function                                             old     new   delta
bb_unsetenv                                           55      83     +28

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-22 02:15:17 +02:00
Denys Vlasenko
72089cf6b4 config: deindent all help texts
Those two spaces after tab have no effect, and always a nuisance when editing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-21 09:50:55 +02:00
Denys Vlasenko
a3df2fa525 config: merge "Busybox Settings" and "Busybox Library Tuning" into one menu
Tweak a few help texts while at it

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-15 20:49:32 +02:00
Johannes Schindelin
e5b1f5af73 copyfd: guard use of munmap() with #if (windows builds need this)
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-15 11:44:13 +02:00
Denys Vlasenko
7d7c7bb220 libbb: hide getnetbyaddr() inside "#if ENABLE_FEATURE_ETC_NETWORKS" block
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-14 20:17:17 +02:00
Denys Vlasenko
90678f0cd7 xxd: allow "-" as file name meaning stdin
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-14 16:29:30 +02:00
Denys Vlasenko
63214a68f1 libbb/dump: allow skipping over stdin too
function                                             old     new   delta
next                                                 294     265     -29

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-14 16:18:16 +02:00
Denys Vlasenko
5f7904b6d1 libbb/dump: fix a few broken commits and shrink code
function                                             old     new   delta
next                                                 310     294     -16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-14 16:03:43 +02:00
Denys Vlasenko
a03ac60677 libbb: safe_write should not return EINTR
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-14 14:22:09 +02:00
Denys Vlasenko
75e90b1548 cat: fix "cat -An" ignoring -n; make numbering go througn all files
function                                             old     new   delta
cat_main                                             418     428     +10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-14 10:47:18 +02:00
Denys Vlasenko
12a4f9afe7 libbb: do not die if setgid/setuid(real_id) on startup fails
Based on a patch from Steven McDonald <steven@steven-mcdonald.id.au>:

This makes 'unshare --user' work correctly in the case where the user's
shell is provided by busybox itself.

'unshare --user' creates a new user namespace without any uid mappings.
As a result, /bin/busybox is setuid nobody:nogroup within the
namespace, as that is the only user. However, since no uids are mapped,
attempting to call setgid/setuid fails, even though this would do
nothing:

  $ unshare --user ./busybox.broken ash
  ash: setgid: Invalid argument

'unshare --map-root-user' still works, but because Linux only allows
uid/gid mappings to be set up once, creating a root mapping makes such
a namespace useless for creating multi-user containers.

With this patch, setgid and setuid will not be called in the case where
they would do nothing, which is always the case inside a new user
namespace because all uids are effectively mapped to nobody:

  $ id -u
  1000
  $ ls -lh busybox.fixed
  -rwsr-xr-x    1 root     root      826.2K May 21 00:33 busybox.fixed
  $ unshare --user ./busybox.fixed ash
  $ id -u
  65534

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-10 09:17:43 +02:00
Denys Vlasenko
69a5ec9dcc main: fix the case where user has "halt" as login shell. Closes 9986
halt::0:0::/:/sbin/halt

function                                             old     new   delta
run_applet_and_exit                                  748     751      +3
run_applet_no_and_exit                               467     459      -8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-07 19:08:56 +02:00
Denys Vlasenko
a8cf9c5a3f libbb: new function bb_getgroups() - allocating wrapper around getgroups()
function                                             old     new   delta
bb_getgroups                                           -     111    +111
nexpr                                                843     757     -86
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/1 up/down: 111/-86)            Total: 25 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-04 18:56:45 +02:00
Denys Vlasenko
d1f222c3b0 Change BB_EXTRA_VERSION: now it needs to contain any spaces/parenthesis
Before this change, BB_EXTRA_VERSION of "" resulted in:

	"BusyBox v1.28.0.git () multi-call binary"

message, after the fix it is:

	"BusyBox v1.28.0.git multi-call binary"

While at it, eliminate BB_BT and BANNER single-use macros.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-04 16:01:12 +02:00
Denys Vlasenko
d4e4fdb5ce fixes for bugs found by make_single_applets.sh
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-03 21:31:16 +02:00
Denys Vlasenko
10ad622dc2 Spelling fixes in comments, documentation, tests and examples
By klemens <ka7@github.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-17 16:13:32 +02:00
Denys Vlasenko
44c0ab4102 libbb: fix "error: redefinition of 'is_tty_secure'"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-13 17:55:05 +02:00
Denys Vlasenko
a3de0b3b86 libbb: make check_password() also return CHECKPASS_PW_HAS_EMPTY_PASSWORD
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-13 13:04:05 +02:00
Denys Vlasenko
335681ca8e su: FEATURE_SU_BLANK_PW_NEEDS_SECURE_TTY
When this feature is enabled, blank passwords are not accepted by su
unless the user is on a secure TTY defined in /etc/securetty. This
resembles the default PAM configuration of some Linux distros which
specify the nullok_secure option for pam_unix.so.

Based on patch by Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-13 12:57:04 +02:00
Kaarle Ritvanen
517a82c5b6 login: move check_securetty to libbb
Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-13 12:39:03 +02:00
Kaarle Ritvanen
835ad3a984 libbb: GETOPT_RESET macro
Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-12 20:11:34 +02:00
Denys Vlasenko
d9eb40c185 fix errors found with make_single_applets.sh
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-12 15:48:19 +02:00
Denys Vlasenko
8a134ec680 libbb: move isqrt from factor, use it in diff too
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-11 07:34:56 +02:00
Denys Vlasenko
4f0b540d08 modprobe: do not descend into /etc/modprobe.d/DIR/. Closes 8686
Also expanded comments in recursive_action.c

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-06 15:23:26 +02:00
Denys Vlasenko
ab518eea9c mount: create loop devices with LO_FLAGS_AUTOCLEAR flag
The "autolooped" mount (mount [-oloop] IMAGE /DIR/DIR)
always creates AUTOCLEARed loopdevs, so that umounting
drops them (and this does not require any code in the
umount userspace).
This happens since circa linux-2.6.25:
	commit 96c5865559cee0f9cbc5173f3c949f6ce3525581
	Date:    Wed Feb 6 01:36:27 2008 -0800
	Subject: Allow auto-destruction of loop devices
IOW: in this case, umount does not have to use -d
to drop the loopdev.

The explicit loop mount (mount /dev/loopN /DIR/DIR)
does not do this. In this case, umount without -d
should not drop loopdev.
Unfortunately, bbox umount currently always implies -d,
this probably needs fixing.

function                                             old     new   delta
set_loop                                             537     597     +60
singlemount                                         1101    1138     +37
losetup_main                                         419     432     +13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 110/0)             Total: 110 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-03-16 16:55:47 +01:00
Rostislav Skudnov
8762512fdb Replace int -> uint to avoid signed integer overflow
An example of such an error (should be compiled with DEBUG_SANITIZE):

runtime error: left shift of 1 by 31 places cannot be represented in
type 'int'

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-02-04 23:10:22 +01:00
Denys Vlasenko
b6871c1965 ps: avoid -o stat to contain spaces. Closes 9631
function                                             old     new   delta
procps_scan                                         1227    1236      +9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-02-02 13:04:30 +01:00
Denys Vlasenko
35b54a3c24 libbb: match_fstype() is unreadable in the extreme, fixing it
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-30 00:45:05 +01:00
Denys Vlasenko
9967c9949e libbb: spawn_and_wait() fflushes before forking NOEXEC; child reinits logmode
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-26 01:13:58 +01:00
Denys Vlasenko
cb8e84e65a libbb: shrink sump.c
function                                             old     new   delta
dot_flags_width_chars                                  -      16     +16
int_convs                                              -       7      +7
lcc                                                    7       -      -7
index_str                                             16       -     -16
rewrite                                             1013     937     -76
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 0/1 up/down: 23/-99)            Total: -76 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-25 16:21:00 +01:00
Denys Vlasenko
0f4364775f xxd: new applet
Yet Another Hexdumper

function                                             old     new   delta
xxd_main                                               -     364    +364
packed_usage                                       31046   31116     +70
applet_names                                        2560    2564      +4
applet_main                                         1476    1480      +4
rewrite                                             1022    1013      -9
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 3/1 up/down: 442/-9)            Total: 433 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-25 01:58:00 +01:00
Denys Vlasenko
49ecee098d tls: add 2nd cipher_id, TLS_RSA_WITH_AES_128_CBC_SHA, so far it doesn't work
Good news that TLS_RSA_WITH_AES_256_CBC_SHA256 still works with new code ;)

This change adds inevitable extension to have different sized hashes and AES key sizes.
In libbb, md5_end() and shaX_end() are extended to return result size instead of void -
this helps *a lot* in tls (the cost is ~5 bytes per _end() function).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-24 16:00:54 +01:00
Denys Vlasenko
16e7f697f8 libbb: eliminate redundant variable in sha_crypt
function                                             old     new   delta
sha_crypt                                           1136    1130      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-15 20:59:32 +01:00
Denys Vlasenko
b8935d00b0 sha512: use larger constant table only if sha512 is in fact selected
function                                             old     new   delta
sha_K                                                640     256    -384

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-15 20:16:27 +01:00
Denys Vlasenko
01ccdd1d3c libbb: consolidate the code to set termios unbuffered mode
function                                             old     new   delta
set_termios_to_raw                                     -     116    +116
count_lines                                           72      74      +2
powertop_main                                       1458    1430     -28
top_main                                             943     914     -29
more_main                                            759     714     -45
fsck_minix_main                                     2969    2921     -48
conspy_main                                         1197    1135     -62
rawmode                                               99      36     -63
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/6 up/down: 118/-275)         Total: -157 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-11 16:17:59 +01:00
Denys Vlasenko
a8a075acfe busybox: stop depending on FEATURE_AUTOWIDTH for applet list
Many other appletw don't - they unconditionally use get_terminal_wodth(),
and here the amount of code saved by FEATURE_AUTOWIDTH=n is tiny.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-11 10:52:24 +01:00
Denys Vlasenko
f560422fa0 Big cleanup in config help and description
Redundant help texts (one which only repeats the description)
are deleted.

Descriptions and help texts are trimmed.

Some config options are moved, even across menus.

No config option _names_ are changed.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 14:58:54 +01:00
Denys Vlasenko
fe93624fb6 Automatically disable FEATURE_COMPRESS_USAGE for small builds.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-06 19:16:36 +01:00
Cristian Ionescu-Idbohrn
f1d76b64a0 appletlib: avoid warning on unused function ingroup
libbb/appletlib.c:558:12: warning: 'ingroup' defined but
                                   not used [-Wunused-function]
 static int ingroup(uid_t u, gid_t g)
            ^~~~~~~

That function is used only if FEATURE_SUID_CONFIG is also enabled.

Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-03 12:01:15 +01:00
Denys Vlasenko
1afa494fd1 Make FEATURE_USERNAME_COMPLETION=y by default
This matches bash behavior on Fedora

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-23 13:40:24 +01:00
Denys Vlasenko
9cc3d3ab21 fix breakage found by mass one-applet builds
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-23 02:42:26 +01:00
Denys Vlasenko
e184a88356 df: implement -B n<suff> and -B <suff> formats of -B option
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-12 19:56:31 +01:00
Denys Vlasenko
ac5d324540 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-10 20:57:00 +01:00
Mike Frysinger
c6f35241b3 selinux: drop deprecated headers
The selinux guys want you to get class values at runtime by converting
textual names into constants.  Drop the deprecated headers and switch
to the new format.

This API has been around for years, so there shouldn't be an issue
with backwards compatibility.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-12-09 18:30:30 -05:00
Denys Vlasenko
548620c18b randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-08 12:24:48 +01:00
Denys Vlasenko
4bd0c2ab38 fix musl problem with dirname, now for all users of bb_make_directory()
function                                             old     new   delta
bb_make_directory                                    412     419      +7
install_main                                         793     769     -24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-24)             Total: -17 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-04 10:42:07 +01:00
Denys Vlasenko
7d877fc931 Do not print useless empty line after list of applets
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-28 01:29:28 +01:00
Denys Vlasenko
038a977d47 lineedit: simplify code a bit
function                                             old     new   delta
lineedit_read_key                                    155     162      +7
put_prompt                                            51      46      -5
read_line_input                                     3722    3715      -7
cmdedit_setwidth                                      81      50     -31
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 7/-43)             Total: -36 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-28 01:10:16 +01:00
Denys Vlasenko
bff71d3b9d lineedit: fix two bugs in SIGWINCH signal handling
(1) restore entire sigaction, not only signal handler function
(2) do not use stdio when not sure WINCH did not interrupt a printf() or such.

function                                             old     new   delta
cmdedit_setwidth                                       -      81     +81
read_line_input                                     3682    3722     +40
lineedit_read_key                                    138     155     +17
put_prompt                                            55      51      -4
win_changed                                           93      47     -46
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/2 up/down: 138/-50)            Total: 88 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-27 22:25:07 +01:00
Denys Vlasenko
4b89d512b1 ash,hush: make ^C in interactive mode visually much closer to bash behavior
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-25 03:41:03 +01:00
Denys Vlasenko
24860fa09c Move FEATURE_BUFFERS_USE_foo options to library tuning
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-24 22:30:52 +01:00
Denys Vlasenko
1255925a61 Move locale, unicode, and "use sendfile?" options to library tuning
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-24 22:18:55 +01:00
Rostislav Skudnov
2e4ef38743 lineedit: fix handling of repeating Alt-b, Alt-f, Alt-d, Alt-Backspace
These key combinations should repeat correctly when the keys are
pressed and held.

Before this change, they do this erratically - many repeats are "eaten"
because they are treated as unrecognized ESC seqs:
ESC 0x7f is treated by Alt+baskspace, but ESC 0x7f ESC 0x7f ESC 0x7f
is unrecognized.

Escape sequences corresponding to these key combinations are moved from
read_line_input to lineedit_read_key.

Also, these key sequences are now enabled regardless of whether
FEATURE_EDITING_VI is set, since Vim does not actually support these key
combinations, but they are present in readline library.

function                                             old     new   delta
static.esccmds                                        93     103     +10
read_line_input                                     3737    3687     -50

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-24 15:04:00 +01:00
Denys Vlasenko
7e8218f9b2 Fix allnoconfig warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-18 21:42:44 +01:00
Denys Vlasenko
834aba3b72 comment and readme updates
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-04 14:13:58 +01:00
Denys Vlasenko
79e2598c48 su: expand help; simplify passing of -c CMD to run_shell()
Also, added a comment about bug 9401 (TIOCSTI input injection).

function                                             old     new   delta
packed_usage                                       30909   30932     +23
su_main                                              470     487     +17
sulogin_main                                         260     258      -2
run_applet_and_exit                                  681     678      -3
run_shell                                            166     126     -40

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-03 22:13:08 +01:00
Denys Vlasenko
7c3c92c533 man: make width selection more thorough; explain how to override it
Fedora's "man CMD >file" still uses terminal width, not 80 (but disables formatting),
this change mimics that.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-31 01:52:18 +01:00
Denys Vlasenko
1336052a49 lineedit: fix completion with applet names. closes 9361
Patch by Ron Yorston <rmy@pobox.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-24 01:25:05 +02:00
Denys Vlasenko
7f0ebbc69e hush: add commented-out debug printouts in "memleak" built-in
Allocation addresses of malloc() are jittery,
thought I had a mem leak in hush, but it was malloc variability.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 17:42:53 +02:00
Denys Vlasenko
3c18e3051d libbb: make xmalloc_sockaddr2dotted use NI_NUMERICSCOPE
Gives "mount -t cifs //fe80::6a05:caff:fe3e:dbf5%eth0/test test"
a chance to work: mount must pass "ip=numeric_IPv6%numeric_iface_id"
in the omunt option string. Currently, it does not.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-26 19:53:04 +02:00
Denys Vlasenko
525209ac94 libbb/speed_table.c: expand comments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-26 14:37:12 +02:00
Denys Vlasenko
4537f83d52 typo fix in comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-26 08:52:52 +02:00
Denys Vlasenko
65ba7113e3 libbb: handle \S in /etc/issue
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-24 23:50:43 +02:00
Denys Vlasenko
7cef4817d6 libbb:/send_to_from: do not require that "to" should have the same AF. Closes 9146
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-15 13:20:51 +02:00
Denys Vlasenko
9fd61be191 libbb/xwrite: print errno on "short write" errors
Lauri Kasanen:
:: Over at TinyCore, we receive a huge number of questions of the type "I
:: got "short write", what does it mean?". Mostly for the rpi port and when
:: using bb wget.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-05 15:20:10 +02:00
Denys Vlasenko
76787a7e02 libbb/speed_table.c: survive B115200 and B230400 not fitting into 16 bits
Seen on OSX.
While at it, expand baud table with B500000..B4000000

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-01 11:44:13 +02:00
Denys Vlasenko
71a090f187 sha3: fix to conform to final SHA3 padding standard, add -a BITS option
function                                             old     new   delta
hash_file                                            331     396     +65
md5_sha1_sum_main                                    485     538     +53
packed_usage                                       30423   30464     +41
sha3_begin                                            17      31     +14
sha3_hash                                            101     110      +9
sha3_end                                              41      49      +8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-29 14:05:25 +02:00
Denys Vlasenko
d3d7f085eb hexdump: fix numerous bugs in handling of backslashes
Was:
	t=48\\	t=45\\	t=4c\\	t=4c\\	t=4f\\	t=0a\\
Now:
	=48=\n	=45=\n	=4c=\n	=4c=\n	=4f=\n	=0a=\n

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-26 20:14:31 +02:00
Denys Vlasenko
215b0ca6e4 hush: fix a bug in FEATURE_SH_STANDALONE=y config. Closes 9186
Run this in a "sh SCRIPT":

sha256sum /dev/null
echo END

sha256sum is a NOEXEC applet. It runs in a forked child. Then child exit()s.
By this time, entire script is read, and buffered in a FILE object
from fopen("SCRIPT"). But fgetc() did not consume entire input.
exit() lseeks back by -9 bytes, from <eof> to 'e' in 'echo'.
(this may be libc-specific).
This change of fd position *is shared with the parent*!

Now parent can read more, and it thinks there is another "echo END".
End result: two "echo END"s are run.

Fix this by _exit()ing instead.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-19 18:43:06 +02:00
Natanael Copa
7e6f9316a8 lineedit: trivial codeshrink for vi-mode
Introduce and use BB_isalnum_or_underscore().

function                                             old     new   delta
BB_isalnum_or_underscore                               -      43     +43
vi_word_motion                                       162     150     -12
vi_end_motion                                        163     145     -18
vi_back_motion                                       198     179     -19
BB_isalnum                                            39       -     -39
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/3 up/down: 43/-88)            Total: -45 bytes

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-14 23:30:29 +02:00
Denys Vlasenko
98c50f93fe cp: fix -i for POSIX mode. Closes 9106
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-13 23:23:48 +02:00
Denys Vlasenko
0fb0045aa9 config: disentangle PREFER_APPLETS from SH_STANDALONE and SH_NOFORK
On user request.
I thought enabling/disabling them all together is more consistent.
Evidently, some people do want them to be separately selectable.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-22 18:48:38 +02:00
Denys Vlasenko
ca003385f1 cp: make verbose cp show symlink copies too
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-14 20:58:39 +02:00
Denys Vlasenko
237bedd499 getopt32: add new syntax of 'o:+' and 'o:*' for -o NUM and -o LIST
In many cases, this aqllows to drop use of opt_complementary.
Approximately -400 bytes:

function                                             old     new   delta
getopt32                                            1423    1502     +79
opt_string                                            17      18      +1
OPT_STR                                               24      25      +1
uniq_main                                            416     406     -10
timeout_main                                         279     269     -10
sulogin_main                                         270     260     -10
readprofile_main                                    1825    1815     -10
ps_main                                              543     533     -10
pidof_main                                           245     235     -10
pgrep_main                                           611     601     -10
od_main                                             2600    2590     -10
mkfs_minix_main                                     2684    2674     -10
mkfs_ext2_main                                      2603    2593     -10
microcom_main                                        712     702     -10
makemime_main                                        315     305     -10
ionice_main                                          282     272     -10
inetd_main                                          2074    2064     -10
ifplugd_main                                        1144    1134     -10
halt_main                                            353     343     -10
getopt_main                                          636     626     -10
fdisk_main                                          2854    2844     -10
env_main                                             206     196     -10
dmesg_main                                           319     309     -10
conspy_main                                         1214    1204     -10
awk_main                                             981     971     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/22 up/down: 81/-220)         Total: -139 bytes
   text	   data	    bss	    dec	    hex	filename
 919373	    906	  14060	 934339	  e41c3	busybox_old
 918969	    906	  14060	 933935	  e402f	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-06 21:58:02 +02:00
Denys Vlasenko
f4f8fe841c build system: fix a few warnings for allnoconfig build
Not that allnoconfig build is useful in any way...

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-05 21:43:28 +02:00
Ron Yorston
1b0dcc02dd libbb: suppress warning about run_applet_and_exit
When busybox is configured to contain a single applet an unnecessary
declaration of run_applet_and_exit results in a warning.  Move the
declaration to avoid this.

Reported-by: Lauri Kasanen <curaga@operamail.com>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-05 21:21:36 +02:00
Denys Vlasenko
bb0bf287d8 randomconfig fixes 2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-06-19 21:54:04 +02:00