Commit Graph

2411 Commits

Author SHA1 Message Date
Denys Vlasenko
036585a911 getopt32: remove applet_long_options
FEATURE_GETOPT_LONG made dependent on LONG_OPTS.

The folloving options are removed, now LONG_OPTS enables long options
for affected applets:
FEATURE_ENV_LONG_OPTIONS	FEATURE_EXPAND_LONG_OPTIONS
FEATURE_UNEXPAND_LONG_OPTIONS	FEATURE_MKDIR_LONG_OPTIONS
FEATURE_MV_LONG_OPTIONS		FEATURE_RMDIR_LONG_OPTIONS
FEATURE_ADDGROUP_LONG_OPTIONS	FEATURE_ADDUSER_LONG_OPTIONS
FEATURE_HWCLOCK_LONG_OPTIONS	FEATURE_NSENTER_LONG_OPTS
FEATURE_CHCON_LONG_OPTIONS	FEATURE_RUNCON_LONG_OPTIONS

They either had a small number of long options, or their long options are
essential.

Example: upstream addgroup and adduser have ONLY longopts,
we should probably go further and get rid
of non-standard short options.

To this end, make addgroup and adduser "select LONG_OPTS".
We had this breakage caused by us even in our own package!
	#if ENABLE_LONG_OPTS || !ENABLE_ADDGROUP
                /* We try to use --gid, not -g, because "standard" addgroup
                 * has no short option -g, it has only long --gid.
                 */
                argv[1] = (char*)"--gid";
	#else
                /* Breaks if system in fact does NOT use busybox addgroup */
                argv[1] = (char*)"-g";
	#endif

xargs: its lone longopt no longer depends on DESKTOP, only on LONG_OPTS.

hwclock TODO: get rid of incompatible -t, -l aliases to --systz, --localtime

Shorten help texts by omitting long option when short opt alternative exists.

Reduction of size comes from the fact that store of an immediate
(an address of longopts) to a fixed address (global variable)
is a longer insn than pushing that immediate or passing it in a register.
This effect is CPU-agnostic.

function                                             old     new   delta
getopt32                                            1350      22   -1328
vgetopt32                                              -    1318   +1318
getopt32long                                           -      24     +24
tftpd_main                                           562     567      +5
scan_recursive                                       376     380      +4
collect_cpu                                          545     546      +1
date_main                                           1096    1095      -1
hostname_main                                        262     259      -3
uname_main                                           259     255      -4
setpriv_main                                         362     358      -4
rmdir_main                                           191     187      -4
mv_main                                              562     558      -4
ipcalc_main                                          548     544      -4
ifenslave_main                                       641     637      -4
gzip_main                                            192     188      -4
gunzip_main                                           77      73      -4
fsfreeze_main                                         81      77      -4
flock_main                                           318     314      -4
deluser_main                                         337     333      -4
cp_main                                              374     370      -4
chown_main                                           175     171      -4
applet_long_options                                    4       -      -4
xargs_main                                           894     889      -5
wget_main                                           2540    2535      -5
udhcpc_main                                         2767    2762      -5
touch_main                                           436     431      -5
tar_main                                            1014    1009      -5
start_stop_daemon_main                              1033    1028      -5
sed_main                                             682     677      -5
script_main                                         1082    1077      -5
run_parts_main                                       330     325      -5
rtcwake_main                                         459     454      -5
od_main                                             2169    2164      -5
nl_main                                              201     196      -5
modprobe_main                                        773     768      -5
mkdir_main                                           160     155      -5
ls_main                                              568     563      -5
install_main                                         773     768      -5
hwclock_main                                         411     406      -5
getopt_main                                          622     617      -5
fstrim_main                                          256     251      -5
env_main                                             198     193      -5
dumpleases_main                                      635     630      -5
dpkg_main                                           3991    3986      -5
diff_main                                           1355    1350      -5
cryptpw_main                                         233     228      -5
cpio_main                                            593     588      -5
conspy_main                                         1135    1130      -5
chpasswd_main                                        313     308      -5
adduser_main                                         887     882      -5
addgroup_main                                        416     411      -5
ftpgetput_main                                       351     345      -6
get_terminal_width_height                            242     234      -8
expand_main                                          690     680     -10
static.expand_longopts                                18       -     -18
static.unexpand_longopts                              27       -     -27
mkdir_longopts                                        28       -     -28
env_longopts                                          30       -     -30
static.ifenslave_longopts                             34       -     -34
mv_longopts                                           46       -     -46
static.rmdir_longopts                                 48       -     -48
packed_usage                                       31739   31687     -52
------------------------------------------------------------------------------
(add/remove: 2/8 grow/shrink: 3/49 up/down: 1352/-1840)      Total: -488 bytes
   text	   data	    bss	    dec	    hex	filename
 915681	    485	   6880	 923046	  e15a6	busybox_old
 915428	    485	   6876	 922789	  e14a5	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-08 17:09:40 +02:00
Denys Vlasenko
ddd1ee4443 libbb: simplify NOFORK/NOEXEC defines, move set_task_comm to libbb
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-08 14:09:23 +02:00
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
Ron Yorston
ce824aecf2 libbb: move common code into run_applet_and_exit
Both calls to run_applet_and_exit are followed by the same code
to print an error message and return status 127.  Remove this
duplication and make run_applet_and_exit static.

function                                             old     new   delta
run_applet_and_exit                                  675     667      -8
main                                                 119      92     -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-35)             Total: -35 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-06-19 15:16:27 +02:00
Ron Yorston
ba12081a9e Allow "busybox <applet>" to work when busybox is disabled
A recent commit made it possible to disable BusyBox's --install
and --list options.  However it also stopped "busybox <applet>
<params>" from working.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-06-18 19:15:20 +02:00
Natanael Copa
b684d1b186 libbb: fix time parsing of [[CC]YY]MMDDhhmm[.SS]. Closes 8951
If SS is not given a value, it is assumed to be zero.
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/touch.html

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-05-31 02:50:54 +02:00
Denys Vlasenko
8e95068c7f Make busybox an optional applet
If it's disabled, code shrinks by about 900 bytes:

function                                             old     new   delta
usr_bin                                               10       -     -10
usr_sbin                                              11       -     -11
install_dir                                           20       -     -20
applet_install_loc                                   184       -    -184
run_applet_and_exit                                  686      21    -665
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 0/1 up/down: 0/-890)           Total: -890 bytes
   text    data     bss     dec     hex filename
 911327     493    7336  919156   e0674 busybox_old
 909848     493    7336  917677   e00ad busybox_unstripped

but busybox executable by itself does not say anything useful:

$ busybox
busybox: applet not found

Based on the patch by Ron Yorston <rmy@pobox.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-05-31 02:44:34 +02:00
Denys Vlasenko
877dedb825 cp: add -u/--update and --remove-destination
Based on the patch by wdlkmpx@gmail.com

function                                             old     new   delta
copy_file                                           1546    1644     +98
add_partition                                       1270    1362     +92
ask_and_unlink                                        95     133     +38
do_iproute                                           132     157     +25
decode_one_format                                    710     715      +5
cp_main                                              369     374      +5
ubirename_main                                       198     202      +4
read_package_field                                   232     230      -2
bb_make_directory                                    421     412      -9
packed_usage                                       30505   30476     -29
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/3 up/down: 267/-40)           Total: 227 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-05-27 00:46:38 +02:00
Denys Vlasenko
3e134ebf6a *: slap on a few ALIGN1/2s where appropriate
The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map"

   text	   data	    bss	    dec	    hex	filename
 829901	   4086	   1904	 835891	  cc133	busybox_before
 829665	   4086	   1904	 835655	  cc047	busybox

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-22 18:09:21 +02:00
Denys Vlasenko
93e1aaa1c7 libbb: constify *bb_common_bufsiz1 (if it is compiled to be a pointer)
This lets gcc optimize much better:

   text	   data	    bss	    dec	    hex	filename
 922846	    910	  13056	 936812	  e4b6c	busybox_unstripped.nonconst
 920255	    910	  13056	 934221	  e414d	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 21:47:45 +02:00
Denys Vlasenko
f56fb5eb11 libbb: make "COMMON_BUFSIZE = 1024 bytes, the buffer will be malloced" work
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 21:03:51 +02:00
Denys Vlasenko
e6a2f4cc5a libbb: make bb_common_bufsiz1 1 kbyte, add capability to use bss tail for it
The config item is FEATURE_USE_BSS_TAIL. When it is off (default):

function                                             old     new   delta
read_config                                          210     228     +18
doCommands                                          2279    2294     +15
ipneigh_list_or_flush                                763     772      +9
ipaddr_list_or_flush                                1256    1261      +5
display_process_list                                1301    1306      +5
conspy_main                                         1378    1383      +5
do_lzo_compress                                      352     355      +3
do_lzo_decompress                                    565     567      +2
push                                                  46      44      -2
inetd_main                                          2136    2134      -2
uevent_main                                          421     418      -3
addLines                                              97      92      -5
bb_common_bufsiz1                                   8193    1024   -7169
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 8/5 up/down: 62/-7181)        Total: -7119 bytes
   text	   data	    bss	    dec	    hex	filename
 829850	   4086	   9080	 843016	  cdd08	busybox_old
 829901	   4086	   1904	 835891	  cc133	busybox_unstripped

FEATURE_USE_BSS_TAIL=y:

read_config                                          210     228     +18
doCommands                                          2279    2294     +15
ipneigh_list_or_flush                                763     772      +9
ipaddr_list_or_flush                                1256    1261      +5
display_process_list                                1301    1306      +5
conspy_main                                         1378    1383      +5
do_lzo_compress                                      352     355      +3
do_lzo_decompress                                    565     567      +2
inetd_main                                          2136    2134      -2
bb_common_bufsiz1                                   8193       -   -8193
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 8/1 up/down: 62/-8195)        Total: -8133 bytes
   text	   data	    bss	    dec	    hex	filename
 829850	   4086	   9080	 843016	  cdd08	busybox_old
 829911	   4086	    880	 834877	  cbd3d	busybox_unstripped

FIXME: setup_common_bufsiz() calls are missing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 17:39:11 +02:00
Ron Yorston
2b91958dff Rewrite iteration through applet names to save a few bytes
function                                             old     new   delta
run_applet_and_exit                                  758     755      -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3)               Total: -3 bytes

