[BusyBox] Problems with ash exec

Matt Kraai kraai at alumni.carnegiemellon.edu
Sun Aug 26 10:54:22 MDT 2001


On Sat, Aug 25, 2001 at 10:20:19PM -0400, Tom Cameron wrote:
> 	My guess (I don't know if anything has been committed to CVS for this
> question) is that when you do the `exec somecommand`, exec isn't
> searching the $PATH variable for the program (actually, the link).  This
> would make sense in the case that when you supply the full path to the
> link, the program gets executed.  Have you tried just typing, say, `vi`
> at the prompt?  If this fails also, then you have a problem elsewhere. 
> Let us know.

I can reproduce this problem on my system, by enabling BB_ASH and
BB_FEATURE_SH_STANDALONE_SHELL.

In order to work if busybox is renamed, run_applet_by_name falls
back to the busybox applet if it doesn't recognize the applet
name.  To prevent this from happening for each argument (assuming
none are valid applets), the recurse_level variable tries to
ensure that this only happens the first time run_applet_by_name is
called.  This also prevents this behavior from happening for other
callers (such as the shells).

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.

Matt

--- busybox-0.60.1.orig/applets.c	Sat Jun 23 23:09:14 2001
+++ busybox/applets.c	Sun Aug 26 14:37:35 2001
@@ -99,7 +99,7 @@
 	if (recurse_level == 1) {
 		run_applet_by_name("busybox", argc, argv);
 	}
-	recurse_level = 0;
+	recurse_level--;
 }
 
 





More information about the busybox mailing list