summaryrefslogtreecommitdiff
blob: 25acc4faabef0f9b893fa8e4fffa0a469f10e214 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
--- trunk/busybox/shell/ash.c	2005/02/10 00:44:31	9838
+++ trunk/busybox/shell/ash.c	2005/05/07 08:27:34	10264
@@ -3722,27 +3722,13 @@
 {
 	int repeated = 0;
 #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
-	int flg_bb = 0;
-	char *name = cmd;
-
-	if(strchr(name, '/') == NULL && find_applet_by_name(name) != NULL) {
-		flg_bb = 1;
-	}
-	if(flg_bb) {
-		char **ap;
-		char **new;
-
-		*argv = name;
-		if(strcmp(name, "busybox")) {
-			for (ap = argv; *ap; ap++);
-			ap = new = xmalloc((ap - argv + 2) * sizeof(char *));
-			*ap++ = cmd = "/bin/busybox";
-			while ((*ap++ = *argv++));
-			argv = new;
-			repeated++;
-		} else {
-			cmd = "/bin/busybox";
-		}
+	if(find_applet_by_name(cmd) != NULL) {
+		/* re-exec ourselves with the new arguments */
+		execve("/proc/self/exe",argv,envp);
+		/* If proc isn't mounted, try hardcoded path to busybox binary*/
+		execve("/bin/busybox",argv,envp);
+		/* If they called chroot or otherwise made the binary no longer
+		 * executable, fall through */
 	}
 #endif