[BusyBox] [patch] ash tryexec() problem with shell scripts
Jean Wolter
jean.wolter at inf.tu-dresden.de
Fri Aug 29 19:24:00 UTC 2003
"Vladimir N. Oleynik" <dzo at simtreas.ru> writes:
> I can`t reproduce your problem.
Try the following:
# pwd
/
# echo "echo argh" > bin/file_in_your_path
# chmod +x bin/file_in_your_path
# type file_in_your_path
file_in_your_path is a tracked alias for /bin/file_in_your_path
# file_in_your_path
/bin/sh: Can't open file_in_your_path
If you use strace you will see that sh is trying to execute
sh file_in_your_path
which fails:
# strace -f -e execve sh -c file_in_your_path
[pid 2017] execve("/bin/file_in_your_path", ["file_in_your_path"],
[/* 14 vars */]) = -1 ENOEXEC (Exec format error)
[pid 2017] execve("/bin/sh", ["/bin/sh", "file_in_your_path"], [/* 14
vars */]) = 0
> > --- 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 *));
>
> Heh. Your patch is bad.
> But require change to + 3
>
> > - *ap++ = cmd = "/bin/sh";
> > + ap[1] = cmd;
> > + *ap = cmd = "/bin/sh";
>
> This up two line must rearrange.
Why? Currently tryexec sets
argv[0] = cmd = "/bin/sh";
argv[1] = "file_in_your_path";
I try to set
argv[1] = cmd; /* /bin/file_in_your_path in this case */
argv[0] = cmd = "/bin/sh";
regards,
Jean
More information about the busybox
mailing list