In standalone shell mode the saving increases to 17 bytes.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-15 22:13:51 +02:00
Ron Yorston
b22061718d find_applet_by_name: loop index should be signed
The loop

   for (j = ARRAY_SIZE(applet_nameofs)-1; j >= 0; j--) {

was intended to terminate when j goes negative, so j needs to be signed.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-03 22:29:35 +02:00
Denys Vlasenko
6aab9928de whitespace and namespace cleanups
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-03 22:24:51 +02:00
Sven Eisenberg
b068cf2a7e ubirmvol: Implement -N switch for ubirmvol
function                                             old     new   delta
get_volid_by_name                                      -     125    +125
ubi_devnum_from_devname                                -      43     +43
ubi_tools_main                                      1215    1220      +5
packed_usage                                       30674   30655     -19
ubirename_main                                       394     221    -173
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 1/2 up/down: 173/-192)          Total: -19 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-03 22:01:43 +02:00
Denys Vlasenko
46b494635e libbb: speed up error_msg functions
function                                             old     new   delta
bb_verror_msg                                        386     466     +80

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-03 16:55:03 +02:00
Denys Vlasenko
bc14f4d13d main(): add a TODO about finding a use for _end[] area
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-03 16:06:42 +02:00
Denys Vlasenko
1cf68e3033 typo fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-02 22:57:17 +02:00
Denys Vlasenko
a93e4fd376 find_applet_by_name: add an example of faster linear search code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-02 22:54:23 +02:00
Denys Vlasenko
8220399173 nsenter,unshare: share common code; fix a bug of not closing all fds
function                                             old     new   delta
xvfork_parent_waits_and_exits                          -      64     +64
exec_prog_or_SHELL                                     -      39     +39
unshare_main                                         873     810     -63
nsenter_main                                         663     596     -67
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/2 up/down: 106/-130)          Total: -27 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-02 18:06:24 +02:00
Denys Vlasenko
c4199f22d0 libbb: two new functions: wait_for_exitstatus(pid), xfchdir(fd)
Bartosz Golaszewski proposed xfchdir()

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-01 22:12:44 +02:00
Denys Vlasenko
8f2e99c813 udhcp: get rid of bb_info_msg()
function                                             old     new   delta
udhcpd_main                                         1501    1531     +30
d6_recv_raw_packet                                   251     264     +13
perform_d6_release                                   188     198     +10
udhcpc6_main                                        2443    2449      +6
udhcp_recv_raw_packet                                582     588      +6
udhcp_recv_kernel_packet                             132     138      +6
send_d6_renew                                        140     146      +6
d6_recv_kernel_packet                                118     124      +6
send_renew                                            77      82      +5
send_discover                                         85      90      +5
send_decline                                          84      89      +5
send_d6_select                                        97     102      +5
send_d6_discover                                     174     179      +5
perform_release                                      167     172      +5
count_lines                                           72      74      +2
udhcpc_main                                         2836    2837      +1
bb_info_msg                                          125       -    -125
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 17/4 up/down: 117/-180)         Total: -63 bytes
   text	   data	    bss	    dec	    hex	filename
 924935	    906	  17160	 943001	  e6399	busybox_old
 924736	    906	  17160	 942802	  e62d2	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-30 18:41:23 +02:00
Ron Yorston
610c4c385b applet_tables: save space by removing applet name offsets
The array applet_nameofs consumes two bytes per applet.  It encodes

   nofork/noexec flags
   suid flags
   the offset of the applet name in the applet_name string

Change the applet_table build tool to store the flags in two separate
arrays (applet_flags and applet_suid).  Replace applet_nameofs[] with a
smaller version that only stores a limited number of offsets.

This requires changes to the macros APPLET_IS_NOFORK, APPLET_IS_NOEXEC
and APPLET_SUID.

   According to Valgrind the original find_applet_by_name required
   353 cycles per call, averaged over all names.  Adjusting the number
   of known offsets allows space to be traded off against execution time:

      KNOWN_OFFSETS     cycles     bytes (wrt KNOWN_OFFSETS = 0)

           0             9057        -
           2             4604       32
           4             2407       75
           8             1342       98
          16              908      130
          32              884      194

   This patch uses KNOWN_OFFSETS = 8.

v2:
   Remove some dead code from the applet_table tool;
   Treat the applet in the middle of the table as a special case.

v3:
   Use the middle applet to adjust the start of the linear search as
   well as the last applet found.

v4:
   Use an augmented linear search in find_applet_by_name.
   Drop the special treatment of the middle name from get_applet_name:
   most of the advantage now derives from the last stored value.

v5:
   Don't store index in applet_nameofs, it can be calculated.

v6:
   Tweaks by Denys

function                                             old     new   delta
find_applet_by_name                                   25     125    +100
applet_suid                                            -      92     +92
run_applet_no_and_exit                               452     460      +8
run_applet_and_exit                                  695     697      +2
applet_name_compare                                   31       -     -31
applet_nameofs                                       734      14    -720
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 3/1 up/down: 202/-751)         Total: -549 bytes
   text       data        bss        dec        hex    filename
 925464        906      17160     943530      e65aa    busybox_old
 924915        906      17160     942981      e6385    busybox_unstripped

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-30 00:44:11 +02:00
Pascal Bach
2c0d3f5fd0 chpasswd: support -c argument and respect DEFAULT_PASSWD_ALGO
Signed-off-by: Pascal Bach <pascal.bach@siemens.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-12-18 19:01:14 +01:00
Chris Renshaw
6df961257d Resolve linker issues with Android API 21 (dprintf, tcdrain)
Signed-off-by: Chris Renshaw <osm0sis@outlook.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-12-17 16:42:41 +01:00
Denys Vlasenko
fe0dc34746 lineedit: FEATURE_REVERSE_SEARCH should not depend on SAVEHISTORY
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-30 21:39:19 +01:00
Ron Yorston
f23264b35f lineedit: search applets as well as PATH for tab completion
In standalone shell mode search the applet table as well as PATH
when tab completing a command.

Use a stupid linear search:  we're also about to read all the
directories on PATH so efficiency isn't a big concern.

function                                             old     new   delta
add_match                                              -      53     +53
complete_cmd_dir_file                                687     724     +37
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 90/0)               Total: 90 bytes

Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-30 19:49:33 +01:00
Ron Yorston
ae57af6e78 busybox: alter help message in standalone shell mode
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-30 19:00:38 +01:00
Denys Vlasenko
db700330d8 tweak defconfig
MONOTONIC_SYSCALL=y by default

FEATURE_LAST_SMALL is gone: now FEATURE_LAST_FANCY is a "bool", not a "choice".

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-25 20:36:03 +01:00
Denys Vlasenko
049b007865 pmap: fix bogus {no such process} comm field text
function                                             old     new   delta
read_cmdline                                         246     266     +20
procps_get_maps                                      196     193      -3
packed_usage                                       30413   30404      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 20/-12)              Total: 8 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24 03:45:57 +02:00
Denys Vlasenko
00da72bee0 tidy up strtok use
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-23 18:43:16 +02:00
Denys Vlasenko
d3d6534b2a wget: if stderr is not a tty, progress bar shouldn't use tty-tricks
function                                             old     new   delta
bb_progress_update                                   706     768     +62

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-23 02:01:38 +02:00
Denys Vlasenko
641caaec3d libbb: factor out code which queries screen width
function                                             old     new   delta
get_terminal_width                                     -      17     +17
stty_main                                           1196    1197      +1
pstree_main                                          321     319      -2
ls_main                                              735     731      -4
watch_main                                           232     225      -7
bb_progress_update                                   714     706      -8
ps_main                                              555     543     -12
run_applet_and_exit                                  708     695     -13
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/6 up/down: 18/-46)            Total: -28 byte

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-23 01:44:22 +02:00
Denys Vlasenko
accd9eeb71 remove systemd support
systemd people are not willing to play nice with the rest of the world.
Therefore there is no reason for the rest of the world to cooperate with them.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-22 16:01:57 +02:00
Denys Vlasenko
526d85831e libbb: get_uidgid() always called with allow_numeric=1
function                                             old     new   delta
xget_uidgid                                           30      25      -5
make_device                                         2188    2183      -5
main                                                 797     792      -5
get_uidgid                                           240     225     -15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-19 04:27:17 +02:00
Denys Vlasenko
93dd9fd90a du: extra compat: with -k and -m, round sizes up
function                                             old     new   delta
print                                                 36      65     +29

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-15 21:33:34 +02:00
Denys Vlasenko
0f296a3a56 libiproute: rename invarg(a,b) to invarg_1_to_2(a,b)
invarg(a,b) - "invalid argument", but how a and b enter the message?

invarg_1_to_2(a,b) is somewhat easier to read: "invalid argument 'a' to 'b'"

Audit of usage revealed a number of bad uses, with too long messages.

   text	   data	    bss	    dec	    hex	filename
 938848	    932	  17448	 957228	  e9b2c	busybox_old
 938788	    932	  17448	 957168	  e9af0	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-14 13:21:01 +02:00
Denys Vlasenko
ab3964db4e libbb: introduce kernel-style BUILD_BUG_ON()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-13 14:50:20 +02:00
Denys Vlasenko
02859aaeb2 use auto_string() where appropriate to kill a few statics
Custom linker script 'busybox_ldscript' found, using it
function                                             old     new   delta
static.str                                             4       -      -4
static.passwd                                          4       0      -4
bb_ask                                               322     311     -11
ether_print                                           63      47     -16
UNSPEC_print                                          82      66     -16
INET_sprint                                           59      38     -21
INET6_sprint                                          54      30     -24
make_human_readable_str                              292     235     -57
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/7 up/down: 0/-153)           Total: -153 bytes
   text	   data	    bss	    dec	    hex	filename
 939880	    992	  17480	 958352	  e9f90	busybox_old
 939736	    992	  17456	 958184	  e9ee8	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-09 18:16:40 +02:00
Denys Vlasenko
e52da5570e libbb: auto_string() for efficient handling of temporary malloced stirngs
Use it in libiproute: get rid of one static string buffer.

function                                             old     new   delta
auto_string                                            -      51     +51
ll_index_to_name                                      10      49     +39
buffer_fill_and_print                                169     178      +9
scan_recursive                                       378     380      +2
decode_one_format                                    732     734      +2
cmdputs                                              334     332      -2
static.cur_saved                                       4       1      -3
static.nbuf                                           16       -     -16
printable_string                                      94      57     -37
ll_idx_n2a                                            53       -     -53
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 4/3 up/down: 103/-111)           Total: -8 bytes
   text	   data	    bss	    dec	    hex	filename
 939880	    992	  17496	 958368	  e9fa0	busybox_old
 939880	    992	  17480	 958352	  e9f90	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-09 17:59:56 +02:00
