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

Jean Wolter jw5 at os.inf.tu-dresden.de
Mon Sep 15 07:05:03 UTC 2003


Glenn McGrath <bug1 at optushome.com.au> writes:

> On 13 Sep 2003 13:04:38 +0200
> Jean Wolter <jw5 at os.inf.tu-dresden.de> wrote:
> 
> > Glenn McGrath <bug1 at optushome.com.au> writes:
> > 
> > > But, i get the same error with and without your patch.
> > 
> > Could you do an strace on busybox ash with the patch applied? It
> > should show the following:
> > 
> > # strace -f -e execve ./busybox ash -c arg
> 
> strace -f -e execve ash -c arg
> execve("/bin/ash", ["ash", "-c", "arg"], [/* 50 vars */]) = 0
> ash: arg: not found

Ok, you picked a different name for your test script :)

> strace -f -e execve /bin/busybox ash -c test.sh
> execve("/bin/busybox", ["/bin/busybox", "ash", "-c", "test.sh"], [/* 50 vars */]) = 0
> Process 23439 attached
> Process 23438 suspended
> [pid 23439] execve("/usr/bin/test.sh", ["test.sh"], [/* 50 vars */]) = -1 ENOEXEC (Exec format error)
> [pid 23439] execve("/bin/sh", ["/bin/sh", "/usr/bin/test.sh"], [/* 50 vars */]) = 0

Ok, this is, what the patch was trying to achieve: Pass the absolute
pathname to /bin/sh. Without the patch there would be only a "test.sh"
as argv[1].

> # test.sh
> blah

So it works (without the patch it would not).

> # sh /usr/bin/test.sh
> blah

Ok.

> # sh test.sh
> sh: Can't open test.sh

Is this the error message leading to your statement: "But, i get the
same error with and without your patch."? Then  maybe you should read
my bug description once again:

"It correctly locates the script, tries to execute it via execve which
fails. After that it tries to hand it over to /bin/sh which fails too,
since ash 

    - neither provides the absolute pathname to /bin/sh
    - nor tries to lookup the script via PATH if called as "sh script"
"

To make the last statement work ash would have to lookup test.sh via
PATH which for some reasons it doesn't. Adding this would be a better
alternative to my patch.

regards,
Jean



More information about the busybox mailing list