diff options
author | Ron Yorston <rmy@pobox.com> | 2012-03-23 12:12:03 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2012-03-23 12:12:03 +0000 |
commit | b0f54743e36af163ae2530c381c485bb29df13dc (patch) | |
tree | cda4cfeaae6e47fe4f14c1b566092be4da9affc4 /shell/ash.c | |
parent | 40514a0309939f2446f0d4ed9600cad5de396e7f (diff) | |
parent | ba88826c66411affc1da3614742b454654f7298a (diff) | |
download | busybox-w32-b0f54743e36af163ae2530c381c485bb29df13dc.tar.gz busybox-w32-b0f54743e36af163ae2530c381c485bb29df13dc.tar.bz2 busybox-w32-b0f54743e36af163ae2530c381c485bb29df13dc.zip |
Merge branch 'busybox' into merge
Conflicts:
Makefile.flags
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/shell/ash.c b/shell/ash.c index a79099bc5..065678ea5 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -7794,6 +7794,12 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) char *cmd, char **argv, char ** | |||
7794 | * | 7794 | * |
7795 | * That is, do not use $SHELL, user's shell, or /bin/sh; | 7795 | * That is, do not use $SHELL, user's shell, or /bin/sh; |
7796 | * just call ourselves. | 7796 | * just call ourselves. |
7797 | * | ||
7798 | * Note that bash reads ~80 chars of the file, and if it sees | ||
7799 | * a zero byte before it sees newline, it doesn't try to | ||
7800 | * interpret it, but fails with "cannot execute binary file" | ||
7801 | * message and exit code 126. For one, this prevents attempts | ||
7802 | * to interpret foreign ELF binaries as shell scripts. | ||
7797 | */ | 7803 | */ |
7798 | char **ap; | 7804 | char **ap; |
7799 | char **new; | 7805 | char **new; |
@@ -7824,9 +7830,7 @@ shellexec(char **argv, const char *path, int idx) | |||
7824 | int e; | 7830 | int e; |
7825 | char **envp; | 7831 | char **envp; |
7826 | int exerrno; | 7832 | int exerrno; |
7827 | #if ENABLE_FEATURE_SH_STANDALONE | 7833 | int applet_no = -1; /* used only by FEATURE_SH_STANDALONE */ |
7828 | int applet_no = -1; | ||
7829 | #endif | ||
7830 | 7834 | ||
7831 | clearredir(/*drop:*/ 1); | 7835 | clearredir(/*drop:*/ 1); |
7832 | envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL); | 7836 | envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL); |
@@ -7836,8 +7840,16 @@ shellexec(char **argv, const char *path, int idx) | |||
7836 | #endif | 7840 | #endif |
7837 | ) { | 7841 | ) { |
7838 | tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) argv[0], argv, envp); | 7842 | tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) argv[0], argv, envp); |
7843 | if (applet_no >= 0) { | ||
7844 | /* We tried execing ourself, but it didn't work. | ||
7845 | * Maybe /proc/self/exe doesn't exist? | ||
7846 | * Try $PATH search. | ||
7847 | */ | ||
7848 | goto try_PATH; | ||
7849 | } | ||
7839 | e = errno; | 7850 | e = errno; |
7840 | } else { | 7851 | } else { |
7852 | try_PATH: | ||
7841 | e = ENOENT; | 7853 | e = ENOENT; |
7842 | while ((cmdname = path_advance(&path, argv[0])) != NULL) { | 7854 | while ((cmdname = path_advance(&path, argv[0])) != NULL) { |
7843 | if (--idx < 0 && pathopt == NULL) { | 7855 | if (--idx < 0 && pathopt == NULL) { |