Denys Vlasenko
550bf5b4a4 remove global "jmp_buf die_jmp" from !FEATURE_PREFER_APPLETS builds
function                                             old     new   delta
xfunc_has_died                                         -      21     +21
sleep_much                                             -      12     +12
sleep10                                                -       9      +9
die_func                                               -       4      +4
fflush_stdout_and_exit                                35      36      +1
builtin_type                                         121     119      -2
die_sleep                                              4       -      -4
xfunc_die                                             60      24     -36
hush_main                                           1128    1011    -117
die_jmp                                              156       -    -156
------------------------------------------------------------------------------
(add/remove: 4/2 grow/shrink: 1/3 up/down: 47/-315)          Total: -268 bytes
   text	   data	    bss	    dec	    hex	filename
 939992	    992	  17652	 958636	  ea0ac	busybox_old
 939880	    992	  17496	 958368	  e9fa0	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-09 16:42:57 +02:00
Denys Vlasenko
305958dbd4 md5sum: code shrink
For CONFIG_MD5_SMALL=1:
function                                             old     new   delta
md5_process_block64                                  925     881     -44

For CONFIG_MD5_SMALL=0:
function                                             old     new   delta
md5_process_block64                                 1603    1586     -17

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-07 19:17:01 +02:00
Denys Vlasenko
5711a2a4ad libbb: more compact API for bb_parse_mode()
function                                             old     new   delta
make_device                                         2182    2188      +6
parse_command                                       1440    1443      +3
parse_params                                        1497    1499      +2
install_main                                         773     769      -4
mkdir_main                                           168     160      -8
getoptscmd                                           641     632      -9
builtin_umask                                        158     147     -11
bb_parse_mode                                        431     410     -21
umaskcmd                                             286     258     -28
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/6 up/down: 11/-81)            Total: -70 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-07 17:55:33 +02:00
Tito Ragusa
f085344d5c libbb: another unit test for is_suffixed_with
Suggested by Bartosz Golaszewski.

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-09-15 23:38:01 +02:00
Denys Vlasenko
68acc0f835 libbb: make is_suffixed_with() return pointer inside string, not key.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-25 21:47:33 +02:00
Bartosz Golaszewski
7448b513c8 libbb: add is_suffixed_with() function
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-25 16:36:43 +02:00
Bartosz Golaszewski
0a4d0e8fbf libbb: add a comment describing the way is_prefixed_with() works
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-25 15:04:16 +02:00
Bartosz Golaszewski
b432923e29 libbb: add unit tests for is_prefixed_with()
Test corner cases too like looking for an empty prefix etc.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-25 15:00:24 +02:00
Denys Vlasenko
c52cbea2bb libbb: add setsockopt_foo helpers
function                                             old     new   delta
setsockopt_int                                         -      23     +23
do_load                                              918     934     +16
setsockopt_SOL_SOCKET_int                              -      14     +14
setsockopt_keepalive                                   -      10     +10
setsockopt_SOL_SOCKET_1                                -      10     +10
buffer_fill_and_print                                169     178      +9
setsockopt_1                                           -       8      +8
nfsmount                                            3560    3566      +6
redirect                                            1277    1282      +5
tcpudpsvd_main                                      1782    1786      +4
d6_send_kernel_packet                                272     275      +3
i2cget_main                                          380     382      +2
ed_main                                             2544    2545      +1
scan_recursive                                       380     378      -2
nbdclient_main                                       492     490      -2
hash_find                                            235     233      -2
cmdputs                                              334     332      -2
parse_command                                       1443    1440      -3
static.two                                             4       -      -4
ntpd_main                                           1039    1035      -4
const_int_1                                            4       -      -4
const_IPTOS_LOWDELAY                                   4       -      -4
RCVBUF                                                 4       -      -4
ntp_init                                             474     469      -5
change_listen_mode                                   316     310      -6
uevent_main                                          416     409      -7
arping_main                                         1697    1690      -7
telnet_main                                         1612    1603      -9
socket_want_pktinfo                                   42      33      -9
setsockopt_reuseaddr                                  21      10     -11
setsockopt_broadcast                                  21      10     -11
httpd_main                                           772     757     -15
get_remote_transfer_fd                               109      94     -15
make_new_session                                     503     487     -16
ftpd_main                                           2177    2160     -17
read_bunzip                                         1896    1866     -30
common_traceroute_main                              4099    4058     -41
common_ping_main                                    1836    1783     -53
------------------------------------------------------------------------------
(add/remove: 5/4 grow/shrink: 8/21 up/down: 111/-283)        Total: -172 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-24 20:00:17 +02:00
Bartosz Golaszewski
718e228adc unit-tests: remove code depending on WANT_TIMING
Since there is no interest in merging a config option for WANT_TIMING,
remove the parts of code depending on it altogether.

While we're at it: add some newlines to improve readability.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-17 17:01:49 +02:00
Bartosz Golaszewski
d077565bb2 unit-tests: remove unnecesary field from struct bbunit_listelem
In the initial submission struct bbunit_listelem was manipulated by
custom list functions implemented in bbunit.c. Since the tests are now
added to the list by llist_add_to_end(), which allocates the llist_t
objects behind the scenes, there's no need for the *next field.

function                                             old     new   delta
unit_main                                            142     141      -1
bbunit_strrstr_elem                                   24      16      -8
bbunit_obscure_weak_pass_elem                         24      16      -8
bbunit_obscure_strong_pass_elem                       24      16      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-25)             Total: -25 bytes

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-17 17:00:10 +02:00
Ron Yorston
d840c5d139 libbb: add a function to make a copy of a region of memory
Introduce a library routine to package the idiom:

    p = xmalloc(b, n);
    memcpy(p, b, n);

and use it where possible.  The example in traceroute used xzalloc
but it didn't need to.

function                                             old     new   delta
xmemdup                                                -      32     +32
last_main                                            834     826      -8
make_device                                         2321    2311     -10
common_traceroute_main                              3698    3685     -13
readtoken1                                          3182    3168     -14
procps_scan                                         1222    1206     -16
forkchild                                            655     638     -17
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/6 up/down: 32/-78)            Total: -46 bytes

Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-19 23:05:20 +02:00
Maninder Singh
97f2f7ca7f Removes stray empty line from code
This patch removes stray empty line from busybox code
reported by script find_stray_empty_lines

Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Akhilesh Kumar <akhilesh.k@samsung.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-13 03:25:46 +02:00
Denys Vlasenko
7f4a49a96c Print one less newline at the end of bb_show_usage()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-25 14:30:52 +02:00
Daniel Thompson
a818777d42 libbb: Enable support for !CONFIG_MULTIUSER
Linux recently gained a new config option, CONFIG_MULTIUSER, that makes
support for non-root users optional. This results in a number of syscalls
being disabled: setuid, setregid, setgid, setreuid, setresuid, getresuid,
setresgid, getresgid, setgroups, getgroups, setfsuid, setfsgid, capget,
capset.

Currently a number of busybox applets, including login, struggle to run
when CONFIG_MULTIUSER is disabled. Even the root user is unable to login:
  login: can't set groups: Functi

This patch adds code to make change_identity() a nop on single user
systems. It works by recognising the signature errno value (ENOSYS, due
to the system calls being disabled) and, to avoid security risks, only
deploys when the current uid and target uid is the same.

After the patch is applied any attempt to switch to a non-root user will
fail. Thus a badly configured userspace (for example, one that tries to
start a daemon as a non-root user when the kernel cannot support this)
will report errors as one would expect.

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-12 23:59:57 +02:00
Matt Whitlock
93b98ff572 Bionic lacks tcdrain; provide a workaround
Signed-off-by: Matt Whitlock <busybox@mattwhitlock.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-26 13:14:50 +02:00
Matt Whitlock
cee59053dc Bionic lacks ttyname_r; provide a workaround
Signed-off-by: Matt Whitlock <busybox@mattwhitlock.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-25 21:32:48 +02:00
Denys Vlasenko
de5edadee2 special-case {true,false,test} --help
This also removes their help texts.

function                                             old     new   delta
run_applet_no_and_exit                               442     452     +10
packed_usage                                       30713   30625     -88

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-21 16:00:41 +02:00
Ron Yorston
61d6ae244a libbb: remove unnecessary argument to nonblock_immune_read
The loop_on_EINTR argument to nonblock_immune_read is always set to 1.

function                                             old     new   delta
xmalloc_reads                                        200     195      -5
pgetc                                                488     483      -5
argstr                                              1313    1308      -5
nonblock_immune_read                                 123      86     -37
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-52)             Total: -52 bytes

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-20 13:41:32 +02:00
Aaro Koskinen
7b729edd33 update copyright years
Copyright years seem to be out of date, e.g. coreutils/truncate.c
has Copyright (C) 2015.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2015-04-02 23:03:56 +02:00
Bernhard Reutner-Fischer
86a7f18f21 *: Switch to POSIX utmpx API
UTMP is SVID legacy, UTMPX is mandated by POSIX.

