From cf2600c3661c11491a838ef29733583afb6ad968 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 3 Dec 2016 11:49:23 +0100 Subject: install: fix musl problem with dirname Signed-off-by: Denys Vlasenko --- coreutils/install.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/coreutils/install.c b/coreutils/install.c index e68589229..d0dcd0e89 100644 --- a/coreutils/install.c +++ b/coreutils/install.c @@ -209,9 +209,16 @@ int install_main(int argc, char **argv) dest = last; if (opts & OPT_MKDIR_LEADING) { char *ddir = xstrdup(dest); - bb_make_directory(dirname(ddir), 0755, mkdir_flags); - /* errors are not checked. copy_file - * will fail if dir is not created. */ + char *dn = dirname(ddir); + /* musl can return read-only "/" or "." string. + * bb_make_directory needs writable string. + */ + if ((dn[0] != '/' && dn[0] != '.') || dn[1] != '\0') { + bb_make_directory(dn, 0755, mkdir_flags); + /* errors are not checked. copy_file + * will fail if dir is not created. + */ + } free(ddir); } if (isdir) -- cgit v1.2.3-55-g6feb From 718e4fd564fa99eb17281b6a23aef21652f23af5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 3 Dec 2016 12:09:50 +0100 Subject: top: fix help text: with !TERMIOS, no keys are affected top output Signed-off-by: Denys Vlasenko --- procps/top.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/procps/top.c b/procps/top.c index c66cdb764..71207bac1 100644 --- a/procps/top.c +++ b/procps/top.c @@ -1042,7 +1042,9 @@ static unsigned handle_input(unsigned scan_mask, unsigned interval) //usage: "Provide a view of process activity in real time." //usage: "\n""Read the status of all processes from /proc each SECONDS" //usage: "\n""and display a screenful of them." -//usage: "\n""Keys:" +//usage: "\n" +//usage: IF_FEATURE_USE_TERMIOS( +//usage: "Keys:" //usage: "\n"" N/M" //usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/P") //usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/T") @@ -1062,6 +1064,7 @@ static unsigned handle_input(unsigned scan_mask, unsigned interval) //usage: "\n"" Q,^C: exit" //usage: "\n" //usage: "\n""Options:" +//usage: ) //usage: "\n"" -b Batch mode" //usage: "\n"" -n N Exit after N iterations" //usage: "\n"" -d N Delay between updates" -- cgit v1.2.3-55-g6feb From fdb4421e00cc5115cffb55aac79c709a3a5108dd Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 3 Dec 2016 14:06:55 +0100 Subject: README_distro_proposal.txt: writeup about runit adoption Signed-off-by: Denys Vlasenko --- examples/var_service/README_distro_proposal.txt | 291 ++++++++++++++++++++++++ 1 file changed, 291 insertions(+) create mode 100644 examples/var_service/README_distro_proposal.txt diff --git a/examples/var_service/README_distro_proposal.txt b/examples/var_service/README_distro_proposal.txt new file mode 100644 index 000000000..9b3fe04ba --- /dev/null +++ b/examples/var_service/README_distro_proposal.txt @@ -0,0 +1,291 @@ + A distro which already uses runit + +I installed Void Linux, in order to see what do they have. +Xfce desktop looks fairly okay, network is up. +ps tells me they did put X, dbus, NM and udev into runsvdir-supervised tree: + + 1 ? 00:00:01 runit + 623 ? 00:00:00 runsvdir + 629 ? 00:00:00 runsv + 650 tty1 00:00:00 agetty + 630 ? 00:00:00 runsv + 644 ? 00:00:09 NetworkManager + 1737 ? 00:00:00 dhclient + 631 ? 00:00:00 runsv + 639 tty4 00:00:00 agetty + 632 ? 00:00:00 runsv + 640 ? 00:00:00 sshd + 1804 ? 00:00:00 sshd + 1809 pts/3 00:00:00 sh + 1818 pts/3 00:00:00 ps + 633 ? 00:00:00 runsv + 637 tty5 00:00:00 agetty + 634 ? 00:00:00 runsv + 796 ? 00:00:00 dhclient + 635 ? 00:00:00 runsv + 649 ? 00:00:00 uuidd + 636 ? 00:00:00 runsv + 647 ? 00:00:00 acpid + 638 ? 00:00:00 runsv + 652 ? 00:00:00 console-kit-dae + 641 ? 00:00:00 runsv + 651 tty6 00:00:00 agetty + 642 ? 00:00:00 runsv + 660 tty2 00:00:00 agetty + 643 ? 00:00:00 runsv + 657 ? 00:00:02 dbus-daemon + 645 ? 00:00:00 runsv + 658 ? 00:00:00 cgmanager + 648 ? 00:00:00 runsv + 656 tty3 00:00:00 agetty + 653 ? 00:00:00 runsv + 655 ? 00:00:00 lxdm-binary + 698 tty7 00:00:14 Xorg + 729 ? 00:00:00 lxdm-session + 956 ? 00:00:00 sh + 982 ? 00:00:00 xfce4-session + 1006 ? 00:00:04 nm-applet + 654 ? 00:00:00 runsv + 659 ? 00:00:00 udevd + +Here is a link to Vod Linux's wiki: + + https://wiki.voidlinux.eu/Runit + +Void Linux packages install their services as subdirectories of /etc/rc, +such as /etc/sv/sshd, with a script file, "run", and a link +"supervise" -> /run/runit/supervise.sshd + +For sshd, "run" contains: + + #!/bin/sh + ssh-keygen -A >/dev/null 2>&1 # generate host keys if they don't exist + [ -r conf ] && . ./conf + exec /usr/bin/sshd -D $OPTS + +That's it from the POV of the packager. + +This is pretty minimalistic, and yet, it is already distro-specific: +the link to /run/runit/* is conceptually wrong, it requires packagers +to know that /etc/rc should not be mutable and thus they need to use +a different location in filesystem for supervise/ directory. + +I think a good thing would be to require just one file: the "run" script. +The rest should be handled by distro tooling, not by packager. + +A similar issue is arising with logging. It would be ideal if packagers +would not need to know how a particular distro manages logs. +Whatever their daemons print to stdout/stderr, should be automagically logged +in a way distro prefers. + +* * * * * * * * + + Proposed "standard" on how distros should use runit + +The original idea of services-as-directories belongs to D.J.Bernstein (djb), +and his project to implement it is daemontools: https://cr.yp.to/daemontools.html + +There are several reimplementations of daemontools: +- runit: by Gerrit Pape, http://smarden.org/runit/ + (busybox has it included) +- s6: by Laurent Bercot, http://skarnet.org/software/s6/ + + +It is not required that a specific clone should be used. Let evolution work. + + Terminology + +daemon: any long running background program. Common examples are sshd, getty, +ntpd, dhcp client... + +service: same as "daemon" + +service directory: a directory with an executable file (script) named "run" +which (usually) execs daemon (possibly after some preparatory steps). +It should start it not as a child or daemonized process, but by exec'ing it +(inheriting the same PID and the place in the process tree). + +service monitor: a tool which watches a set of service directories. +In daemontools package, it is called "svscan". In runit, it is called +"runsvdir". In s6, it is called "s6-svscan". +Service monitor starts a supervisor for each service directory. +If it dies, it restarts it. If service directory disappears, +service monitor will not be restarted if it dies. +runit's service monitor (runsvdir) sends SIGTERM to supervisors +whose directories disappeared. + +supervisor: a tool which monitors one service directory. +It runs "run" script as its child. It restarts it if it dies. +It can be instructed to start/top/signal its child. +In daemontools package, it is called "supervise". In runit, it is called +"runsv". In s6, it is called "s6-supervise". + +Conceptually, a daemontools clone can be designed such that it does not *have* +the supervisor component: service monitor can directly monitor all its daemons +(for example, this may be a good idea for memory-constrained systems). +However all three existing projects (daemontools/runit/s6) do have a per-service +supervisor process. + +log service: a service which is exclusively tasked with logging +the output of another service. It is implemented as log/ subdirectory +in a service directory. It has the same structure as "normal" +service dirs: it has a "run" script which starts a logging tool. + +If log service exists, stdout of its "main" service is piped +to log service. Stops/restarts of either of them do not sever the pipe +between them. + +If log service exists, daemontools and s6 run a pair of supervisors +(one for the daemon, one for the logger); runit runs only one supervisor +per service, which is handling both of them (presumably this is done +to use fewer processes and thus, fewer resources). + + + User API + +"Users" of service monitoring are authors of software which has daemons. +They need to package their daemons to be installed as services at package +install time. And they need to do this for many distros. +The less distros diverge, the easier users' lives are. + +System-wide service dirs reside in a distro-specific location. +The recommended location is /var/service. (However, since it is not +a mandatory location, avoid depending on it in your run scripts). + +The install location for service dirs is /etc/rc: +when e.g. ntpd daemon is installed, it creates the /etc/rc/ntpd +directory with (minimally) one executable file (script) named "run" +which starts ntpd daemon. It can have other files there. + +At boot, distro should copy /etc/rc/* to a suitable writable +directory (common choice are /var/service, /run/service etc). +It should create log/ directories in each subdirectory +and create "run" files in them with suitable (for this particular distro) +logging tool invocation, unless this directory chose to channel +all logging from all daemons through service monitor process +and log all of them into one file/database/whatever, +in which case log/ directories should not be created. + +It is allowable for a distro to directly use /etc/rc/ as the only +location of its service directories. (For example, +/var/service may be a symlink to /etc/rc). +However, it poses some problems: + +(1) Supervision tools will need to write to subdirectories: +the control of running daemons is implemented via some files and fifos +in automatically created supervise/ subdirectory in each /etc/rc/DIR. + +(2) Creation of a new service can race with the rescanning of /etc/rc/ +by service monitor: service monitor may see a directory with only some files +present. If it attempts to start the service in this state, all sorts +of bad things may happen. This may be worked around by various +heuristics in service monitor which give new service a few seconds +of "grace time" to be fully populated; but this is not yet +implemented in any of three packages. + +Daemons' output file descriptors are handled somewhat awkwardly +by various daemontools implementations. For example, for runit tools, +daemons' stdout goes to wherever runsdir's stdout was directied; +stderr goes to runsvdir, which in turn "rotates" it on its command line +(which is visible in ps output). + +Hopefully this get changed/standardized; while it is not, the "run" file +should start with a + + exec 2>&1 + +command, making stderr equivalent to stdout. +An especially primitive service which does not want its output to be logged +with standard tools can do + + exec >LOGFILE 2>&1 + +or even + + exec >/dev/null 2>&1 + +To prevent creation of distro-specific log/ directory, a service directory +in /etc/rc can contain an empty "log" file. + + + Controlling daemons + +The "svc" tool is available for admins and scripts to control services. +In particular, often one service needs to control another: +e.g. ifplugd can detect that the network cable was just plugged in, +and it needs to (re)start DHCP service for this network device. + +The name of this tool is not standard either, which is an obvious problem. +I propose to fix this by implementing a tool with fixed name and API by all +daemontools clones. Lets use original daemontools name and API. Thus: + +The following form must work: + + svc -udopchaitkx DIR + +Options map to up/down/once/STOP/CONT/HUP/ALRM/INT/TERM/KILL/exit +commands to the daemon being controlled. + +The form with one option letter must work. If multiple-option form +is supported, there is no guarantee in which order they take effect: +svc -it DIR can deliver TERM and INT in any order. + +If more than one DIR can be specified (which is not a requirement), +there is no guarantee in which order commands are sent to them. + +If DIR has no slash and is not "." or "..", it is assumed to be +relative to the system-wide service directory. + +The "svok DIR" tool exits 0 if service is running, and nonzero if not. + +The "svstat DIR1 DIR2..." prints one human-readable line for each directory, +saying whether supervise is successfully running in that directory, +and reporting the status information maintained by supervise. + +Other tools with different names and APIs may exist; however +for portability scripts should use the above tools. + +Creation of a new service on a running system should be done atomically. +To this end, first create and populate a new /etc/rc/DIR. + +Then "activate" it by running ??????? - this copies (or symlinks, +depending on the distro) its files to the "live" service directory, +whereever it is located on this distro. + +Removal of the service should be done as follows: +svc -d DIR [DIR/log], then remove the service directory +(this makes service monitor SIGTERM per-directory supervisors +(if they exist in the implementation)) + + + Implementation details + +Top-level service monitor program name is not standardized. +[svscan, runsvdir, s6-svscan ...] + +It may run one per-directory supervisor, or two supervisors +(one for DIR/ and one for DIR/log/); for memory-constrained systems +an implementation is possible which itself controls all services, without +intermediate supervisors. +[runsvdir runs one "runsv DIR" per DIR, runsv handles DIR/log/ if that exists] +[svscan runs a pair of "superwise DIR" and "superwise DIR/log"] + +Directores are remembered by device+inode numbers, not names. Renaming a directory +does not affect the running service (unless it is renamed to a .dotdir). + +Removal (or .dotdiring) of a directory sends SIGTERM to any running services. + +Standard output of non-logged services goes to standard output of service monitor. +Standard output of logger services goes to standard output of service monitor. +Standard error of them always goes to standard error of service monitor. + +If you want to log standard error of your logged service along with its stdout, use +"exec 2>&1" in the beginning of your "run" script. + +Whether stdout/stderr of service monitor is discarded (>/dev/null) +or logged in some way is system-dependent. + + + Containers + +[What do containers need?] -- cgit v1.2.3-55-g6feb From 4bd0c2ab38a53d5ecc89eacc61b3291d4fe01d51 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 4 Dec 2016 10:42:07 +0100 Subject: fix musl problem with dirname, now for all users of bb_make_directory() function old new delta bb_make_directory 412 419 +7 install_main 793 769 -24 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-24) Total: -17 bytes Signed-off-by: Denys Vlasenko --- coreutils/install.c | 12 +++--------- libbb/make_directory.c | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/coreutils/install.c b/coreutils/install.c index d0dcd0e89..831f9b802 100644 --- a/coreutils/install.c +++ b/coreutils/install.c @@ -209,16 +209,10 @@ int install_main(int argc, char **argv) dest = last; if (opts & OPT_MKDIR_LEADING) { char *ddir = xstrdup(dest); - char *dn = dirname(ddir); - /* musl can return read-only "/" or "." string. - * bb_make_directory needs writable string. + bb_make_directory(dirname(ddir), 0755, mkdir_flags); + /* errors are not checked. copy_file + * will fail if dir is not created. */ - if ((dn[0] != '/' && dn[0] != '.') || dn[1] != '\0') { - bb_make_directory(dn, 0755, mkdir_flags); - /* errors are not checked. copy_file - * will fail if dir is not created. - */ - } free(ddir); } if (isdir) diff --git a/libbb/make_directory.c b/libbb/make_directory.c index 89352ca1f..a6b7c28df 100644 --- a/libbb/make_directory.c +++ b/libbb/make_directory.c @@ -35,9 +35,20 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags) char c; struct stat st; - /* Happens on bb_make_directory(dirname("no_slashes"),...) */ - if (LONE_CHAR(path, '.')) + /* "path" can be a result of dirname(). + * dirname("no_slashes") returns ".", possibly read-only. + * musl dirname() can return read-only "/" too. + * We need writable string. And for "/", "." (and ".."?) + * nothing needs to be created anyway. + */ + if (LONE_CHAR(path, '/')) return 0; + if (path[0] == '.') { + if (path[1] == '\0') + return 0; /* "." */ +// if (path[1] == '.' && path[2] == '\0') +// return 0; /* ".." */ + } org_mask = cur_mask = (mode_t)-1L; s = path; -- cgit v1.2.3-55-g6feb From 4051a99f5fe4b1e1914e26924d166a629bf3c71e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 5 Dec 2016 13:56:40 +0100 Subject: svc: new applet (daemontools-compatible version of "sv") function old new delta sv - 1199 +1199 svc_main - 145 +145 packed_usage 30255 30364 +109 applet_names 2437 2441 +4 applet_main 1420 1424 +4 find_applet_by_name 125 126 +1 sv_main 1201 9 -1192 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 4/1 up/down: 1462/-1192) Total: 270 bytes Signed-off-by: Denys Vlasenko --- runit/sv.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 94 insertions(+), 18 deletions(-) diff --git a/runit/sv.c b/runit/sv.c index 42abbbbb5..71865bd4f 100644 --- a/runit/sv.c +++ b/runit/sv.c @@ -166,26 +166,19 @@ Exit Codes //config: help //config: Default directory for services. //config: Defaults to "/var/service" +//config: +//config:config SVC +//config: bool "svc" +//config: default y +//config: help +//config: svc controls the state of services monitored by the runsv supervisor. +//config: It is comaptible with daemontools command with the same name. //applet:IF_SV(APPLET(sv, BB_DIR_USR_BIN, BB_SUID_DROP)) +//applet:IF_SV(APPLET(svc, BB_DIR_USR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_SV) += sv.o - -//usage:#define sv_trivial_usage -//usage: "[-v] [-w SEC] CMD SERVICE_DIR..." -//usage:#define sv_full_usage "\n\n" -//usage: "Control services monitored by runsv supervisor.\n" -//usage: "Commands (only first character is enough):\n" -//usage: "\n" -//usage: "status: query service status\n" -//usage: "up: if service isn't running, start it. If service stops, restart it\n" -//usage: "once: like 'up', but if service stops, don't restart it\n" -//usage: "down: send TERM and CONT signals. If ./run exits, start ./finish\n" -//usage: " if it exists. After it stops, don't restart service\n" -//usage: "exit: send TERM and CONT signals to service and log service. If they exit,\n" -//usage: " runsv exits too\n" -//usage: "pause, cont, hup, alarm, interrupt, quit, 1, 2, term, kill: send\n" -//usage: "STOP, CONT, HUP, ALRM, INT, QUIT, USR1, USR2, TERM, KILL signal to service" +//kbuild:lib-$(CONFIG_SVC) += sv.o #include #include "libbb.h" @@ -452,8 +445,22 @@ static int control(const char *a) return 1; } -int sv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; -int sv_main(int argc UNUSED_PARAM, char **argv) +//usage:#define sv_trivial_usage +//usage: "[-v] [-w SEC] CMD SERVICE_DIR..." +//usage:#define sv_full_usage "\n\n" +//usage: "Control services monitored by runsv supervisor.\n" +//usage: "Commands (only first character is enough):\n" +//usage: "\n" +//usage: "status: query service status\n" +//usage: "up: if service isn't running, start it. If service stops, restart it\n" +//usage: "once: like 'up', but if service stops, don't restart it\n" +//usage: "down: send TERM and CONT signals. If ./run exits, start ./finish\n" +//usage: " if it exists. After it stops, don't restart service\n" +//usage: "exit: send TERM and CONT signals to service and log service. If they exit,\n" +//usage: " runsv exits too\n" +//usage: "pause, cont, hup, alarm, interrupt, quit, 1, 2, term, kill: send\n" +//usage: "STOP, CONT, HUP, ALRM, INT, QUIT, USR1, USR2, TERM, KILL signal to service" +static int sv(char **argv) { char *x; char *action; @@ -634,3 +641,72 @@ int sv_main(int argc UNUSED_PARAM, char **argv) } return rc > 99 ? 99 : rc; } + +#if ENABLE_SV +int sv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; +int sv_main(int argc UNUSED_PARAM, char **argv) +{ + return sv(argv); +} +#endif + +//usage:#define svc_trivial_usage +//usage: "[-udopchaitkx] SERVICE_DIR..." +//usage:#define svc_full_usage "\n\n" +//usage: "Control services monitored by runsv supervisor" +//usage: "\n" +//usage: "\n"" -u If service is not running, start it; restart if it stops" +//usage: "\n"" -d If service is running, send TERM+CONT signals; do not restart it" +//usage: "\n"" -o Once: if service is not running, start it; do not restart it" +//usage: "\n"" -pchaitk Send STOP, CONT, HUP, ALRM, INT, TERM, KILL signal to service" +//usage: "\n"" -x Exit: runsv will exit as soon as the service is down" +#if ENABLE_SVC +int svc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; +int svc_main(int argc UNUSED_PARAM, char **argv) +{ + char command[2]; + const char *optstring; + unsigned opts; + + INIT_G(); + + optstring = "udopchaitkx"; + opts = getopt32(argv, optstring); + argv += optind; + if (!argv[0] || !opts) + bb_show_usage(); + + argv -= 2; + if (optind > 2) { + argv--; + argv[2] = (char*)"--"; + } + argv[0] = (char*)"sv"; + argv[1] = command; + command[1] = '\0'; + + /* getopt32() was already called: + * reset the libc getopt() function, which keeps internal state. + */ +#ifdef __GLIBC__ + optind = 0; +#else /* BSD style */ + optind = 1; + /* optreset = 1; */ +#endif + + do { + if (opts & 1) { + int r; + command[0] = *optstring; + r = sv(argv); + if (r) + return 1; + } + optstring++; + opts >>= 1; + } while (opts); + + return 0; +} +#endif -- cgit v1.2.3-55-g6feb From 548620c18b1f0988dbeab1009788daf9f002e927 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 8 Dec 2016 12:24:48 +0100 Subject: randomconfig fixes Signed-off-by: Denys Vlasenko --- archival/bbunzip.c | 7 ++++++- archival/libarchive/Kbuild.src | 9 ++++++++- include/libbb.h | 12 ++++++++++-- libbb/Kbuild.src | 5 +++++ runit/sv.c | 2 +- 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/archival/bbunzip.c b/archival/bbunzip.c index 7d5402e8d..d5db4627f 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c @@ -9,6 +9,8 @@ /* lzop_main() uses bbunpack(), need this: */ //kbuild:lib-$(CONFIG_LZOP) += bbunzip.o +/* bzip2_main() too: */ +//kbuild:lib-$(CONFIG_BZIP2) += bbunzip.o /* Note: must be kept in sync with archival/lzop.c */ enum { @@ -190,7 +192,10 @@ int FAST_FUNC bbunpack(char **argv, return exitcode; } -#if ENABLE_UNCOMPRESS || ENABLE_BUNZIP2 || ENABLE_UNLZMA || ENABLE_UNXZ +#if ENABLE_UNCOMPRESS \ + || ENABLE_BUNZIP2 || ENABLE_BZCAT \ + || ENABLE_UNLZMA || ENABLE_LZCAT || ENABLE_LZMA \ + || ENABLE_UNXZ || ENABLE_XZCAT || ENABLE_XZ static char* FAST_FUNC make_new_name_generic(char *filename, const char *expected_ext) { diff --git a/archival/libarchive/Kbuild.src b/archival/libarchive/Kbuild.src index b159a786a..ad5c5c42d 100644 --- a/archival/libarchive/Kbuild.src +++ b/archival/libarchive/Kbuild.src @@ -48,16 +48,23 @@ lib-$(CONFIG_CPIO) += get_header_cpio.o lib-$(CONFIG_TAR) += get_header_tar.o unsafe_prefix.o lib-$(CONFIG_FEATURE_TAR_TO_COMMAND) += data_extract_to_command.o lib-$(CONFIG_LZOP) += lzo1x_1.o lzo1x_1o.o lzo1x_d.o +lib-$(CONFIG_UNLZOP) += lzo1x_1.o lzo1x_1o.o lzo1x_d.o +lib-$(CONFIG_LZOPCAT) += lzo1x_1.o lzo1x_1o.o lzo1x_d.o lib-$(CONFIG_LZOP_COMPR_HIGH) += lzo1x_9x.o lib-$(CONFIG_BUNZIP2) += open_transformer.o decompress_bunzip2.o +lib-$(CONFIG_BZCAT) += open_transformer.o decompress_bunzip2.o lib-$(CONFIG_UNLZMA) += open_transformer.o decompress_unlzma.o +lib-$(CONFIG_LZCAT) += open_transformer.o decompress_unlzma.o +lib-$(CONFIG_LZMA) += open_transformer.o decompress_unlzma.o lib-$(CONFIG_UNXZ) += open_transformer.o decompress_unxz.o +lib-$(CONFIG_XZCAT) += open_transformer.o decompress_unxz.o +lib-$(CONFIG_XZ) += open_transformer.o decompress_unxz.o lib-$(CONFIG_GUNZIP) += open_transformer.o decompress_gunzip.o +lib-$(CONFIG_ZCAT) += open_transformer.o decompress_gunzip.o lib-$(CONFIG_UNCOMPRESS) += open_transformer.o decompress_uncompress.o lib-$(CONFIG_UNZIP) += open_transformer.o decompress_gunzip.o unsafe_prefix.o lib-$(CONFIG_RPM2CPIO) += open_transformer.o decompress_gunzip.o get_header_cpio.o lib-$(CONFIG_RPM) += open_transformer.o decompress_gunzip.o get_header_cpio.o - lib-$(CONFIG_GZIP) += open_transformer.o lib-$(CONFIG_BZIP2) += open_transformer.o lib-$(CONFIG_LZOP) += open_transformer.o diff --git a/include/libbb.h b/include/libbb.h index bdafcf5a6..a42a2fba8 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1191,8 +1191,16 @@ int bb_cat(char** argv); /* If shell needs them, they exist even if not enabled as applets */ int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE); int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE); -int test_main(int argc, char **argv) IF_TEST(MAIN_EXTERNALLY_VISIBLE); -int kill_main(int argc, char **argv) IF_KILL(MAIN_EXTERNALLY_VISIBLE); +int test_main(int argc, char **argv) +#if ENABLE_TEST || ENABLE_TEST1 || ENABLE_TEST2 + MAIN_EXTERNALLY_VISIBLE +#endif +; +int kill_main(int argc, char **argv) +#if ENABLE_KILL || ENABLE_KILLALL || ENABLE_KILLALL5 + MAIN_EXTERNALLY_VISIBLE +#endif +; /* Similar, but used by chgrp, not shell */ int chown_main(int argc, char **argv) IF_CHOWN(MAIN_EXTERNALLY_VISIBLE); /* Used by ftpd */ diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src index 52a90e9a1..7440974b0 100644 --- a/libbb/Kbuild.src +++ b/libbb/Kbuild.src @@ -132,6 +132,7 @@ lib-$(CONFIG_TFTPD) += udp_io.o lib-$(CONFIG_TCPSVD) += udp_io.o lib-$(CONFIG_UDPSVD) += udp_io.o lib-$(CONFIG_TRACEROUTE) += udp_io.o +lib-$(CONFIG_TRACEROUTE6) += udp_io.o lib-$(CONFIG_LOSETUP) += loop.o lib-$(CONFIG_FEATURE_MOUNT_LOOP) += loop.o @@ -156,6 +157,7 @@ lib-$(CONFIG_FEATURE_FTP_AUTHENTICATION) += pw_encrypt.o lib-$(CONFIG_DF) += find_mount_point.o lib-$(CONFIG_MKFS_MINIX) += find_mount_point.o lib-$(CONFIG_MKFS_EXT2) += find_mount_point.o +lib-$(CONFIG_MKE2FS) += find_mount_point.o lib-$(CONFIG_MKFS_REISER) += find_mount_point.o lib-$(CONFIG_FSCK_MINIX) += find_mount_point.o lib-$(CONFIG_MOUNT) += find_mount_point.o @@ -168,6 +170,7 @@ lib-$(CONFIG_MPSTAT) += get_cpu_count.o lib-$(CONFIG_POWERTOP) += get_cpu_count.o lib-$(CONFIG_PING) += inet_cksum.o +lib-$(CONFIG_PING6) += inet_cksum.o lib-$(CONFIG_TRACEROUTE) += inet_cksum.o lib-$(CONFIG_TRACEROUTE6) += inet_cksum.o lib-$(CONFIG_UDHCPC) += inet_cksum.o @@ -181,6 +184,8 @@ lib-$(CONFIG_UDHCPD) += inet_cksum.o lib-$(CONFIG_AWK) += xregcomp.o lib-$(CONFIG_SED) += xregcomp.o lib-$(CONFIG_GREP) += xregcomp.o +lib-$(CONFIG_EGREP) += xregcomp.o +lib-$(CONFIG_FGREP) += xregcomp.o lib-$(CONFIG_EXPR) += xregcomp.o lib-$(CONFIG_MDEV) += xregcomp.o lib-$(CONFIG_LESS) += xregcomp.o diff --git a/runit/sv.c b/runit/sv.c index 71865bd4f..9e2132259 100644 --- a/runit/sv.c +++ b/runit/sv.c @@ -175,7 +175,7 @@ Exit Codes //config: It is comaptible with daemontools command with the same name. //applet:IF_SV(APPLET(sv, BB_DIR_USR_BIN, BB_SUID_DROP)) -//applet:IF_SV(APPLET(svc, BB_DIR_USR_BIN, BB_SUID_DROP)) +//applet:IF_SVC(APPLET(svc, BB_DIR_USR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_SV) += sv.o //kbuild:lib-$(CONFIG_SVC) += sv.o -- cgit v1.2.3-55-g6feb From 2098c3511cfa0e79c5d6e19e41a74ef19bcf91af Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 9 Dec 2016 16:12:15 -0500 Subject: mdev.conf: rename hw_random to hwrng The kernel broke the name years ago, but didn't notice until it was much too late. Rename the node to match expectations of userland software, and what the kernel itself documents in its Kconfig help: This provides a device that's usually called /dev/hwrng, ... URL: https://marc.info/?l=linux-crypto-vger&m=144249767024990&w=2 Signed-off-by: Mike Frysinger --- examples/mdev.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/mdev.conf b/examples/mdev.conf index 51795694d..fab1dc451 100644 --- a/examples/mdev.conf +++ b/examples/mdev.conf @@ -34,3 +34,5 @@ fd[0-9]* 0:11 660 sd[a-z]* 0:6 660 hd[a-z]* 0:6 660 + +hw_random 0:0 600 =hwrng -- cgit v1.2.3-55-g6feb From 1cda8790803a6fb072375c8fa53273333d2d4607 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 9 Dec 2016 18:14:12 -0500 Subject: setfiles: fix build failure after common_bufsiz change Commit 47cfbf32fd66563f8c4e09ad6cced6abfbe2fad5 ("*: add most of the required setup_common_bufsiz() calls") switched this tool over to use the common_bufsiz logic but missed including the header leading to a build failure when enabled: selinux/setfiles.c:80:30: error: 'bb_common_bufsiz1' undeclared (first use in this function) URL: https://bugs.gentoo.org/600106 Reported-by: Jonas Jelten Signed-off-by: Mike Frysinger --- selinux/setfiles.c | 1 + 1 file changed, 1 insertion(+) diff --git a/selinux/setfiles.c b/selinux/setfiles.c index 4fc307f55..9fa5d3f30 100644 --- a/selinux/setfiles.c +++ b/selinux/setfiles.c @@ -77,6 +77,7 @@ //usage: "\n if it has changed" #include "libbb.h" +#include "common_bufsiz.h" #if ENABLE_FEATURE_SETFILES_CHECK_OPTION #include #endif -- cgit v1.2.3-55-g6feb From c6f35241b38ea0c9581409efcd83716b74918903 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 9 Dec 2016 18:30:30 -0500 Subject: selinux: drop deprecated headers The selinux guys want you to get class values at runtime by converting textual names into constants. Drop the deprecated headers and switch to the new format. This API has been around for years, so there shouldn't be an issue with backwards compatibility. Signed-off-by: Mike Frysinger --- include/libbb.h | 2 -- libbb/update_passwd.c | 13 ++++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/libbb.h b/include/libbb.h index a42a2fba8..2e9ea46e2 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -81,8 +81,6 @@ #if ENABLE_SELINUX # include # include -# include -# include #endif #if ENABLE_FEATURE_UTMP # if defined __UCLIBC__ && ( \ diff --git a/libbb/update_passwd.c b/libbb/update_passwd.c index a2004f480..6255af492 100644 --- a/libbb/update_passwd.c +++ b/libbb/update_passwd.c @@ -30,7 +30,18 @@ static void check_selinux_update_passwd(const char *username) if (!seuser) bb_error_msg_and_die("invalid context '%s'", context); if (strcmp(seuser, username) != 0) { - if (checkPasswdAccess(PASSWD__PASSWD) != 0) + security_class_t tclass; + access_vector_t av; + + tclass = string_to_security_class("passwd"); + if (tclass == 0) + goto die; + av = string_to_av_perm(tclass, "passwd"); + if (av == 0) + goto die; + + if (selinux_check_passwd_access(av) != 0) + die: bb_error_msg_and_die("SELinux: access denied"); } if (ENABLE_FEATURE_CLEAN_UP) -- cgit v1.2.3-55-g6feb From ac5d324540c5ec38c016848f2075b9f3e0560c11 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 10 Dec 2016 20:57:00 +0100 Subject: randomconfig fixes Signed-off-by: Denys Vlasenko --- libbb/Kbuild.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src index 7440974b0..e426f3c7e 100644 --- a/libbb/Kbuild.src +++ b/libbb/Kbuild.src @@ -142,7 +142,7 @@ lib-$(CONFIG_ADDUSER) += update_passwd.o lib-$(CONFIG_DELGROUP) += update_passwd.o lib-$(CONFIG_DELUSER) += update_passwd.o -lib-$(CONFIG_FTPD) += correct_password.o +lib-$(CONFIG_FTPD) += pw_encrypt.o correct_password.o lib-$(CONFIG_PASSWD) += pw_encrypt.o update_passwd.o obscure.o lib-$(CONFIG_CHPASSWD) += pw_encrypt.o update_passwd.o lib-$(CONFIG_CRYPTPW) += pw_encrypt.o -- cgit v1.2.3-55-g6feb From 52ae0980112f57bbdf4590f649432264d00cc943 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 12 Dec 2016 09:26:16 +0100 Subject: randomconfig fixes Signed-off-by: Denys Vlasenko --- testsuite/bunzip2/bzcat-does-not-remove-compressed-file | 3 --- testsuite/bzcat/bzcat-does-not-remove-compressed-file | 3 +++ testsuite/cpio.tests | 3 +++ testsuite/tar.tests | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) delete mode 100644 testsuite/bunzip2/bzcat-does-not-remove-compressed-file create mode 100644 testsuite/bzcat/bzcat-does-not-remove-compressed-file diff --git a/testsuite/bunzip2/bzcat-does-not-remove-compressed-file b/testsuite/bunzip2/bzcat-does-not-remove-compressed-file deleted file mode 100644 index 7d4016ec5..000000000 --- a/testsuite/bunzip2/bzcat-does-not-remove-compressed-file +++ /dev/null @@ -1,3 +0,0 @@ -echo foo | bzip2 >foo.bz2 -busybox bzcat foo.bz2 -test -f foo.bz2 diff --git a/testsuite/bzcat/bzcat-does-not-remove-compressed-file b/testsuite/bzcat/bzcat-does-not-remove-compressed-file new file mode 100644 index 000000000..7d4016ec5 --- /dev/null +++ b/testsuite/bzcat/bzcat-does-not-remove-compressed-file @@ -0,0 +1,3 @@ +echo foo | bzip2 >foo.bz2 +busybox bzcat foo.bz2 +test -f foo.bz2 diff --git a/testsuite/cpio.tests b/testsuite/cpio.tests index d44c95b10..88ec086b6 100755 --- a/testsuite/cpio.tests +++ b/testsuite/cpio.tests @@ -127,6 +127,7 @@ testing "cpio extracts in existing directory" \ " "" "" SKIP= +optional FEATURE_CPIO_O testing "cpio uses by default uid/gid" \ "echo $0 | cpio -o -H newc | cpio -tv 2>&1 | tail -n +2 | awk ' { print \$2 } '; echo \$?" \ "\ @@ -135,6 +136,7 @@ $user/$group " "" "" SKIP= +optional FEATURE_CPIO_O testing "cpio -R with create" \ "echo $0 | cpio -o -H newc -R 1234:5678 | cpio -tv 2>&1 | tail -n +2 | awk ' { print \$2 } '; echo \$?" \ "\ @@ -143,6 +145,7 @@ testing "cpio -R with create" \ " "" "" SKIP= +optional FEATURE_CPIO_O testing "cpio -R with extract" \ "echo $0 | cpio -o -H newc | cpio -tv -R 8765:4321 2>&1 | tail -n +2 | awk ' { print \$2 } '; echo \$?" \ "\ diff --git a/testsuite/tar.tests b/testsuite/tar.tests index ffcbe9ba9..18883c966 100755 --- a/testsuite/tar.tests +++ b/testsuite/tar.tests @@ -299,7 +299,7 @@ l4/V8LDoe90yiWJhOJvIypgEfxdyRThQkBVn/bI= " SKIP= -optional UNICODE_SUPPORT +optional UNICODE_SUPPORT FEATURE_TAR_GNU_EXTENSIONS testing "Pax-encoded UTF8 names and symlinks" '\ tar xvf ../tar.utf8.tar.bz2 2>&1; echo $? export LANG=en_US.UTF-8 -- cgit v1.2.3-55-g6feb From de912f0153c8c3f30040d546a7e96ccb949a803d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 12 Dec 2016 11:08:51 +0100 Subject: randomconfig fixes Signed-off-by: Denys Vlasenko --- scripts/randomtest.loop | 1 + testsuite/tar.tests | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/randomtest.loop b/scripts/randomtest.loop index 758a8e862..710f5fd05 100755 --- a/scripts/randomtest.loop +++ b/scripts/randomtest.loop @@ -33,6 +33,7 @@ while sleep 1; do ) if test $? != 0; then echo "Failed runtest in $dir" + grep ^FAIL -- "$dir/testsuite/runtest.log" exit 1 # you may comment this out... let fail++ continue diff --git a/testsuite/tar.tests b/testsuite/tar.tests index 18883c966..535052c36 100755 --- a/testsuite/tar.tests +++ b/testsuite/tar.tests @@ -299,7 +299,7 @@ l4/V8LDoe90yiWJhOJvIypgEfxdyRThQkBVn/bI= " SKIP= -optional UNICODE_SUPPORT FEATURE_TAR_GNU_EXTENSIONS +optional UNICODE_SUPPORT FEATURE_TAR_GNU_EXTENSIONS FEATURE_SEAMLESS_BZ2 testing "Pax-encoded UTF8 names and symlinks" '\ tar xvf ../tar.utf8.tar.bz2 2>&1; echo $? export LANG=en_US.UTF-8 -- cgit v1.2.3-55-g6feb From df25df784f2bbc5e3b27f8be6c3555c358f470c1 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 12 Dec 2016 14:33:53 +0100 Subject: randomconfig fixes Signed-off-by: Denys Vlasenko --- testsuite/tar.tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/tar.tests b/testsuite/tar.tests index 535052c36..16130f9b6 100755 --- a/testsuite/tar.tests +++ b/testsuite/tar.tests @@ -299,7 +299,7 @@ l4/V8LDoe90yiWJhOJvIypgEfxdyRThQkBVn/bI= " SKIP= -optional UNICODE_SUPPORT FEATURE_TAR_GNU_EXTENSIONS FEATURE_SEAMLESS_BZ2 +optional UNICODE_SUPPORT FEATURE_TAR_GNU_EXTENSIONS FEATURE_SEAMLESS_BZ2 FEATURE_TAR_AUTODETECT testing "Pax-encoded UTF8 names and symlinks" '\ tar xvf ../tar.utf8.tar.bz2 2>&1; echo $? export LANG=en_US.UTF-8 -- cgit v1.2.3-55-g6feb From 4f13a7050787aadb402c9c47aae0ff778dbc2c8b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 12 Dec 2016 16:29:32 +0100 Subject: suppress glibc "use sysmacros.h for major" warning Signed-off-by: Denys Vlasenko --- include/libbb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/libbb.h b/include/libbb.h index 2e9ea46e2..b1fec0157 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -45,7 +45,7 @@ #include #include #include -#ifndef major +#if !defined(major) || defined(__GLIBC__) # include #endif #include -- cgit v1.2.3-55-g6feb From b6afcc78194aa0801544bc606b9562339c846eb4 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 12 Dec 2016 16:30:20 +0100 Subject: shell: suppress "unused var/func" warnings on some configs Signed-off-by: Denys Vlasenko --- shell/ash.c | 12 ++++++------ shell/hush.c | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index 2bdb4aad7..91bcccb9d 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -11373,13 +11373,13 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs) smallint quotef; smallint dblquote; smallint oldstyle; - smallint prevsyntax; /* syntax before arithmetic */ + IF_SH_MATH_SUPPORT(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 */ - int arinest; /* levels of arithmetic expansion */ - int parenlevel; /* levels of parens in arithmetic */ + IF_SH_MATH_SUPPORT(int arinest;) /* levels of arithmetic expansion */ + IF_SH_MATH_SUPPORT(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;) @@ -11387,7 +11387,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs) startlinno = g_parsefile->linno; bqlist = NULL; quotef = 0; - prevsyntax = 0; + IF_SH_MATH_SUPPORT(prevsyntax = 0;) #if ENABLE_ASH_EXPAND_PRMT pssyntax = (syntax == PSSYNTAX); if (pssyntax) @@ -11395,8 +11395,8 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs) #endif dblquote = (syntax == DQSYNTAX); varnest = 0; - arinest = 0; - parenlevel = 0; + IF_SH_MATH_SUPPORT(arinest = 0;) + IF_SH_MATH_SUPPORT(parenlevel = 0;) dqvarnest = 0; STARTSTACKSTR(out); diff --git a/shell/hush.c b/shell/hush.c index bcd4dffee..888be6e6e 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -1574,9 +1574,8 @@ static sighandler_t install_sighandler(int sig, sighandler_t handler) } static void hush_exit(int exitcode) NORETURN; -static void fflush_and__exit(void) NORETURN; -static void restore_ttypgrp_and__exit(void) NORETURN; +static void restore_ttypgrp_and__exit(void) NORETURN; static void restore_ttypgrp_and__exit(void) { /* xfunc has failed! die die die */ @@ -1585,6 +1584,8 @@ static void restore_ttypgrp_and__exit(void) hush_exit(xfunc_error_retval); } +#if ENABLE_HUSH_JOB + /* Needed only on some libc: * It was observed that on exit(), fgetc'ed buffered data * gets "unwound" via lseek(fd, -NUM, SEEK_CUR). @@ -1598,14 +1599,13 @@ static void restore_ttypgrp_and__exit(void) * and in `cmd` handling. * If set as die_func(), this makes xfunc_die() exit via _exit(), not exit(): */ +static void fflush_and__exit(void) NORETURN; static void fflush_and__exit(void) { fflush_all(); _exit(xfunc_error_retval); } -#if ENABLE_HUSH_JOB - /* After [v]fork, in child: do not restore tty pgrp on xfunc death */ # define disable_restore_tty_pgrp_on_exit() (die_func = fflush_and__exit) /* After [v]fork, in parent: restore tty pgrp on xfunc death */ -- cgit v1.2.3-55-g6feb From 2fe66b1d2dc50f9d5ed98d5c537745f3066fb4d8 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 12 Dec 2016 17:39:12 +0100 Subject: ash: fix signed char expansion bug Signed-off-by: Denys Vlasenko --- shell/ash.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index 91bcccb9d..8d8cc466b 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -3113,7 +3113,18 @@ static const uint8_t syntax_index_table[] ALIGN1 = { # endif }; +#if 1 # define SIT(c, syntax) ((S_I_T[syntax_index_table[c]] >> ((syntax)*4)) & 0xf) +#else /* debug version, caught one signed char bug */ +# define SIT(c, syntax) \ + ({ \ + 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)) \ + bb_error_msg_and_die("line:%d c:%d", __LINE__, (c)); \ + ((S_I_T[syntax_index_table[c]] >> ((syntax)*4)) & 0xf); \ + }) +#endif #endif /* !USE_SIT_FUNCTION */ @@ -5869,14 +5880,15 @@ memtodest(const char *p, size_t len, int syntax, int quotes) do { unsigned char c = *p++; if (c) { - int n = SIT(c, syntax); - if ((quotes & QUOTES_ESC) - && ((n == CCTL) - || (((quotes & EXP_FULL) || syntax != BASESYNTAX) - && n == CBACK) - ) - ) { - USTPUTC(CTLESC, q); + if (quotes & QUOTES_ESC) { + int n = SIT(c, syntax); + if (n == CCTL + || (((quotes & EXP_FULL) || syntax != BASESYNTAX) + && n == CBACK + ) + ) { + USTPUTC(CTLESC, q); + } } } else if (!(quotes & QUOTES_KEEPNUL)) continue; @@ -10051,7 +10063,7 @@ pgetc(void) return g_parsefile->lastc[--g_parsefile->unget]; if (--g_parsefile->left_in_line >= 0) - c = (signed char)*g_parsefile->next_to_pgetc++; + c = (unsigned char)*g_parsefile->next_to_pgetc++; else c = preadbuffer(); -- cgit v1.2.3-55-g6feb From 76de3257f7133a760c3d8908a99b850ea2d0f0b0 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 12 Dec 2016 19:17:12 +0100 Subject: randomconfig fixes Signed-off-by: Denys Vlasenko --- testsuite/tar.tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/tar.tests b/testsuite/tar.tests index 16130f9b6..9f7ce1587 100755 --- a/testsuite/tar.tests +++ b/testsuite/tar.tests @@ -303,7 +303,7 @@ optional UNICODE_SUPPORT FEATURE_TAR_GNU_EXTENSIONS FEATURE_SEAMLESS_BZ2 FEATURE testing "Pax-encoded UTF8 names and symlinks" '\ tar xvf ../tar.utf8.tar.bz2 2>&1; echo $? export LANG=en_US.UTF-8 -ls -l etc/ssl/certs/* | sed "s:.*etc/:etc/:" +ls -l etc/ssl/certs/* | sed "s:.*etc/:etc/:" | sort unset LANG rm -rf etc usr ' "\ -- cgit v1.2.3-55-g6feb From e184a883567ee3fd735644416e4bd683f1894ac5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 12 Dec 2016 19:56:31 +0100 Subject: df: implement -B n and -B formats of -B option Signed-off-by: Denys Vlasenko --- coreutils/df.c | 20 ++++++++++++++++++-- include/libbb.h | 1 + libbb/xatonum.c | 19 +++++++++++++++++++ util-linux/fstrim.c | 25 +++---------------------- 4 files changed, 41 insertions(+), 24 deletions(-) diff --git a/coreutils/df.c b/coreutils/df.c index fdcdae675..79e4c4670 100644 --- a/coreutils/df.c +++ b/coreutils/df.c @@ -129,8 +129,19 @@ int df_main(int argc UNUSED_PARAM, char **argv) if (opt & OPT_MEGA) df_disp_hr = 1024*1024; - if (opt & OPT_BSIZE) - df_disp_hr = xatoul_range(chp, 1, ULONG_MAX); /* disallow 0 */ + if (opt & OPT_BSIZE) { + /* GNU coreutils 8.25 accepts "-BMiB" form too */ + int i; + for (i = 0; kmg_i_suffixes[i].suffix[0]; i++) { + if (strcmp(kmg_i_suffixes[i].suffix, chp) == 0) { + df_disp_hr = kmg_i_suffixes[i].mult; + goto got_it; + } + } + /* Range used to disallow 0 */ + df_disp_hr = xatoul_range_sfx(chp, 1, ULONG_MAX, kmg_i_suffixes); + got_it: ; + } /* From the manpage of df from coreutils-6.10: * Disk space is shown in 1K blocks by default, unless the environment @@ -203,6 +214,11 @@ int df_main(int argc UNUSED_PARAM, char **argv) bb_simple_perror_msg(mount_point); goto set_error; } + /* Some uclibc versions were seen to lose f_frsize + * (kernel does return it, but then uclibc does not copy it) + */ + if (s.f_frsize == 0) + s.f_frsize = s.f_bsize; if ((s.f_blocks > 0) || !mount_table || (opt & OPT_ALL)) { if (opt & OPT_INODE) { diff --git a/include/libbb.h b/include/libbb.h index b1fec0157..abdc8c2b8 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -923,6 +923,7 @@ extern const struct suffix_mult bkm_suffixes[]; #define km_suffixes (bkm_suffixes + 1) extern const struct suffix_mult cwbkMG_suffixes[]; #define kMG_suffixes (cwbkMG_suffixes + 3) +extern const struct suffix_mult kmg_i_suffixes[]; #include "xatonum.h" /* Specialized: */ diff --git a/libbb/xatonum.c b/libbb/xatonum.c index 9dd5c3e7e..b63b7f54d 100644 --- a/libbb/xatonum.c +++ b/libbb/xatonum.c @@ -96,3 +96,22 @@ const struct suffix_mult cwbkMG_suffixes[] = { /* coreutils also understands TPEZY suffixes for tera- and so on, with B suffix for decimal */ { "", 0 } }; + +const struct suffix_mult kmg_i_suffixes[] = { + { "KiB", 1024 }, + { "kiB", 1024 }, + { "K", 1024 }, + { "k", 1024 }, + { "MiB", 1048576 }, + { "miB", 1048576 }, + { "M", 1048576 }, + { "m", 1048576 }, + { "GiB", 1073741824 }, + { "giB", 1073741824 }, + { "G", 1073741824 }, + { "g", 1073741824 }, + { "KB", 1000 }, + { "MB", 1000000 }, + { "GB", 1000000000 }, + { "", 0 } +}; diff --git a/util-linux/fstrim.c b/util-linux/fstrim.c index 51400ef0b..fc51878b6 100644 --- a/util-linux/fstrim.c +++ b/util-linux/fstrim.c @@ -47,25 +47,6 @@ struct fstrim_range { #define FITRIM _IOWR('X', 121, struct fstrim_range) #endif -static const struct suffix_mult fstrim_sfx[] = { - { "KiB", 1024 }, - { "kiB", 1024 }, - { "K", 1024 }, - { "k", 1024 }, - { "MiB", 1048576 }, - { "miB", 1048576 }, - { "M", 1048576 }, - { "m", 1048576 }, - { "GiB", 1073741824 }, - { "giB", 1073741824 }, - { "G", 1073741824 }, - { "g", 1073741824 }, - { "KB", 1000 }, - { "MB", 1000000 }, - { "GB", 1000000000 }, - { "", 0 } -}; - int fstrim_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int fstrim_main(int argc UNUSED_PARAM, char **argv) { @@ -98,11 +79,11 @@ int fstrim_main(int argc UNUSED_PARAM, char **argv) range.len = ULLONG_MAX; if (opts & OPT_o) - range.start = xatoull_sfx(arg_o, fstrim_sfx); + range.start = xatoull_sfx(arg_o, kmg_i_suffixes); if (opts & OPT_l) - range.len = xatoull_sfx(arg_l, fstrim_sfx); + range.len = xatoull_sfx(arg_l, kmg_i_suffixes); if (opts & OPT_m) - range.minlen = xatoull_sfx(arg_m, fstrim_sfx); + range.minlen = xatoull_sfx(arg_m, kmg_i_suffixes); mp = argv[optind]; if (find_block_device(mp)) { -- cgit v1.2.3-55-g6feb From b42107f21538e39d9a344376372f8261aed589b2 Mon Sep 17 00:00:00 2001 From: Lukasz Nowak Date: Tue, 13 Dec 2016 12:58:31 +0000 Subject: libiproute: handle table ids larger than 255 Linux kernel, starting from 2.6.19 allows ip table ids to have 32-bit values. In order to preserve compatibility, the old 8-bit field: rtm_table is still in use when table id is lower than 256. Add support for the 32-bit table id (RTA_TABLE attribute) in: - ip route print - ip route modify - ip rule print - ip rule modify Add printing of table ids to ip route. Changes are compatible with the mainline iproute2 utilities. These changes are required for compatibility with ConnMan, which by default uses table ids greater than 255. function old new delta print_route 1588 1637 +49 do_iproute 2187 2222 +35 do_iprule 955 987 +32 print_rule 617 630 +13 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 129/0) Total: 129 bytes Signed-off-by: Lukasz Nowak Signed-off-by: Denys Vlasenko --- networking/libiproute/iproute.c | 24 ++++++++++++++++++++---- networking/libiproute/iprule.c | 11 +++++++++-- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index 48dc6e3d9..0f2b89682 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c @@ -66,6 +66,7 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM, inet_prefix dst; inet_prefix src; int host_len = -1; + uint32_t tid; if (n->nlmsg_type != RTM_NEWROUTE && n->nlmsg_type != RTM_DELROUTE) { fprintf(stderr, "Not a route: %08x %08x %08x\n", @@ -78,6 +79,14 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM, if (len < 0) bb_error_msg_and_die("wrong nlmsg len %d", len); + memset(tb, 0, sizeof(tb)); + parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len); + + if (tb[RTA_TABLE]) + tid = *(uint32_t *)RTA_DATA(tb[RTA_TABLE]); + else + tid = r->rtm_table; + if (r->rtm_family == AF_INET6) host_len = 128; else if (r->rtm_family == AF_INET) @@ -107,7 +116,7 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM, } } } else { - if (G_filter.tb > 0 && G_filter.tb != r->rtm_table) { + if (G_filter.tb > 0 && G_filter.tb != tid) { return 0; } } @@ -136,10 +145,8 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM, return 0; } - memset(tb, 0, sizeof(tb)); memset(&src, 0, sizeof(src)); memset(&dst, 0, sizeof(dst)); - parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len); if (tb[RTA_SRC]) { src.bitlen = r->rtm_src_len; @@ -258,6 +265,10 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM, if (tb[RTA_OIF]) { printf("dev %s ", ll_index_to_name(*(int*)RTA_DATA(tb[RTA_OIF]))); } +#if ENABLE_FEATURE_IP_RULE + if (tid && tid != RT_TABLE_MAIN && !G_filter.tb) + printf("table %s ", rtnl_rttable_n2a(tid)); +#endif /* Todo: parse & show "proto kernel", "scope link" here */ @@ -419,7 +430,12 @@ IF_FEATURE_IP_RULE(ARG_table,) NEXT_ARG(); if (rtnl_rttable_a2n(&tid, *argv)) invarg_1_to_2(*argv, "table"); - req.r.rtm_table = tid; + if (tid < 256) + req.r.rtm_table = tid; + else { + req.r.rtm_table = RT_TABLE_UNSPEC; + addattr32(&req.n, sizeof(req), RTA_TABLE, tid); + } #endif } else if (arg == ARG_dev || arg == ARG_oif) { NEXT_ARG(); diff --git a/networking/libiproute/iprule.c b/networking/libiproute/iprule.c index c486834b0..8f3f86286 100644 --- a/networking/libiproute/iprule.c +++ b/networking/libiproute/iprule.c @@ -114,7 +114,9 @@ static int FAST_FUNC print_rule(const struct sockaddr_nl *who UNUSED_PARAM, printf("iif %s ", (char*)RTA_DATA(tb[RTA_IIF])); } - if (r->rtm_table) + if (tb[RTA_TABLE]) + printf("lookup %s ", rtnl_rttable_n2a(*(uint32_t*)RTA_DATA(tb[RTA_TABLE]))); + else if (r->rtm_table) printf("lookup %s ", rtnl_rttable_n2a(r->rtm_table)); if (tb[RTA_FLOW]) { @@ -256,7 +258,12 @@ static int iprule_modify(int cmd, char **argv) NEXT_ARG(); if (rtnl_rttable_a2n(&tid, *argv)) invarg_1_to_2(*argv, "table ID"); - req.r.rtm_table = tid; + if (tid < 256) + req.r.rtm_table = tid; + else { + req.r.rtm_table = RT_TABLE_UNSPEC; + addattr32(&req.n, sizeof(req), RTA_TABLE, tid); + } table_ok = 1; } else if (key == ARG_dev || key == ARG_iif -- cgit v1.2.3-55-g6feb From dc3701d2e7d847536814b939022f024ca16cbad6 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 20 Dec 2016 03:00:43 +0100 Subject: Bump version to 1.26.0 Signed-off-by: Denys Vlasenko --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5cfc76306..23518ac33 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION = 1 PATCHLEVEL = 26 SUBLEVEL = 0 -EXTRAVERSION = .git +EXTRAVERSION = NAME = Unnamed # *DOCUMENTATION* -- cgit v1.2.3-55-g6feb From 18a7bee73670af792d25dac1835e75eeeef0a08e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 21 Dec 2016 04:13:23 +0100 Subject: ash: error out if ASH_INTERNAL_GLOB is not selected on uClibc Signed-off-by: Denys Vlasenko --- shell/ash.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/shell/ash.c b/shell/ash.c index 8d8cc466b..7d45b2cd2 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -51,6 +51,14 @@ # 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"/ 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 in it. +#endif + #if !ENABLE_ASH_INTERNAL_GLOB # include #endif -- cgit v1.2.3-55-g6feb From 2169b25b152b54935fdc706dbf1032df6ae1af27 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 21 Dec 2016 21:04:16 +0100 Subject: ash: clarify uclibc glob() bug in comment Signed-off-by: Denys Vlasenko --- shell/ash.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shell/ash.c b/shell/ash.c index 7d45b2cd2..802626d4e 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -57,6 +57,9 @@ # 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 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 -- cgit v1.2.3-55-g6feb From e1065da652ca3680fdf465dd502a2bae2c2a89b9 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 22 Dec 2016 14:36:49 +0100 Subject: Tweak some config defaults; fix MODPROBE_SMALL ordering in "make config" Signed-off-by: Denys Vlasenko --- include/applets.h.sh | 8 ++++---- init/init.c | 2 +- modutils/Config.src | 31 +++++++++++++++++++++++++++++++ modutils/modprobe-small.c | 34 +++------------------------------- shell/ash.c | 5 ++--- 5 files changed, 41 insertions(+), 39 deletions(-) diff --git a/include/applets.h.sh b/include/applets.h.sh index bab4e0d72..be8b92404 100755 --- a/include/applets.h.sh +++ b/include/applets.h.sh @@ -6,9 +6,6 @@ # 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/[[/' \ | sort | uniq \ >applets_APP1 @@ -17,8 +14,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 diff --git a/init/init.c b/init/init.c index 0813d1b5f..08cfa2f8c 100644 --- a/init/init.c +++ b/init/init.c @@ -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 diff --git a/modutils/Config.src b/modutils/Config.src index 4227f356a..84ff34a08 100644 --- a/modutils/Config.src +++ b/modutils/Config.src @@ -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" diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c index 51ba42f7a..e3a349b4e 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c @@ -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 diff --git a/shell/ash.c b/shell/ash.c index 802626d4e..89339182e 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -117,7 +117,7 @@ //config: //config:config ASH_INTERNAL_GLOB //config: bool "Use internal glob() implementation" -//config: default n +//config: default y # Y is bigger, but because of uclibc glob() bug, let Y be default for now //config: depends on ASH //config: help //config: Do not use glob() function from libc, use internal implementation. @@ -218,11 +218,10 @@ //config: //config:config ASH_MAIL //config: bool "Check for new mail on interactive shells" -//config: default n +//config: default y //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)) -- cgit v1.2.3-55-g6feb From 8d0dedf1f6c1cd984c47767659ffba533cc5c5d4 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 22 Dec 2016 15:21:58 +0100 Subject: shell: move "config" blocks above their use in coditional includes Signed-off-by: Denys Vlasenko --- shell/ash.c | 163 +++++++++++++++++++++++++++++------------------------------ shell/hush.c | 58 ++++++++++----------- 2 files changed, 110 insertions(+), 111 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index 89339182e..b11f36589 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -15,88 +15,6 @@ * * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ - -/* - * The following should be set to reflect the type of system you have: - * JOBS -> 1 if you have Berkeley job control, 0 otherwise. - * define SYSV if you are running under System V. - * define DEBUG=1 to compile in debugging ('set -o debug' to turn on) - * define DEBUG=2 to compile in and turn on debugging. - * - * When debugging is on (DEBUG is 1 and "set -o debug" was executed), - * debugging info will be written to ./trace and a quit signal - * will generate a core dump. - */ -#define DEBUG 0 -/* Tweak debug output verbosity here */ -#define DEBUG_TIME 0 -#define DEBUG_PID 1 -#define DEBUG_SIG 1 -#define DEBUG_INTONOFF 0 - -#define PROFILE 0 - -#define JOBS ENABLE_ASH_JOB_CONTROL - -#include -#include -#include -#include /* for setting $HOSTNAME */ - -#include "busybox.h" /* for applet_names */ - -#if defined(__ANDROID_API__) && __ANDROID_API__ <= 24 -/* Bionic at least up to version 24 has no glob() */ -# undef ENABLE_ASH_INTERNAL_GLOB -# 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"/ 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 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 -#endif - -#include "unicode.h" -#include "shell_common.h" -#if ENABLE_SH_MATH_SUPPORT -# include "math.h" -#endif -#if ENABLE_ASH_RANDOM_SUPPORT -# include "random.h" -#else -# define CLEAR_RANDOM_T(rnd) ((void)0) -#endif - -#include "NUM_APPLETS.h" -#if NUM_APPLETS == 1 -/* STANDALONE does not make sense, and won't compile */ -# undef CONFIG_FEATURE_SH_STANDALONE -# undef ENABLE_FEATURE_SH_STANDALONE -# undef IF_FEATURE_SH_STANDALONE -# undef IF_NOT_FEATURE_SH_STANDALONE -# define ENABLE_FEATURE_SH_STANDALONE 0 -# define IF_FEATURE_SH_STANDALONE(...) -# define IF_NOT_FEATURE_SH_STANDALONE(...) __VA_ARGS__ -#endif - -#ifndef PIPE_BUF -# define PIPE_BUF 4096 /* amount of buffering in a pipe */ -#endif - -#if !BB_MMU -# error "Do not even bother, ash will not run on NOMMU machine" -#endif - //config:config ASH //config: bool "ash" //config: default y @@ -230,6 +148,87 @@ //kbuild:lib-$(CONFIG_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: + * JOBS -> 1 if you have Berkeley job control, 0 otherwise. + * define SYSV if you are running under System V. + * define DEBUG=1 to compile in debugging ('set -o debug' to turn on) + * define DEBUG=2 to compile in and turn on debugging. + * + * When debugging is on (DEBUG is 1 and "set -o debug" was executed), + * debugging info will be written to ./trace and a quit signal + * will generate a core dump. + */ +#define DEBUG 0 +/* Tweak debug output verbosity here */ +#define DEBUG_TIME 0 +#define DEBUG_PID 1 +#define DEBUG_SIG 1 +#define DEBUG_INTONOFF 0 + +#define PROFILE 0 + +#define JOBS ENABLE_ASH_JOB_CONTROL + +#include +#include +#include +#include /* for setting $HOSTNAME */ + +#include "busybox.h" /* for applet_names */ + +#if defined(__ANDROID_API__) && __ANDROID_API__ <= 24 +/* Bionic at least up to version 24 has no glob() */ +# undef ENABLE_ASH_INTERNAL_GLOB +# 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"/ 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 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 +#endif + +#include "unicode.h" +#include "shell_common.h" +#if ENABLE_SH_MATH_SUPPORT +# include "math.h" +#endif +#if ENABLE_ASH_RANDOM_SUPPORT +# include "random.h" +#else +# define CLEAR_RANDOM_T(rnd) ((void)0) +#endif + +#include "NUM_APPLETS.h" +#if NUM_APPLETS == 1 +/* STANDALONE does not make sense, and won't compile */ +# undef CONFIG_FEATURE_SH_STANDALONE +# undef ENABLE_FEATURE_SH_STANDALONE +# undef IF_FEATURE_SH_STANDALONE +# undef IF_NOT_FEATURE_SH_STANDALONE +# define ENABLE_FEATURE_SH_STANDALONE 0 +# define IF_FEATURE_SH_STANDALONE(...) +# define IF_NOT_FEATURE_SH_STANDALONE(...) __VA_ARGS__ +#endif + +#ifndef PIPE_BUF +# define PIPE_BUF 4096 /* amount of buffering in a pipe */ +#endif + +#if !BB_MMU +# error "Do not even bother, ash will not run on NOMMU machine" +#endif + /* ============ Hash table sizes. Configurable. */ diff --git a/shell/hush.c b/shell/hush.c index 888be6e6e..c5821259a 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -82,35 +82,6 @@ * $ "export" i=`echo 'aaa bbb'`; echo "$i" * aaa */ -#if !(defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \ - || defined(__APPLE__) \ - ) -# include /* for malloc_trim */ -#endif -#include -/* #include */ -#if ENABLE_HUSH_CASE -# include -#endif -#include /* for setting $HOSTNAME */ - -#include "busybox.h" /* for APPLET_IS_NOFORK/NOEXEC */ -#include "unicode.h" -#include "shell_common.h" -#include "math.h" -#include "match.h" -#if ENABLE_HUSH_RANDOM_SUPPORT -# include "random.h" -#else -# define CLEAR_RANDOM_T(rnd) ((void)0) -#endif -#ifndef F_DUPFD_CLOEXEC -# define F_DUPFD_CLOEXEC F_DUPFD -#endif -#ifndef PIPE_BUF -# define PIPE_BUF 4096 /* amount of buffering in a pipe */ -#endif - //config:config HUSH //config: bool "hush" //config: default y @@ -277,6 +248,35 @@ //usage:# define bash_full_usage hush_full_usage //usage:#endif +#if !(defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \ + || defined(__APPLE__) \ + ) +# include /* for malloc_trim */ +#endif +#include +/* #include */ +#if ENABLE_HUSH_CASE +# include +#endif +#include /* for setting $HOSTNAME */ + +#include "busybox.h" /* for APPLET_IS_NOFORK/NOEXEC */ +#include "unicode.h" +#include "shell_common.h" +#include "math.h" +#include "match.h" +#if ENABLE_HUSH_RANDOM_SUPPORT +# include "random.h" +#else +# define CLEAR_RANDOM_T(rnd) ((void)0) +#endif +#ifndef F_DUPFD_CLOEXEC +# define F_DUPFD_CLOEXEC F_DUPFD +#endif +#ifndef PIPE_BUF +# define PIPE_BUF 4096 /* amount of buffering in a pipe */ +#endif + /* Build knobs */ #define LEAK_HUNTING 0 -- cgit v1.2.3-55-g6feb From 05069b4682d70b9c8d3220db646d07ffc4052549 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 22 Dec 2016 22:30:13 +0100 Subject: ip: make ip aliases individually selectable Signed-off-by: Denys Vlasenko --- networking/ip.c | 162 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 85 insertions(+), 77 deletions(-) diff --git a/networking/ip.c b/networking/ip.c index c3607b74f..939721e46 100644 --- a/networking/ip.c +++ b/networking/ip.c @@ -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 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 -- cgit v1.2.3-55-g6feb From c2f3655842f5e9872631fbf0a4d0339baa44dc63 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 23 Dec 2016 02:42:26 +0100 Subject: fix breakage found by mass one-applet builds Signed-off-by: Denys Vlasenko --- archival/bbunzip.c | 4 ++++ libbb/Kbuild.src | 1 + libbb/appletlib.c | 32 ++++++++++++++++---------------- libbb/update_passwd.c | 2 ++ networking/libiproute/Kbuild.src | 3 +++ networking/udhcp/Config.src | 2 -- networking/udhcp/Kbuild.src | 2 +- sysklogd/logread.c | 3 ++- 8 files changed, 29 insertions(+), 20 deletions(-) diff --git a/archival/bbunzip.c b/archival/bbunzip.c index d5db4627f..60a837e22 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c @@ -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 { diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src index e426f3c7e..898a51a89 100644 --- a/libbb/Kbuild.src +++ b/libbb/Kbuild.src @@ -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 diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 9425c7bd4..ee8b4ec14 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -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 */ diff --git a/libbb/update_passwd.c b/libbb/update_passwd.c index 6255af492..95423d19b 100644 --- a/libbb/update_passwd.c +++ b/libbb/update_passwd.c @@ -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) { diff --git a/networking/libiproute/Kbuild.src b/networking/libiproute/Kbuild.src index c20e2fee8..056a58540 100644 --- a/networking/libiproute/Kbuild.src +++ b/networking/libiproute/Kbuild.src @@ -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 diff --git a/networking/udhcp/Config.src b/networking/udhcp/Config.src index c34c8d6f0..90fb313b5 100644 --- a/networking/udhcp/Config.src +++ b/networking/udhcp/Config.src @@ -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 diff --git a/networking/udhcp/Kbuild.src b/networking/udhcp/Kbuild.src index 5ea77df06..fcb725fbc 100644 --- a/networking/udhcp/Kbuild.src +++ b/networking/udhcp/Kbuild.src @@ -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 diff --git a/sysklogd/logread.c b/sysklogd/logread.c index 5b999730a..1f0c6252d 100644 --- a/sysklogd/logread.c +++ b/sysklogd/logread.c @@ -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 -- cgit v1.2.3-55-g6feb From f2200af1a8ca47777bff36ed2bd31047aff01a06 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 23 Dec 2016 13:39:22 +0100 Subject: make_single_applets.sh: a tool to check single-applet builds Signed-off-by: Denys Vlasenko --- make_single_applets.sh | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 make_single_applets.sh diff --git a/make_single_applets.sh b/make_single_applets.sh new file mode 100755 index 000000000..5b9393e33 --- /dev/null +++ b/make_single_applets.sh @@ -0,0 +1,57 @@ +#!/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/' \ +| grep -v ^MODPROBE_SMALL \ +| 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 + +# 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 ! 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} + else + mv busybox busybox_${app} + rm busybox_make_${app}.log + fi + mv .config.SV .config + #exit +done +echo "Failures: $fail" +test $fail = 0 # set exitcode -- cgit v1.2.3-55-g6feb From 048c043ae64183967505b6fddd5b68663bdf6c40 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 23 Dec 2016 13:40:24 +0100 Subject: Make FEATURE_USERNAME_COMPLETION=y by default This matches bash behavior on Fedora Signed-off-by: Denys Vlasenko --- libbb/Config.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libbb/Config.src b/libbb/Config.src index 00804e31e..172fbcc0e 100644 --- a/libbb/Config.src +++ b/libbb/Config.src @@ -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. -- cgit v1.2.3-55-g6feb From ed6fb36124784d1cd2cb4421b150edc5bca719dc Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 23 Dec 2016 13:52:13 +0100 Subject: Selinux complains about deprecated selinux/flask.h, stop including it Signed-off-by: Denys Vlasenko --- loginutils/login.c | 4 +++- selinux/runcon.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/loginutils/login.c b/loginutils/login.c index 52abc1886..3ca8213bb 100644 --- a/loginutils/login.c +++ b/loginutils/login.c @@ -69,7 +69,9 @@ #if ENABLE_SELINUX # include /* for is_selinux_enabled() */ # include /* for get_default_context() */ -# include /* for security class definitions */ +# /* from deprecated : */ +# undef SECCLASS_CHR_FILE +# define SECCLASS_CHR_FILE 10 #endif #if ENABLE_PAM diff --git a/selinux/runcon.c b/selinux/runcon.c index 366834e46..16f171101 100644 --- a/selinux/runcon.c +++ b/selinux/runcon.c @@ -68,7 +68,9 @@ //usage: ) #include -#include +/* from deprecated : */ +#undef SECCLASS_PROCESS +#define SECCLASS_PROCESS 2 #include "libbb.h" -- cgit v1.2.3-55-g6feb From 909edacc5ef8960784c5ec1ab529522bed1deaa8 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 23 Dec 2016 13:52:53 +0100 Subject: Make DPKG=y and DPKG_DEB=y by default Signed-off-by: Denys Vlasenko --- archival/dpkg.c | 2 +- archival/dpkg_deb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/archival/dpkg.c b/archival/dpkg.c index df7a0db64..f133299e3 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c @@ -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 diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c index 86850469d..ebbc7f035 100644 --- a/archival/dpkg_deb.c +++ b/archival/dpkg_deb.c @@ -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. -- cgit v1.2.3-55-g6feb From d28cd9900a58a902b1bf53404a250dfb345b2e96 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 23 Dec 2016 15:12:27 +0100 Subject: modprobe-small: make applets individually selectable Signed-off-by: Denys Vlasenko --- include/applets.h.sh | 3 +-- make_single_applets.sh | 7 ++++++- modutils/depmod.c | 7 ++++--- modutils/insmod.c | 5 +++-- modutils/lsmod.c | 11 ++++++----- modutils/modprobe-small.c | 24 ++++++++++++------------ modutils/modprobe.c | 11 ++++++----- modutils/rmmod.c | 5 +++-- 8 files changed, 41 insertions(+), 32 deletions(-) diff --git a/include/applets.h.sh b/include/applets.h.sh index be8b92404..be117cf84 100755 --- a/include/applets.h.sh +++ b/include/applets.h.sh @@ -4,8 +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 \ +grep ^IF_ applets.h | grep -v ^IF_FEATURE_ | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \ | sort | uniq \ >applets_APP1 diff --git a/make_single_applets.sh b/make_single_applets.sh index 5b9393e33..6473e4ddd 100755 --- a/make_single_applets.sh +++ b/make_single_applets.sh @@ -14,7 +14,6 @@ apps="` grep ^IF_ include/applets.h \ | grep -v ^IF_FEATURE_ \ | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \ -| grep -v ^MODPROBE_SMALL \ | sort | uniq `" @@ -46,6 +45,11 @@ for app in $apps; do : $((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 @@ -53,5 +57,6 @@ for app in $apps; do mv .config.SV .config #exit done +touch .config # or else next "make" can be confused echo "Failures: $fail" test $fail = 0 # set exitcode diff --git a/modutils/depmod.c b/modutils/depmod.c index b9347027e..cfa9abb1a 100644 --- a/modutils/depmod.c +++ b/modutils/depmod.c @@ -9,15 +9,16 @@ */ //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)) +//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y) +//applet:IF_DEPMOD(IF_NOT_MODPROBE_SMALL(APPLET(depmod, BB_DIR_SBIN, BB_SUID_DROP))) +//kbuild:endif //kbuild:lib-$(CONFIG_DEPMOD) += depmod.o modutils.o diff --git a/modutils/insmod.c b/modutils/insmod.c index 2ebf4beb9..5949fe551 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c @@ -9,14 +9,15 @@ //config:config INSMOD //config: bool "insmod" //config: default n -//config: depends on !MODPROBE_SMALL //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" diff --git a/modutils/lsmod.c b/modutils/lsmod.c index ee85fb0fb..24589420a 100644 --- a/modutils/lsmod.c +++ b/modutils/lsmod.c @@ -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 diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c index e3a349b4e..652ff4dfa 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c @@ -25,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 @@ -930,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; } @@ -940,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) @@ -986,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); } @@ -1014,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; @@ -1034,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(); } diff --git a/modutils/modprobe.c b/modutils/modprobe.c index d404ef92f..09e3de6c3 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c @@ -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" diff --git a/modutils/rmmod.c b/modutils/rmmod.c index e0358838a..4c4d50885 100644 --- a/modutils/rmmod.c +++ b/modutils/rmmod.c @@ -10,14 +10,15 @@ //config:config RMMOD //config: bool "rmmod" //config: default n -//config: depends on !MODPROBE_SMALL //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 -- cgit v1.2.3-55-g6feb From 890b1feaa011261748e085037da4ef4720ef3de2 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 23 Dec 2016 15:18:31 +0100 Subject: 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 --- networking/ifupdown.c | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 7ac517afd..1806a6ccc 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c @@ -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: -//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: 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 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" -- cgit v1.2.3-55-g6feb From e5dc0d01203fd5b0ea21890007c86966f78c37f6 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 23 Dec 2016 15:22:44 +0100 Subject: Make INSMOD=y by default Signed-off-by: Denys Vlasenko --- modutils/insmod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modutils/insmod.c b/modutils/insmod.c index 5949fe551..f2c70e16f 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c @@ -8,7 +8,7 @@ */ //config:config INSMOD //config: bool "insmod" -//config: default n +//config: default y //config: select PLATFORM_LINUX //config: help //config: insmod is used to load specified modules in the running kernel. -- cgit v1.2.3-55-g6feb From 9982d88a61684743f24143d97a634b8e12f56bcb Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 23 Dec 2016 15:57:26 +0100 Subject: Make RMMOD=y by default Signed-off-by: Denys Vlasenko --- modutils/rmmod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modutils/rmmod.c b/modutils/rmmod.c index 4c4d50885..527696f63 100644 --- a/modutils/rmmod.c +++ b/modutils/rmmod.c @@ -9,7 +9,7 @@ */ //config:config RMMOD //config: bool "rmmod" -//config: default n +//config: default y //config: select PLATFORM_LINUX //config: help //config: rmmod is used to unload specified modules from the kernel. -- cgit v1.2.3-55-g6feb From 28251dfa64a999c69605471863a2bb8692bfc7b3 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 23 Dec 2016 16:49:07 +0100 Subject: 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 --- coreutils/Kbuild.src | 20 ++++++----- coreutils/test.c | 2 ++ make_single_applets.sh | 11 ++++++ procps/Kbuild.src | 2 ++ shell/Config.src | 45 +++++++++++------------- shell/Kbuild.src | 2 +- shell/ash.c | 95 ++++++++++++++++++++++++-------------------------- shell/hush.c | 59 +++++++++++++------------------ shell/math.h | 2 +- 9 files changed, 120 insertions(+), 118 deletions(-) diff --git a/coreutils/Kbuild.src b/coreutils/Kbuild.src index 8e2c097a3..d9a448781 100644 --- a/coreutils/Kbuild.src +++ b/coreutils/Kbuild.src @@ -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 diff --git a/coreutils/test.c b/coreutils/test.c index 9e18ee986..288f66508 100644 --- a/coreutils/test.c +++ b/coreutils/test.c @@ -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 diff --git a/make_single_applets.sh b/make_single_applets.sh index 6473e4ddd..705f9821c 100755 --- a/make_single_applets.sh +++ b/make_single_applets.sh @@ -26,6 +26,7 @@ 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 @@ -37,6 +38,16 @@ for app in $apps; do 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"; then + # $allno has all choices for "sh" aliasing at off. + # "sh" aliasing defaults to "ash", not none. + # without this fix, "make oldconfig" sets it wrong, + # resulting in NUM_APPLETS = 2 + 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}" diff --git a/procps/Kbuild.src b/procps/Kbuild.src index 83af05a05..e7adc7340 100644 --- a/procps/Kbuild.src +++ b/procps/Kbuild.src @@ -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 diff --git a/shell/Config.src b/shell/Config.src index e4df35973..7f5f67050 100644 --- a/shell/Config.src +++ b/shell/Config.src @@ -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 _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 diff --git a/shell/Kbuild.src b/shell/Kbuild.src index c00aec92a..6bba4989f 100644 --- a/shell/Kbuild.src +++ b/shell/Kbuild.src @@ -8,4 +8,4 @@ lib-y:= INSERT -lib-$(CONFIG_SH_MATH_SUPPORT) += math.o +lib-$(CONFIG_FEATURE_SH_MATH) += math.o diff --git a/shell/ash.c b/shell/ash.c index b11f36589..430e42a7b 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -29,14 +29,14 @@ //config:config ASH_OPTIMIZE_FOR_SIZE //config: bool "Optimize for size instead of speed" //config: default y -//config: depends on ASH +//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 +//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" @@ -45,7 +45,7 @@ //config:config ASH_RANDOM_SUPPORT //config: bool "Pseudorandom generator and $RANDOM variable" //config: default y -//config: depends on ASH +//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. @@ -56,7 +56,7 @@ //config:config ASH_EXPAND_PRMT //config: bool "Expand prompt string" //config: default y -//config: depends on ASH +//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 @@ -65,70 +65,70 @@ //config:config ASH_BASH_COMPAT //config: bool "bash-compatible extensions" //config: default y -//config: depends on ASH +//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 +//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 +//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 +//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 +//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 +//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 +//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 +//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 +//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 +//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, @@ -137,15 +137,17 @@ //config:config ASH_MAIL //config: bool "Check for new mail on interactive shells" //config: default y -//config: depends on ASH +//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_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)) +//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 /* @@ -200,7 +202,7 @@ #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 @@ -2144,6 +2146,7 @@ lookupvar(const char *name) return NULL; } +#if ENABLE_UNICODE_SUPPORT static void reinit_unicode_for_ash(void) { @@ -2160,6 +2163,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. @@ -2741,7 +2747,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)) @@ -3129,7 +3135,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); \ }) @@ -4487,7 +4493,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; @@ -5547,7 +5553,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) { @@ -5635,7 +5641,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" @@ -6148,7 +6154,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. @@ -6230,7 +6236,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' @@ -6266,7 +6272,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++; @@ -6346,7 +6352,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); @@ -9265,7 +9271,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; @@ -9345,7 +9351,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 }, @@ -11394,13 +11400,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;) @@ -11408,7 +11414,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) @@ -11416,8 +11422,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); @@ -11524,7 +11530,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); @@ -11575,7 +11581,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 @@ -11754,7 +11760,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"); @@ -12009,7 +12015,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) */ @@ -13046,7 +13052,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. @@ -13301,15 +13307,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. */ diff --git a/shell/hush.c b/shell/hush.c index c5821259a..fecc89294 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -99,7 +99,7 @@ //config:config HUSH_BASH_COMPAT //config: bool "bash-compatible extensions" //config: default y -//config: depends on HUSH +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH //config: help //config: Enable bash-compatible extensions. //config: @@ -113,14 +113,14 @@ //config:config HUSH_HELP //config: bool "help builtin" //config: default y -//config: depends on HUSH +//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 +//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 @@ -148,35 +148,35 @@ //config:config HUSH_TICK //config: bool "Process substitution" //config: default y -//config: depends on HUSH +//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 +//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 +//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 +//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 +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH //config: help //config: Enable support for shell functions in hush. +800 bytes. //config: @@ -190,7 +190,7 @@ //config:config HUSH_RANDOM_SUPPORT //config: bool "Pseudorandom generator and $RANDOM variable" //config: default y -//config: depends on HUSH +//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. @@ -198,14 +198,14 @@ //config:config HUSH_EXPORT_N //config: bool "Support 'export -n' option" //config: default y -//config: depends on HUSH +//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 +//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. @@ -216,14 +216,15 @@ //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)) +//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, @@ -236,18 +237,6 @@ //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 - #if !(defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \ || defined(__APPLE__) \ ) @@ -4011,7 +4000,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 +4168,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 +4322,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); @@ -5217,7 +5206,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 +5458,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:NM @@ -5604,7 +5593,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 +5687,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 '+': { /* +cmd */ arith_t res; diff --git a/shell/math.h b/shell/math.h index 864bee691..32e1ffe35 100644 --- a/shell/math.h +++ b/shell/math.h @@ -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 -- cgit v1.2.3-55-g6feb From fe3f55c540ed21005ba5bd981e098cb5dec64c37 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 23 Dec 2016 19:42:53 +0100 Subject: 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 --- make_single_applets.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/make_single_applets.sh b/make_single_applets.sh index 705f9821c..00f502eda 100755 --- a/make_single_applets.sh +++ b/make_single_applets.sh @@ -39,11 +39,11 @@ for app in $apps; do echo "CONFIG_${app}=y" >.config echo "$allno" | sed "/^# CONFIG_${app} is not set\$/d" >>.config - if test x"${app}" != x"SH_IS_ASH"; then - # $allno has all choices for "sh" aliasing at off. + 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 + # 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 @@ -52,7 +52,7 @@ for app in $apps; do : $((fail++)) echo "Config error for ${app}" mv .config busybox_config_${app} - elif ! make $makeopts >busybox_make_${app}.log 2>&1; then + elif ! make $makeopts >>busybox_make_${app}.log 2>&1; then : $((fail++)) echo "Build error for ${app}" mv .config busybox_config_${app} -- cgit v1.2.3-55-g6feb From 1a6aca3d6002e133b7517f8f1ff3d7f0dd954c3f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 1 Jan 2017 13:12:48 +0100 Subject: depmod: don't build it if MODPROBE_SMALL=y Signed-off-by: Denys Vlasenko --- modutils/depmod.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modutils/depmod.c b/modutils/depmod.c index cfa9abb1a..b7965ebd2 100644 --- a/modutils/depmod.c +++ b/modutils/depmod.c @@ -16,11 +16,11 @@ //config: and modules.symbols) that contain dependency information //config: for modprobe. -//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y) //applet:IF_DEPMOD(IF_NOT_MODPROBE_SMALL(APPLET(depmod, BB_DIR_SBIN, BB_SUID_DROP))) -//kbuild:endif +//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y) //kbuild:lib-$(CONFIG_DEPMOD) += depmod.o modutils.o +//kbuild:endif #include "libbb.h" #include "modutils.h" -- cgit v1.2.3-55-g6feb From a12eb9c64d736ffa8e335683f54b33b40fbc7385 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 2 Jan 2017 01:43:37 +0100 Subject: Bump version to 1.26.1 Signed-off-by: Denys Vlasenko --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 23518ac33..06d307708 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ VERSION = 1 PATCHLEVEL = 26 -SUBLEVEL = 0 +SUBLEVEL = 1 EXTRAVERSION = NAME = Unnamed -- cgit v1.2.3-55-g6feb From e94d2c5f242c793db1d76a4c0a63740de8ae6899 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 2 Jan 2017 10:46:08 +0100 Subject: 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 --- networking/tcpudp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/networking/tcpudp.c b/networking/tcpudp.c index 94c89b9ef..3a6c68646 100644 --- a/networking/tcpudp.c +++ b/networking/tcpudp.c @@ -107,10 +107,10 @@ #include "libbb.h" #include "common_bufsiz.h" -/* Wants etc, thus included after libbb.h: */ #ifdef __linux__ -#include /* for __be32 etc */ -#include +/* from linux/netfilter_ipv4.h: */ +# undef SO_ORIGINAL_DST +# define SO_ORIGINAL_DST 80 #endif // TODO: move into this file: -- cgit v1.2.3-55-g6feb From 568cabf98a11e2e594243a309a9ffd7729a2b213 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 3 Jan 2017 11:18:23 +0100 Subject: 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 Reported-by: Martijn Dekker Signed-off-by: Denys Vlasenko --- shell/ash.c | 8 ++++++-- shell/ash_test/ash-misc/exitcode2.right | 4 ++++ shell/ash_test/ash-misc/exitcode2.tests | 12 ++++++++++++ shell/hush_test/hush-misc/exitcode2.right | 4 ++++ shell/hush_test/hush-misc/exitcode2.tests | 12 ++++++++++++ 5 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 shell/ash_test/ash-misc/exitcode2.right create mode 100755 shell/ash_test/ash-misc/exitcode2.tests create mode 100644 shell/hush_test/hush-misc/exitcode2.right create mode 100755 shell/hush_test/hush-misc/exitcode2.tests diff --git a/shell/ash.c b/shell/ash.c index 430e42a7b..7c53946ce 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -1284,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 */ @@ -9588,11 +9590,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; } diff --git a/shell/ash_test/ash-misc/exitcode2.right b/shell/ash_test/ash-misc/exitcode2.right new file mode 100644 index 000000000..f7cb983c6 --- /dev/null +++ b/shell/ash_test/ash-misc/exitcode2.right @@ -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 diff --git a/shell/ash_test/ash-misc/exitcode2.tests b/shell/ash_test/ash-misc/exitcode2.tests new file mode 100755 index 000000000..79a6ebd50 --- /dev/null +++ b/shell/ash_test/ash-misc/exitcode2.tests @@ -0,0 +1,12 @@ +# syntax error should return status 2 +cat >test.sh <test.sh < Date: Tue, 3 Jan 2017 11:47:50 +0100 Subject: hush: correct exitcode for unterminated ')' - exitcode2.tests testcase function old new delta parse_stream 2595 2609 +14 Signed-off-by: Denys Vlasenko --- shell/hush.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/shell/hush.c b/shell/hush.c index fecc89294..a56d3b280 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -1137,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); } @@ -4997,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); @@ -5005,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;) @@ -5038,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; -- cgit v1.2.3-55-g6feb From 7bcc3c46a7749226697e8b4a486edadcac4f1723 Mon Sep 17 00:00:00 2001 From: Jörg Krause Date: Tue, 3 Jan 2017 12:29:52 +0100 Subject: Fix dependency for IFUPDOWN_UDHCPC_CMD_OPTIONS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit a8c696bf09d8151323f6e99348c4bc8989f829c8 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 Signed-off-by: Denys Vlasenko --- networking/Config.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/networking/Config.src b/networking/Config.src index 527bdd15d..0adb1e2f9 100644 --- a/networking/Config.src +++ b/networking/Config.src @@ -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. -- cgit v1.2.3-55-g6feb From add927e3d16414738ce46c28bb9d83e173848740 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Mon, 26 Dec 2016 20:07:59 +0100 Subject: modutils: remove special handling of uClibc Commit 3a45b87ac36f (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 Signed-off-by: Waldemar Brodkorb Signed-off-by: Denys Vlasenko --- modutils/modprobe-small.c | 4 ++-- modutils/modutils.c | 16 ++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c index 652ff4dfa..0fc9ea454 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c @@ -39,8 +39,8 @@ #include #include -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 diff --git a/modutils/modutils.c b/modutils/modutils.c index d36caaf68..4204f06fe 100644 --- a/modutils/modutils.c +++ b/modutils/modutils.c @@ -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 -# 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 + +#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) { -- cgit v1.2.3-55-g6feb From 8e38108d03e0e583eabf61953b5e7b4f5af8966f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 7 Jan 2017 10:15:01 +0100 Subject: ash: fix open fds leaking in redirects. Closes 9561 commit e19923f6652a638ac39c84012e97f52cf5a7568e 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 --- shell/ash.c | 11 +++++++---- shell/ash_test/ash-redir/redir_leak.right | 6 ++++++ shell/ash_test/ash-redir/redir_leak.tests | 10 ++++++++++ shell/hush_test/hush-redir/redir_leak.right | 6 ++++++ shell/hush_test/hush-redir/redir_leak.tests | 10 ++++++++++ 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 shell/ash_test/ash-redir/redir_leak.right create mode 100755 shell/ash_test/ash-redir/redir_leak.tests create mode 100644 shell/hush_test/hush-redir/redir_leak.right create mode 100755 shell/hush_test/hush-redir/redir_leak.tests diff --git a/shell/ash.c b/shell/ash.c index 7c53946ce..e6d02f69c 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -5426,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) { @@ -5445,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 */ diff --git a/shell/ash_test/ash-redir/redir_leak.right b/shell/ash_test/ash-redir/redir_leak.right new file mode 100644 index 000000000..b1c48292b --- /dev/null +++ b/shell/ash_test/ash-redir/redir_leak.right @@ -0,0 +1,6 @@ +4 +4 +4 +4 +4 +4 diff --git a/shell/ash_test/ash-redir/redir_leak.tests b/shell/ash_test/ash-redir/redir_leak.tests new file mode 100755 index 000000000..c8a9c6343 --- /dev/null +++ b/shell/ash_test/ash-redir/redir_leak.tests @@ -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 diff --git a/shell/hush_test/hush-redir/redir_leak.right b/shell/hush_test/hush-redir/redir_leak.right new file mode 100644 index 000000000..b1c48292b --- /dev/null +++ b/shell/hush_test/hush-redir/redir_leak.right @@ -0,0 +1,6 @@ +4 +4 +4 +4 +4 +4 diff --git a/shell/hush_test/hush-redir/redir_leak.tests b/shell/hush_test/hush-redir/redir_leak.tests new file mode 100755 index 000000000..c8a9c6343 --- /dev/null +++ b/shell/hush_test/hush-redir/redir_leak.tests @@ -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 -- cgit v1.2.3-55-g6feb From 889425812b5cda8b3394d73253cbde7355fb1115 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 10 Jan 2017 17:01:20 +0100 Subject: Bump version to 1.26.2 Signed-off-by: Denys Vlasenko --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 06d307708..971e68e87 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ VERSION = 1 PATCHLEVEL = 26 -SUBLEVEL = 1 +SUBLEVEL = 2 EXTRAVERSION = NAME = Unnamed -- cgit v1.2.3-55-g6feb