diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-03 23:12:17 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-03 23:12:17 +0000 |
commit | 29e31ddd81d797af6aad5d119f645ab2fc217a5b (patch) | |
tree | 526a300a71482a1230f9a23232ef524dadaddfbc /shell/ash.c | |
parent | dcbd51dd2874164b693fc7133a07714c8ea14234 (diff) |
ash: do not use "safe applets" in non-standalone shell
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 50 |
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) /* ============ find_command */ -static int is_safe_applet(char *name) +#if ENABLE_FEATURE_SH_STANDALONE_SHELL +static int +is_safe_applet(char *name) { /* It isn't a bug to have non-existent applet here... */ /* ...just a waste of space... */ @@ -6488,6 +6490,7 @@ static int is_safe_applet(char *name) return 0; } +#endif struct builtincmd { const char *name; @@ -6551,27 +6554,26 @@ static void tryexec(char *cmd, char **argv, char **envp) { int repeated = 0; - struct BB_applet *a; - int argc = 0; - char **c; - if (strchr(cmd, '/') == NULL - && (a = find_applet_by_name(cmd)) != NULL - && is_safe_applet(cmd) - ) { - c = argv; - while (*c != NULL) { - c++; argc++; - } - applet_name = cmd; - exit(a->main(argc, argv)); - } #if ENABLE_FEATURE_SH_STANDALONE_SHELL - if (find_applet_by_name(cmd) != NULL) { - /* re-exec ourselves with the new arguments */ - execve(CONFIG_BUSYBOX_EXEC_PATH, argv, envp); - /* If they called chroot or otherwise made the binary no longer - * executable, fall through */ + if (strchr(cmd, '/') == NULL) { + struct BB_applet *a; + char **c; + + a = find_applet_by_name(cmd); + if (a) { + if (is_safe_applet(cmd)) { + c = argv; + while (*c) + c++; + applet_name = cmd; + exit(a->main(c - argv, argv)); + } + /* re-exec ourselves with the new arguments */ + execve(CONFIG_BUSYBOX_EXEC_PATH, argv, envp); + /* If they called chroot or otherwise made the binary no longer + * executable, fall through */ + } } #endif @@ -6619,7 +6621,7 @@ shellexec(char **argv, const char *path, int idx) clearredir(1); envp = environment(); - if (strchr(argv[0], '/') || is_safe_applet(argv[0]) + if (strchr(argv[0], '/') #if ENABLE_FEATURE_SH_STANDALONE_SHELL || find_applet_by_name(argv[0]) #endif @@ -11141,13 +11143,13 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) entry->u.index = -1; return; } -#endif - + /* Already caught above if (is_safe_applet(name)) { entry->cmdtype = CMDNORMAL; entry->u.index = -1; return; - } + }*/ +#endif updatetbl = (path == pathval()); if (!updatetbl) { |