Glibc and uClibc have identical layout of UTMP and UTMPX, both of these
libc treat _PATH_UTMPX as _PATH_UTMP so from a user-perspective nothing
changes except the names of the API entrypoints.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2015-04-02 23:03:46 +02:00
Ari Sundholm
911db16229 truncate: new applet
function                                             old     new   delta
truncate_main                                          -     161    +161
cwbkMG_suffixes                                        -     128    +128
packed_usage                                       30443   30459     +16
applet_names                                        2512    2521      +9
applet_main                                         1456    1460      +4
parse_command                                       1460    1463      +3
applet_nameofs                                       728     730      +2
applet_install_loc                                   182     183      +1
dd_suffixes                                          112       -    -112
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 10/3 up/down: 337/-133)         Total: 204 bytes

Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-22 17:56:38 +01:00
Ari Sundholm
8893023ba2 dd: move suffix struct to xatonum.c
This way it can be used by other applets without duplication.

Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-22 17:41:04 +01:00
Denys Vlasenko
8dff01d06a libbb: introduce and use is_prefixed_with()
function                                             old     new   delta
is_prefixed_with                                       -      18     +18
complete_username                                     78      77      -1
man_main                                             737     735      -2
fsck_device                                          429     427      -2
unpack_ar_archive                                     80      76      -4
strip_unsafe_prefix                                  105     101      -4
singlemount                                         1054    1050      -4
rtc_adjtime_is_utc                                    90      86      -4
resolve_mount_spec                                    88      84      -4
parse_one_line                                      1029    1025      -4
parse_conf                                          1460    1456      -4
may_wakeup                                            83      79      -4
loadkmap_main                                        219     215      -4
get_irqs_from_stat                                   103      99      -4
get_header_cpio                                      913     909      -4
findfs_main                                           79      75      -4
fbsplash_main                                       1230    1226      -4
load_crontab                                         776     771      -5
expand_vars_to_list                                 1151    1146      -5
date_main                                            881     876      -5
skip_dev_pfx                                          30      24      -6
make_device                                         2199    2193      -6
complete_cmd_dir_file                                773     767      -6
run_applet_and_exit                                  715     708      -7
uudecode_main                                        321     313      -8
pwdx_main                                            197     189      -8
execute                                              568     560      -8
i2cdetect_main                                      1186    1176     -10
procps_scan                                         1242    1230     -12
procps_read_smaps                                   1017    1005     -12
process_module                                       746     734     -12
patch_main                                          1903    1891     -12
nfsmount                                            3572    3560     -12
stack_machine                                        126     112     -14
process_timer_stats                                  449     435     -14
match_fstype                                         111      97     -14
do_ipaddr                                           1344    1330     -14
open_list_and_close                                  359     343     -16
get_header_tar                                      1795    1779     -16
prepend_new_eth_table                                340     323     -17
fsck_main                                           1811    1794     -17
find_iface_state                                      56      38     -18
dnsd_main                                           1321    1303     -18
base_device                                          179     158     -21
find_keyword                                         104      82     -22
handle_incoming_and_exit                            2785    2762     -23
parse_and_put_prompt                                 774     746     -28
modinfo                                              347     317     -30
find_action                                          204     171     -33
update_passwd                                       1470    1436     -34
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/49 up/down: 18/-540)         Total: -522 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-12 17:48:34 +01:00
Denys Vlasenko
936c8809ca deluser: also remove user from /etc/group
function                                             old     new   delta
update_passwd                                       1270    1470    +200
deluser_main                                         310     332     +22

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-12 15:30:46 +01:00
Denys Vlasenko
23cfaab47d libpwdgrp: use getpwent() instead of getpwent_r()
function                                             old     new   delta
massage_data_for_non_r_func                            -      90     +90
bb_internal_getpwent                                   -      69     +69
getXXnam_r                                            94     162     +68
fill_bounds                                          131     128      -3
deluser_main                                         355     310     -45
complete_username                                    123      78     -45
getXXnam                                             163      90     -73
massage_data_for_r_func                              103       -    -103
bb_internal_getpwent_r                               121       -    -121
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 1/5 up/down: 227/-407)         Total: -163 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-07 21:21:02 +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
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
da9212667c libbb: code shrink by factoring out common update_utmp_DEAD_PROCESS
function                                             old     new   delta
update_utmp_DEAD_PROCESS                               -      17     +17
telnetd_main                                        1685    1674     -11
mark_terminated                                       56      45     -11
handle_sigchld                                        74      63     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-05 15:37:58 +01:00
Tito Ragusa
1da09cfacf libpwdgrp: rewritten to use malloced implementation
This removed buffer size limitations.

function                                             old     new   delta
convert_to_struct                                      -     269    +269
getXXnam_r                                             -     204    +204
parse_common                                           -     185    +185
getXXnam                                               -     164    +164
tokenize                                               -     126    +126
bb_internal_getpwent_r                               102     167     +65
get_S                                                 30      88     +58
getgrouplist_internal                                195     240     +45
const_sp_db                                            -      20     +20
const_pw_db                                            -      20     +20
const_gr_db                                            -      20     +20
bb_internal_endpwent                                  27      36      +9
bb_internal_endgrent                                  27      36      +9
decode_one_format                                    726     734      +8
bb_internal_setpwent                                  17      24      +7
volume_id_probe_iso9660                              319     322      +3
scriptreplay_main                                    204     207      +3
mkfs_minix_main                                     2684    2687      +3
id_main                                              478     480      +2
hash_find                                            233     235      +2
pstree_main                                          321     322      +1
gr_off                                                 3       4      +1
expand_one_var                                      1579    1578      -1
pwf                                                    4       -      -4
grf                                                    4       -      -4
pack_gzip                                           1787    1780      -7
addattr32                                             67      56     -11
buffer_fill_and_print                                191     178     -13
dpkg_main                                           2944    2927     -17
bb_internal_setgrent                                  17       -     -17
bb_internal_getpwuid                                  38      19     -19
bb_internal_getgrgid                                  44      19     -25
bb_internal_getpwnam                                  38      11     -27
bb_internal_getgrnam                                  44      14     -30
bb_internal_fgetpwent_r                               51       -     -51
bb_internal_fgetgrent_r                               51       -     -51
bb_internal_getspnam_r                               121      42     -79
bb_internal_getpwnam_r                               121      39     -82
bb_internal_getgrent_r                               102       -    -102
bb__parsepwent                                       110       -    -110
bb_internal_getpwuid_r                               113       -    -113
bb_internal_getgrgid_r                               113       -    -113
bb__parsespent                                       120       -    -120
bb_internal_getgrnam_r                               121       -    -121
bb__pgsreader                                        213       -    -213
bb__parsegrent                                       226       -    -226
------------------------------------------------------------------------------
(add/remove: 8/13 grow/shrink: 14/11 up/down: 1224/-1556)    Total: -332 bytes
   text	   data	    bss	    dec	    hex	filename
 923471	    928	  17684	 942083	  e6003	busybox_old
 923167	    928	  17676	 941771	  e5ecb	busybox_unstripped

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-02 21:37:59 +01:00
Denys Vlasenko
ca9c4653a9 libbb: add sanity check in bb_arg_max()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-24 01:46:29 +01:00
Denys Vlasenko
11775edbfc randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-22 19:37:05 +01:00
Ron Yorston
20cd31a2d7 lineedit: don't block when looking for escape sequence in vi-mode
In vi-mode lineedit tries to detect some escape sequences.
After the ESC it reads the next character to check for certain
values.  This read should have a timeout or a user-entered ESC to
switch to command mode doesn't properly handle the next character.

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-15 13:30:58 +01:00
Denys Vlasenko
d598a8d4e6 lineedit: don't fall back to simple line input if tty is in raw mode
Testcase: shell command input after python ^Z should still work

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-10 17:22:13 +01:00
Bartosz Golaszewski
8d75d794ea libbb: use sendfile() to copy data between file descriptors
Busybox already uses sendfile in httpd. This patch proposes to use it
globally to copy data between file descriptors.

It speeds up the copying on slow systems a lot - below are the times needed
to copy a 450Mb file with and without this option enabled on a BeagleBone
Black:

sendfile:
user    0m0.000s
sys     0m8.170s

read/write 4k:
user    0m0.470s
sys     0m16.300s

function                                             old     new   delta
bb_full_fd_action                                    394     474     +80

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-27 23:31:58 +01:00
Denys Vlasenko
04c1417602 libbb: use ARG_MAX for bb_arg_max() only if it's 60k+
Sometimes ARG_MAX is small (like 32k) yet sysconf(_SC_ARG_MAX)
is big, and people prefer using the bigger value.

OTOH, with sufficiently large ARG_MAX, further wins from
sysconf(_SC_ARG_MAX) being bigger are exponentially smaller:
you can see 4 times fewer fork+execs when you run find, but
when each execed process already takes a thousand parameters
it's likely execution time is dominated by what that process
does with each parameter.

Thus, with this change ARG_MAX is used if it's sufficiently big,
otherwise sysconf(_SC_ARG_MAX) is used.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-26 15:17:59 +01:00
Denys Vlasenko
2835a224cd bbunit: fix WANT_TIMING compilation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-26 14:04:51 +01:00
Denys Vlasenko
628f134fe7 exit with 127 if appled name wasn't found - it's more POSIXy
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-17 17:03:47 +01:00
Michel Stam
d3fabf89d7 zcip: Add environment variable for overriding log functionality
function                                             old     new   delta
bb_logenv_override                                     -      70     +70
packed_usage                                       29969   30033     +64
zcip_main                                           1426    1431      +5
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/0 up/down: 139/0)             Total: 139 bytes

Signed-off-by: Michel Stam <m.stam@fugro.nl>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-04 12:19:04 +01:00
Denys Vlasenko
d6e7672545 less: move "retry-on-EAGAIN" logic closer to read ops
This makes "G" (goto end of input) command work as well as
/search_for_nonexistent_string: both will read to EOF now
even from somewhat slow input (such as kernel's "git log").

function                                             old     new   delta
ndelay_on                                             35      43      +8
ndelay_off                                            35      43      +8
read_lines                                           695     691      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 16/-4)              Total: 12 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-09-22 21:14:02 +02:00
Denys Vlasenko
cd7a38a87d false: make "false --help" exit with 1
function                                             old     new   delta
run_applet_no_and_exit                               447     445      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-09-18 00:47:05 +02:00
Denys Vlasenko
45b4ecc868 init: if libc-based Unicode support is on, run setlocale(LC_ALL, "") at startup
It is not clear why we were excluding init from this.
The "getpid() != 1" clause was there from the beginning (2001)
but not explained.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-08-11 20:33:18 +02:00
Morten Kvistgaard
feac9b607d ftpd: add optional support for authentication
function                                             old     new   delta
cmdio_get_cmd_and_arg                                  -     237    +237
get_passwd                                             -      97     +97
check_password                                         -      82     +82
ftpd_main                                           2297    2178    -119
ask_and_check_password_extended                      206      84    -122
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 0/2 up/down: 416/-241)          Total: 175 bytes

Signed-off-by: Morten Kvistgaard <MK@pch-engineering.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-08-05 21:57:18 +02:00
Denys Vlasenko
09a0e2223f sha3: tweak comments and indentation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-07-30 16:26:09 +02:00
Denys Vlasenko
4ff933c0e7 sha3: code shrink (and speedup for SHA3_SMALL=0)
function                                             old     new   delta
sha3_process_block72                                1454    1359     -95

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-07-30 14:18:57 +02:00
Denys Vlasenko
2a563ea49a sha3: add 32-bit optimized bit-sliced implementation
It is an interesting trick, but so far I only managed to make it work
correctly, not to make it faster and/or smaller.
The code is ifdefed out for now.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-07-25 17:24:13 +02:00
Denys Vlasenko
d32fc647d7 libbb: fix bb_ask() to flush input before prompt, not after. Closes 7190
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-07-01 13:20:22 +02:00
Denys Vlasenko
5aeae36e2b libbb: fix compile failure if both ARG_MAX and _SC_ARG_MAX are defined
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-25 15:39:27 +02:00
Bartosz Golaszewski
3ed81cf052 unit-tests: implement the unit-testing framework
This set of patches adds a simple unit-testing framework to Busybox

