mirror of
https://github.com/sheumann/hush.git
synced 2024-10-11 10:23:41 +00:00
ash: in standalone mode, search in $PATH if /proc/self/exe doesn't exist
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
3365e9f3cc
commit
83f103b30e
12
shell/ash.c
12
shell/ash.c
@ -7471,9 +7471,7 @@ shellexec(char **argv, const char *path, int idx)
|
|||||||
int e;
|
int e;
|
||||||
char **envp;
|
char **envp;
|
||||||
int exerrno;
|
int exerrno;
|
||||||
#if ENABLE_FEATURE_SH_STANDALONE
|
int applet_no = -1; /* used only by FEATURE_SH_STANDALONE */
|
||||||
int applet_no = -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
clearredir(/*drop:*/ 1);
|
clearredir(/*drop:*/ 1);
|
||||||
envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL);
|
envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL);
|
||||||
@ -7483,8 +7481,16 @@ shellexec(char **argv, const char *path, int idx)
|
|||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) argv[0], argv, envp);
|
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;
|
e = errno;
|
||||||
} else {
|
} else {
|
||||||
|
try_PATH:
|
||||||
e = ENOENT;
|
e = ENOENT;
|
||||||
while ((cmdname = path_advance(&path, argv[0])) != NULL) {
|
while ((cmdname = path_advance(&path, argv[0])) != NULL) {
|
||||||
if (--idx < 0 && pathopt == NULL) {
|
if (--idx < 0 && pathopt == NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user