[BusyBox] Problems with ash exec
Vladimir N. Oleynik
dzo at simtreas.ru
Sun Aug 26 11:24:07 UTC 2001
Matt,
> When ash's exec command is used, it calls run_applet_by_name for
> each component in the path with the full pathname, until it finds
> the applet. The first time it is called, it fails to find the
> applet (since it is specified with a full pathname), and resets
> recurse_level to 0. On the next attempt, it falls back to
> busybox. It bumps argv and tries to find the command, which
> fails, and it prints the usage message.
>
> The least intrusive solution is to modify run_applet_by_name to
> decrement, rather than reset, recurse_level.
And as you concern to such addition of small convenience?
It is required only 32 additional bytes.
After this patch both variants will give identical result:
$ busybox --help applet
$ busybox applet --help
-------------- next part --------------
--- applets_orig.c Sun Aug 26 21:00:47 2001
+++ applets.c Sun Aug 26 21:07:13 2001
@@ -45,13 +45,6 @@
const char *format_string;
const char *usage_string = usage_messages;
int i;
- /* From busybox.c */
- extern int been_there_done_that;
-
- if (strcmp(applet_using->name, "busybox")==0) {
- been_there_done_that=1;
- busybox_main(0, NULL);
- }
for (i = applet_using - applets; i > 0; ) {
if (!*usage_string++) {
@@ -85,13 +78,23 @@
void run_applet_by_name(const char *name, int argc, char **argv)
{
static int recurse_level = 0;
+ extern int been_there_done_that; /* From busybox.c */
recurse_level++;
/* Do a binary search to find the applet entry given the name. */
if ((applet_using = find_applet_by_name(name)) != NULL) {
applet_name = applet_using->name;
if (argv[1] && strcmp(argv[1], "--help") == 0) {
- show_usage();
+ if (strcmp(applet_using->name, "busybox")==0) {
+ if(argv[2])
+ applet_using = find_applet_by_name(argv[2]);
+ else
+ applet_using = NULL;
+ }
+ if(applet_using)
+ show_usage();
+ been_there_done_that=1;
+ busybox_main(0, NULL);
}
exit((*(applet_using->main)) (argc, argv));
}
@@ -99,7 +102,7 @@
if (recurse_level == 1) {
run_applet_by_name("busybox", argc, argv);
}
- recurse_level = 0;
+ recurse_level--;
}
More information about the busybox
mailing list