unit-tests: add some helper macros for unit-test framework implementation
unit-tests: implement the unit-testing framework
unit-tests: add basic documentation on writing the unit test cases
unit-tests: modify the Makefile 'test' target to run unit-tests too
unit-tests: add two example test cases
unit-tests: modify the existing strrstr test code to use the unit-test framework

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-22 16:30:41 +02:00
Bartosz Golaszewski
5d2e409ef8 libbb: use a wrapper around sysconf(_SC_CLK_TCK) to save a few bytes
function                                             old     new   delta
bb_sc_clk_tck                                          -      10     +10
timescmd                                             118     113      -5
print_route                                         1763    1758      -5
mpstat_main                                         1288    1283      -5
iostat_main                                         1947    1942      -5
INET_setroute                                        879     871      -8
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/5 up/down: 10/-28)            Total: -18 bytes
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-22 14:01:13 +02:00
Denys Vlasenko
f92f1d0181 find: use sysconf(_SC_ARG_MAX) to determine the command-line size limit
The find utility uses a hardcoded value of 32 * 1024 as the limit of
the command-line length when calling 'find -exec ... {} +'. This results
in over 4 times more execve() calls than in coreutils' find.

This patch uses the limit defined in system headers.

Based on the patch by  Bartosz Golaszewski <bartekgola@gmail.com>.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-22 13:54:40 +02:00
Denys Vlasenko
17f8418ea7 Add conditional support for -v / --verbose
With FEATURE_VERBOSE off, practically no size change.
With it on:

function                                             old     new   delta
remove_file                                          493     556     +63
install_main                                         719     765     +46
bb_make_directory                                    383     419     +36
rmdir_main                                           162     191     +29
copy_file                                           1516    1544     +28
mv_main                                              502     525     +23
cmp_main                                             677     693     +16
bbconfig_config_bz2                                 5264    5279     +15
mkdir_main                                           158     168     +10
install_longopts                                      66      76     +10
rm_main                                              167     175      +8
nexpr                                                840     846      +6
scan_tree                                            275     280      +5
fsck_main                                           1807    1811      +4
ed_main                                             2541    2545      +4
expand_one_var                                      1574    1575      +1
swap_on_off_main                                     420     418      -2
parse_command                                       1443    1440      -3
redirect                                            1279    1274      -5
do_load                                              946     918     -28
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 16/4 up/down: 304/-38)          Total: 266 bytes

Based on the patch by Igor Živković.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-19 16:23:50 +02:00
Denys Vlasenko
e765b5ac34 libbb: rename execable -> executable. No code changes
English speakers complained that it sounded awfully broken.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-02 17:15:58 +02:00
Denys Vlasenko
15a357e596 libbb: fix empty PATH components handling
function                                             old     new   delta
find_execable                                         81      86      +5
exists_execable                                       71      66      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-02 17:08:29 +02:00
Denys Vlasenko
d8290c2ef0 libbb: fix thinko in rtc_xopen()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-02 09:07:16 +02:00
Denys Vlasenko
528808fa7b libbb: make rtc_xopen try harder on EBUSY
function                                             old     new   delta
rtc_xopen                                             77     139     +62

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-02 09:05:03 +02:00
Denys Vlasenko
fe33683c8b Fix compile failures
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-02 07:18:55 +02:00
Denys Vlasenko
3dfe0ae5a8 libbb: make syslog level for bb_error_msg's configurable. use it in crond
function                                             old     new   delta
bb_verror_msg                                        380     386      +6
syslog_level                                           -       1      +1
crondlog                                             165     108     -57

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-30 14:48:28 +02:00
Denys Vlasenko
eb9f485b07 libbb/obscure.c: code shrink. Suggested by Tito.
function                                             old     new   delta
string_checker                                        97      92      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-16 19:51:34 +02:00
Bernhard Reutner-Fischer
ad16741ccd libbb: provide usleep() fallback implementation
POSIX.1-2008 removed the usleep function, provide a fallback
implementaion using the recommended nanosleep().

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-13 16:37:57 +02:00
Denys Vlasenko
c50493854a libbb: fix a bad check for uclibc >= 0.9.31
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-03-16 20:53:40 +01:00
Denys Vlasenko
438b4ac286 script: make it work even if fd 0 is closed
Testcase:
script -q -c "echo hey" /dev/null 0>&-

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-03-16 12:34:53 +01:00
Denys Vlasenko
6f068904dc xargs: add support for -I and -i. Closes 493
function                                             old     new   delta
process_stdin_with_replace                             -     195    +195
xmalloc_substitute_string                              -     145    +145
xargs_main                                           808     884     +76
count_strstr                                           -      45     +45
packed_usage                                       29580   29571      -9
parse_params                                        1445    1416     -29
func_exec                                            285     138    -147
------------------------------------------------------------------------------
(add/remove: 4/0 grow/shrink: 1/3 up/down: 461/-185)          Total: 276 bytes
   text	   data	    bss	    dec	    hex	filename
 922156	    932	  17692	 940780	  e5aec	busybox_old
 922440	    932	  17692	 941064	  e5c08	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-27 11:17:06 +01:00
Denys Vlasenko
83bc4332e7 du, copy_file: fix file matching on cramfs. Closes 5456
function                                             old     new   delta
is_in_ino_dev_hashtable                               88     108     +20
add_to_ino_dev_hashtable                             150     142      -8
reset_ino_dev_hashtable                               84      75      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 20/-17)              Total: 3 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-25 15:27:58 +01:00
Denys Vlasenko
12916b9220 libbb: trivial code shrink
function                                             old     new   delta
reset_ino_dev_hashtable                               84      74     -10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-25 15:09:01 +01:00
Denys Vlasenko
8ed9672660 libbb: don't die if crypt() returns NULL
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-09 14:38:03 +01:00
Mike Frysinger
f1999b5a9d appletlib: fix set-but-unused warning
When you build with FEATURE_INSTALLER disabled, you get a build
warning like so:

libbb/appletlib.c: In function 'busybox_main':
libbb/appletlib.c:691:7: warning: variable 'use_symbolic_links' set but
                                  not used [-Wunused-but-set-variable]
   int use_symbolic_links;
       ^

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2014-01-31 00:29:47 -05:00
Denys Vlasenko
fa6ab56353 libbb: if opening /dev/loopN returns ENXIO, don't try N++.
function                                             old     new   delta
set_loop                                             639     635      -4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-21 13:44:21 +01:00
Denys Vlasenko
3b394781b5 libbb: fix parsing of "10101010" date/time form
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-21 07:58:18 +01:00
Denys Vlasenko
79df481dc4 lineedit: fix trivial build failure
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-10 14:38:26 +01:00
Denys Vlasenko
96f92a1afa libbb: FreeBSD fix for B<num> baud rate constants not fitting into a short.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-08 15:25:20 +01:00
Denys Vlasenko
198b02f7dd fix failures found by randomconfig builds
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-12-31 23:22:36 +01:00
Michael Tokarev
9f4f60183b do not fail build if MAXSYMLINKS isn't defined
This is needed for, eg, hurd, which is known to have no constraints.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-12-16 03:41:30 +01:00
Denys Vlasenko
9b2a9f0210 fix assorted unused code and wrong format specs found by cppchekc (bug 6716)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-29 16:43:33 +01:00
Denys Vlasenko
1a7256ac38 chpst: fix a bug where -U USER was using wrong USER (one from -u USER)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-29 16:39:28 +01:00
Denys Vlasenko
259b3c047a sed: open input files sequentially to avoid EMFILE
Currently, sed pre-opens all files, which may cause EMFILE errors
on systems with low ulimit -n.  Change sed to open one file at a time.

function                                             old     new   delta
get_next_line                                        177     235     +58
sed_main                                             682     652     -30
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 58/-30)             Total: 28 bytes

Based on the patch by Daniel Borca <dborca@yahoo.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-28 03:14:16 +01:00
Denys Vlasenko
cffe28ef87 libbb: add sketch of tentative 'better' passwd/group API
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-26 13:46:18 +01:00
Denys Vlasenko
8b59b2c13e libbb: move nuke_str() from passwd into libbb
function                                             old     new   delta
nuke_str                                               -      15     +15
ask_and_check_password_extended                      215     206      -9
init_main                                            781     771     -10
nuke_str                                              27       -     -27
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/2 up/down: 15/-46)            Total: -31 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-19 13:36:45 +01:00
Denys Vlasenko
6ef7729112 comment tweak
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-19 13:16:44 +01:00
Denys Vlasenko
9c1c605b1a sulogin: use common password-checking routine.
This needed some extensions correct_passwd() function,
which got renamed ask_and_check_password() to better describe what it does.

function                                             old     new   delta
ask_and_check_password_extended                        -     215    +215
ask_and_check_password                                 -      12     +12
vlock_main                                           394     397      +3
sulogin_main                                         494     326    -168
correct_password                                     207       -    -207
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 1/1 up/down: 230/-375)         Total: -145 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-19 13:09:06 +01:00
Ryan Mallon
5906a5c26c libbb: Add xsetegid(), xseteuid(), xopen_as_uid_gid() functions
Signed-off-by: Ryan Mallon <rmallon@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-10-08 14:52:49 +02:00
Denys Vlasenko
a407cf74cc Make smart_ulltoa return pointer to end (allows for code shink in callers)
function                                             old     new   delta
smart_ulltoa5                                        405     408      +3
smart_ulltoa4                                        273     276      +3
list_table                                          1113    1114      +1
scale                                                 36      34      -2
put_lu                                                55      53      -2
ulltoa6_and_space                                     19      14      -5
powertop_main                                       1470    1461      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-09-06 12:53:14 +02:00
Denys Vlasenko
1b9ac21166 lineedit: use unicode_strwidth instead of unicode_strlen
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-08-20 16:13:05 +02:00
Denys Vlasenko
e66a56de23 lineedit: fix multi-line PS1 handling: calculate PS1 length from last \n
function                                             old     new   delta
parse_and_put_prompt                                 755     774     +19

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-08-19 16:45:04 +02:00
Denys Vlasenko
7a18043a96 lineedit: improve Unicode handling (still buggy though)
function                                             old     new   delta
unicode_strlen                                         -      31     +31
read_line_input                                     3876    3879      +3
lineedit_read_key                                    255     246      -9
parse_and_put_prompt                                 785     755     -30
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/2 up/down: 34/-39)             Total: -5 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-08-19 16:44:05 +02:00
Denys Vlasenko
543efd7b4b libbb: code shrink
function                                             old     new   delta
xmalloc_ttyname                                       46      42      -4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-08-06 00:41:06 +02:00
Denys Vlasenko
982e87f2fb Whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-30 11:52:58 +02:00
Bartosz Golaszewski
79c618c411 Refactor catv. Move visible() from stty to libbb.
Fixes the following TODO:

  stty's visible() function and catv's guts are identical. Merge them into
  an appropriate libbb function.

