diff options
author | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-05-07 08:27:34 +0000 |
---|---|---|
committer | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-05-07 08:27:34 +0000 |
commit | 4f01f36837763bd5bb2968196126aaee8e929307 (patch) | |
tree | 2a0143f3ae1e7706e1ea7b2a741e9a8894b34c9a /shell | |
parent | 70ec70f8d124eeeae5487aca7265bb26c83b129a (diff) | |
download | busybox-w32-4f01f36837763bd5bb2968196126aaee8e929307.tar.gz busybox-w32-4f01f36837763bd5bb2968196126aaee8e929307.tar.bz2 busybox-w32-4f01f36837763bd5bb2968196126aaee8e929307.zip |
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.
git-svn-id: svn://busybox.net/trunk/busybox@10264 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/shell/ash.c b/shell/ash.c index 0e9d58ae6..57316c916 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -3722,27 +3722,13 @@ tryexec(char *cmd, char **argv, char **envp) | |||
3722 | { | 3722 | { |
3723 | int repeated = 0; | 3723 | int repeated = 0; |
3724 | #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL | 3724 | #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL |
3725 | int flg_bb = 0; | 3725 | if(find_applet_by_name(cmd) != NULL) { |
3726 | char *name = cmd; | 3726 | /* re-exec ourselves with the new arguments */ |
3727 | 3727 | execve("/proc/self/exe",argv,envp); | |
3728 | if(strchr(name, '/') == NULL && find_applet_by_name(name) != NULL) { | 3728 | /* If proc isn't mounted, try hardcoded path to busybox binary*/ |
3729 | flg_bb = 1; | 3729 | execve("/bin/busybox",argv,envp); |
3730 | } | 3730 | /* If they called chroot or otherwise made the binary no longer |
3731 | if(flg_bb) { | 3731 | * executable, fall through */ |
3732 | char **ap; | ||
3733 | char **new; | ||
3734 | |||
3735 | *argv = name; | ||
3736 | if(strcmp(name, "busybox")) { | ||
3737 | for (ap = argv; *ap; ap++); | ||
3738 | ap = new = xmalloc((ap - argv + 2) * sizeof(char *)); | ||
3739 | *ap++ = cmd = "/bin/busybox"; | ||
3740 | while ((*ap++ = *argv++)); | ||
3741 | argv = new; | ||
3742 | repeated++; | ||
3743 | } else { | ||
3744 | cmd = "/bin/busybox"; | ||
3745 | } | ||
3746 | } | 3732 | } |
3747 | #endif | 3733 | #endif |
3748 | 3734 | ||