[BusyBox] [patch] ash tryexec() problem with shell scripts

Vladimir N. Oleynik dzo at simtreas.ru
Tue Sep 2 09:30:29 UTC 2003


Jean,

> Hello,
> 
> ash is unable  to execute a shell script without #! /bin/sh as the first
> line. It correctly locates the script, tries to execute it via eceve
> which fails. After that it tries to hand it over to /bin/sh which fails
> too, since
> 
>     - ash isn providing the absolute pathname to /bin/sh
>     - ash isn't trying to lookup the script via PATH
> 
> The following patch hands the absolute pathname to /bin/sh to solve
> this problem. It replaces argv[1] with the cmd to be executed.
> 
> --- shell/ash.c	23 Aug 2003 10:16:09 -0000
> +++ shell/ash.c	29 Aug 2003 11:57:54 -0000
> @@ -3754,7 +3754,10 @@
>  		for (ap = argv; *ap; ap++)
>  			;
>  		ap = new = ckmalloc((ap - argv + 2) * sizeof(char *));
> -		*ap++ = cmd = "/bin/sh";
> +		ap[1] = cmd;
> + 		*ap = cmd = "/bin/sh";
> +		ap += 2;
> +		argv++;
>  		while ((*ap++ = *argv++))
>  			;
>  		argv = new;

Excuse me.
Your patch is absolute correct.

I confused your message:
1) >     - ash isn't ... absolute pathname to /bin/sh
but ap[0] may be have "sh" only, not have absolute path
2) > 	- ash isn't ... the script...
but only for this scripts

;-)

I think, should send this patch to Herbert too, small correction bugreport also ;-)

Thanks!


--w
vodz




More information about the busybox mailing list