Also makes catv behave exactly like coreutils' cat -v e.g. it'll print 'M-^I'
instead of 'M-   '.

function                                             old     new   delta
visible                                                -      70     +70
do_display                                           431     379     -52
catv_main                                            306     250     -56
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 70/-108)           Total: -38 bytes

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-30 06:29:42 +02:00
Bartosz Golaszewski
688a7e3f04 date: accept 'yyyy-mm-dd HH' and 'yyyy-mm-dd' date formats
function                                             old     new   delta
parse_datestr                                        794     885     +91

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-25 05:10:01 +02:00
Bartosz Golaszewski
c19be75d57 networking: code shrink
function                                             old     new   delta
in_ether                                               -     124    +124
hexchar2int                                           42       -     -42
ifconfig_main                                       1237    1106    -131
ether_input                                          141       -    -141
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 0/1 up/down: 124/-314)         Total: -190 bytes

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-25 04:39:04 +02:00
Denys Vlasenko
c72b43c2f0 Commonalize typical [b,]k,m suffix struct
function                                             old     new   delta
bkm_suffixes                                           -      32     +32
static.km_suffixes                                    24       -     -24
suffixes                                              32       -     -32
static.bkm                                            32       -     -32
head_tail_suffixes                                    32       -     -32
------------------------------------------------------------------------------
(add/remove: 2/6 grow/shrink: 0/0 up/down: 72/-160)           Total: -88 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-13 23:49:45 +02:00
Denys Vlasenko
d8f6d8c627 Call setlocale("") , not "C", if we want to set the default one
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-07 14:41:58 +02:00
Denys Vlasenko
2301d127a2 unicode: check $LC_CTYPE too to detect Unicode mode
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-05 22:00:57 +02:00
Denys Vlasenko
3e7ecb179b unicode: check $LC_ALL to detect Unicode mode, not only $LANG
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-02 17:30:23 +02:00
Denys Vlasenko
59f46676a9 Move create_icmp[6]_socket to its only user, and simplify it
function                                             old     new   delta
run_applet_and_exit                                  711     714      +3
sendping_tail                                        239     236      -3
common_ping_main                                    1798    1770     -28
create_icmp_socket                                    65       -     -65
create_icmp6_socket                                   65       -     -65
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 1/2 up/down: 3/-161)           Total: -158 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-06-28 00:30:46 +02:00
Denys Vlasenko
1f5e81f8f8 md5/sha512: a better fix for strict aliasing warnings
The locations *are* well-aligned for direct stores
on any architecture.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-06-27 01:03:19 +02:00
Mike Frysinger
f6205c6ab7 md5/sha512: fix strict aliasing warnings
If the target can tolerate these issues, then gcc is smart enough
to generate the same code (x86_64 produces the same code).  If the
target can't, then it needs the memcpy anyways.

libbb/hash_md5_sha.c: In function 'common64_end':
libbb/hash_md5_sha.c:87:4: warning:
  dereferencing type-punned pointer will break strict-aliasing rules
    *(uint64_t *) (&ctx->wbuffer[64 - 8]) = t;
libbb/hash_md5_sha.c: In function 'sha512_end':
libbb/hash_md5_sha.c:886:4: warning:
  dereferencing type-punned pointer will break strict-aliasing rules
    *(uint64_t *) (&ctx->wbuffer[128 - 8]) = t;
libbb/hash_md5_sha.c:889:4: warning:
  dereferencing type-punned pointer will break strict-aliasing rules
    *(uint64_t *) (&ctx->wbuffer[128 - 16]) = t;

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-06-19 11:49:15 -04:00
Jonathan Liu
b6dc13c2d3 sulogin: allow system maintenance login if root password is empty
The current password checking is unable to distinguish between the user
entering an empty password or pressing Control-D. As a result, an empty
password always results in normal startup.

We modify bb_ask to return NULL if Control-D is pressed without entering
a password. The sulogin applet is then modified to only proceed to
normal startup if bb_ask returns NULL. This covers EOF with no password,
interrupt by timeout and ^C.

Signed-off-by: Jonathan Liu <net147@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-05-21 17:01:55 +02:00
Flemming Madsen
d96ffda62e ash,hush: history builtin
function                                             old     new   delta
show_history                                           -      39     +39
builtin_history                                        -      16     +16
historycmd                                             -      13     +13
bltins1                                              312     324     +12
builtintab                                           336     344      +8
popstring                                            134     140      +6
hush_main                                           1048    1046      -2
ash_main                                            1398    1396      -2
size_from_HISTFILESIZE                                44      40      -4
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 3/3 up/down: 94/-8)              Total: 86 bytes

Signed-off-by: Flemming Madsen <busybox@themadsens.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-04-07 18:47:24 +02:00
Denys Vlasenko
8172d054db lineedit: \W on "/bin" should show "bin", not "/bin"
function                                             old     new   delta
parse_and_put_prompt                                 793     785      -8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-29 13:21:53 +01:00
Denys Vlasenko
1d14569a66 lineedit: implement \T \t \A \@ prompts escapes, fix \W escape, drop \!
function                                             old     new   delta
parse_and_put_prompt                                 742     793     +51
read_line_input                                     3836    3826     -10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-29 13:10:23 +01:00
Denys Vlasenko
8f2cb7ab26 libbb: introduce and use strftime_[YYYYMMDD]HHMMSS()
function                                             old     new   delta
strftime_fmt                                           -      53     +53
strftime_YYYYMMDDHHMMSS                                -      12     +12
strftime_HHMMSS                                        -      12     +12
human_time                                            44      43      -1
fmtstr_t                                               9       -      -9
step_time                                            361     345     -16
watch_main                                           261     232     -29
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 0/3 up/down: 77/-55)             Total: 22 bytes
   text	   data	    bss	    dec	    hex	filename
 919203	    932	  17692	 937827	  e4f63	busybox_old
 919209	    932	  17692	 937833	  e4f69	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-29 12:30:33 +01:00
Denys Vlasenko
6c852bfcad lineedit: add handling of \H in prompt
Based on the patch by Arnaud Rébillout <rebillout@syscom.ch>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-28 13:20:12 +01:00
Denys Vlasenko
ef6747e290 hexdump: don't unconditionally limit the usable address range
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-27 15:15:33 +01:00
Mike Frysinger
af9e70b8cb readlink: uClibc supports automatic allocation too now
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-03-12 11:14:24 -04:00
Denys Vlasenko
efd0698f74 make --help return exitcode 0. Closes 5612
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-28 12:34:18 +01:00
Shawn J. Goff
46031da862 lineedit: initialize delptr
In vi mode, the 'p' and 'P' commands caused a segfault when nothing had
been put in the buffer yet because the delptr was not initialized.

Signed-off-by: Shawn J. Goff <shawn7400@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-27 18:30:05 +01:00
Denys Vlasenko
1961aea305 move endofname() to libbb
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-26 00:36:53 +01:00
Denys Vlasenko
272d85cc85 vasprintf: return -1 on strdup failure
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-10 23:03:38 +01:00
Denys Vlasenko
b5fc51198b vasprintf: do not use xmalloc, it will deadlock on OOM
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-07 16:06:54 +01:00
Denys Vlasenko
2cfcc9e9d7 sha3: code shrink
function                                             old     new   delta
sha3_hash                                            155     101     -54

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-20 00:38:09 +01:00
Denys Vlasenko
5d78355d5a code shrink
function                                             old     new   delta
applet_name_compare                                   36      31      -5
find_applet_by_name                                   43      25     -18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-17 11:02:43 +01:00
Denys Vlasenko
e4f0f26bad sha3: s/sha3_process_block76/sha3_process_block72/
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-16 12:23:23 +01:00
Denys Vlasenko
5368fe541c sha3: rename KeccakF->sha3_process_block76.
This brings the naming more in line with other hashes.
Pulled most statics and constants into it.
Also noticed that two byte arrays are 1 element too big.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-16 02:20:31 +01:00
Denys Vlasenko
970aa6b5bd sha3: cache ctx->bytes_queued
function                                             old     new   delta
sha3_hash                                            171     155     -16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 22:19:24 +01:00
Denys Vlasenko
8fb3ab528e sha3: remove two "small code" codepaths: I can't reproduce code size win on them anymore
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 22:07:48 +01:00
Denys Vlasenko
8e7312e12f sha3: tweak choice of a fast code path for 64-bit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 21:50:41 +01:00
Denys Vlasenko
5b7f50f372 sha3: cosmetic tweaks to various names, comments. No logic changes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 19:52:30 +01:00
Denys Vlasenko
ac4100e103 sha3: code shrink
function                                             old     new   delta
KeccakF                                             1053    1078     +25
KeccakF_RoundConstants                               192      48    -144

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 16:27:39 +01:00
Denys Vlasenko
a55df27936 sha3: code shrink
function                                             old     new   delta
KeccakF                                             1064    1053     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 15:22:30 +01:00
Denys Vlasenko
07a54e21dd sha3: another speedup for SHA3_SMALL=0 case
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 14:47:05 +01:00
Denys Vlasenko
6830ade6aa whitespace fixes. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 13:58:01 +01:00
Denys Vlasenko
30a8652fbf sha3: make size/speed optimization decision configurable
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 01:12:26 +01:00
Denys Vlasenko
60cb48ca50 whitespace cleanup. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 15:57:44 +01:00
Lauri Kasanen
b8173b603f sha3sum: new applet
function                                             old     new   delta
KeccakF                                                -     496    +496
KeccakF_RoundConstants                                 -     192    +192
sha3_hash                                              -     171    +171
sha3_end                                               -      40     +40
hash_file                                            274     299     +25
KeccakF_RotationConstants                              -      25     +25
KeccakF_PiLane                                         -      25     +25
packed_usage                                       29213   29232     +19
sha3_begin                                             -      18     +18
KeccakF_Mod5                                           -      10     +10
applet_names                                        2445    2453      +8
applet_main                                         1420    1424      +4
applet_nameofs                                       710     712      +2
------------------------------------------------------------------------------
(add/remove: 8/0 grow/shrink: 9/7 up/down: 1049/-54)         Total: ~995 bytes

