aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-10-20 08:15:51 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-10-20 08:15:51 +0000
commitb730474bda4a964930e8013301ace7b49a0c5726 (patch)
tree67a8c0ebd37a6231017e8e8dc3598b63a8c4402c
parentd1660cb9ad3adb4b99c098de88f79cbeb74c3a5d (diff)
downloadbusybox-w32-b730474bda4a964930e8013301ace7b49a0c5726.tar.gz
busybox-w32-b730474bda4a964930e8013301ace7b49a0c5726.tar.bz2
busybox-w32-b730474bda4a964930e8013301ace7b49a0c5726.zip
ash: fix NOEXEC mode - we were forgetting to pass environment!
env: promote to NOEXEC hd: promote to NOEXEC, as hexdump is NOEXEC already
-rw-r--r--coreutils/env.c4
-rw-r--r--include/applets.h4
-rw-r--r--shell/ash.c7
-rw-r--r--shell/ash_test/ash-standalone/noexec_gets_no_env.right2
-rwxr-xr-xshell/ash_test/ash-standalone/noexec_gets_no_env.tests3
5 files changed, 14 insertions, 6 deletions
diff --git a/coreutils/env.c b/coreutils/env.c
index 66199e8d6..2f8c8b71d 100644
--- a/coreutils/env.c
+++ b/coreutils/env.c
@@ -29,6 +29,8 @@
29 * - use xfunc_error_retval 29 * - use xfunc_error_retval
30 */ 30 */
31 31
32/* This is a NOEXEC applet. Be very careful! */
33
32#include "libbb.h" 34#include "libbb.h"
33 35
34#if ENABLE_FEATURE_ENV_LONG_OPTIONS 36#if ENABLE_FEATURE_ENV_LONG_OPTIONS
@@ -119,5 +121,3 @@ int env_main(int argc UNUSED_PARAM, char **argv)
119 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 121 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
120 * SUCH DAMAGE. 122 * SUCH DAMAGE.
121 */ 123 */
122
123
diff --git a/include/applets.h b/include/applets.h
index 828900e46..9c16c5dc2 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -137,7 +137,7 @@ USE_ECHO(APPLET_NOFORK(echo, echo, _BB_DIR_BIN, _BB_SUID_NEVER, echo))
137USE_ED(APPLET(ed, _BB_DIR_BIN, _BB_SUID_NEVER)) 137USE_ED(APPLET(ed, _BB_DIR_BIN, _BB_SUID_NEVER))
138USE_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER, egrep)) 138USE_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER, egrep))
139USE_EJECT(APPLET(eject, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 139USE_EJECT(APPLET(eject, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
140USE_ENV(APPLET(env, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 140USE_ENV(APPLET_NOEXEC(env, env, _BB_DIR_USR_BIN, _BB_SUID_NEVER, env))
141USE_ENVDIR(APPLET_ODDNAME(envdir, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envdir)) 141USE_ENVDIR(APPLET_ODDNAME(envdir, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envdir))
142USE_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envuidgid)) 142USE_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envuidgid))
143USE_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, _BB_DIR_USR_BIN, _BB_SUID_NEVER, ether_wake)) 143USE_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, _BB_DIR_USR_BIN, _BB_SUID_NEVER, ether_wake))
@@ -172,7 +172,7 @@ USE_GREP(APPLET(grep, _BB_DIR_BIN, _BB_SUID_NEVER))
172USE_GUNZIP(APPLET(gunzip, _BB_DIR_BIN, _BB_SUID_NEVER)) 172USE_GUNZIP(APPLET(gunzip, _BB_DIR_BIN, _BB_SUID_NEVER))
173USE_GZIP(APPLET(gzip, _BB_DIR_BIN, _BB_SUID_NEVER)) 173USE_GZIP(APPLET(gzip, _BB_DIR_BIN, _BB_SUID_NEVER))
174USE_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_NEVER)) 174USE_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_NEVER))
175USE_HD(APPLET_ODDNAME(hd, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hd)) 175USE_HD(APPLET_NOEXEC(hd, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hd))
176USE_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_NEVER)) 176USE_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_NEVER))
177USE_HEAD(APPLET(head, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 177USE_HEAD(APPLET(head, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
178USE_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hexdump)) 178USE_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hexdump))
diff --git a/shell/ash.c b/shell/ash.c
index 70b7ae32a..81ac563fb 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -7008,8 +7008,11 @@ tryexec(USE_FEATURE_SH_STANDALONE(int applet_no,) char *cmd, char **argv, char *
7008 7008
7009#if ENABLE_FEATURE_SH_STANDALONE 7009#if ENABLE_FEATURE_SH_STANDALONE
7010 if (applet_no >= 0) { 7010 if (applet_no >= 0) {
7011 if (APPLET_IS_NOEXEC(applet_no)) 7011 if (APPLET_IS_NOEXEC(applet_no)) {
7012 while (*envp)
7013 putenv(*envp++);
7012 run_applet_no_and_exit(applet_no, argv); 7014 run_applet_no_and_exit(applet_no, argv);
7015 }
7013 /* re-exec ourselves with the new arguments */ 7016 /* re-exec ourselves with the new arguments */
7014 execve(bb_busybox_exec_path, argv, envp); 7017 execve(bb_busybox_exec_path, argv, envp);
7015 /* If they called chroot or otherwise made the binary no longer 7018 /* If they called chroot or otherwise made the binary no longer
@@ -12094,7 +12097,7 @@ exportcmd(int argc UNUSED_PARAM, char **argv)
12094 char *name; 12097 char *name;
12095 const char *p; 12098 const char *p;
12096 char **aptr; 12099 char **aptr;
12097 int flag = argv[0][0] == 'r'? VREADONLY : VEXPORT; 12100 int flag = argv[0][0] == 'r' ? VREADONLY : VEXPORT;
12098 12101
12099 if (nextopt("p") != 'p') { 12102 if (nextopt("p") != 'p') {
12100 aptr = argptr; 12103 aptr = argptr;
diff --git a/shell/ash_test/ash-standalone/noexec_gets_no_env.right b/shell/ash_test/ash-standalone/noexec_gets_no_env.right
new file mode 100644
index 000000000..3d55d73b8
--- /dev/null
+++ b/shell/ash_test/ash-standalone/noexec_gets_no_env.right
@@ -0,0 +1,2 @@
1VAR7=VAL
20
diff --git a/shell/ash_test/ash-standalone/noexec_gets_no_env.tests b/shell/ash_test/ash-standalone/noexec_gets_no_env.tests
new file mode 100755
index 000000000..5e12e5a25
--- /dev/null
+++ b/shell/ash_test/ash-standalone/noexec_gets_no_env.tests
@@ -0,0 +1,3 @@
1export VAR7=VAL
2env | grep ^VAR7=
3echo $?