tail: fix SEGV on "tail -N"
config system: clarify PREFER_APPLETS/SH_STANDALONE effects in help text
This commit is contained in:
parent
0cacc80952
commit
92c0b8222e
@ -244,8 +244,13 @@ config FEATURE_PREFER_APPLETS
|
|||||||
help
|
help
|
||||||
This is an experimental option which directs applets about to
|
This is an experimental option which directs applets about to
|
||||||
call 'exec' to try and find an applicable busybox applet before
|
call 'exec' to try and find an applicable busybox applet before
|
||||||
searching the PATH. This may affect shell, find -exec, xargs and
|
searching the PATH. This is typically done by exec'ing
|
||||||
similar programs.
|
/proc/self/exe.
|
||||||
|
This may affect shell, find -exec, xargs and similar applets.
|
||||||
|
They will use applets even if /bin/<applet> -> busybox link
|
||||||
|
is missing (or is not a link to busybox). However, this causes
|
||||||
|
problems in chroot jails without mounted /proc and with ps/top
|
||||||
|
(command name can be shown as 'exe' for applets started this way).
|
||||||
|
|
||||||
config BUSYBOX_EXEC_PATH
|
config BUSYBOX_EXEC_PATH
|
||||||
string "Path to BusyBox executable"
|
string "Path to BusyBox executable"
|
||||||
|
@ -79,7 +79,8 @@ int tail_main(int argc, char **argv)
|
|||||||
unsigned sleep_period = 1;
|
unsigned sleep_period = 1;
|
||||||
bool from_top;
|
bool from_top;
|
||||||
int header_threshhold = 1;
|
int header_threshhold = 1;
|
||||||
const char *str_c, *str_n, *str_s;
|
const char *str_c, *str_n;
|
||||||
|
USE_FEATURE_FANCY_TAIL(const char *str_s;)
|
||||||
|
|
||||||
char *tailbuf;
|
char *tailbuf;
|
||||||
size_t tailbufsize;
|
size_t tailbufsize;
|
||||||
@ -96,13 +97,18 @@ int tail_main(int argc, char **argv)
|
|||||||
if (argc >= 2 && (argv[1][0] == '+' || argv[1][0] == '-')
|
if (argc >= 2 && (argv[1][0] == '+' || argv[1][0] == '-')
|
||||||
&& isdigit(argv[1][1])
|
&& isdigit(argv[1][1])
|
||||||
) {
|
) {
|
||||||
argv[0] = (char*)"-n";
|
/* replacing arg[0] with "-n" can segfault, so... */
|
||||||
argv--;
|
argv[1] = xasprintf("-n%s", argv[1]);
|
||||||
argc++;
|
#if 0 /* If we ever decide to make tail NOFORK */
|
||||||
|
char *s = alloca(strlen(argv[1]) + 3);
|
||||||
|
sprintf(s, "-n%s", argv[1]);
|
||||||
|
argv[1] = s;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
opt = getopt32(argc, argv, "fc:n:" USE_FEATURE_FANCY_TAIL("qs:v"), &str_c, &str_n, &str_s);
|
opt = getopt32(argc, argv, "fc:n:" USE_FEATURE_FANCY_TAIL("qs:v"),
|
||||||
|
&str_c, &str_n USE_FEATURE_FANCY_TAIL(,&str_s));
|
||||||
#define FOLLOW (opt & 0x1)
|
#define FOLLOW (opt & 0x1)
|
||||||
#define COUNT_BYTES (opt & 0x2)
|
#define COUNT_BYTES (opt & 0x2)
|
||||||
//if (opt & 0x1) // -f
|
//if (opt & 0x1) // -f
|
||||||
|
@ -242,7 +242,7 @@ config FEATURE_SH_STANDALONE
|
|||||||
default n
|
default n
|
||||||
depends on (MSH || LASH || HUSH || ASH) && FEATURE_PREFER_APPLETS
|
depends on (MSH || LASH || HUSH || ASH) && FEATURE_PREFER_APPLETS
|
||||||
help
|
help
|
||||||
This option causes the selected busybox shell to use busybox applets
|
This option causes busybox shells to use busybox applets
|
||||||
in preference to executables in the PATH whenever possible. For
|
in preference to executables in the PATH whenever possible. For
|
||||||
example, entering the command 'ifconfig' into the shell would cause
|
example, entering the command 'ifconfig' into the shell would cause
|
||||||
busybox to use the ifconfig busybox applet. Specifying the fully
|
busybox to use the ifconfig busybox applet. Specifying the fully
|
||||||
@ -251,14 +251,23 @@ config FEATURE_SH_STANDALONE
|
|||||||
is generally used when creating a statically linked version of busybox
|
is generally used when creating a statically linked version of busybox
|
||||||
for use as a rescue shell, in the event that you screw up your system.
|
for use as a rescue shell, in the event that you screw up your system.
|
||||||
|
|
||||||
Note that this will *also* cause applets to take precedence
|
This is implemented by re-execing /proc/self/exe (typically)
|
||||||
over shell builtins of the same name. So turning this on will
|
with right parameters. Some selected applets ("NOFORK" applets)
|
||||||
eliminate any performance gained by turning on the builtin "echo"
|
can even be executed without creating new process.
|
||||||
and "test" commands in ash.
|
Instead, busybox will call <applet>_main() internally.
|
||||||
|
|
||||||
Note that when using this option, the shell will attempt to directly
|
However, this causes problems in chroot jails without mounted /proc
|
||||||
run '/bin/busybox'. If you do not have the busybox binary sitting in
|
and with ps/top (command name can be shown as 'exe' for applets
|
||||||
that exact location with that exact name, this option will not work at
|
started this way).
|
||||||
all.
|
# untrue?
|
||||||
|
# Note that this will *also* cause applets to take precedence
|
||||||
|
# over shell builtins of the same name. So turning this on will
|
||||||
|
# eliminate any performance gained by turning on the builtin "echo"
|
||||||
|
# and "test" commands in ash.
|
||||||
|
# untrue?
|
||||||
|
# Note that when using this option, the shell will attempt to directly
|
||||||
|
# run '/bin/busybox'. If you do not have the busybox binary sitting in
|
||||||
|
# that exact location with that exact name, this option will not work at
|
||||||
|
# all.
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
Loading…
Reference in New Issue
Block a user