Signed-off-by: Lauri Kasanen <curaga@operamail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 05:20:50 +01:00
Denys Vlasenko
fd77ea505e mark get_shell_name FAST_FUNC
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-10-03 09:42:21 +02:00
Denys Vlasenko
32711c4141 top/ps: argv0:"gdm-session-worker [pam/gdm-password]" == comm:"gdm-session-wor"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-10-02 11:31:37 +02:00
Denys Vlasenko
b2320370be lineedit: in !EDITING config, return -1 on fgets error
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-27 16:03:49 +02:00
Denys Vlasenko
c4f2d997a4 libbb: correctness/size tweaks in signal-related helpers
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-27 13:20:34 +02:00
Denys Vlasenko
50157f3dec top: fix "last CPU" parsing
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-06 12:43:22 +02:00
walter harms
d1d794fd48 refactor correct_password.c to avoid one if
Signed-off-by: walter harms <wharms@bfs.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-04 12:26:20 +02:00
Cliff Frey
4919565c15 lineedit: fix Alt-D when cursor==0
Signed-off-by: Cliff Frey <cliff@meraki.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-08-07 17:59:40 +02:00
Bradley M. Kuhn
0e941d5427 Simplify copyright/license notice that appears in the binary.
Existing copyright notice for binary would need to be longer to achieve
optimal accuracy.  This compromise punts to the source for full notices,
but does note the years of the copyrights and that there are many authors,
all licensing under GPLv2.

Signed-off-by: Bradley M. Kuhn <bkuhn@ebb.org>
Signed-off-by: Tony Sebro <tony@sfconservancy.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-26 13:17:06 +02:00
Pascal Bellard
70fc8c17e2 su: do not change to home dir unless -l
Signed-off-by: Pascal Bellard <pascal.bellard@ads-lu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-12 13:21:02 +02:00
Denys Vlasenko
0ccae4d8b3 Add comments in keyboard escape sequences table
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-11 14:40:17 +02:00
Tias Guns
c9677ed83c libbb: add missing_syscalls.c: for now, only Android syscalls
Signed-off-by: Tias Guns <tias@ulyssis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-10 14:40:30 +02:00
Natanael Copa
02112d8ae3 unzip: ignore chmod errors
This makes unzip to FAT filesystems not exit with error.
This is similar to how the "normal" unzip works.

Signed-off-by: Natanael Copa <natanael.copa@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-28 01:29:15 +02:00
Denys Vlasenko
02b8b9b014 busybox: tweak help text and copyright year
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-14 23:52:57 +02:00
Simon B
44642d1ec1 ln: support -T and -v
function                                             old     new   delta
ln_main                                              445     524     +79
packed_usage                                       29182   29179      -3

Signed-off-by: Simon B <sburnet@hotmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-06 13:18:35 +02:00
Andreas Oberritter
556ac3633c get_linux_version_code: don't fail on Linux version strints like "3.0-foo"
Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-05 17:47:23 +02:00
Ron Yorston
576b1d3c41 sendmail: use host rather than NIS domain name for HELO
According to RFC 5321 the argument to HELO "contains the fully-qualified
domain name of the SMTP client" or its IP address if no FQDN is available.
BusyBox sendmail uses the NIS domain name instead which, in many cases,
is likely to be the default "(none)". [vda: yes, I checked my machine
and its uts.domainname was indeed "(none)"]

Using the host name is more likely to satisfy the intent of the RFC while
allowing the otherwise unused safe_getdomainname function to be removed.

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-28 17:04:19 +02:00
Dennis Groenen
deee356a62 lineedit: histfile can get emptied when CONFIG_FEATURE_EDITING_SAVE_ON_EXIT=y
When CONFIG_FEATURE_EDITING_SAVE_ON_EXIT is set to y, the histfile
will get cleared if the total amount of history lines is less than MAX_HISTORY.
Only if the histfile is not empty _and_ the amount of lines currently
in memory are equal to or greater than MAX_HISTORY, history saving will
work as expected with this feature enabled.

Output from defconfig + CONFIG_FEATURE_EDITING_SAVE_ON_EXIT=y:
$ echo "foo" > ~/.ash_history
$ ./busybox ash
~/busybox/a $ echo "bar" > /dev/null
~/busybox/a $ exit
$ cat ~/.ash_history
$

Output with the patch applied and same config as above:
$ echo "foo" > ~/.ash_history
$ ./busybox ash
~/busybox/b $ echo "bar" > /dev/null
~/busybox/b $ exit
$ cat ~/.ash_history
foo
echo "bar" > /dev/null
exit
$

Signed-off-by: Dennis Groenen <tj.groenen at gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-26 11:19:38 +02:00
Denys Vlasenko
56443cdbdd whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-20 15:07:22 +02:00
Denys Vlasenko
8cab66730a fix build breakage found by randconfig
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-20 14:48:00 +02:00
Denys Vlasenko
ba88826c66 busybox: tweak help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-22 11:15:06 +01:00
Denys Vlasenko
0687a5b496 libbb: make xchroot do a chdir("/") after chroot
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-08 00:28:24 +01:00
Denys Vlasenko
59655077c5 preparatory cleanups for seamless uncompression improvements
unpack_gz_stream_with_info: fix buggy error check
man: fix possible accesses past the end of a string
move seamless uncompression helpers from read_printf.c to open_transformer.c

function                                             old     new   delta
show_manpage                                         153     212     +59
unpack_gz_stream_with_info                           520     539     +19

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-06 16:23:50 +01:00
Denys Vlasenko
62c006d508 libbb/procps.c: make fast_strtoul_10() stop on '\n' too
This time for real :)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-02-28 11:16:21 +01:00
Denys Vlasenko
0b170e6a09 libbb/procps.c: make fast_strtoul_10() stop on '\n' too
This is needed for parsing /proc data on linux 2.4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-02-28 03:36:49 +01:00
Jonh Wendell
9106107a50 Make unix (local) sockets work without IPv6 enabled
The xsocket_type() function had an optional "family" argument
that was enabled only if IPv6 is enabled. In the case of the
function was called with a valid AF_UNIX argument, and IPv6 is
disabled, this argument was silently ignored.

This patch makes the "family" argument mandatory, while keeping
the old behavior i.e., if AF_UNSPEC is passed, we try first IPv6
(if it's enabled) and fallback to IPv4.

Also I changed all callers of xsocket_type() to reflect its new
interface.

Signed-off-by: Jonh Wendell <jonh.wendell@vexcorp.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-02-09 15:14:33 +01:00
Denys Vlasenko
9ec3cd400a tweak comment, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-02-02 11:29:43 +01:00
Javier Viguera
ce4f39ac7c find_mount_point: fix find_mount_point for char devices
This allows to find mount points of 'char' devices such as UBI volumes
which otherwise fail for example with 'df' command:

/ # df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root             72091984  12360980  56068924  18% /
devtmpfs                115236         4    115232   0% /dev
tmpfs                    28672        32     28640   0% /tmp
/dev/ubi0_0             360268     18348    341920   5% /tmp/mnt/userfs

/ # df /dev/ubi0_0
Filesystem           1K-blocks      Used Available Use% Mounted on
devtmpfs                115236         4    115232   0% /dev

Signed-off-by: Javier Viguera <javier.viguera@digi.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-18 01:49:11 +01:00
Denys Vlasenko
7ce209b9d4 shell_builtin_read: set cc[VMIN] to 1; lineedit: don't clear c_cc[VINTR]
First change fixes "read -n NUM". Apparently poll() won't report
data availability if cc[VMIN] > 1 until there are at least cc[VMIN] bytes.

function                                             old     new   delta
read_line_input                                     3885    3877      -8
shell_builtin_read                                  1097    1087     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-18)             Total: -18 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-15 22:58:06 +01:00
Denys Vlasenko
499597d6ef mdev: do not treat non-leading '#' chars as start of comment. Closes 4676
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-11 00:37:17 +01:00
Denys Vlasenko
ba65872950 libbb/bb_strtonum: always set end ptr, even on error return
function                                             old     new   delta
handle_errors                                         69      61      -8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-12-22 13:00:32 +01:00
Denys Vlasenko
f282c6b657 libbb: remove is_directory's argument which is always NULL
function                                             old     new   delta
send_cgi_and_exit                                    892     890      -2
ln_main                                              447     445      -2
handle_incoming_and_exit                            2784    2780      -4
is_directory                                          66      59      -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/6 up/down: 2/-19)             Total: -15 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-12-18 03:27:46 +01:00
Denys Vlasenko
a0bef7cc27 hexdump: fix hexdump -n1 -ve '8/2 ""' SEGV. Closes 4478
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-18 02:47:35 +01:00
Peter Korsgaard
743edac6c8 bb_daemonize_or_rexec(): add flag to double-fork; use it in start-stop-daemon
Add a DAEMON_DOUBLE_FORK flag to make bb_daemonize double-fork so it isn't a
session leader, and hence doesn't get a controlling tty on Linux if a tty is
ever opened, similar to how libdaemon's daemon_fork or the big
start-stop-daemon does it - And use it in start-stop-daemon.

