This one's from me. Fix ash "standalone shell".
If we exec /proc/self/exe and only fall back to /bin/busybox if /proc isn't there, then we have a reasonable chance of having the standalone shell work even if busybox isn't installed in /bin on the system in question. Still won't work in a chroot environment, but it's an improvement.
This commit is contained in:
parent
cce1ae2ce5
commit
0fcd9430ce
28
shell/ash.c
28
shell/ash.c
@ -3722,27 +3722,13 @@ tryexec(char *cmd, char **argv, char **envp)
|
|||||||
{
|
{
|
||||||
int repeated = 0;
|
int repeated = 0;
|
||||||
#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
|
#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
|
||||||
int flg_bb = 0;
|
if(find_applet_by_name(cmd) != NULL) {
|
||||||
char *name = cmd;
|
/* re-exec ourselves with the new arguments */
|
||||||
|
execve("/proc/self/exe",argv,envp);
|
||||||
if(strchr(name, '/') == NULL && find_applet_by_name(name) != NULL) {
|
/* If proc isn't mounted, try hardcoded path to busybox binary*/
|
||||||
flg_bb = 1;
|
execve("/bin/busybox",argv,envp);
|
||||||
}
|
/* If they called chroot or otherwise made the binary no longer
|
||||||
if(flg_bb) {
|
* executable, fall through */
|
||||||
char **ap;
|
|
||||||
char **new;
|
|
||||||
|
|
||||||
*argv = name;
|
|
||||||
if(strcmp(name, "busybox")) {
|
|
||||||
for (ap = argv; *ap; ap++);
|
|
||||||
ap = new = xmalloc((ap - argv + 2) * sizeof(char *));
|
|
||||||
*ap++ = cmd = "/bin/busybox";
|
|
||||||
while ((*ap++ = *argv++));
|
|
||||||
argv = new;
|
|
||||||
repeated++;
|
|
||||||
} else {
|
|
||||||
cmd = "/bin/busybox";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user