Compare commits

...
25 Commits
Author SHA1 Message Date
Denys Vlasenko 889425812b Bump version to 1.26.2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 17:01:20 +01:00
Denys Vlasenko 8e38108d03 ash: fix open fds leaking in redirects. Closes 9561
commit e19923f665 deleted clearredir()
call in shellexec():

	ash: [REDIR] Remove redundant CLOEXEC calls
	Upstream commit:

	Now that we're marking file descriptors as CLOEXEC in savefd, we no longer
	need to close them on exec or in setinputfd.

but it missed one place where we don't set CLOEXEC. Fixing this.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 16:55:51 +01:00
Waldemar Brodkorb add927e3d1 modutils: remove special handling of uClibc
Commit 3a45b87ac3 (modutils: support finit_module syscall) introduced
macro finit_module. But it is not defined for uClibc.

The compilation for busybox fails for MIPS with:
With uClibc, we get following build errors:

  modutils/lib.a(modutils.o): In function `bb_init_module':
  modutils.c:(.text.bb_init_module+0x94): undefined reference to `finit_module'
  modutils.c:(.text.bb_init_module+0xa0): undefined reference to `finit_module'

We can just use syscall() without any need for the
uClibc wrappers.

Newer versions of uClibc-ng (>1.0.20) will remove the
module syscall wrappers.

Found via Buildroot autobuilders:
http://autobuild.buildroot.net/results/556/55655daef23788fb3967f801ec8b79e9bed7122b/build-end.log

function                                             old     new   delta
bb_delete_module                                      26      32      +6
bb_init_module                                        90      95      +5
delete_module                                         37       -     -37
init_module                                           53       -     -53
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 2/0 up/down: 11/-90)            Total: -79 bytes

Reported-by: Rahul Bedarkar <rahul.bedarkar@imgtec.com>
Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 16:55:51 +01:00
Jörg Krause 7bcc3c46a7 Fix dependency for IFUPDOWN_UDHCPC_CMD_OPTIONS
Commit a8c696bf09 makes ifup and ifdown
individually selectable, but forgets to update the dependency to
IFUPDOWN_UDHCPC_CMD_OPTIONS, so it is not selectable anymore.

This patch fixes the dependency by checking for IFUP or IFDOWN, instead
of the obsolete IFUPDOWN.

Also, it drops dependency on UDHCPC: udhcpc on the target system
does not have to come from the _same_ binary.

Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 16:55:51 +01:00
Denys Vlasenko 9c806db4b7 hush: correct exitcode for unterminated ')' - exitcode2.tests testcase
function                                             old     new   delta
parse_stream                                        2595    2609     +14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 16:55:51 +01:00
Ron Yorston 568cabf98a ash: fix error code regression
The commit 'ash,hush: set exit code 127 in "sh /does/not/exist" case'
only partly implemented the dash commit '[ERROR] Allow the originator
of EXERROR to set the exit status'.  This resulted in incorrect error
codes for a syntax error:

   $ )
   $ echo $?
   0

or a redirection error for a special builtin:

   $ rm -f xxx
   $ eval cat <xxx
   $ echo $?
   0

Signed-off-by: Ron Yorston <rmy@pobox.com>
Reported-by: Martijn Dekker <martijn@inlv.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 16:55:51 +01:00
Denys Vlasenko e94d2c5f24 tcpudp: define SO_ORIGINAL_DST directly, not via include
musl does not like including linux/netfilter_ipv4.h
(enum / #define collision in two headers, resulting in "3 = 3"
type situation in enum definition).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 16:55:51 +01:00
Denys Vlasenko a12eb9c64d Bump version to 1.26.1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-02 01:43:37 +01:00
Denys Vlasenko 1a6aca3d60 depmod: don't build it if MODPROBE_SMALL=y
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:13:48 +01:00
Denys Vlasenko fe3f55c540 make_single_applets.sh: SH_IS_HUSH needs special handling too
Well, in fact it works (make oldconfig throws only a warning when it sees
both SH_IS_HUSH=y and SH_IS_NONE=y), but let's be nice.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko 28251dfa64 Make it possible to select "sh" and "bash" aliases without selecting ash or hush
The same can be done for msh, but we are probably better off just deleting it
in a next versio or two.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko 9982d88a61 Make RMMOD=y by default
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko e5dc0d0120 Make INSMOD=y by default
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko 890b1feaa0 Remove FEATURE_IFUPDOWN_IP_BUILTIN and FEATURE_IFUPDOWN_IFCONFIG_BUILTIN
They merely enable ip or ifconfig/route. There is already a way to do this
on the same menuconfig page.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko d28cd9900a modprobe-small: make applets individually selectable
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko 909edacc5e Make DPKG=y and DPKG_DEB=y by default
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko ed6fb36124 Selinux complains about deprecated selinux/flask.h, stop including it
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko 048c043ae6 Make FEATURE_USERNAME_COMPLETION=y by default
This matches bash behavior on Fedora

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko f2200af1a8 make_single_applets.sh: a tool to check single-applet builds
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko c2f3655842 fix breakage found by mass one-applet builds
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko 05069b4682 ip: make ip aliases individually selectable
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko 8d0dedf1f6 shell: move "config" blocks above their use in coditional includes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko e1065da652 Tweak some config defaults; fix MODPROBE_SMALL ordering in "make config"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko 2169b25b15 ash: clarify uclibc glob() bug in comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
Denys Vlasenko 18a7bee736 ash: error out if ASH_INTERNAL_GLOB is not selected on uClibc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-01 13:01:04 +01:00
45 changed files with 750 additions and 599 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
VERSION = 1
PATCHLEVEL = 26
SUBLEVEL = 0
SUBLEVEL = 2
EXTRAVERSION =
NAME = Unnamed
+4
View File
@@ -9,8 +9,12 @@
/* lzop_main() uses bbunpack(), need this: */
//kbuild:lib-$(CONFIG_LZOP) += bbunzip.o
//kbuild:lib-$(CONFIG_LZOPCAT) += bbunzip.o
//kbuild:lib-$(CONFIG_UNLZOP) += bbunzip.o
/* bzip2_main() too: */
//kbuild:lib-$(CONFIG_BZIP2) += bbunzip.o
/* gzip_main() too: */
//kbuild:lib-$(CONFIG_GZIP) += bbunzip.o
/* Note: must be kept in sync with archival/lzop.c */
enum {
+1 -1
View File
@@ -28,7 +28,7 @@
//config:config DPKG
//config: bool "dpkg"
//config: default n
//config: default y
//config: select FEATURE_SEAMLESS_GZ
//config: help
//config: dpkg is a medium-level tool to install, build, remove and manage
+1 -1
View File
@@ -7,7 +7,7 @@
//config:config DPKG_DEB
//config: bool "dpkg_deb"
//config: default n
//config: default y
//config: select FEATURE_SEAMLESS_GZ
//config: help
//config: dpkg-deb unpacks and provides information about Debian archives.
+12 -8
View File
@@ -10,12 +10,16 @@ lib-y:=
INSERT
lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty
lib-$(CONFIG_LESS) += cat.o # less too
lib-$(CONFIG_CRONTAB) += cat.o # crontab -l
lib-$(CONFIG_ADDUSER) += chown.o # used by adduser
lib-$(CONFIG_ADDGROUP) += chown.o # used by adduser
lib-$(CONFIG_ASH) += echo.o # used by ash
lib-$(CONFIG_HUSH) += echo.o # used by hush
lib-$(CONFIG_FTPD) += ls.o # used by ftpd
lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty
lib-$(CONFIG_LESS) += cat.o # less too
lib-$(CONFIG_CRONTAB) += cat.o # crontab -l
lib-$(CONFIG_ADDUSER) += chown.o # used by adduser
lib-$(CONFIG_ADDGROUP) += chown.o # used by adduser
lib-$(CONFIG_ASH) += echo.o # used by ash
lib-$(CONFIG_SH_IS_ASH) += echo.o # used by ash
lib-$(CONFIG_BASH_IS_ASH) += echo.o # used by ash
lib-$(CONFIG_HUSH) += echo.o # used by hush
lib-$(CONFIG_SH_IS_HUSH) += echo.o # used by hush
lib-$(CONFIG_BASH_IS_HUSH) += echo.o # used by hush
lib-$(CONFIG_FTPD) += ls.o # used by ftpd
lib-$(CONFIG_ASH_BUILTIN_PRINTF) += printf.o
+2
View File
@@ -55,6 +55,8 @@
//kbuild:lib-$(CONFIG_TEST2) += test.o test_ptr_hack.o
//kbuild:lib-$(CONFIG_ASH_BUILTIN_TEST) += test.o test_ptr_hack.o
//kbuild:lib-$(CONFIG_HUSH) += test.o test_ptr_hack.o
//kbuild:lib-$(CONFIG_SH_IS_HUSH) += test.o test_ptr_hack.o
//kbuild:lib-$(CONFIG_BASH_IS_HUSH) += test.o test_ptr_hack.o
/* "test --help" is special-cased to ignore --help */
//usage:#define test_trivial_usage NOUSAGE_STR
+5 -6
View File
@@ -4,11 +4,7 @@
# enabling it. Run it after applets.h is generated.
# CONFIG_applet names
grep ^IF_ applets.h | grep -v IF_FEATURE_ | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \
| grep -v MODPROBE_SMALL \
| sed 's/BB_SYSCTL/SYSCTL/' \
| sed 's/TEST1/[/' \
| sed 's/TEST2/[[/' \
grep ^IF_ applets.h | grep -v ^IF_FEATURE_ | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \
| sort | uniq \
>applets_APP1
@@ -17,8 +13,11 @@ grep ^IF_ applets.h | sed -e's/ //g' -e's/.*(\([a-z[][^,]*\),.*/\1/' \
| grep -v '^bash$' \
| grep -v '^sh$' \
| tr a-z A-Z \
| sed 's/^SYSCTL$/BB_SYSCTL/' \
| sed 's/^\[\[$/TEST1/' \
| sed 's/^\[$/TEST2/' \
| sort | uniq \
>applets_APP2
diff -u applets_APP1 applets_APP2 >applets_APP.diff
rm applets_APP1 applets_APP2
#rm applets_APP1 applets_APP2
+1 -1
View File
@@ -83,7 +83,7 @@
//config:
//config:config FEATURE_INIT_COREDUMPS
//config: bool "Support dumping core for child processes (debugging only)"
//config: default y
//config: default n # not Y because this is a debug option
//config: depends on INIT || LINUXRC
//config: help
//config: If this option is enabled and the file /.init_enable_core
+1 -1
View File
@@ -152,7 +152,7 @@ config FEATURE_TAB_COMPLETION
config FEATURE_USERNAME_COMPLETION
bool "Username completion"
default n
default y
depends on FEATURE_TAB_COMPLETION
help
Enable username completion.
+1
View File
@@ -176,6 +176,7 @@ lib-$(CONFIG_TRACEROUTE6) += inet_cksum.o
lib-$(CONFIG_UDHCPC) += inet_cksum.o
lib-$(CONFIG_UDHCPC6) += inet_cksum.o
lib-$(CONFIG_UDHCPD) += inet_cksum.o
lib-$(CONFIG_DHCPRELAY) += inet_cksum.o
# We shouldn't build xregcomp.c if we don't need it - this ensures we don't
# require regex.h to be in the include dir even if we don't need it thereby
+16 -16
View File
@@ -329,21 +329,6 @@ static struct suid_config_t {
static bool suid_cfg_readable;
/* check if u is member of group g */
static int ingroup(uid_t u, gid_t g)
{
struct group *grp = getgrgid(g);
if (grp) {
char **mem;
for (mem = grp->gr_mem; *mem; mem++) {
struct passwd *pwd = getpwnam(*mem);
if (pwd && (pwd->pw_uid == u))
return 1;
}
}
return 0;
}
/* libbb candidate */
static char *get_trimmed_slice(char *s, char *e)
{
@@ -568,7 +553,22 @@ static inline void parse_config_file(void)
# endif /* FEATURE_SUID_CONFIG */
# if ENABLE_FEATURE_SUID
# if ENABLE_FEATURE_SUID && NUM_APPLETS > 0
/* check if u is member of group g */
static int ingroup(uid_t u, gid_t g)
{
struct group *grp = getgrgid(g);
if (grp) {
char **mem;
for (mem = grp->gr_mem; *mem; mem++) {
struct passwd *pwd = getpwnam(*mem);
if (pwd && (pwd->pw_uid == u))
return 1;
}
}
return 0;
}
static void check_suid(int applet_no)
{
gid_t rgid; /* real gid */
+2
View File
@@ -180,6 +180,7 @@ int FAST_FUNC update_passwd(const char *filename,
if (!line) /* EOF/error */
break;
#if ENABLE_FEATURE_ADDUSER_TO_GROUP || ENABLE_FEATURE_DEL_USER_FROM_GROUP
if (!name && member) {
/* Delete member from all groups */
/* line is "GROUP:PASSWD:[member1[,member2]...]" */
@@ -209,6 +210,7 @@ int FAST_FUNC update_passwd(const char *filename,
fprintf(new_fp, "%s\n", line);
goto next;
}
#endif
cp = is_prefixed_with(line, name_colon);
if (!cp) {
+3 -1
View File
@@ -69,7 +69,9 @@
#if ENABLE_SELINUX
# include <selinux/selinux.h> /* for is_selinux_enabled() */
# include <selinux/get_context_list.h> /* for get_default_context() */
# include <selinux/flask.h> /* for security class definitions */
# /* from deprecated <selinux/flask.h>: */
# undef SECCLASS_CHR_FILE
# define SECCLASS_CHR_FILE 10
#endif
#if ENABLE_PAM
+73
View File
@@ -0,0 +1,73 @@
#!/bin/sh
# This script expects that the tree was built with the desired .config:
# in particular, it expects that include/applets.h is generated already.
#
# The script will try to rebuild each enabled applet in isolation.
# All other options which chose general bbox config, applet features, etc,
# are not modified for the builds.
makeopts="-j9"
# The list of all applet config symbols
test -f include/applets.h || { echo "No include/applets.h file"; exit 1; }
apps="`
grep ^IF_ include/applets.h \
| grep -v ^IF_FEATURE_ \
| sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \
| sort | uniq
`"
# Take existing config
test -f .config || { echo "No .config file"; exit 1; }
cfg="`cat .config`"
# Make a config with all applet symbols off
allno="$cfg"
for app in $apps; do
allno="`echo "$allno" | sed "s/^CONFIG_${app}=y\$/# CONFIG_${app} is not set/"`"
done
#echo "$allno" >.config_allno
# Turn on each applet individually and build single-applet executable
fail=0
for app in $apps; do
# Only if it was indeed originally enabled...
{ echo "$cfg" | grep -q "^CONFIG_${app}=y\$"; } || continue
echo "Making ${app}..."
mv .config .config.SV
echo "CONFIG_${app}=y" >.config
echo "$allno" | sed "/^# CONFIG_${app} is not set\$/d" >>.config
if test x"${app}" != x"SH_IS_ASH" && test x"${app}" != x"SH_IS_HUSH"; then
# $allno has all choices for "sh" aliasing set to off.
# "sh" aliasing defaults to "ash", not none.
# without this fix, "make oldconfig" sets it wrong,
# resulting in NUM_APPLETS = 2 (the second applet is "sh")
sed '/CONFIG_SH_IS_NONE/d' -i .config
echo "CONFIG_SH_IS_NONE=y" >>.config
fi
if ! yes '' | make oldconfig >busybox_make_${app}.log 2>&1; then
: $((fail++))
echo "Config error for ${app}"
mv .config busybox_config_${app}
elif ! make $makeopts >>busybox_make_${app}.log 2>&1; then
: $((fail++))
echo "Build error for ${app}"
mv .config busybox_config_${app}
elif ! grep -q '^#define NUM_APPLETS 1$' include/NUM_APPLETS.h; then
mv busybox busybox_${app}
: $((fail++))
echo "NUM_APPLETS != 1 for ${app}: `cat include/NUM_APPLETS.h`"
mv .config busybox_config_${app}
else
mv busybox busybox_${app}
rm busybox_make_${app}.log
fi
mv .config.SV .config
#exit
done
touch .config # or else next "make" can be confused
echo "Failures: $fail"
test $fail = 0 # set exitcode
+31
View File
@@ -5,6 +5,37 @@
menu "Linux Module Utilities"
config MODPROBE_SMALL
bool "Simplified modutils"
default y
select PLATFORM_LINUX
help
Simplified modutils.
With this option modprobe does not require modules.dep file
and does not use /etc/modules.conf file.
It scans module files in /lib/modules/`uname -r` and
determines dependencies and module alias names on the fly.
This may make module loading slower, most notably
when one needs to load module by alias (this requires
scanning through module _bodies_).
At the first attempt to load a module by alias modprobe
will try to generate modules.dep.bb file in order to speed up
future loads by alias. Failure to do so (read-only /lib/modules,
etc) is not reported, and future modprobes will be slow too.
NB: modules.dep.bb file format is not compatible
with modules.dep file as created/used by standard module tools.
Additional module parameters can be stored in
/etc/modules/$module_name files.
Apart from modprobe, other utilities are also provided:
- insmod is an alias to modprobe
- rmmod is an alias to modprobe -r
- depmod generates modules.dep.bb
INSERT
comment "Options common to multiple modutils"
+4 -3
View File
@@ -9,17 +9,18 @@
*/
//config:config DEPMOD
//config: bool "depmod"
//config: default n
//config: depends on !MODPROBE_SMALL
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: depmod generates modules.dep (and potentially modules.alias
//config: and modules.symbols) that contain dependency information
//config: for modprobe.
//applet:IF_DEPMOD(APPLET(depmod, BB_DIR_SBIN, BB_SUID_DROP))
//applet:IF_DEPMOD(IF_NOT_MODPROBE_SMALL(APPLET(depmod, BB_DIR_SBIN, BB_SUID_DROP)))
//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y)
//kbuild:lib-$(CONFIG_DEPMOD) += depmod.o modutils.o
//kbuild:endif
#include "libbb.h"
#include "modutils.h"
+4 -3
View File
@@ -8,15 +8,16 @@
*/
//config:config INSMOD
//config: bool "insmod"
//config: default n
//config: depends on !MODPROBE_SMALL
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: insmod is used to load specified modules in the running kernel.
//applet:IF_INSMOD(APPLET(insmod, BB_DIR_SBIN, BB_SUID_DROP))
//applet:IF_INSMOD(IF_NOT_MODPROBE_SMALL(APPLET(insmod, BB_DIR_SBIN, BB_SUID_DROP)))
//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y)
//kbuild:lib-$(CONFIG_INSMOD) += insmod.o modutils.o
//kbuild:endif
#include "libbb.h"
#include "modutils.h"
+6 -5
View File
@@ -9,25 +9,26 @@
*/
//config:config LSMOD
//config: bool "lsmod"
//config: default n
//config: depends on !MODPROBE_SMALL
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: lsmod is used to display a list of loaded modules.
//config:
//config:config FEATURE_LSMOD_PRETTY_2_6_OUTPUT
//config: bool "Pretty output"
//config: default n
//config: depends on LSMOD
//config: default y
//config: depends on LSMOD && !MODPROBE_SMALL
//config: select PLATFORM_LINUX
//config: help
//config: This option makes output format of lsmod adjusted to
//config: the format of module-init-tools for Linux kernel 2.6.
//config: Increases size somewhat.
//applet:IF_LSMOD(APPLET(lsmod, BB_DIR_SBIN, BB_SUID_DROP))
//applet:IF_LSMOD(IF_NOT_MODPROBE_SMALL(APPLET(lsmod, BB_DIR_SBIN, BB_SUID_DROP)))
//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y)
//kbuild:lib-$(CONFIG_LSMOD) += lsmod.o modutils.o
//kbuild:endif
//usage:#if !ENABLE_MODPROBE_SMALL
//usage:#define lsmod_trivial_usage
+17 -45
View File
@@ -7,37 +7,9 @@
*
* Licensed under GPLv2, see file LICENSE in this source tree.
*/
//config:config MODPROBE_SMALL
//config: bool "Simplified modutils"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Simplified modutils.
//config:
//config: With this option modprobe does not require modules.dep file
//config: and does not use /etc/modules.conf file.
//config: It scans module files in /lib/modules/`uname -r` and
//config: determines dependencies and module alias names on the fly.
//config: This may make module loading slower, most notably
//config: when one needs to load module by alias (this requires
//config: scanning through module _bodies_).
//config:
//config: At the first attempt to load a module by alias modprobe
//config: will try to generate modules.dep.bb file in order to speed up
//config: future loads by alias. Failure to do so (read-only /lib/modules,
//config: etc) is not reported, and future modprobes will be slow too.
//config:
//config: NB: modules.dep.bb file format is not compatible
//config: with modules.dep file as created/used by standard module tools.
//config:
//config: Additional module parameters can be stored in
//config: /etc/modules/$module_name files.
//config:
//config: Apart from modprobe, other utilities are also provided:
//config: - insmod is an alias to modprobe
//config: - rmmod is an alias to modprobe -r
//config: - depmod generates modules.dep.bb
//config:
/* config MODPROBE_SMALL is defined in Config.src to ensure better "make config" order */
//config:config FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE
//config: bool "Accept module options on modprobe command line"
//config: default y
@@ -53,11 +25,11 @@
//config: help
//config: Check if the module is already loaded.
//applet:IF_MODPROBE_SMALL(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP))
//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(depmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, depmod))
//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, insmod))
//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, lsmod))
//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(rmmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, rmmod))
//applet:IF_MODPROBE(IF_MODPROBE_SMALL(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP)))
//applet:IF_DEPMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(depmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, depmod)))
//applet:IF_INSMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, insmod)))
//applet:IF_LSMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, lsmod)))
//applet:IF_RMMOD(IF_MODPROBE_SMALL(APPLET_ODDNAME(rmmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, rmmod)))
//kbuild:lib-$(CONFIG_MODPROBE_SMALL) += modprobe-small.o
@@ -67,8 +39,8 @@
#include <fnmatch.h>
#include <sys/syscall.h>
extern int init_module(void *module, unsigned long len, const char *options);
extern int delete_module(const char *module, unsigned flags);
#define init_module(mod, len, opts) syscall(__NR_init_module, mod, len, opts)
#define delete_module(mod, flags) syscall(__NR_delete_module, mod, flags)
#ifdef __NR_finit_module
# define finit_module(fd, uargs, flags) syscall(__NR_finit_module, fd, uargs, flags)
#endif
@@ -958,7 +930,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(char *options;)
/* are we lsmod? -> just dump /proc/modules */
if ('l' == applet0) {
if (ENABLE_LSMOD && 'l' == applet0) {
xprint_and_close_file(xfopen_for_read("/proc/modules"));
return EXIT_SUCCESS;
}
@@ -968,14 +940,14 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
/* Prevent ugly corner cases with no modules at all */
modinfo = xzalloc(sizeof(modinfo[0]));
if ('i' != applet0) { /* not insmod */
if (!ENABLE_INSMOD || 'i' != applet0) { /* not insmod */
/* Goto modules directory */
xchdir(CONFIG_DEFAULT_MODULES_DIR);
}
uname(&uts); /* never fails */
/* depmod? */
if ('d' == applet0) {
if (ENABLE_DEPMOD && 'd' == applet0) {
/* Supported:
* -n: print result to stdout
* -a: process all modules (default)
@@ -1014,11 +986,11 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
argv += optind;
/* are we rmmod? -> simulate modprobe -r */
if ('r' == applet0) {
if (ENABLE_RMMOD && 'r' == applet0) {
option_mask32 |= OPT_r;
}
if ('i' != applet0) { /* not insmod */
if (!ENABLE_INSMOD || 'i' != applet0) { /* not insmod */
/* Goto $VERSION directory */
xchdir(uts.release);
}
@@ -1042,7 +1014,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
argv[1] = NULL;
#endif
if ('i' == applet0) { /* insmod */
if (ENABLE_INSMOD && 'i' == applet0) { /* insmod */
size_t len;
void *map;
@@ -1062,7 +1034,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
}
/* Try to load modprobe.dep.bb */
if ('r' != applet0) { /* not rmmod */
if (!ENABLE_RMMOD || 'r' != applet0) { /* not rmmod */
load_dep_bb();
}
+6 -5
View File
@@ -9,8 +9,7 @@
*/
//config:config MODPROBE
//config: bool "modprobe"
//config: default n
//config: depends on !MODPROBE_SMALL
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: Handle the loading of modules, and their dependencies on a high
@@ -18,8 +17,8 @@
//config:
//config:config FEATURE_MODPROBE_BLACKLIST
//config: bool "Blacklist support"
//config: default n
//config: depends on MODPROBE
//config: default y
//config: depends on MODPROBE && !MODPROBE_SMALL
//config: select PLATFORM_LINUX
//config: help
//config: Say 'y' here to enable support for the 'blacklist' command in
@@ -28,9 +27,11 @@
//config: hardware autodetection scripts to load modules like evdev, frame
//config: buffer drivers etc.
//applet:IF_MODPROBE(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP))
//applet:IF_MODPROBE(IF_NOT_MODPROBE_SMALL(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP)))
//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y)
//kbuild:lib-$(CONFIG_MODPROBE) += modprobe.o modutils.o
//kbuild:endif
#include "libbb.h"
#include "modutils.h"
+6 -10
View File
@@ -7,17 +7,13 @@
*/
#include "modutils.h"
#ifdef __UCLIBC__
extern int init_module(void *module, unsigned long len, const char *options);
extern int delete_module(const char *module, unsigned int flags);
#else
# include <sys/syscall.h>
# define init_module(mod, len, opts) syscall(__NR_init_module, mod, len, opts)
# if defined(__NR_finit_module)
# define finit_module(fd, uargs, flags) syscall(__NR_finit_module, fd, uargs, flags)
# endif
# define delete_module(mod, flags) syscall(__NR_delete_module, mod, flags)
#include <sys/syscall.h>
#define init_module(mod, len, opts) syscall(__NR_init_module, mod, len, opts)
#if defined(__NR_finit_module)
# define finit_module(fd, uargs, flags) syscall(__NR_finit_module, fd, uargs, flags)
#endif
#define delete_module(mod, flags) syscall(__NR_delete_module, mod, flags)
static module_entry *helper_get_module(module_db *db, const char *module, int create)
{
+4 -3
View File
@@ -9,15 +9,16 @@
*/
//config:config RMMOD
//config: bool "rmmod"
//config: default n
//config: depends on !MODPROBE_SMALL
//config: default y
//config: select PLATFORM_LINUX
//config: help
//config: rmmod is used to unload specified modules from the kernel.
//applet:IF_RMMOD(APPLET(rmmod, BB_DIR_SBIN, BB_SUID_DROP))
//applet:IF_RMMOD(IF_NOT_MODPROBE_SMALL(APPLET(rmmod, BB_DIR_SBIN, BB_SUID_DROP)))
//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y)
//kbuild:lib-$(CONFIG_RMMOD) += rmmod.o modutils.o
//kbuild:endif
//usage:#if !ENABLE_MODPROBE_SMALL
//usage:#define rmmod_trivial_usage
+1 -1
View File
@@ -53,7 +53,7 @@ source networking/udhcp/Config.in
config IFUPDOWN_UDHCPC_CMD_OPTIONS
string "ifup udhcpc command line options"
default "-R -n"
depends on IFUPDOWN && UDHCPC
depends on IFUP || IFDOWN
help
Command line options to pass to udhcpc from ifup.
Intended to alter options not available in /etc/network/interfaces.
+7 -29
View File
@@ -51,41 +51,19 @@
//config: This config option defines location of ifstate.
//config:
//config:config FEATURE_IFUPDOWN_IP
//config: bool "Use ip applet"
//config: bool "Use ip tool (else ifconfig/route is used)"
//config: default y
//config: depends on IFUP || IFDOWN
//config: help
//config: Use the iproute "ip" command to implement "ifup" and "ifdown", rather
//config: than the default of using the older 'ifconfig' and 'route' utilities.
//config: than the default of using the older "ifconfig" and "route" utilities.
//config:
//config:config FEATURE_IFUPDOWN_IP_BUILTIN
//config: bool "Use busybox ip applet"
//config: default y
//config: depends on FEATURE_IFUPDOWN_IP
//config: select PLATFORM_LINUX
//config: select IP
//config: select FEATURE_IP_ADDRESS
//config: select FEATURE_IP_LINK
//config: select FEATURE_IP_ROUTE
//config: help
//config: Use the busybox iproute "ip" applet to implement "ifupdown".
//config: If Y: you must install either the full-blown iproute2 package
//config: or enable "ip" applet in Busybox, or the "ifup" and "ifdown" applets
//config: will not work.
//config:
//config: If left disabled, you must install the full-blown iproute2
//config: utility or the "ifup" and "ifdown" applets will not work.
//config:
//config:config FEATURE_IFUPDOWN_IFCONFIG_BUILTIN
//config: bool "Use busybox ifconfig and route applets"
//config: default n
//config: depends on (IFUP || IFDOWN) && !FEATURE_IFUPDOWN_IP
//config: select IFCONFIG
//config: select ROUTE
//config: help
//config: Use the busybox iproute "ifconfig" and "route" applets to
//config: implement the "ifup" and "ifdown" utilities.
//config:
//config: If left disabled, you must install the full-blown ifconfig
//config: and route utilities, or the "ifup" and "ifdown" applets will not
//config: work.
//config: If N: you must install either the full-blown ifconfig and route
//config: utilities, or enable these applets in Busybox.
//config:
//config:config FEATURE_IFUPDOWN_IPV4
//config: bool "Support for IPv4"
+85 -77
View File
@@ -17,24 +17,72 @@
//config: utility. You generally don't need "ip" to use busybox with
//config: TCP/IP.
//config:
//config:config IPADDR
//config: bool "ipaddr"
//config: default y
//config: select FEATURE_IP_ADDRESS
//config: select PLATFORM_LINUX
//config: help
//config: Support short form of ip addr: ipaddr
//config:
//config:config IPLINK
//config: bool "iplink"
//config: default y
//config: select FEATURE_IP_LINK
//config: select PLATFORM_LINUX
//config: help
//config: Support short form of ip link: iplink
//config:
//config:config IPROUTE
//config: bool "iproute"
//config: default y
//config: select FEATURE_IP_ROUTE
//config: select PLATFORM_LINUX
//config: help
//config: Support short form of ip route: iproute
//config:
//config:config IPTUNNEL
//config: bool "iptunnel"
//config: default y
//config: select FEATURE_IP_TUNNEL
//config: select PLATFORM_LINUX
//config: help
//config: Support short form of ip tunnel: iptunnel
//config:
//config:config IPRULE
//config: bool "iprule"
//config: default y
//config: select FEATURE_IP_RULE
//config: select PLATFORM_LINUX
//config: help
//config: Support short form of ip rule: iprule
//config:
//config:config IPNEIGH
//config: bool "ipneigh"
//config: default y
//config: select FEATURE_IP_NEIGH
//config: select PLATFORM_LINUX
//config: help
//config: Support short form of ip neigh: ipneigh
//config:
//config:config FEATURE_IP_ADDRESS
//config: bool "ip address"
//config: default y
//config: depends on IP
//config: depends on IP || IPADDR
//config: help
//config: Address manipulation support for the "ip" applet.
//config:
//config:config FEATURE_IP_LINK
//config: bool "ip link"
//config: default y
//config: depends on IP
//config: depends on IP || IPLINK
//config: help
//config: Configure network devices with "ip".
//config:
//config:config FEATURE_IP_ROUTE
//config: bool "ip route"
//config: default y
//config: depends on IP
//config: depends on IP || IPROUTE
//config: help
//config: Add support for routing table management to "ip".
//config:
@@ -48,83 +96,35 @@
//config:config FEATURE_IP_TUNNEL
//config: bool "ip tunnel"
//config: default y
//config: depends on IP
//config: depends on IP || IPTUNNEL
//config: help
//config: Add support for tunneling commands to "ip".
//config:
//config:config FEATURE_IP_RULE
//config: bool "ip rule"
//config: default y
//config: depends on IP
//config: depends on IP || IPRULE
//config: help
//config: Add support for rule commands to "ip".
//config:
//config:config FEATURE_IP_NEIGH
//config: bool "ip neighbor"
//config: default y
//config: depends on IP
//config: depends on IP || IPNEIGH
//config: help
//config: Add support for neighbor commands to "ip".
//config:
//config:config FEATURE_IP_SHORT_FORMS
//config: bool "Support short forms of ip commands"
//config: default y
//config: depends on IP
//config: help
//config: Also support short-form of ip <OBJECT> commands:
//config: ip addr -> ipaddr
//config: ip link -> iplink
//config: ip route -> iproute
//config: ip tunnel -> iptunnel
//config: ip rule -> iprule
//config: ip neigh -> ipneigh
//config:
//config: Say N unless you desparately need the short form of the ip
//config: object commands.
//config:
//config:config FEATURE_IP_RARE_PROTOCOLS
//config: bool "Support displaying rarely used link types"
//config: default n
//config: depends on IP
//config: depends on IP || IPADDR || IPLINK || IPROUTE || IPTUNNEL || IPRULE || IPNEIGH
//config: help
//config: If you are not going to use links of type "frad", "econet",
//config: "bif" etc, you probably don't need to enable this.
//config: Ethernet, wireless, infrared, ppp/slip, ip tunnelling
//config: link types are supported without this option selected.
//config:
//config:config IPADDR
//config: bool
//config: default y
//config: depends on FEATURE_IP_SHORT_FORMS && FEATURE_IP_ADDRESS
//config:
//config:config IPLINK
//config: bool
//config: default y
//config: depends on FEATURE_IP_SHORT_FORMS && FEATURE_IP_LINK
//config:
//config:config IPROUTE
//config: bool
//config: default y
//config: depends on FEATURE_IP_SHORT_FORMS && FEATURE_IP_ROUTE
//config:
//config:config IPTUNNEL
//config: bool
//config: default y
//config: depends on FEATURE_IP_SHORT_FORMS && FEATURE_IP_TUNNEL
//config:
//config:config IPRULE
//config: bool
//config: default y
//config: depends on FEATURE_IP_SHORT_FORMS && FEATURE_IP_RULE
//config:
//config:config IPNEIGH
//config: bool
//config: default y
//config: depends on FEATURE_IP_SHORT_FORMS && FEATURE_IP_NEIGH
//applet:#if ENABLE_FEATURE_IP_ADDRESS || ENABLE_FEATURE_IP_ROUTE || ENABLE_FEATURE_IP_LINK || ENABLE_FEATURE_IP_TUNNEL || ENABLE_FEATURE_IP_RULE || ENABLE_FEATURE_IP_NEIGH
//applet:IF_IP(APPLET(ip, BB_DIR_SBIN, BB_SUID_DROP))
//applet:#endif
//applet:IF_IPADDR(APPLET(ipaddr, BB_DIR_SBIN, BB_SUID_DROP))
//applet:IF_IPLINK(APPLET(iplink, BB_DIR_SBIN, BB_SUID_DROP))
//applet:IF_IPROUTE(APPLET(iproute, BB_DIR_SBIN, BB_SUID_DROP))
@@ -133,6 +133,12 @@
//applet:IF_IPNEIGH(APPLET(ipneigh, BB_DIR_SBIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_IP) += ip.o
//kbuild:lib-$(CONFIG_IPADDR) += ip.o
//kbuild:lib-$(CONFIG_IPLINK) += ip.o
//kbuild:lib-$(CONFIG_IPROUTE) += ip.o
//kbuild:lib-$(CONFIG_IPRULE) += ip.o
//kbuild:lib-$(CONFIG_IPTUNNEL) += ip.o
//kbuild:lib-$(CONFIG_IPNEIGH) += ip.o
/* would need to make the " | " optional depending on more than one selected: */
//usage:#define ip_trivial_usage
@@ -218,62 +224,57 @@
#include "libiproute/utils.h"
#include "libiproute/ip_common.h"
#if ENABLE_FEATURE_IP_ADDRESS \
|| ENABLE_FEATURE_IP_ROUTE \
|| ENABLE_FEATURE_IP_LINK \
|| ENABLE_FEATURE_IP_TUNNEL \
|| ENABLE_FEATURE_IP_RULE \
|| ENABLE_FEATURE_IP_NEIGH
static int FAST_FUNC ip_print_help(char **argv UNUSED_PARAM)
{
bb_show_usage();
}
typedef int FAST_FUNC (*ip_func_ptr_t)(char**);
#if ENABLE_IPADDR \
|| ENABLE_IPLINK \
|| ENABLE_IPROUTE \
|| ENABLE_IPRULE \
|| ENABLE_IPTUNNEL \
|| ENABLE_IPNEIGH
static int ip_do(ip_func_ptr_t ip_func, char **argv)
{
argv = ip_parse_common_args(argv + 1);
return ip_func(argv);
}
#endif
#if ENABLE_FEATURE_IP_ADDRESS
#if ENABLE_IPADDR
int ipaddr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ipaddr_main(int argc UNUSED_PARAM, char **argv)
{
return ip_do(do_ipaddr, argv);
}
#endif
#if ENABLE_FEATURE_IP_LINK
#if ENABLE_IPLINK
int iplink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int iplink_main(int argc UNUSED_PARAM, char **argv)
{
return ip_do(do_iplink, argv);
}
#endif
#if ENABLE_FEATURE_IP_ROUTE
#if ENABLE_IPROUTE
int iproute_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int iproute_main(int argc UNUSED_PARAM, char **argv)
{
return ip_do(do_iproute, argv);
}
#endif
#if ENABLE_FEATURE_IP_RULE
#if ENABLE_IPRULE
int iprule_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int iprule_main(int argc UNUSED_PARAM, char **argv)
{
return ip_do(do_iprule, argv);
}
#endif
#if ENABLE_FEATURE_IP_TUNNEL
#if ENABLE_IPTUNNEL
int iptunnel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int iptunnel_main(int argc UNUSED_PARAM, char **argv)
{
return ip_do(do_iptunnel, argv);
}
#endif
#if ENABLE_FEATURE_IP_NEIGH
#if ENABLE_IPNEIGH
int ipneigh_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ipneigh_main(int argc UNUSED_PARAM, char **argv)
{
@@ -281,11 +282,16 @@ int ipneigh_main(int argc UNUSED_PARAM, char **argv)
}
#endif
#if ENABLE_IP
static int FAST_FUNC ip_print_help(char **argv UNUSED_PARAM)
{
bb_show_usage();
}
int ip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ip_main(int argc UNUSED_PARAM, char **argv)
{
static const char keywords[] ALIGN1 =
static const char keywords[] ALIGN1 = ""
IF_FEATURE_IP_ADDRESS("address\0")
IF_FEATURE_IP_ROUTE("route\0")
IF_FEATURE_IP_ROUTE("r\0")
@@ -310,10 +316,12 @@ int ip_main(int argc UNUSED_PARAM, char **argv)
int key;
argv = ip_parse_common_args(argv + 1);
key = *argv ? index_in_substrings(keywords, *argv++) : -1;
if (ARRAY_SIZE(ip_func_ptrs) > 1 && *argv)
key = index_in_substrings(keywords, *argv++);
else
key = -1;
ip_func = ip_func_ptrs[key + 1];
return ip_func(argv);
}
#endif /* any of ENABLE_FEATURE_IP_xxx is 1 */
#endif
+3
View File
@@ -62,13 +62,16 @@ lib-$(CONFIG_FEATURE_IP_TUNNEL) += \
lib-$(CONFIG_FEATURE_IP_RULE) += \
ip_parse_common_args.o \
iprule.o \
libnetlink.o \
rt_names.o \
rtm_map.o \
utils.o
lib-$(CONFIG_FEATURE_IP_NEIGH) += \
ip_parse_common_args.o \
ipneigh.o \
libnetlink.o \
ll_addr.o \
ll_map.o \
rt_names.o \
utils.o
+3 -3
View File
@@ -107,10 +107,10 @@
#include "libbb.h"
#include "common_bufsiz.h"
/* Wants <limits.h> etc, thus included after libbb.h: */
#ifdef __linux__
#include <linux/types.h> /* for __be32 etc */
#include <linux/netfilter_ipv4.h>
/* from linux/netfilter_ipv4.h: */
# undef SO_ORIGINAL_DST
# define SO_ORIGINAL_DST 80
#endif
// TODO: move into this file:
-2
View File
@@ -16,7 +16,6 @@ config UDHCPD
config DHCPRELAY
bool "dhcprelay"
default y
depends on UDHCPD
help
dhcprelay listens for dhcp requests on one or more interfaces
and forwards these requests to a different interface or dhcp
@@ -25,7 +24,6 @@ config DHCPRELAY
config DUMPLEASES
bool "Lease display utility (dumpleases)"
default y
depends on UDHCPD
help
dumpleases displays the leases written out by the udhcpd server.
Lease times are stored in the file by time remaining in lease, or
+1 -1
View File
@@ -15,7 +15,7 @@ lib-$(CONFIG_UDHCPD) += common.o packet.o signalpipe.o socket.o
lib-$(CONFIG_UDHCPC) += dhcpc.o
lib-$(CONFIG_UDHCPD) += dhcpd.o arpping.o
lib-$(CONFIG_DUMPLEASES) += dumpleases.o
lib-$(CONFIG_DHCPRELAY) += dhcprelay.o
lib-$(CONFIG_DHCPRELAY) += dhcprelay.o common.o socket.o packet.o
lib-$(CONFIG_FEATURE_UDHCPC_ARPING) += arpping.o
lib-$(CONFIG_FEATURE_UDHCP_RFC3397) += domain_codec.o
+2
View File
@@ -9,3 +9,5 @@ lib-y:=
INSERT
lib-$(CONFIG_ASH) += kill.o # used for built-in kill by ash
lib-$(CONFIG_SH_IS_ASH) += kill.o # used for built-in kill by ash
lib-$(CONFIG_BASH_IS_ASH) += kill.o # used for built-in kill by ash
+3 -1
View File
@@ -68,7 +68,9 @@
//usage: )
#include <selinux/context.h>
#include <selinux/flask.h>
/* from deprecated <selinux/flask.h>: */
#undef SECCLASS_PROCESS
#define SECCLASS_PROCESS 2
#include "libbb.h"
+21 -24
View File
@@ -5,34 +5,30 @@
menu "Shells"
INSERT
choice
prompt "Choose which shell is aliased to 'sh' name"
default FEATURE_SH_IS_ASH
default SH_IS_ASH
help
Choose which shell you want to be executed by 'sh' alias.
The ash shell is the most bash compatible and full featured one.
# note: cannot use "select ASH" here, it breaks "make allnoconfig"
config FEATURE_SH_IS_ASH
depends on ASH
bool "ash"
config SH_IS_ASH
depends on !NOMMU
bool "ash"
config FEATURE_SH_IS_HUSH
depends on HUSH
config SH_IS_HUSH
bool "hush"
config FEATURE_SH_IS_NONE
config SH_IS_NONE
bool "none"
endchoice
choice
prompt "Choose which shell is aliased to 'bash' name"
default FEATURE_BASH_IS_NONE
default BASH_IS_NONE
help
Choose which shell you want to be executed by 'bash' alias.
The ash shell is the most bash compatible and full featured one.
@@ -47,32 +43,33 @@ choice
can't be used for running them because it won't recongnize
"bash" as a supported applet name.
config FEATURE_BASH_IS_ASH
depends on ASH
bool "ash"
config BASH_IS_ASH
depends on !NOMMU
bool "ash"
config FEATURE_BASH_IS_HUSH
depends on HUSH
config BASH_IS_HUSH
bool "hush"
config FEATURE_BASH_IS_NONE
config BASH_IS_NONE
bool "none"
endchoice
config SH_MATH_SUPPORT
INSERT
config FEATURE_SH_MATH
bool "POSIX math support"
default y
depends on ASH || HUSH
depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
help
Enable math support in the shell via $((...)) syntax.
config SH_MATH_SUPPORT_64
config FEATURE_SH_MATH_64
bool "Extend POSIX math support to 64 bit"
default y
depends on SH_MATH_SUPPORT
depends on FEATURE_SH_MATH
help
Enable 64-bit math support in the shell. This will make the shell
slightly larger, but will allow computation with very large numbers.
@@ -81,14 +78,14 @@ config SH_MATH_SUPPORT_64
config FEATURE_SH_EXTRA_QUIET
bool "Hide message on interactive shell startup"
default y
depends on HUSH || ASH
depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
help
Remove the busybox introduction when starting a shell.
config FEATURE_SH_STANDALONE
bool "Standalone shell"
default n
depends on (HUSH || ASH)
depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
help
This option causes busybox shells to use busybox applets
in preference to executables in the PATH whenever possible. For
@@ -121,7 +118,7 @@ config FEATURE_SH_STANDALONE
config FEATURE_SH_NOFORK
bool "Run 'nofork' applets directly"
default n
depends on (HUSH || ASH)
depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
help
This option causes busybox shells to not execute typical
fork/exec/wait sequence, but call <applet>_main directly,
@@ -139,7 +136,7 @@ config FEATURE_SH_NOFORK
config FEATURE_SH_HISTFILESIZE
bool "Use $HISTFILESIZE"
default y
depends on HUSH || ASH
depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
help
This option makes busybox shells to use $HISTFILESIZE variable
to set shell history size. Note that its max value is capped
+1 -1
View File
@@ -8,4 +8,4 @@ lib-y:=
INSERT
lib-$(CONFIG_SH_MATH_SUPPORT) += math.o
lib-$(CONFIG_FEATURE_SH_MATH) += math.o
+185 -172
View File
@@ -15,6 +15,140 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config ASH
//config: bool "ash"
//config: default y
//config: depends on !NOMMU
//config: help
//config: Tha 'ash' shell adds about 60k in the default configuration and is
//config: the most complete and most pedantically correct shell included with
//config: busybox. This shell is actually a derivative of the Debian 'dash'
//config: shell (by Herbert Xu), which was created by porting the 'ash' shell
//config: (written by Kenneth Almquist) from NetBSD.
//config:
//config:config ASH_OPTIMIZE_FOR_SIZE
//config: bool "Optimize for size instead of speed"
//config: default y
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help
//config: Compile ash for reduced size at the price of speed.
//config:
//config:config ASH_INTERNAL_GLOB
//config: bool "Use internal glob() implementation"
//config: default y # Y is bigger, but because of uclibc glob() bug, let Y be default for now
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help
//config: Do not use glob() function from libc, use internal implementation.
//config: Use this if you are getting "glob.h: No such file or directory"
//config: or similar build errors.
//config:
//config:config ASH_RANDOM_SUPPORT
//config: bool "Pseudorandom generator and $RANDOM variable"
//config: default y
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help
//config: Enable pseudorandom generator and dynamic variable "$RANDOM".
//config: Each read of "$RANDOM" will generate a new pseudorandom value.
//config: You can reset the generator by using a specified start value.
//config: After "unset RANDOM" the generator will switch off and this
//config: variable will no longer have special treatment.
//config:
//config:config ASH_EXPAND_PRMT
//config: bool "Expand prompt string"
//config: default y
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help
//config: "PS#" may contain volatile content, such as backquote commands.
//config: This option recreates the prompt string from the environment
//config: variable each time it is displayed.
//config:
//config:config ASH_BASH_COMPAT
//config: bool "bash-compatible extensions"
//config: default y
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help
//config: Enable bash-compatible extensions.
//config:
//config:config ASH_IDLE_TIMEOUT
//config: bool "Idle timeout variable"
//config: default n
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help
//config: Enables bash-like auto-logout after $TMOUT seconds of idle time.
//config:
//config:config ASH_JOB_CONTROL
//config: bool "Job control"
//config: default y
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help
//config: Enable job control in the ash shell.
//config:
//config:config ASH_ALIAS
//config: bool "Alias support"
//config: default y
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help
//config: Enable alias support in the ash shell.
//config:
//config:config ASH_GETOPTS
//config: bool "Builtin getopt to parse positional parameters"
//config: default y
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help
//config: Enable support for getopts builtin in ash.
//config:
//config:config ASH_BUILTIN_ECHO
//config: bool "Builtin version of 'echo'"
//config: default y
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help
//config: Enable support for echo builtin in ash.
//config:
//config:config ASH_BUILTIN_PRINTF
//config: bool "Builtin version of 'printf'"
//config: default y
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help
//config: Enable support for printf builtin in ash.
//config:
//config:config ASH_BUILTIN_TEST
//config: bool "Builtin version of 'test'"
//config: default y
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help
//config: Enable support for test builtin in ash.
//config:
//config:config ASH_HELP
//config: bool "help builtin"
//config: default y
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help
//config: Enable help builtin in ash.
//config:
//config:config ASH_CMDCMD
//config: bool "'command' command to override shell builtins"
//config: default y
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help
//config: Enable support for the ash 'command' builtin, which allows
//config: you to run the specified command with the specified arguments,
//config: even when there is an ash builtin command with the same name.
//config:
//config:config ASH_MAIL
//config: bool "Check for new mail on interactive shells"
//config: default y
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help
//config: Enable "check for new mail" function in the ash shell.
//applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP))
//applet:IF_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, ash))
//applet:IF_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, ash))
//kbuild:lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o shell_common.o
//kbuild:lib-$(CONFIG_SH_IS_ASH) += ash.o ash_ptr_hack.o shell_common.o
//kbuild:lib-$(CONFIG_BASH_IS_ASH) += ash.o ash_ptr_hack.o shell_common.o
//kbuild:lib-$(CONFIG_ASH_RANDOM_SUPPORT) += random.o
/*
* The following should be set to reflect the type of system you have:
@@ -51,13 +185,24 @@
# define ENABLE_ASH_INTERNAL_GLOB 1
#endif
#if !ENABLE_ASH_INTERNAL_GLOB && defined(__UCLIBC__)
# error uClibc glob() is buggy, use ASH_INTERNAL_GLOB.
# error The bug is: for "$PWD"/<pattern> ash will escape e.g. dashes in "$PWD"
# error with backslash, even ones which do not need to be: "/a-b" -> "/a\-b"
# error glob() should unbackslash them and match. uClibc does not unbackslash,
# error fails to match dirname, subsequently not expanding <pattern> in it.
// Testcase:
// if (glob("/etc/polkit\\-1", 0, NULL, &pglob)) - this returns 0 on uclibc, no bug
// if (glob("/etc/polkit\\-1/*", 0, NULL, &pglob)) printf("uclibc bug!\n");
#endif
#if !ENABLE_ASH_INTERNAL_GLOB
# include <glob.h>
#endif
#include "unicode.h"
#include "shell_common.h"
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
# include "math.h"
#endif
#if ENABLE_ASH_RANDOM_SUPPORT
@@ -86,140 +231,6 @@
# error "Do not even bother, ash will not run on NOMMU machine"
#endif
//config:config ASH
//config: bool "ash"
//config: default y
//config: depends on !NOMMU
//config: help
//config: Tha 'ash' shell adds about 60k in the default configuration and is
//config: the most complete and most pedantically correct shell included with
//config: busybox. This shell is actually a derivative of the Debian 'dash'
//config: shell (by Herbert Xu), which was created by porting the 'ash' shell
//config: (written by Kenneth Almquist) from NetBSD.
//config:
//config:config ASH_OPTIMIZE_FOR_SIZE
//config: bool "Optimize for size instead of speed"
//config: default y
//config: depends on ASH
//config: help
//config: Compile ash for reduced size at the price of speed.
//config:
//config:config ASH_INTERNAL_GLOB
//config: bool "Use internal glob() implementation"
//config: default n
//config: depends on ASH
//config: help
//config: Do not use glob() function from libc, use internal implementation.
//config: Use this if you are getting "glob.h: No such file or directory"
//config: or similar build errors.
//config:
//config:config ASH_RANDOM_SUPPORT
//config: bool "Pseudorandom generator and $RANDOM variable"
//config: default y
//config: depends on ASH
//config: help
//config: Enable pseudorandom generator and dynamic variable "$RANDOM".
//config: Each read of "$RANDOM" will generate a new pseudorandom value.
//config: You can reset the generator by using a specified start value.
//config: After "unset RANDOM" the generator will switch off and this
//config: variable will no longer have special treatment.
//config:
//config:config ASH_EXPAND_PRMT
//config: bool "Expand prompt string"
//config: default y
//config: depends on ASH
//config: help
//config: "PS#" may contain volatile content, such as backquote commands.
//config: This option recreates the prompt string from the environment
//config: variable each time it is displayed.
//config:
//config:config ASH_BASH_COMPAT
//config: bool "bash-compatible extensions"
//config: default y
//config: depends on ASH
//config: help
//config: Enable bash-compatible extensions.
//config:
//config:config ASH_IDLE_TIMEOUT
//config: bool "Idle timeout variable"
//config: default n
//config: depends on ASH
//config: help
//config: Enables bash-like auto-logout after $TMOUT seconds of idle time.
//config:
//config:config ASH_JOB_CONTROL
//config: bool "Job control"
//config: default y
//config: depends on ASH
//config: help
//config: Enable job control in the ash shell.
//config:
//config:config ASH_ALIAS
//config: bool "Alias support"
//config: default y
//config: depends on ASH
//config: help
//config: Enable alias support in the ash shell.
//config:
//config:config ASH_GETOPTS
//config: bool "Builtin getopt to parse positional parameters"
//config: default y
//config: depends on ASH
//config: help
//config: Enable support for getopts builtin in ash.
//config:
//config:config ASH_BUILTIN_ECHO
//config: bool "Builtin version of 'echo'"
//config: default y
//config: depends on ASH
//config: help
//config: Enable support for echo builtin in ash.
//config:
//config:config ASH_BUILTIN_PRINTF
//config: bool "Builtin version of 'printf'"
//config: default y
//config: depends on ASH
//config: help
//config: Enable support for printf builtin in ash.
//config:
//config:config ASH_BUILTIN_TEST
//config: bool "Builtin version of 'test'"
//config: default y
//config: depends on ASH
//config: help
//config: Enable support for test builtin in ash.
//config:
//config:config ASH_HELP
//config: bool "help builtin"
//config: default y
//config: depends on ASH
//config: help
//config: Enable help builtin in ash.
//config:
//config:config ASH_CMDCMD
//config: bool "'command' command to override shell builtins"
//config: default y
//config: depends on ASH
//config: help
//config: Enable support for the ash 'command' builtin, which allows
//config: you to run the specified command with the specified arguments,
//config: even when there is an ash builtin command with the same name.
//config:
//config:config ASH_MAIL
//config: bool "Check for new mail on interactive shells"
//config: default n
//config: depends on ASH
//config: help
//config: Enable "check for new mail" function in the ash shell.
//config:
//applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP))
//applet:IF_FEATURE_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, sh))
//applet:IF_FEATURE_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, bash))
//kbuild:lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o shell_common.o
//kbuild:lib-$(CONFIG_ASH_RANDOM_SUPPORT) += random.o
/* ============ Hash table sizes. Configurable. */
@@ -1273,6 +1284,8 @@ ash_msg_and_raise_error(const char *msg, ...)
{
va_list ap;
exitstatus = 2;
va_start(ap, msg);
ash_vmsg_and_raise(EXERROR, msg, ap);
/* NOTREACHED */
@@ -2135,6 +2148,7 @@ lookupvar(const char *name)
return NULL;
}
#if ENABLE_UNICODE_SUPPORT
static void
reinit_unicode_for_ash(void)
{
@@ -2151,6 +2165,9 @@ reinit_unicode_for_ash(void)
reinit_unicode(s);
}
}
#else
# define reinit_unicode_for_ash() ((void)0)
#endif
/*
* Search the environment of a builtin command.
@@ -2732,7 +2749,7 @@ pwdcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
#define USE_SIT_FUNCTION ENABLE_ASH_OPTIMIZE_FOR_SIZE
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
# define SIT_ITEM(a,b,c,d) (a | (b << 4) | (c << 8) | (d << 12))
#else
# define SIT_ITEM(a,b,c,d) (a | (b << 4) | (c << 8))
@@ -3120,7 +3137,7 @@ static const uint8_t syntax_index_table[] ALIGN1 = {
({ \
if ((c) < 0 || (c) > (PEOF + ENABLE_ASH_ALIAS)) \
bb_error_msg_and_die("line:%d c:%d", __LINE__, (c)); \
if ((syntax) < 0 || (syntax) > (2 + ENABLE_SH_MATH_SUPPORT)) \
if ((syntax) < 0 || (syntax) > (2 + ENABLE_FEATURE_SH_MATH)) \
bb_error_msg_and_die("line:%d c:%d", __LINE__, (c)); \
((S_I_T[syntax_index_table[c]] >> ((syntax)*4)) & 0xf); \
})
@@ -4478,7 +4495,7 @@ cmdputs(const char *s)
case CTLBACKQ:
str = "$(...)";
goto dostr;
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
case CTLARI:
str = "$((";
goto dostr;
@@ -5409,11 +5426,11 @@ redirect(union node *redir, int flags)
/* Careful to not accidentally "save"
* to the same fd as right side fd in N>&M */
int minfd = right_fd < 10 ? 10 : right_fd + 1;
#if defined(F_DUPFD_CLOEXEC)
i = fcntl(fd, F_DUPFD_CLOEXEC, minfd);
#else
i = fcntl(fd, F_DUPFD, minfd);
/* You'd expect copy to be CLOEXECed. Currently these extra "saved" fds
* are closed in popredir() in the child, preventing them from leaking
* into child. (popredir() also cleans up the mess in case of failures)
*/
#endif
if (i == -1) {
i = errno;
if (i != EBADF) {
@@ -5428,6 +5445,9 @@ redirect(union node *redir, int flags)
remember_to_close:
i = CLOSED;
} else { /* fd is open, save its copy */
#if !defined(F_DUPFD_CLOEXEC)
fcntl(i, F_SETFD, FD_CLOEXEC);
#endif
/* "exec fd>&-" should not close fds
* which point to script file(s).
* Force them to be restored afterwards */
@@ -5538,7 +5558,7 @@ redirectsafe(union node *redir, int flags)
* We have to deal with backquotes, shell variables, and file metacharacters.
*/
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
static arith_t
ash_arith(const char *s)
{
@@ -5626,7 +5646,7 @@ static struct arglist exparg;
/*
* Our own itoa().
*/
#if !ENABLE_SH_MATH_SUPPORT
#if !ENABLE_FEATURE_SH_MATH
/* cvtnum() is used even if math support is off (to prepare $? values and such) */
typedef long arith_t;
# define ARITH_FMT "%ld"
@@ -6139,7 +6159,7 @@ expbackq(union node *cmd, int flag)
stackblock() + startloc));
}
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
/*
* Expand arithmetic expression. Backup to start of expression,
* evaluate, place result in (backed up) result, adjust string position.
@@ -6221,7 +6241,7 @@ argstr(char *p, int flags, struct strlist *var_str_list)
CTLESC,
CTLVAR,
CTLBACKQ,
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
CTLENDARI,
#endif
'\0'
@@ -6257,7 +6277,7 @@ argstr(char *p, int flags, struct strlist *var_str_list)
c = p[length];
if (c) {
if (!(c & 0x80)
IF_SH_MATH_SUPPORT(|| c == CTLENDARI)
IF_FEATURE_SH_MATH(|| c == CTLENDARI)
) {
/* c == '=' || c == ':' || c == CTLENDARI */
length++;
@@ -6337,7 +6357,7 @@ argstr(char *p, int flags, struct strlist *var_str_list)
expbackq(argbackq->n, flags | inquotes);
argbackq = argbackq->next;
goto start;
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
case CTLENDARI:
p--;
expari(flags | inquotes);
@@ -9256,7 +9276,7 @@ static int helpcmd(int, char **) FAST_FUNC;
#if MAX_HISTORY
static int historycmd(int, char **) FAST_FUNC;
#endif
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
static int letcmd(int, char **) FAST_FUNC;
#endif
static int readcmd(int, char **) FAST_FUNC;
@@ -9336,7 +9356,7 @@ static const struct builtincmd builtintab[] = {
{ BUILTIN_REGULAR "jobs" , jobscmd },
{ BUILTIN_REGULAR "kill" , killcmd },
#endif
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
{ BUILTIN_NOSPEC "let" , letcmd },
#endif
{ BUILTIN_ASSIGN "local" , localcmd },
@@ -9573,11 +9593,13 @@ evalcommand(union node *cmd, int flags)
}
if (status) {
bail:
exitstatus = status;
/* We have a redirection error. */
if (spclbltin > 0)
raise_exception(EXERROR);
bail:
exitstatus = status;
goto out;
}
@@ -11385,13 +11407,13 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
smallint quotef;
smallint dblquote;
smallint oldstyle;
IF_SH_MATH_SUPPORT(smallint prevsyntax;) /* syntax before arithmetic */
IF_FEATURE_SH_MATH(smallint prevsyntax;) /* syntax before arithmetic */
#if ENABLE_ASH_EXPAND_PRMT
smallint pssyntax; /* we are expanding a prompt string */
#endif
int varnest; /* levels of variables expansion */
IF_SH_MATH_SUPPORT(int arinest;) /* levels of arithmetic expansion */
IF_SH_MATH_SUPPORT(int parenlevel;) /* levels of parens in arithmetic */
IF_FEATURE_SH_MATH(int arinest;) /* levels of arithmetic expansion */
IF_FEATURE_SH_MATH(int parenlevel;) /* levels of parens in arithmetic */
int dqvarnest; /* levels of variables expansion within double quotes */
IF_ASH_BASH_COMPAT(smallint bash_dollar_squote = 0;)
@@ -11399,7 +11421,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
startlinno = g_parsefile->linno;
bqlist = NULL;
quotef = 0;
IF_SH_MATH_SUPPORT(prevsyntax = 0;)
IF_FEATURE_SH_MATH(prevsyntax = 0;)
#if ENABLE_ASH_EXPAND_PRMT
pssyntax = (syntax == PSSYNTAX);
if (pssyntax)
@@ -11407,8 +11429,8 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
#endif
dblquote = (syntax == DQSYNTAX);
varnest = 0;
IF_SH_MATH_SUPPORT(arinest = 0;)
IF_SH_MATH_SUPPORT(parenlevel = 0;)
IF_FEATURE_SH_MATH(arinest = 0;)
IF_FEATURE_SH_MATH(parenlevel = 0;)
dqvarnest = 0;
STARTSTACKSTR(out);
@@ -11515,7 +11537,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
}
USTPUTC(c, out);
break;
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
case CLP: /* '(' in arithmetic */
parenlevel++;
USTPUTC(c, out);
@@ -11566,7 +11588,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
} /* for (;;) */
endword:
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
if (syntax == ARISYNTAX)
raise_error_syntax("missing '))'");
#endif
@@ -11745,7 +11767,7 @@ parsesub: {
} else if (c == '(') {
/* $(command) or $((arith)) */
if (pgetc_eatbnl() == '(') {
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
PARSEARITH();
#else
raise_error_syntax("you disabled math support for $((arith)) syntax");
@@ -12000,7 +12022,7 @@ parsebackq: {
goto parsebackq_newreturn;
}
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
/*
* Parse an arithmetic expansion (indicate start of one and set state)
*/
@@ -13037,7 +13059,7 @@ timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
return 0;
}
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
/*
* The let builtin. Partially stolen from GNU Bash, the Bourne Again SHell.
* Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
@@ -13292,15 +13314,6 @@ init(void)
//usage:#define ash_full_usage "\n\n"
//usage: "Unix shell interpreter"
//usage:#if ENABLE_FEATURE_SH_IS_ASH
//usage:# define sh_trivial_usage ash_trivial_usage
//usage:# define sh_full_usage ash_full_usage
//usage:#endif
//usage:#if ENABLE_FEATURE_BASH_IS_ASH
//usage:# define bash_trivial_usage ash_trivial_usage
//usage:# define bash_full_usage ash_full_usage
//usage:#endif
/*
* Process the shell command line arguments.
*/
+4
View File
@@ -0,0 +1,4 @@
./test.sh: line 1: syntax error: unexpected ")"
Done:2
./exitcode2.tests: line 11: can't open does_not_exist: no such file
Done:1
+12
View File
@@ -0,0 +1,12 @@
# syntax error should return status 2
cat >test.sh <<EOF
)
EOF
chmod +x test.sh
$THIS_SH ./test.sh
echo Done:$?
rm -f test.sh
# redirection error with special builtin should return status 1
(eval cat <does_not_exist)
echo Done:$?
@@ -0,0 +1,6 @@
4
4
4
4
4
4
+10
View File
@@ -0,0 +1,10 @@
# Each of these should show only four lines:
# fds 0,1,2 are stdio; fd 3 is open by opendir() in ls.
# This test detects bugs where redirects leave stray open fds.
ls -1 /proc/self/fd | wc -l
ls -1 /proc/self/fd >/proc/self/fd/1 | wc -l
ls -1 /proc/self/fd >/proc/self/fd/1 2>&1 | wc -l
echo "`ls -1 /proc/self/fd `" | wc -l
echo "`ls -1 /proc/self/fd >/proc/self/fd/1 `" | wc -l
echo "`ls -1 /proc/self/fd >/proc/self/fd/1 2>&1 `" | wc -l
+170 -176
View File
@@ -82,6 +82,161 @@
* $ "export" i=`echo 'aaa bbb'`; echo "$i"
* aaa
*/
//config:config HUSH
//config: bool "hush"
//config: default y
//config: help
//config: hush is a small shell (25k). It handles the normal flow control
//config: constructs such as if/then/elif/else/fi, for/in/do/done, while loops,
//config: case/esac. Redirections, here documents, $((arithmetic))
//config: and functions are supported.
//config:
//config: It will compile and work on no-mmu systems.
//config:
//config: It does not handle select, aliases, tilde expansion,
//config: &>file and >&file redirection of stdout+stderr.
//config:
//config:config HUSH_BASH_COMPAT
//config: bool "bash-compatible extensions"
//config: default y
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help
//config: Enable bash-compatible extensions.
//config:
//config:config HUSH_BRACE_EXPANSION
//config: bool "Brace expansion"
//config: default y
//config: depends on HUSH_BASH_COMPAT
//config: help
//config: Enable {abc,def} extension.
//config:
//config:config HUSH_HELP
//config: bool "help builtin"
//config: default y
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help
//config: Enable help builtin in hush. Code size + ~1 kbyte.
//config:
//config:config HUSH_INTERACTIVE
//config: bool "Interactive mode"
//config: default y
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help
//config: Enable interactive mode (prompt and command editing).
//config: Without this, hush simply reads and executes commands
//config: from stdin just like a shell script from a file.
//config: No prompt, no PS1/PS2 magic shell variables.
//config:
//config:config HUSH_SAVEHISTORY
//config: bool "Save command history to .hush_history"
//config: default y
//config: depends on HUSH_INTERACTIVE && FEATURE_EDITING_SAVEHISTORY
//config: help
//config: Enable history saving in hush.
//config:
//config:config HUSH_JOB
//config: bool "Job control"
//config: default y
//config: depends on HUSH_INTERACTIVE
//config: help
//config: Enable job control: Ctrl-Z backgrounds, Ctrl-C interrupts current
//config: command (not entire shell), fg/bg builtins work. Without this option,
//config: "cmd &" still works by simply spawning a process and immediately
//config: prompting for next command (or executing next command in a script),
//config: but no separate process group is formed.
//config:
//config:config HUSH_TICK
//config: bool "Process substitution"
//config: default y
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help
//config: Enable process substitution `command` and $(command) in hush.
//config:
//config:config HUSH_IF
//config: bool "Support if/then/elif/else/fi"
//config: default y
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help
//config: Enable if/then/elif/else/fi in hush.
//config:
//config:config HUSH_LOOPS
//config: bool "Support for, while and until loops"
//config: default y
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help
//config: Enable for, while and until loops in hush.
//config:
//config:config HUSH_CASE
//config: bool "Support case ... esac statement"
//config: default y
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help
//config: Enable case ... esac statement in hush. +400 bytes.
//config:
//config:config HUSH_FUNCTIONS
//config: bool "Support funcname() { commands; } syntax"
//config: default y
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help
//config: Enable support for shell functions in hush. +800 bytes.
//config:
//config:config HUSH_LOCAL
//config: bool "Support local builtin"
//config: default y
//config: depends on HUSH_FUNCTIONS
//config: help
//config: Enable support for local variables in functions.
//config:
//config:config HUSH_RANDOM_SUPPORT
//config: bool "Pseudorandom generator and $RANDOM variable"
//config: default y
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help
//config: Enable pseudorandom generator and dynamic variable "$RANDOM".
//config: Each read of "$RANDOM" will generate a new pseudorandom value.
//config:
//config:config HUSH_EXPORT_N
//config: bool "Support 'export -n' option"
//config: default y
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help
//config: export -n unexports variables. It is a bash extension.
//config:
//config:config HUSH_MODE_X
//config: bool "Support 'hush -x' option and 'set -x' command"
//config: default y
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help
//config: This instructs hush to print commands before execution.
//config: Adds ~300 bytes.
//config:
//config:config MSH
//config: bool "msh (deprecated: aliased to hush)"
//config: default n
//config: select HUSH
//config: help
//config: msh is deprecated and will be removed, please migrate to hush.
//applet:IF_HUSH(APPLET(hush, BB_DIR_BIN, BB_SUID_DROP))
//applet:IF_MSH(APPLET_ODDNAME(msh, hush, BB_DIR_BIN, BB_SUID_DROP, hush))
//applet:IF_SH_IS_HUSH(APPLET_ODDNAME(sh, hush, BB_DIR_BIN, BB_SUID_DROP, hush))
//applet:IF_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, BB_DIR_BIN, BB_SUID_DROP, hush))
//kbuild:lib-$(CONFIG_HUSH) += hush.o match.o shell_common.o
//kbuild:lib-$(CONFIG_SH_IS_HUSH) += hush.o match.o shell_common.o
//kbuild:lib-$(CONFIG_BASH_IS_HUSH) += hush.o match.o shell_common.o
//kbuild:lib-$(CONFIG_HUSH_RANDOM_SUPPORT) += random.o
/* -i (interactive) and -s (read stdin) are also accepted,
* but currently do nothing, therefore aren't shown in help.
* NOMMU-specific options are not meant to be used by users,
* therefore we don't show them either.
*/
//usage:#define hush_trivial_usage
//usage: "[-nxl] [-c 'SCRIPT' [ARG0 [ARGS]] / FILE [ARGS]]"
//usage:#define hush_full_usage "\n\n"
//usage: "Unix shell interpreter"
#if !(defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \
|| defined(__APPLE__) \
)
@@ -111,172 +266,6 @@
# define PIPE_BUF 4096 /* amount of buffering in a pipe */
#endif
//config:config HUSH
//config: bool "hush"
//config: default y
//config: help
//config: hush is a small shell (25k). It handles the normal flow control
//config: constructs such as if/then/elif/else/fi, for/in/do/done, while loops,
//config: case/esac. Redirections, here documents, $((arithmetic))
//config: and functions are supported.
//config:
//config: It will compile and work on no-mmu systems.
//config:
//config: It does not handle select, aliases, tilde expansion,
//config: &>file and >&file redirection of stdout+stderr.
//config:
//config:config HUSH_BASH_COMPAT
//config: bool "bash-compatible extensions"
//config: default y
//config: depends on HUSH
//config: help
//config: Enable bash-compatible extensions.
//config:
//config:config HUSH_BRACE_EXPANSION
//config: bool "Brace expansion"
//config: default y
//config: depends on HUSH_BASH_COMPAT
//config: help
//config: Enable {abc,def} extension.
//config:
//config:config HUSH_HELP
//config: bool "help builtin"
//config: default y
//config: depends on HUSH
//config: help
//config: Enable help builtin in hush. Code size + ~1 kbyte.
//config:
//config:config HUSH_INTERACTIVE
//config: bool "Interactive mode"
//config: default y
//config: depends on HUSH
//config: help
//config: Enable interactive mode (prompt and command editing).
//config: Without this, hush simply reads and executes commands
//config: from stdin just like a shell script from a file.
//config: No prompt, no PS1/PS2 magic shell variables.
//config:
//config:config HUSH_SAVEHISTORY
//config: bool "Save command history to .hush_history"
//config: default y
//config: depends on HUSH_INTERACTIVE && FEATURE_EDITING_SAVEHISTORY
//config: help
//config: Enable history saving in hush.
//config:
//config:config HUSH_JOB
//config: bool "Job control"
//config: default y
//config: depends on HUSH_INTERACTIVE
//config: help
//config: Enable job control: Ctrl-Z backgrounds, Ctrl-C interrupts current
//config: command (not entire shell), fg/bg builtins work. Without this option,
//config: "cmd &" still works by simply spawning a process and immediately
//config: prompting for next command (or executing next command in a script),
//config: but no separate process group is formed.
//config:
//config:config HUSH_TICK
//config: bool "Process substitution"
//config: default y
//config: depends on HUSH
//config: help
//config: Enable process substitution `command` and $(command) in hush.
//config:
//config:config HUSH_IF
//config: bool "Support if/then/elif/else/fi"
//config: default y
//config: depends on HUSH
//config: help
//config: Enable if/then/elif/else/fi in hush.
//config:
//config:config HUSH_LOOPS
//config: bool "Support for, while and until loops"
//config: default y
//config: depends on HUSH
//config: help
//config: Enable for, while and until loops in hush.
//config:
//config:config HUSH_CASE
//config: bool "Support case ... esac statement"
//config: default y
//config: depends on HUSH
//config: help
//config: Enable case ... esac statement in hush. +400 bytes.
//config:
//config:config HUSH_FUNCTIONS
//config: bool "Support funcname() { commands; } syntax"
//config: default y
//config: depends on HUSH
//config: help
//config: Enable support for shell functions in hush. +800 bytes.
//config:
//config:config HUSH_LOCAL
//config: bool "Support local builtin"
//config: default y
//config: depends on HUSH_FUNCTIONS
//config: help
//config: Enable support for local variables in functions.
//config:
//config:config HUSH_RANDOM_SUPPORT
//config: bool "Pseudorandom generator and $RANDOM variable"
//config: default y
//config: depends on HUSH
//config: help
//config: Enable pseudorandom generator and dynamic variable "$RANDOM".
//config: Each read of "$RANDOM" will generate a new pseudorandom value.
//config:
//config:config HUSH_EXPORT_N
//config: bool "Support 'export -n' option"
//config: default y
//config: depends on HUSH
//config: help
//config: export -n unexports variables. It is a bash extension.
//config:
//config:config HUSH_MODE_X
//config: bool "Support 'hush -x' option and 'set -x' command"
//config: default y
//config: depends on HUSH
//config: help
//config: This instructs hush to print commands before execution.
//config: Adds ~300 bytes.
//config:
//config:config MSH
//config: bool "msh (deprecated: aliased to hush)"
//config: default n
//config: select HUSH
//config: help
//config: msh is deprecated and will be removed, please migrate to hush.
//config:
//applet:IF_HUSH(APPLET(hush, BB_DIR_BIN, BB_SUID_DROP))
//applet:IF_MSH(APPLET(msh, BB_DIR_BIN, BB_SUID_DROP))
//applet:IF_FEATURE_SH_IS_HUSH(APPLET_ODDNAME(sh, hush, BB_DIR_BIN, BB_SUID_DROP, sh))
//applet:IF_FEATURE_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, BB_DIR_BIN, BB_SUID_DROP, bash))
//kbuild:lib-$(CONFIG_HUSH) += hush.o match.o shell_common.o
//kbuild:lib-$(CONFIG_HUSH_RANDOM_SUPPORT) += random.o
/* -i (interactive) and -s (read stdin) are also accepted,
* but currently do nothing, therefore aren't shown in help.
* NOMMU-specific options are not meant to be used by users,
* therefore we don't show them either.
*/
//usage:#define hush_trivial_usage
//usage: "[-nxl] [-c 'SCRIPT' [ARG0 [ARGS]] / FILE [ARGS]]"
//usage:#define hush_full_usage "\n\n"
//usage: "Unix shell interpreter"
//usage:#define msh_trivial_usage hush_trivial_usage
//usage:#define msh_full_usage hush_full_usage
//usage:#if ENABLE_FEATURE_SH_IS_HUSH
//usage:# define sh_trivial_usage hush_trivial_usage
//usage:# define sh_full_usage hush_full_usage
//usage:#endif
//usage:#if ENABLE_FEATURE_BASH_IS_HUSH
//usage:# define bash_trivial_usage hush_trivial_usage
//usage:# define bash_full_usage hush_full_usage
//usage:#endif
/* Build knobs */
#define LEAK_HUNTING 0
@@ -1148,6 +1137,9 @@ static void syntax_error_unexpected_ch(unsigned lineno UNUSED_PARAM, int ch)
char msg[2];
msg[0] = ch;
msg[1] = '\0';
#if HUSH_DEBUG >= 2
bb_error_msg("hush.c:%u", lineno);
#endif
bb_error_msg("syntax error: unexpected %s", ch == EOF ? "EOF" : msg);
}
@@ -4011,7 +4003,7 @@ static int i_peek_and_eat_bkslash_nl(struct in_str *input)
}
}
#if ENABLE_HUSH_TICK || ENABLE_SH_MATH_SUPPORT || ENABLE_HUSH_DOLLAR_OPS
#if ENABLE_HUSH_TICK || ENABLE_FEATURE_SH_MATH || ENABLE_HUSH_DOLLAR_OPS
/* Subroutines for copying $(...) and `...` things */
static int add_till_backquote(o_string *dest, struct in_str *input, int in_dquote);
/* '...' */
@@ -4179,7 +4171,7 @@ static int add_till_closing_bracket(o_string *dest, struct in_str *input, unsign
}
return ch;
}
#endif /* ENABLE_HUSH_TICK || ENABLE_SH_MATH_SUPPORT || ENABLE_HUSH_DOLLAR_OPS */
#endif /* ENABLE_HUSH_TICK || ENABLE_FEATURE_SH_MATH || ENABLE_HUSH_DOLLAR_OPS */
/* Return code: 0 for OK, 1 for syntax error */
#if BB_MMU
@@ -4333,13 +4325,13 @@ static int parse_dollar(o_string *as_string,
o_addchr(dest, SPECIAL_VAR_SYMBOL);
break;
}
#if ENABLE_SH_MATH_SUPPORT || ENABLE_HUSH_TICK
#if ENABLE_FEATURE_SH_MATH || ENABLE_HUSH_TICK
case '(': {
unsigned pos;
ch = i_getch(input);
nommu_addchr(as_string, ch);
# if ENABLE_SH_MATH_SUPPORT
# if ENABLE_FEATURE_SH_MATH
if (i_peek_and_eat_bkslash_nl(input) == '(') {
ch = i_getch(input);
nommu_addchr(as_string, ch);
@@ -5008,7 +5000,8 @@ static struct pipe *parse_stream(char **pstring,
* if we see {, we call parse_group(..., end_trigger='}')
* and it will match } earlier (not here). */
syntax_error_unexpected_ch(ch);
goto parse_error;
G.last_exitcode = 2;
goto parse_error1;
default:
if (HUSH_DEBUG)
bb_error_msg_and_die("BUG: unexpected %c\n", ch);
@@ -5016,6 +5009,8 @@ static struct pipe *parse_stream(char **pstring,
} /* while (1) */
parse_error:
G.last_exitcode = 1;
parse_error1:
{
struct parse_context *pctx;
IF_HAS_KEYWORDS(struct parse_context *p2;)
@@ -5049,7 +5044,6 @@ static struct pipe *parse_stream(char **pstring,
} while (HAS_KEYWORDS && pctx);
o_free(&dest);
G.last_exitcode = 1;
#if !BB_MMU
if (pstring)
*pstring = NULL;
@@ -5217,7 +5211,7 @@ static char *encode_then_expand_string(const char *str, int process_bkslash, int
return exp_str;
}
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
static arith_t expand_and_evaluate_arith(const char *arg, const char **errmsg_p)
{
arith_state_t math_state;
@@ -5469,7 +5463,7 @@ static NOINLINE const char *expand_one_var(char **to_be_freed_pp, char *arg, cha
}
#endif
else if (exp_op == ':') {
#if ENABLE_HUSH_BASH_COMPAT && ENABLE_SH_MATH_SUPPORT
#if ENABLE_HUSH_BASH_COMPAT && ENABLE_FEATURE_SH_MATH
/* It's ${var:N[:M]} bashism.
* Note that in encoded form it has TWO parts:
* var:N<SPECIAL_VAR_SYMBOL>M<SPECIAL_VAR_SYMBOL>
@@ -5604,7 +5598,7 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg)
#if ENABLE_HUSH_TICK
o_string subst_result = NULL_O_STRING;
#endif
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
char arith_buf[sizeof(arith_t)*3 + 2];
#endif
@@ -5698,7 +5692,7 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg)
val = subst_result.data;
goto store_val;
#endif
#if ENABLE_SH_MATH_SUPPORT
#if ENABLE_FEATURE_SH_MATH
case '+': { /* <SPECIAL_VAR_SYMBOL>+cmd<SPECIAL_VAR_SYMBOL> */
arith_t res;
@@ -0,0 +1,4 @@
hush: syntax error: unexpected )
Done:2
hush: can't open 'does_not_exist': No such file or directory
Done:1
+12
View File
@@ -0,0 +1,12 @@
# syntax error should return status 2
cat >test.sh <<EOF
)
EOF
chmod +x test.sh
$THIS_SH ./test.sh
echo Done:$?
rm -f test.sh
# redirection error with special builtin should return status 1
(eval cat <does_not_exist)
echo Done:$?
@@ -0,0 +1,6 @@
4
4
4
4
4
4
+10
View File
@@ -0,0 +1,10 @@
# Each of these should show only four lines:
# fds 0,1,2 are stdio; fd 3 is open by opendir() in ls.
# This test detects bugs where redirects leave stray open fds.
ls -1 /proc/self/fd | wc -l
ls -1 /proc/self/fd >/proc/self/fd/1 | wc -l
ls -1 /proc/self/fd >/proc/self/fd/1 2>&1 | wc -l
echo "`ls -1 /proc/self/fd `" | wc -l
echo "`ls -1 /proc/self/fd >/proc/self/fd/1 `" | wc -l
echo "`ls -1 /proc/self/fd >/proc/self/fd/1 2>&1 `" | wc -l
+1 -1
View File
@@ -63,7 +63,7 @@
PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
#if ENABLE_SH_MATH_SUPPORT_64
#if ENABLE_FEATURE_SH_MATH_64
typedef long long arith_t;
#define ARITH_FMT "%lld"
#define strto_arith_t strtoull
+2 -1
View File
@@ -11,7 +11,8 @@
//config:config LOGREAD
//config: bool "logread"
//config: default y
//config: depends on FEATURE_IPC_SYSLOG
//WRONG: it should be compilable without SYSLOG=y:
//WRONG: depends on FEATURE_IPC_SYSLOG
//config: help
//config: If you enabled Circular Buffer support, you almost
//config: certainly want to enable this feature as well. This