For details, see http://www.win.tue.nl/~aeb/linux/lk/lk-10.html#ss10.3

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-09 19:44:37 +01:00
Denys Vlasenko
c0cae52662 lineedit: fix build failure
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-04 01:09:09 +01:00
Denys Vlasenko
9ce09bc9cb lineedit: add support for M-b, M-f, M-d, M-Backspace
function                                             old     new   delta
ctrl_left                                              -      96     +96
ctrl_right                                             -      76     +76
static.esccmds                                        81      93     +12
read_line_input                                     3876    3885      +9
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/0 up/down: 193/0)             Total: 193 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-03 13:28:22 +01:00
Denys Vlasenko
e6094d95b5 libbb: shrink base64 decoding a bit
function                                             old     new   delta
bb_uuenc_tbl_base64                                   67      66      -1
decode_base64                                        182     161     -21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-28 16:15:00 +02:00
Denys Vlasenko
73d249e704 whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-28 14:07:44 +02:00
Leonid Lisovskiy
328f27fe44 libbb: split decode_base64 off read_base64
function                                             old     new   delta
decode_base64                                          -     182    +182
read_base64                                          378     255    -123
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 182/-123)           Total: 59 bytes

Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-28 13:59:55 +02:00
Denys Vlasenko
ec447c7f01 libbb.h: remove unused defines
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-24 04:06:18 +02:00
Denys Vlasenko
7449e18190 getty,login: tighten up handling of ctty, pgrp, and tty attr restoring on timeout
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-22 06:27:41 +02:00
Denys Vlasenko
d184a728cf rename archive.h to bb_archive.h. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-22 12:45:14 +02:00
Bernhard Reutner-Fischer
74b871febb Config: fix wording in help-text
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-09-13 14:59:06 +02:00
Denys Vlasenko
13e709c53f losetup: implement -r option. Closes 4033.
function                                             old     new   delta
packed_usage                                       28595   28633     +38
losetup_main                                         285     290      +5
singlemount                                          906     908      +2
set_loop                                             674     672      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-12 08:30:16 +02:00
Denys Vlasenko
dd1061b6a7 wget: URL-decode user:password before base64-encoding it into auth hdr. Closes 3625.
function                                             old     new   delta
percent_decode_in_place                                -     152    +152
parse_url                                            304     317     +13
handle_incoming_and_exit                            2795    2798      +3
httpd_main                                           763     760      -3
decodeString                                         152       -    -152
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 2/1 up/down: 168/-155)           Total: 13 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-11 21:04:02 +02:00
Denys Vlasenko
522041ee7b regularize options which control size/speed trade
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-10 13:25:57 +02:00
Denys Vlasenko
0d0260fd1e inet_cksum: big-endian fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-08 10:59:26 +02:00
Denys Vlasenko
9289935cfd Fix compile breakage
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-07 22:19:46 +02:00
Baruch Siach
e8f36330d9 networking: consolidate the IP checksum code. -129 bytes.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-07 17:55:40 +02:00
Denys Vlasenko
e45af7ad17 lineedit: remove SAVE_HISTORY bit, ->hist_file can be used as indicator
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-04 16:15:24 +02:00
Denys Vlasenko
bede215cf1 lineedit: add support for history saving on exit
Based on the patch by Dennis Groenen <tj.groenen@gmail.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-04 16:12:33 +02:00
Denys Vlasenko
4840ae8a06 lineedit: fix atomic replace of history file; hush: fix $HISTFILE handling
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-04 15:28:03 +02:00
Denys Vlasenko
2390109dcb top: fix CPU% for thread display. Closes 4081
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-28 11:57:36 +02:00
Denys Vlasenko
24915117a2 Fixes for warnings in FreeBSD build
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-28 05:31:49 +02:00
Matthias Andree
1285437217 Fixes for FreeBSD build
Signed-off-by: Matthias Andree <mandree@freebsd.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-28 05:05:02 +02:00
Denys Vlasenko
d84b175cb6 Bump version to 1.19.0, update copyright year in help message
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-13 08:46:00 +02:00
Denys Vlasenko
b47b3ce1bd randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-10 00:51:29 +02:00
Denys Vlasenko
7485086f1e die_if_bad_username: tighten up a bit
function                                             old     new   delta
die_if_bad_username                                   77      97     +20

Based on patches from Tito.
The changes are:
better comments
we disallow '@' now - in practice such usernames will be unusable
use of the portable filename character set plus '$'
don't use isalnum as it allows non-ASCII letters in legacy 8-bit locales (pointed out by Rich Felker)
enforce maximum length of LOGIN_NAME_MAX (including NUL)
don't allow '$', '.', and '-' as first char
don't print the illegal char in error message as if it is a wide char it will be unreadable
print the position of the illegal character

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-09 04:05:13 +02:00
Denys Vlasenko
4e552a70ec less: optionally query terminal size via "ESC [ 6 n". Closes bug 2659.
+7 bytes is not selected, +100 if selected.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-07-25 15:18:20 +02:00
Denys Vlasenko
a669eca3a2 libbb/lineedit: implement optional Ctrl-R history search
function                                             old     new   delta
read_line_input                                     3433    3957    +524
load_string                                           77      90     +13
input_tab                                           1086    1069     -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 537/-17)           Total: 520 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-07-11 07:36:59 +02:00
Denys Vlasenko
8f6ce094dc a few tweaks for bionic
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-07-08 08:34:28 +02:00
Denys Vlasenko
4dc35fb5b6 platform.h: tweaks for cygwin
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-07-08 04:41:38 +02:00
Timo Teras
0a5b310067 platform.c: provide getline implementation
Signed-off-by: Timo Teras <timo.teras@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-29 02:19:58 +02:00
Timo Teras
adcabf3235 parse_config: use getline. BIG speedup with glibc (~40%).
function                                             old     new   delta
config_read                                          559     604     +45
getline                                                -      23     +23
config_close                                          29      49     +20
find_pair                                            169     187     +18
showmode                                             330     338      +8
hash_find                                            233     234      +1
builtin_umask                                        133     132      -1
lzo1x_optimize                                      1434    1429      -5
test_main                                            253     247      -6
buffer_fill_and_print                                196     179     -17
create_J                                            1849    1826     -23
config_free_data                                      37       -     -37
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 5/5 up/down: 138/-89)            Total: 26 bytes

Signed-off-by: Timo Teras <timo.teras@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-20 09:49:56 +02:00
Denys Vlasenko
5331e382f7 libbb/read_cmdline: prepend {comm} if different from argv0. Closes 3835.
function                                             old     new   delta
read_cmdline                                         114     233    +119

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-18 15:51:16 +02:00
Denys Vlasenko
12ac6287ee procps: remove PSSCAN_STAT define, users were using it incorrectly
Also contains small cleanups ps.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-18 15:49:47 +02:00
Denys Vlasenko
3a649363aa parse_config: make test applet easier to enable; fix its code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-18 09:23:09 +02:00
Denys Vlasenko
a1a448347e libbb: split bb_get_chunk_from_file and bb_get_chunk_with_continuation
This also moves bb_get_chunk_with_continuation into its sole user,
parse_config.c.
This allows to optimize both functions separately,
they need to be optimized for speed.
(this need was highlighted by slow modprobe caused in part by slow
bb_get_chunk_with_continuation in config parser).

function                                             old     new   delta
bb_get_chunk_from_file                                 7     130    +123
config_read                                          457     558    +101
bb_get_chunk_with_continuation                       194       -    -194
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 2/0 up/down: 224/-194)           Total: 30 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-17 03:37:43 +02:00
Denys Vlasenko
fe86d6b636 appletlib.c: do not use PAGE_SIZE for malloc tweaking
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-03 21:39:42 +02:00
Dan Fandrich
2f5769151f only compile obscure.c when needed
Signed-off-by: Dan Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-03 20:28:14 +02:00
Denys Vlasenko
488dd70869 fix !ENABLE_FEATURE_GETOPT_LONG build. Closes 3775
When compiling with !ENABLE_FEATURE_GETOPT_LONG, busybox still tries
to include getopt.h which is not available; for example with uClibc
when !UCLIBC_HAS_GETOPT_LONG.  getopt.h is only required
for the _long set of functions.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-29 04:24:52 +02:00
Denys Vlasenko
b24ef035bd find: cater for libc w/o FNM_CASEFOLD
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-23 00:40:54 +02:00
Alexey Fomenko
232ebaa568 lineedit: fix rare SEGV; mark a few FIXMEs
Signed-off-by: Alexey Fomenko <ext-alexey.fomenko@nokia.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-20 04:26:29 +02:00
Cristian Ionescu-Idbohrn
ea137aa931 warning removal
Signed-off-by: Cristian Ionescu-Idbohrn <cii@axis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-20 03:52:36 +02:00
Denys Vlasenko
351fec332a busybox.conf: code shrink
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-16 14:30:26 +02:00
Denys Vlasenko
d83aff1aed busybox.conf: USER.GROUP is _optional_
function                                             old     new   delta
main                                                 785     809     +24

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-16 13:53:19 +02:00
Denys Vlasenko
3770b6b061 main: make busybox.conf mode handling less obscure
function                                             old     new   delta
static.mode_mask                                       -      20     +20
main                                                 782     785      +3
static.mode_chars                                     15      13      -2
run_applet_no_and_exit                               450     441      -9
mode_mask                                             24       -     -24
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 1/2 up/down: 41/-53)            Total: -12 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-16 13:19:25 +02:00
Denys Vlasenko
9be4702a30 main: free suid_config list after use
function                                             old     new   delta
run_applet_no_and_exit                               438     450     +12
ifupdown_main                                       2147    2149      +2
writeFileToTarball                                  1325    1326      +1
pidof_main                                           244     245      +1
last_main                                            896     897      +1
grep_main                                            779     780      +1
find_list_entry2                                     121     122      +1
tar_main                                             835     833      -2
llist_unlink                                          28      26      -2
llist_rev                                             23      21      -2
main                                                 791     782      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/4 up/down: 19/-15)              Total: 4 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-16 12:21:31 +02:00
Denys Vlasenko
4566e172eb simplify parsing of /etc/busybox.conf
function                                             old     new   delta
parse_config_file                                    799     667    -132

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-16 00:01:08 +02:00
Denys Vlasenko
60a9414cad fix "variable 'foo' set but not used" warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-13 20:57:01 +02:00
Denys Vlasenko
12a432715f adduser: safe username passing to passwd/addgroup
passwd: support creating SHA passwords
random code shrink

function                                             old     new   delta
crypt_make_pw_salt                                     -      87     +87
adduser_main                                         883     904     +21
...
crypt_make_salt                                       99      89     -10
chpasswd_main                                        329     312     -17
packed_usage                                       28731   28691     -40
passwd_main                                         1070    1000     -70
cryptpw_main                                         310     224     -86
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/12 up/down: 154/-288)        Total: -134 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-13 03:19:01 +02:00
Denys Vlasenko
80542bad2f hush: make read builtin interruptible.
function                                             old     new   delta
builtin_read                                         185     471    +286
check_and_run_traps                                  200     262     +62
nonblock_immune_read                                  73     119     +46
sigismember                                            -      44     +44
record_signal                                          -      21     +21
sigisemptyset                                          -      16     +16
...
------------------------------------------------------------------------------
(add/remove: 5/0 grow/shrink: 7/5 up/down: 483/-46)           Total: 437 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-08 21:23:43 +02:00
Denys Vlasenko
80c5b6893d libbb: nonblock_safe_read->nonblock_immune_read, remove unused param of xmalloc_reads
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-08 21:21:10 +02:00
Denys Vlasenko
47061b4e9b straighten out dprintf/fdprintf mess; remove old "define lchown chown"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-17 23:14:19 +02:00
Denys Vlasenko
0288b27ad8 small fixes atop syslog config patch
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-16 20:15:14 +02:00
Marek Polacek
b0b8884009 Fix double words in comments. No code changes
Signed-off-by: Marek Polacek <mpolacek@redhat.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-16 17:33:43 +02:00