aboutsummaryrefslogtreecommitdiff
path: root/libbb (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* getopt32: remove applet_long_optionsDenys Vlasenko2017-08-082-34/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* libbb: simplify NOFORK/NOEXEC defines, move set_task_comm to libbbDenys Vlasenko2017-08-082-25/+24
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: rearrange NOFORK/NOEXEC code, logic is not changedDenys Vlasenko2017-08-081-56/+69
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* noexec: consolidate codeDenys Vlasenko2017-08-072-18/+21
| | | | | | | | | | | | | 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>
* noexec: do GETOPT_RESET() before entering APPLET_main()Denys Vlasenko2017-08-071-0/+1
| | | | | | | | | | 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>
* noexec: set comm field for noexecsDenys Vlasenko2017-08-072-5/+15
| | | | | | | | | | | | 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>
* free,stat: make NOEXECDenys Vlasenko2017-08-071-0/+2
| | | | | | pkill/pgrep/pidof uncovered another quirk: what about noexec's _process names_? Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ubi tools: ubiupdatevol supports "-" input and actually respects -s SIZEDenys Vlasenko2017-08-071-0/+1
| | | | | | | | | | | | | | | | | | 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>
* slattach: code shrink, better --help textDenys Vlasenko2017-08-061-1/+1
| | | | | | | | | | | | | | 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>
* kbd_mode: try harder to find console device if -C TTY is not givenDenys Vlasenko2017-08-061-1/+0
| | | | | | | | | | | | | | | | | | | | 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>
* sysctl: recognize ";comment" and "<whitespace>#comment" linesDenys Vlasenko2017-08-051-2/+10
| | | | | | | function old new delta config_read 639 699 +60 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: make trim() return pointer to terminating NULDenys Vlasenko2017-08-051-2/+10
| | | | | | | | | | | 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>
* sysctl: fix file parsing, do not require -w for VAR=VALDenys Vlasenko2017-08-051-5/+5
| | | | | | | | | | | | | 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>
* libbb: use _exit, not exit, in bb_daemonize_or_rexec()Denys Vlasenko2017-08-041-2/+8
| | | | | | | | | 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>
* getopt32: move support for "always treat first arg as option" to users (tar/ar)Denys Vlasenko2017-08-041-33/+3
| | | | | | | | | | | | | 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>
* getopt32: factor out code to treat all args as optionsDenys Vlasenko2017-08-043-26/+33
| | | | | | | | | | | | | 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>
* nofork: fix a bug uncovered by hush testsuite (forgotten fflush)Denys Vlasenko2017-08-031-0/+2
| | | | | | | function old new delta run_nofork_applet 280 287 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* new NOFORKs: pwdx,kill[all5],ttysize,realpath,readlink NOEXECs: date,resizeDenys Vlasenko2017-08-032-3/+6
| | | | | | | | | | 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>
* line editing: make read_line_input() not take timeout paramDenys Vlasenko2017-08-021-7/+16
| | | | | | | | | | | | | | | | | | 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>
* do not use `a' quoting style in commentsDenys Vlasenko2017-08-027-7/+7
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: remove vdprintfRon Yorston2017-07-292-22/+0
| | | | | | | | | | | 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>
* standalone shell / prefer_applets: fix "exe" in comm fieldsDenys Vlasenko2017-07-291-0/+18
| | | | | | | function old new delta main 92 106 +14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: make standalone shell tab-complete "busybox"Denys Vlasenko2017-07-292-6/+21
| | | | | | | | | | | | | | 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>
* config: trim/improve item names and help texts.Denys Vlasenko2017-07-271-3/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: allow "trap NUM [SIG]..." syntaxDenys Vlasenko2017-07-251-1/+1
| | | | | | | | | | | | | 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>
* libbb: avoid malloc/free in bb_unsetenv()Denys Vlasenko2017-07-221-13/+21
| | | | | | | function old new delta bb_unsetenv 55 83 +28 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* config: deindent all help textsDenys Vlasenko2017-07-214-169/+169
| | | | | | Those two spaces after tab have no effect, and always a nuisance when editing. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* config: merge "Busybox Settings" and "Busybox Library Tuning" into one menuDenys Vlasenko2017-07-152-6/+8
| | | | | | Tweak a few help texts while at it Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* copyfd: guard use of munmap() with #if (windows builds need this)Johannes Schindelin2017-07-151-0/+3
| | | | | Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: hide getnetbyaddr() inside "#if ENABLE_FEATURE_ETC_NETWORKS" blockDenys Vlasenko2017-07-141-27/+19
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* xxd: allow "-" as file name meaning stdinDenys Vlasenko2017-07-141-4/+6
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/dump: allow skipping over stdin tooDenys Vlasenko2017-07-141-20/+13
| | | | | | | function old new delta next 294 265 -29 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/dump: fix a few broken commits and shrink codeDenys Vlasenko2017-07-141-10/+10
| | | | | | | function old new delta next 310 294 -16 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: safe_write should not return EINTRDenys Vlasenko2017-07-141-2/+10
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* cat: fix "cat -An" ignoring -n; make numbering go througn all filesDenys Vlasenko2017-07-141-0/+1
| | | | | | | function old new delta cat_main 418 428 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: do not die if setgid/setuid(real_id) on startup failsDenys Vlasenko2017-07-101-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* main: fix the case where user has "halt" as login shell. Closes 9986Denys Vlasenko2017-07-072-4/+8
| | | | | | | | | | 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>
* libbb: new function bb_getgroups() - allocating wrapper around getgroups()Denys Vlasenko2017-07-041-0/+47
| | | | | | | | | | 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>
* Change BB_EXTRA_VERSION: now it needs to contain any spaces/parenthesisDenys Vlasenko2017-07-041-4/+2
| | | | | | | | | | | | | | 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>
* fixes for bugs found by make_single_applets.shDenys Vlasenko2017-07-033-8/+19
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Spelling fixes in comments, documentation, tests and examplesDenys Vlasenko2017-04-171-1/+1
| | | | | | By klemens <ka7@github.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: fix "error: redefinition of 'is_tty_secure'"Denys Vlasenko2017-04-131-0/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: make check_password() also return CHECKPASS_PW_HAS_EMPTY_PASSWORDDenys Vlasenko2017-04-132-4/+6
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* su: FEATURE_SU_BLANK_PW_NEEDS_SECURE_TTYDenys Vlasenko2017-04-131-2/+2
| | | | | | | | | | | 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>
* login: move check_securetty to libbbKaarle Ritvanen2017-04-132-0/+23
| | | | | Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: GETOPT_RESET macroKaarle Ritvanen2017-04-122-33/+3
| | | | | Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* fix errors found with make_single_applets.shDenys Vlasenko2017-04-122-0/+62
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: move isqrt from factor, use it in diff tooDenys Vlasenko2017-04-111-0/+60
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* modprobe: do not descend into /etc/modprobe.d/DIR/. Closes 8686Denys Vlasenko2017-04-061-17/+29
| | | | | | Also expanded comments in recursive_action.c Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* mount: create loop devices with LO_FLAGS_AUTOCLEAR flagDenys Vlasenko2017-03-161-16/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>