aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-03-03 23:12:17 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-03-03 23:12:17 +0000
commit29e31ddd81d797af6aad5d119f645ab2fc217a5b (patch)
tree526a300a71482a1230f9a23232ef524dadaddfbc
parentdcbd51dd2874164b693fc7133a07714c8ea14234 (diff)
downloadbusybox-w32-29e31ddd81d797af6aad5d119f645ab2fc217a5b.tar.gz
busybox-w32-29e31ddd81d797af6aad5d119f645ab2fc217a5b.tar.bz2
busybox-w32-29e31ddd81d797af6aad5d119f645ab2fc217a5b.zip
ash: do not use "safe applets" in non-standalone shell
-rw-r--r--shell/ash.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 371b5d9c3..335dcbab1 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -6455,7 +6455,9 @@ casematch(union node *pattern, char *val)
6455 6455
6456/* ============ find_command */ 6456/* ============ find_command */
6457 6457
6458static int is_safe_applet(char *name) 6458#if ENABLE_FEATURE_SH_STANDALONE_SHELL
6459static int
6460is_safe_applet(char *name)
6459{ 6461{
6460 /* It isn't a bug to have non-existent applet here... */ 6462 /* It isn't a bug to have non-existent applet here... */
6461 /* ...just a waste of space... */ 6463 /* ...just a waste of space... */
@@ -6488,6 +6490,7 @@ static int is_safe_applet(char *name)
6488 6490
6489 return 0; 6491 return 0;
6490} 6492}
6493#endif
6491 6494
6492struct builtincmd { 6495struct builtincmd {
6493 const char *name; 6496 const char *name;
@@ -6551,27 +6554,26 @@ static void
6551tryexec(char *cmd, char **argv, char **envp) 6554tryexec(char *cmd, char **argv, char **envp)
6552{ 6555{
6553 int repeated = 0; 6556 int repeated = 0;
6554 struct BB_applet *a;
6555 int argc = 0;
6556 char **c;
6557 6557
6558 if (strchr(cmd, '/') == NULL
6559 && (a = find_applet_by_name(cmd)) != NULL
6560 && is_safe_applet(cmd)
6561 ) {
6562 c = argv;
6563 while (*c != NULL) {
6564 c++; argc++;
6565 }
6566 applet_name = cmd;
6567 exit(a->main(argc, argv));
6568 }
6569#if ENABLE_FEATURE_SH_STANDALONE_SHELL 6558#if ENABLE_FEATURE_SH_STANDALONE_SHELL
6570 if (find_applet_by_name(cmd) != NULL) { 6559 if (strchr(cmd, '/') == NULL) {
6571 /* re-exec ourselves with the new arguments */ 6560 struct BB_applet *a;
6572 execve(CONFIG_BUSYBOX_EXEC_PATH, argv, envp); 6561 char **c;
6573 /* If they called chroot or otherwise made the binary no longer 6562
6574 * executable, fall through */ 6563 a = find_applet_by_name(cmd);
6564 if (a) {
6565 if (is_safe_applet(cmd)) {
6566 c = argv;
6567 while (*c)
6568 c++;
6569 applet_name = cmd;
6570 exit(a->main(c - argv, argv));
6571 }
6572 /* re-exec ourselves with the new arguments */
6573 execve(CONFIG_BUSYBOX_EXEC_PATH, argv, envp);
6574 /* If they called chroot or otherwise made the binary no longer
6575 * executable, fall through */
6576 }
6575 } 6577 }
6576#endif 6578#endif
6577 6579
@@ -6619,7 +6621,7 @@ shellexec(char **argv, const char *path, int idx)
6619 6621
6620 clearredir(1); 6622 clearredir(1);
6621 envp = environment(); 6623 envp = environment();
6622 if (strchr(argv[0], '/') || is_safe_applet(argv[0]) 6624 if (strchr(argv[0], '/')
6623#if ENABLE_FEATURE_SH_STANDALONE_SHELL 6625#if ENABLE_FEATURE_SH_STANDALONE_SHELL
6624 || find_applet_by_name(argv[0]) 6626 || find_applet_by_name(argv[0])
6625#endif 6627#endif
@@ -11141,13 +11143,13 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path)
11141 entry->u.index = -1; 11143 entry->u.index = -1;
11142 return; 11144 return;
11143 } 11145 }
11144#endif 11146 /* Already caught above
11145
11146 if (is_safe_applet(name)) { 11147 if (is_safe_applet(name)) {
11147 entry->cmdtype = CMDNORMAL; 11148 entry->cmdtype = CMDNORMAL;
11148 entry->u.index = -1; 11149 entry->u.index = -1;
11149 return; 11150 return;
11150 } 11151 }*/
11152#endif
11151 11153
11152 updatetbl = (path == pathval()); 11154 updatetbl = (path == pathval());
11153 if (!updatetbl) { 11155 if (!updatetbl) {