aboutsummaryrefslogtreecommitdiff
path: root/libbb (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
| * libbb: code shrink in last_char_is()Denys Vlasenko2020-06-301-8/+9
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * compare_string_array: code shrinkMartin Lewis2020-06-291-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Code shrink and prevention of possible out of bounds access. function old new delta nth_string 36 26 -10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-10) Total: -10 bytes text data bss dec hex filename 981342 16915 1872 1000129 f42c1 busybox_old 981332 16915 1872 1000119 f42b7 busybox_unstripped Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * procps: code shrinkMartin Lewis2020-06-291-2/+10
| | | | | | | | | | | | | | | | | | | | | | function old new delta skip_whitespace_if_prefixed_with - 17 +17 procps_read_smaps 911 854 -57 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 17/-57) Total: -40 bytes Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * nologin: make it possible to build it as single appletDenys Vlasenko2020-06-241-5/+33
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * suppress a few compile warningsDenys Vlasenko2020-06-241-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * randomconfig fixesDenys Vlasenko2020-06-231-0/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * xstrndup: Use strndup instead of implementing it.Martin Lewis2020-06-091-14/+5
| | | | | | | | | | Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: avoid duplicated slashes in output of type/command builtinsRon Yorston2020-06-291-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Microsoft developers have a penchant for adding trailing slashes to entries in PATH: C:/Windows/System32/WindowsPowerShell/v1.0/ C:/Windows/System32/OpenSSH/ The 'type' and 'command -v' shell builtins return paths with duplicated slashes for executables in those directories. See GitHub issue #191. Bonus fixes: - handle backslashes as well as slashes in concat_path_file() - convert backslashes to slashes in the output of 'type', 'command -v'
* | win32: enable globbing by defaultRon Yorston2020-06-141-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change how busybox.exe expands wildcards on the command line. When globbing is enabled at compile time provide an implementation of _setargv(), which is run early during startup of C programs. This: - enables globbing by setting _dowildcard to -1 - checks for the presence of the environment BB_GLOBBING - if it exists and is set to 0 disables globbing - if it doesn't exist sets BB_GLOBBING=0 but continues to apply Windows' globbing in the current process The consequences of this are: - When busybox.exe is initially run from a Command Prompt Windows' globbing is applied; - Windows' globbing is turned off for future child processes, thus allowing the shell re-execute busybox.exe without it interfering with wildcards; - this behaviour can be overridden by setting BB_GLOBBING explicitly. Globbing can still be disabled at compile time if required. In that case BB_GLOBBING has no effect. With these changes globbing can be enabled by default and BusyBox will do the right thing in most circumstances. (See GitHub issues #172 and #189.)
* | ash: treat all applets as NOEXECRon Yorston2020-06-091-0/+3
| | | | | | | | | | | | | | | | | | In standalone shell mode tryexec() treats all applets as NOEXEC. Except for the shell: calling ash_main() recursively seems unwise. This avoids creating a new process for the applet (which is a Good Thing on Microsoft Windows where creating processes is expensive) but leaves the resources used by the invoking shell in the current process.
* | win32: only initialise networking if necessaryRon Yorston2020-06-011-4/+0
| | | | | | | | | | | | A call to initialise networking is made during start up even if the applet doesn't need it. Instead, only initialise networking when a call is made to a function that definitely requires it.
* | ash: reset ANSI emulation when BB_SKIP_ANSI_EMULATION changesRon Yorston2020-04-131-0/+2
| | | | | | | | | | Update the skip status on the first call to skip_ansi_emulation() and whenever the BB_SKIP_ANSI_EMULATION variable changes.
* | httpd: enable in default configurationsRon Yorston2020-04-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enable the httpd applet in WIN32 default configurations. Some additional features have also been enabled: 'Ranges:' header Basic HTTP authentication Custom error pages GZIP content encoding Common Gateway Interface (CGI) and related features are not enabled. Basic HTTP authentication requires bb_simplify_abs_path_inplace(). This function shouldn't be used for WIN32 paths. In this case it's processing a URL which is OK.
* | libbb: rearrange command line processingRon Yorston2020-04-051-13/+11
| | | | | | | | Process the '--busybox' flag before checking argv[0].
* | win32: more improvements to 'c:file' pathsRon Yorston2020-03-291-1/+1
| | | | | | | | | | | | | | | | Tab-completion of 'c:file' paths was leaking memory and incorrectly included BusyBox applets and shell built-ins. Fix handling of 'c:file' paths used as arguments to spawn functions. Otherwise things like 'timeout 5 c:busybox sleep 99' don't work.
* | win32: improve handling of 'c:file' paths for executablesRon Yorston2020-03-181-1/+1
| | | | | | | | | | | | | | | | bb_basename() didn't properly handle paths of the form 'c:file'. Attempting to run 'c:busybox' resulted in 'c:busybox: applet not found'. The shell had a similar problem: trying to run 'c:busybox' reported 'sh: c:busybox: not found'.
* | Merge branch 'busybox' into mergeRon Yorston2020-02-151-3/+14
|\|
| * ash,hush: allow builtins to be tab-completed, closes 7532Ron Yorston2020-01-291-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta complete_cmd_dir_file 678 830 +152 get_builtin_name - 35 +35 optschanged 125 132 +7 hush_main 1069 1076 +7 save_command_ps_at_cur_history 76 78 +2 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 4/0 up/down: 203/0) Total: 203 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2020-01-088-21/+27
|\|
| * Remove stime() function callsAlistair Francis2019-11-191-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | stime() has been deprecated in glibc 2.31 and replaced with clock_settime(). Let's replace the stime() function calls with clock_settime() in preperation. function old new delta rdate_main 197 224 +27 clock_settime - 27 +27 date_main 926 941 +15 stime 37 - -37 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 2/0 up/down: 69/-37) Total: 32 bytes Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * read_key(): placate "warning: shifting a negative signed value is undefined"Denys Vlasenko2019-10-251-1/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * clang/llvm 9 fix - do not eliminate a store to a fake "const"Denys Vlasenko2019-10-252-2/+2
| | | | | | | | | | | | | | This is *much* better (9 kbytes better) than dropping "*const" optimization trick. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Remove syscall wrappers around clock_gettime, closes 12091Denys Vlasenko2019-10-241-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 12091 "Direct use of __NR_clock_gettime is not time64-safe". function old new delta runsv_main 1698 1712 +14 startservice 378 383 +5 get_mono 31 25 -6 date_main 932 926 -6 gettimeofday_ns 17 - -17 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 2/2 up/down: 19/-29) Total: -10 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * dpkg-deb: work around bogus error message when working with XZ compressed ↵Denys Vlasenko2019-10-111-5/+8
| | | | | | | | | | | | | | | | | | | | packages function old new delta unpack_xz_stream 2309 2317 +8 bb_full_fd_action 464 472 +8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * replace: count_strstr - Handle an edge case where sub is emptyMartin Lewis2019-10-091-0/+4
| | | | | | | | | | | | | | | | | | | | If sub is empty, avoids an infinite loop. function old new delta count_strstr 45 63 +18 Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: Converted safe_read to safe_write formatMartin Lewis2019-10-091-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | Changed safe_read to be symmetrical to safe_write, it shall never return EINTR because it calls read multiple times, the error is considered transient. function old new delta safe_read 44 57 +13 Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * time: Use 64 prefix syscall if we have toAlistair Francis2019-10-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some 32-bit architectures no longer have the 32-bit time_t syscalls. Instead they have suffixed syscalls that returns a 64-bit time_t. If the architecture doesn't have the non-suffixed syscall and is using a 64-bit time_t let's use the suffixed syscall instead. This fixes build issues when building for RISC-V 32-bit with 5.1+ kernel headers. If an architecture only supports the suffixed syscalls, but is still using a 32-bit time_t report a compilation error. This avoids us have to deal with converting between 64-bit and 32-bit values. There are currently no architectures where this is the case. Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Update copyright dateRon Yorston2020-01-081-1/+1
| |
* | Merge branch 'busybox' into mergeRon Yorston2019-08-1635-73/+209
|\|
| * unicode: code shrink in character width determinationDenys Vlasenko2019-07-231-0/+6
| | | | | | | | | | | | | | function old new delta bb_wcwidth 267 238 -29 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: include <crypt.h> only if necessaryDenys Vlasenko2019-07-161-0/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: reduce the overhead of single parameter bb_error_msg() callsJames Byrne2019-07-0230-65/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower overhead call to bb_perror_msg() when only a string was being printed with no parameters. This saves space for some CPU architectures because it avoids the overhead of a call to a variadic function. However there has never been a simple version of bb_error_msg(), and since 2007 many new calls to bb_perror_msg() have been added that only take a single parameter and so could have been using bb_simple_perror_message(). This changeset introduces 'simple' versions of bb_info_msg(), bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and bb_herror_msg_and_die(), and replaces all calls that only take a single parameter, or use something like ("%s", arg), with calls to the corresponding 'simple' version. Since it is likely that single parameter calls to the variadic functions may be accidentally reintroduced in the future a new debugging config option WARN_SIMPLE_MSG has been introduced. This uses some macro magic which will cause any such calls to generate a warning, but this is turned off by default to avoid use of the unpleasant macros in normal circumstances. This is a large changeset due to the number of calls that have been replaced. The only files that contain changes other than simple substitution of function calls are libbb.h, libbb/herror_msg.c, libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c, networking/udhcp/common.h and util-linux/mdev.c additonal macros have been added for logging so that single parameter and multiple parameter logging variants exist. The amount of space saved varies considerably by architecture, and was found to be as follows (for 'defconfig' using GCC 7.4): Arm: -92 bytes MIPS: -52 bytes PPC: -1836 bytes x86_64: -938 bytes Note that for the MIPS architecture only an exception had to be made disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h) because it made these files larger on MIPS. Signed-off-by: James Byrne <james.byrne@origamienergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: deal with "declaration of 'link' shadows a global declaration" warningDenys Vlasenko2019-06-251-7/+7
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * pidof: support "pidof /path/to/binary" caseDenys Vlasenko2019-06-151-1/+5
| | | | | | | | | | | | | | function old new delta find_pid_by_name 230 227 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * readlink,realpath: fix a case with a symplink, closes 11021Denys Vlasenko2019-06-131-0/+29
| | | | | | | | | | | | | | function old new delta xmalloc_realpath_coreutils 125 201 +76 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * mount,losetup: use /dev/loop-control is it existsDenys Vlasenko2019-06-091-6/+36
| | | | | | | | | | | | | | | | | | | | | | function old new delta get_free_loop - 58 +58 set_loop 597 649 +52 losetup_main 482 476 -6 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 110/-6) Total: 104 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * tftp: optional tftp-hpa compatDenys Vlasenko2019-06-091-0/+1
| | | | | | | | | | | | | | function old new delta tftp_main 276 394 +118 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * passwd: do not set 0 as date of last password change, closes 11951Denys Vlasenko2019-06-071-1/+7
| | | | | | | | | | | | | | function old new delta update_passwd 1491 1505 +14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: move netlink socket binding to the utility functionDenys Vlasenko2019-06-031-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta create_and_bind_to_netlink - 134 +134 ifplugd_main 1117 1052 -65 uevent_main 399 306 -93 mdev_main 314 215 -99 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/3 up/down: 134/-257) Total: -123 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2019-05-276-21/+61
|\|
| * libarchive: treat one "FIXME: avoid seek"Denys Vlasenko2019-05-241-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta xmalloc_read_with_initial_buf - 205 +205 setup_transformer_on_fd 154 150 -4 xmalloc_open_zipped_read_close 143 135 -8 xmalloc_read 201 10 -191 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/3 up/down: 205/-203) Total: 2 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * dd: fix handling of short result of full_write(), closes 11711Denys Vlasenko2019-05-141-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | $ dd bs=1G <sda1 of=/dev/sda1 dd: error writing '/dev/sda1': No space left on device 1+0 records in 0+0 records out 999292928 bytes (953.0MB) copied, 0.784617 seconds, 1.2GB/s function old new delta write_and_stats 99 102 +3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * style fix, no code changesDenys Vlasenko2019-05-141-3/+10
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Optionally re-introduce bb_info_msg()James Byrne2019-04-301-2/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Between Busybox 1.24.2 and 1.25.0 the bb_info_msg() function was eliminated and calls to it changed to be bb_error_msg(). The downside of this is that daemons now log all messages to syslog at the LOG_ERR level which makes it hard to filter errors from informational messages. This change optionally re-introduces bb_info_msg(), controlled by a new option FEATURE_SYSLOG_INFO, restores all the calls to bb_info_msg() that were removed (only in applets that set logmode to LOGMODE_SYSLOG or LOGMODE_BOTH), and also changes informational messages in ifplugd and ntpd. The code size change of this is as follows (using 'defconfig' on x86_64 with gcc 7.3.0-27ubuntu1~18.04) function old new delta bb_info_msg - 182 +182 bb_vinfo_msg - 27 +27 static.log7 194 198 +4 log8 190 191 +1 log5 190 191 +1 crondlog 45 - -45 ------------------------------------------------------------------------------ (add/remove: 2/1 grow/shrink: 3/0 up/down: 215/-45) Total: 170 bytes If you don't care about everything being logged at LOG_ERR level then when FEATURE_SYSLOG_INFO is disabled Busybox actually gets smaller: function old new delta static.log7 194 200 +6 log8 190 193 +3 log5 190 193 +3 syslog_level 1 - -1 bb_verror_msg 583 581 -2 crondlog 45 - -45 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 3/1 up/down: 12/-48) Total: -36 bytes Signed-off-by: James Byrne <james.byrne@origamienergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbbb: find_mount_point() too eager to stat mounted devicesDenys Vlasenko2019-04-291-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | None of the below "devices" (first word on the line) are real. sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0 proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0 devtmpfs /dev devtmpfs rw,nosuid,size=7917900k,nr_inodes=1979475,mode=755 0 0 tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0 devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0 tmpfs /run tmpfs rw,nosuid,nodev,mode=755 0 0 pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0 configfs /sys/kernel/config configfs rw,relatime 0 0 tmpfs /tmp tmpfs rw,relatime 0 0 function old new delta find_mount_point 297 302 +5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * start-stop-daemon: do try to close fds > 2Denys Vlasenko2019-04-291-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | sh -c 'exec 3>&1; exec start-stop-daemon -S -b -x /bin/sleep -- 123' now closes fd 3. function old new delta bb_daemonize_or_rexec 183 192 +9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 9/0) Total: 9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | lineedit: reinstate tab-completion of '~/'Ron Yorston2019-04-091-1/+7
| | | | | | | | | | | | Commit 195902a64 (lineedit: improvements to tab completion) disabled tab-completion of usernames. It was too heavy-handed, in that it also removed tab-completion of '~/'.
* | Merge branch 'busybox' into mergeRon Yorston2019-03-312-0/+19
|\|
| * libbb: mark scripted_main() as externally visibleRon Yorston2019-03-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Building with individual binaries enabled fails when embedded script applets are included: /tmp/ccIvMFZg.o: In function `main': applet.c:(.text.main+0x20): undefined reference to `scripted_main' Mark scripted_main() as externally visible. Reported-by: Yann E. MORIN <yann.morin.1998@free.fr> Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * do not duplicate CONFIG_PID_FILE_PATH and ".pid" stringsDenys Vlasenko2019-03-171-0/+18
| | | | | | | | | | | | | | | | text data bss dec hex filename 981737 485 7296 989518 f194e busybox_old 981704 485 7296 989485 f192d busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>