aboutsummaryrefslogtreecommitdiff
path: root/libbb/appletlib.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
| * ash: allow shell scripts to be embedded in the binaryDenys Vlasenko2018-11-011-1/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To assist in the deployment of shell scripts it may be convenient to embed them in the BusyBox binary. 'Embed scripts in the binary' takes any files in the directory 'embed', concatenates them with null separators, compresses them and embeds them in the binary. When scripts are embedded in the binary, scripts can be run as 'busybox SCRIPT [ARGS]' or by usual (sym)link mechanism. embed/nologin is provided as an example. function old new delta packed_scripts - 123 +123 unpack_scripts - 87 +87 ash_main 1103 1171 +68 run_applet_and_exit 78 128 +50 get_script_content - 32 +32 script_names - 10 +10 expmeta 663 659 -4 ------------------------------------------------------------------------------ (add/remove: 4/0 grow/shrink: 2/1 up/down: 370/-4) Total: 366 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | libbb: add missing define that breaks non-default buildsRon Yorston2018-10-261-0/+2
| |
* | Merge branch 'busybox'Ron Yorston2018-07-251-3/+6
|\|
| * whitespace fixesDenys Vlasenko2018-07-171-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * usage: do not print trailing space for commands which have no argumentsDenys Vlasenko2018-07-091-2/+5
| | | | | | | | | | | | | | function old new delta bb_show_usage 120 130 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Update copyright dateRon Yorston2018-05-131-1/+1
| |
* | Merge branch 'busybox' into mergeRon Yorston2018-04-091-5/+12
|\|
| * bzip2: fix two crashes on corrupted archivesDenys Vlasenko2018-04-081-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As it turns out, longjmp'ing into freed stack is not healthy... function old new delta unpack_usage_messages - 97 +97 unpack_bz2_stream 369 409 +40 get_next_block 1667 1677 +10 get_bits 156 155 -1 start_bunzip 212 183 -29 bb_show_usage 181 120 -61 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/3 up/down: 147/-91) Total: 56 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: more backslash to slash conversionsRon Yorston2018-04-081-1/+2
| | | | | | | | | | | | | | | | | | Convert backslashes to slashes: - in the main program's argv[0] - in the shell's file argument Also, fix the code to remove the .exe extension from argv[0] in the main program.
* | ps: obtain applet names from other BusyBox processesRon Yorston2018-04-041-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the code which passed applet names to child processes using environment variables. This only allowed ps to display names for its ancestors. Instead attempt to read applet names from the memory of unrelated processes. The Microsoft documentation alone wasn't enough to figure out how to do this. Additional hints from: https://stackoverflow.com/questions/4298331/exe-or-dll-image-base-address https://stackoverflow.com/questions/14467229/get-base-address-of-process
* | ash: reinstate applet name variable after forkshellRon Yorston2018-04-031-6/+8
| | | | | | | | | | | | When 'sh --forkshell' is invoked the BB_APPLET_<pid> environment variable is set, but then it's cleared when the environment of the child process is restored. Reinstate it in reinitvar.
* | libbb: improve stripping of extension from argv[0]Ron Yorston2018-03-311-15/+11
| | | | | | | | | | | | | | | | | | | | Use library routines to reduce the amount of code needed to strip the extension from argv[0] in the BusyBox main function. The name of the executable can now have any of the standard extensions, none at all, or a trailing dot. Related to GitHub issue #20.
* | busybox: let --list-full display nofork/noexec appletsRon Yorston2018-03-291-6/+22
| | | | | | | | | | | | The --list-full option to busybox-w32 was disabled because it didn't make sense to display Unix install paths. Repurpose this option to display whether applets are NOFORK or NOEXEC.
* | win32: save a few bytesRon Yorston2018-03-291-2/+3
| | | | | | | | | | | | | | | | In the recently-added code to pass applet names to child processes use local arrays to build the environment variables rather that allocating them every time. mingw_spawn can call mingw_spawn_proc instead of mingw_spawn_1.
* | ps: display applet names in process listingRon Yorston2018-03-281-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In standalone shell mode all busybox-w32 applets are displayed as 'busybox.exe' in a process listing. I haven't found a satisfactory way to query a running instance of busybox-w32 to determine which applet it's running. Handle a couple of cases: - the process running the process scan knows its own PID and knows which applet it is; - just before invoking applet_main set an environment variable whose name contains the PID and whose value is the current applet name. Children running a process scan will inherit their parent's environment and can therefore match the parent's PID to its applet name.
* | libbb: ensure build details are only stored onceRon Yorston2018-02-261-1/+1
| | | | | | | | | | Determine the size of the MINGW_VER string at compile time so it's only stored once.
* | Merge branch 'busybox' into mergeRon Yorston2017-11-031-1/+0
|\|
| * whitespace and comment format fixes, no code changesDenys Vlasenko2017-10-051-1/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Revert "ash: allow long-running nofork applets to be interrupted"Ron Yorston2017-08-221-16/+0
| | | | | | | | | | | | | | This reverts commit f5051d07f196a8ff7aeaae762333d5aa2b824088. Upstream made 'yes' and 'seq' NOEXEC rather than NOFORK which also solves the problem, though NOEXEC doesn't provide any gain in busybox-w32.
* | Merge branch 'busybox' into mergeRon Yorston2017-08-221-13/+2
|\|
| * libbb: simplify NOFORK/NOEXEC defines, move set_task_comm to libbbDenys Vlasenko2017-08-081-16/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * noexec: consolidate codeDenys Vlasenko2017-08-071-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | 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: set comm field for noexecsDenys Vlasenko2017-08-071-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | ash: allow long-running nofork applets to be interruptedRon Yorston2017-08-011-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | Nofork applets can't be interrupted with ctrl-c. This isn't an issue for most such applets because they do very little and won't run for very long. However 'yes' and 'seq 10000000' can't be interrupted in a interactive shell, which is awkward. As a special case ignore the nofork-ness of these applets if they're run from an interactive shell. This isn't foolproof as there are still ways to run them such that they can't be interrupted, but it helps.
* | libbb: avoid annoying blank line in help messageRon Yorston2017-07-291-2/+2
| | | | | | | | | | | | The abbreviated commit in the version string recently increased to 9 digits thus causing the first line of the help message to exceed 80 characters.
* | Merge branch 'busybox' into mergeRon Yorston2017-07-291-4/+37
|\|
| * 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-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>