aboutsummaryrefslogtreecommitdiff
path: root/libbb/appletlib.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
| * shell: make standalone shell tab-complete "busybox"Denys Vlasenko2017-07-291-4/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | win32: simplify spawning appletsRon Yorston2017-07-211-6/+1
| | | | | | | | | | | | | | The original WIN32 code used the BUSYBOX_APPLET_NAME environment variable to pass the applet name to the spawned process. This was based on the (apparently) mistaken idea that WIN32 would replace argv[0] with the path to the executable.
* | Merge branch 'busybox' into mergeRon Yorston2017-07-181-9/+38
|\|
| * 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-071-3/+7
| | | | | | | | | | | | | | | | | | | | 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>
| * fixes for bugs found by make_single_applets.shDenys Vlasenko2017-07-031-4/+16
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2017-02-081-5/+1
|\|
| * busybox: stop depending on FEATURE_AUTOWIDTH for applet listDenys Vlasenko2017-01-111-5/+1
| | | | | | | | | | | | | | 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>
* | Merge branch 'busybox' into mergeRon Yorston2017-01-081-0/+26
|\|
| * Automatically disable FEATURE_COMPRESS_USAGE for small builds.Denys Vlasenko2017-01-061-0/+26
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2017-01-041-16/+18
|\|
| * appletlib: avoid warning on unused function ingroupCristian Ionescu-Idbohrn2017-01-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * fix breakage found by mass one-applet buildsDenys Vlasenko2016-12-231-16/+16
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2016-11-291-9/+17
|\|
| * Do not print useless empty line after list of appletsDenys Vlasenko2016-11-281-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Fix allnoconfig warningsDenys Vlasenko2016-11-181-8/+16
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch busybox (up to "ash: comment out free(p) just before...")Ron Yorston2016-10-191-1/+11
|\|
| * hush: add commented-out debug printouts in "memleak" built-inDenys Vlasenko2016-10-031-0/+8
| | | | | | | | | | | | | | 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>
| * hush: fix a bug in FEATURE_SH_STANDALONE=y config. Closes 9186Denys Vlasenko2016-08-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'busybox' into mergeRon Yorston2016-07-071-28/+35
|\|
| * build system: fix a few warnings for allnoconfig buildDenys Vlasenko2016-07-051-13/+17
| | | | | | | | | | | | Not that allnoconfig build is useful in any way... Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: suppress warning about run_applet_and_exitRon Yorston2016-07-051-2/+2
| | | | | | | | | | | | | | | | | | | | 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>
| * libbb: move common code into run_applet_and_exitRon Yorston2016-06-191-13/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * Allow "busybox <applet>" to work when busybox is disabledRon Yorston2016-06-181-0/+4
| | | | | | | | | | | | | | | | | | 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>
| * Make busybox an optional appletDenys Vlasenko2016-05-311-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'busybox' into mergeRon Yorston2016-05-161-1/+2
|\|
| * Rewrite iteration through applet names to save a few bytesRon Yorston2016-04-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | mingw: enable busybox --install by defaultRon Yorston2016-04-061-2/+40
| | | | | | | | | | | | | | | | | | | | | | Allow FEATURE_INSTALLER to be configured and enable it in the default configuration. The behaviour is slightly different from upstream BusyBox: symbolic links are not permitted; if no target directory is provided the directory containing the busybox binary is used as the target.
* | Merge branch 'busybox' into mergeRon Yorston2016-04-041-26/+140
|\|
| * find_applet_by_name: loop index should be signedRon Yorston2016-04-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | 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>
| * main(): add a TODO about finding a use for _end[] areaDenys Vlasenko2016-04-031-0/+13
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * typo fixDenys Vlasenko2016-04-021-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * find_applet_by_name: add an example of faster linear search codeDenys Vlasenko2016-04-021-3/+77
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * applet_tables: save space by removing applet name offsetsRon Yorston2016-03-301-28/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'busybox' into mergeRon Yorston2015-10-311-5/+5
|\|
| * busybox: alter help message in standalone shell modeRon Yorston2015-10-301-0/+9
| | | | | | | | | | Signed-off-by: Ron Yorston <rmy@frippery.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: factor out code which queries screen widthDenys Vlasenko2015-10-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'busybox' into mergeRon Yorston2015-10-191-1/+1
|\|
| * libbb: get_uidgid() always called with allow_numeric=1Denys Vlasenko2015-10-191-1/+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>
* | Merge branch 'busybox' into mergeRon Yorston2015-07-141-2/+1
|\|
| * Removes stray empty line from codeManinder Singh2015-07-131-1/+0
| | | | | | | | | | | | | | | | | | 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>
| * Print one less newline at the end of bb_show_usage()Denys Vlasenko2015-05-251-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | libbb: really add build details to bannerRon Yorston2015-06-231-4/+3
| | | | | | | | Look at the environment variable during compilation, not runtime.
* | libbb: add details of build environment to bannerRon Yorston2015-06-231-0/+6
| | | | | | | | | | If the environment variable MINGW_VERSION is set print its contents on a line after the BusyBox version string.
* | busybox: update help messageRon Yorston2015-06-171-4/+9
| | | | | | | | | | Tweak text of help message in standalone shell mode. Add a warning if Windows globbing is enabled.
* | mingw: add magic '--busybox' flagRon Yorston2015-06-011-0/+4
| | | | | | | | | | | | | | | | | | If BusyBox is invoked with argv[1] set to --busybox skip the first two arguments so that argv[2] becomes the applet name and argv[3] et seq are its arguments. This is needed when BusyBox is run as sh.exe and the executable is reexecuted to invoke compress/decompress applets.
* | Enable seamless compression for WIN32Ron Yorston2015-05-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the archival code we pretend that WIN32 is a no-MMU platform and use the new mingw_popen_fd routine to pipe data to/from commands to compress/decompress. The pretence is maintained by redefining MMU macros in bb_archive.h. This is mostly used in the archival code but there are a handful of places where it's used to access public interfaces. The symbol BB_ARCHIVE_PUBLIC is defined in these places. With these changes: tar supports seamless compression/decompression rpm2cpio and dpkg-deb can be enabled
* | Merge branch 'busybox' into mergeFRPRon Yorston2015-05-181-11/+13
|\|
| * special-case {true,false,test} --helpDenys Vlasenko2015-04-211-10/+12
| | | | | | | | | | | | | | | | | | | | 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>
| * update copyright yearsAaro Koskinen2015-04-021-1/+1
| | | | | | | | | | | | | | | | 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>