diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-12-20 06:10:35 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-12-20 06:10:35 +0100 |
commit | 83f103b30e41ab038e45661df97625f655abe491 (patch) | |
tree | 2ae327d0bfa34508dcaaaa0fc42b3ea5cb497aed | |
parent | 3365e9f3cc1859e8c427533e13676740d8038719 (diff) | |
download | busybox-83f103b30e41ab038e45661df97625f655abe491.tar.gz |
ash: in standalone mode, search in $PATH if /proc/self/exe doesn't exist
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/shell/ash.c b/shell/ash.c index b4ed8e578..d197fa19a 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -7471,9 +7471,7 @@ shellexec(char **argv, const char *path, int idx) int e; char **envp; int exerrno; -#if ENABLE_FEATURE_SH_STANDALONE - int applet_no = -1; -#endif + int applet_no = -1; /* used only by FEATURE_SH_STANDALONE */ clearredir(/*drop:*/ 1); envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL); @@ -7483,8 +7481,16 @@ shellexec(char **argv, const char *path, int idx) #endif ) { tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) argv[0], argv, envp); + if (applet_no >= 0) { + /* We tried execing ourself, but it didn't work. + * Maybe /proc/self/exe doesn't exist? + * Try $PATH search. + */ + goto try_PATH; + } e = errno; } else { + try_PATH: e = ENOENT; while ((cmdname = path_advance(&path, argv[0])) != NULL) { if (--idx < 0 && pathopt == NULL) { |