svn commit: trunk/busybox: coreutils include shell shell/ash_test/a etc...

vda at busybox.net vda at busybox.net
Mon Oct 20 08:15:52 UTC 2008


Author: vda
Date: 2008-10-20 01:15:51 -0700 (Mon, 20 Oct 2008)
New Revision: 23732

Log:
ash: fix NOEXEC mode - we were forgetting to pass environment!
env: promote to NOEXEC
hd: promote to NOEXEC, as hexdump is NOEXEC already



Added:
   trunk/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.right
   trunk/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.tests

Modified:
   trunk/busybox/coreutils/env.c
   trunk/busybox/include/applets.h
   trunk/busybox/shell/ash.c


Changeset:
Modified: trunk/busybox/coreutils/env.c
===================================================================
--- trunk/busybox/coreutils/env.c	2008-10-20 07:52:33 UTC (rev 23731)
+++ trunk/busybox/coreutils/env.c	2008-10-20 08:15:51 UTC (rev 23732)
@@ -29,6 +29,8 @@
  * - use xfunc_error_retval
  */
 
+/* This is a NOEXEC applet. Be very careful! */
+
 #include "libbb.h"
 
 #if ENABLE_FEATURE_ENV_LONG_OPTIONS
@@ -119,5 +121,3 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-
-

Modified: trunk/busybox/include/applets.h
===================================================================
--- trunk/busybox/include/applets.h	2008-10-20 07:52:33 UTC (rev 23731)
+++ trunk/busybox/include/applets.h	2008-10-20 08:15:51 UTC (rev 23732)
@@ -137,7 +137,7 @@
 USE_ED(APPLET(ed, _BB_DIR_BIN, _BB_SUID_NEVER))
 USE_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER, egrep))
 USE_EJECT(APPLET(eject, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
-USE_ENV(APPLET(env, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
+USE_ENV(APPLET_NOEXEC(env, env, _BB_DIR_USR_BIN, _BB_SUID_NEVER, env))
 USE_ENVDIR(APPLET_ODDNAME(envdir, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envdir))
 USE_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envuidgid))
 USE_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, _BB_DIR_USR_BIN, _BB_SUID_NEVER, ether_wake))
@@ -172,7 +172,7 @@
 USE_GUNZIP(APPLET(gunzip, _BB_DIR_BIN, _BB_SUID_NEVER))
 USE_GZIP(APPLET(gzip, _BB_DIR_BIN, _BB_SUID_NEVER))
 USE_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_NEVER))
-USE_HD(APPLET_ODDNAME(hd, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hd))
+USE_HD(APPLET_NOEXEC(hd, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hd))
 USE_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_NEVER))
 USE_HEAD(APPLET(head, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
 USE_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hexdump))

Modified: trunk/busybox/shell/ash.c
===================================================================
--- trunk/busybox/shell/ash.c	2008-10-20 07:52:33 UTC (rev 23731)
+++ trunk/busybox/shell/ash.c	2008-10-20 08:15:51 UTC (rev 23732)
@@ -7008,8 +7008,11 @@
 
 #if ENABLE_FEATURE_SH_STANDALONE
 	if (applet_no >= 0) {
-		if (APPLET_IS_NOEXEC(applet_no))
+		if (APPLET_IS_NOEXEC(applet_no)) {
+			while (*envp)
+				putenv(*envp++);
 			run_applet_no_and_exit(applet_no, argv);
+		}
 		/* re-exec ourselves with the new arguments */
 		execve(bb_busybox_exec_path, argv, envp);
 		/* If they called chroot or otherwise made the binary no longer
@@ -12094,7 +12097,7 @@
 	char *name;
 	const char *p;
 	char **aptr;
-	int flag = argv[0][0] == 'r'? VREADONLY : VEXPORT;
+	int flag = argv[0][0] == 'r' ? VREADONLY : VEXPORT;
 
 	if (nextopt("p") != 'p') {
 		aptr = argptr;

Added: trunk/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.right
===================================================================
--- trunk/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.right	                        (rev 0)
+++ trunk/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.right	2008-10-20 08:15:51 UTC (rev 23732)
@@ -0,0 +1,2 @@
+VAR7=VAL
+0

Added: trunk/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.tests
===================================================================
--- trunk/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.tests	                        (rev 0)
+++ trunk/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.tests	2008-10-20 08:15:51 UTC (rev 23732)
@@ -0,0 +1,3 @@
+export VAR7=VAL
+env | grep ^VAR7=
+echo $?


Property changes on: trunk/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.tests
___________________________________________________________________
Name: svn:executable
   + *




More information about the busybox-cvs mailing list