From e3b1a1fd28558f7a1b3c0ec33313bedb675be8a1 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 26 Feb 2011 22:24:08 +0100 Subject: Replace "depends on PLATFORM_LINUX" with "select PLATFORM_LINUX" Signed-off-by: Denys Vlasenko --- libbb/Config.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libbb') diff --git a/libbb/Config.src b/libbb/Config.src index 18bdc5151..a25af23b4 100644 --- a/libbb/Config.src +++ b/libbb/Config.src @@ -183,7 +183,7 @@ config FEATURE_SKIP_ROOTFS config MONOTONIC_SYSCALL bool "Use clock_gettime(CLOCK_MONOTONIC) syscall" default n - depends on PLATFORM_LINUX + select PLATFORM_LINUX help Use clock_gettime(CLOCK_MONOTONIC) syscall for measuring time intervals (time, ping, traceroute etc need this). -- cgit v1.2.3-55-g6feb From 7d65abea092e917bc2320cbf1d5a2dccb2a8288f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 1 Mar 2011 16:27:13 +0100 Subject: libbb: make user/group name cache strings longer (~27 chars) Signed-off-by: Denys Vlasenko --- include/libbb.h | 6 +++--- libbb/bb_pwd.c | 4 ++-- libbb/procps.c | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'libbb') diff --git a/include/libbb.h b/include/libbb.h index 65c319402..c26012c5d 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -839,14 +839,14 @@ char* xuid2uname(uid_t uid) FAST_FUNC; char* xgid2group(gid_t gid) FAST_FUNC; char* uid2uname(uid_t uid) FAST_FUNC; char* gid2group(gid_t gid) FAST_FUNC; -char* uid2uname_utoa(long uid) FAST_FUNC; -char* gid2group_utoa(long gid) FAST_FUNC; +char* uid2uname_utoa(uid_t uid) FAST_FUNC; +char* gid2group_utoa(gid_t gid) FAST_FUNC; /* versions which cache results (useful for ps, ls etc) */ const char* get_cached_username(uid_t uid) FAST_FUNC; const char* get_cached_groupname(gid_t gid) FAST_FUNC; void clear_username_cache(void) FAST_FUNC; /* internally usernames are saved in fixed-sized char[] buffers */ -enum { USERNAME_MAX_SIZE = 16 - sizeof(int) }; +enum { USERNAME_MAX_SIZE = 32 - sizeof(uid_t) }; #if ENABLE_FEATURE_CHECK_NAMES void die_if_bad_username(const char* name) FAST_FUNC; #else diff --git a/libbb/bb_pwd.c b/libbb/bb_pwd.c index 32406cb58..4829b723a 100644 --- a/libbb/bb_pwd.c +++ b/libbb/bb_pwd.c @@ -72,13 +72,13 @@ char* FAST_FUNC gid2group(gid_t gid) return (gr) ? gr->gr_name : NULL; } -char* FAST_FUNC uid2uname_utoa(long uid) +char* FAST_FUNC uid2uname_utoa(uid_t uid) { char *name = uid2uname(uid); return (name) ? name : utoa(uid); } -char* FAST_FUNC gid2group_utoa(long gid) +char* FAST_FUNC gid2group_utoa(gid_t gid) { char *name = gid2group(gid); return (name) ? name : utoa(gid); diff --git a/libbb/procps.c b/libbb/procps.c index fb4c32001..5833a1f0d 100644 --- a/libbb/procps.c +++ b/libbb/procps.c @@ -12,13 +12,13 @@ #include "libbb.h" -typedef struct unsigned_to_name_map_t { - long id; +typedef struct id_to_name_map_t { + uid_t id; char name[USERNAME_MAX_SIZE]; -} unsigned_to_name_map_t; +} id_to_name_map_t; typedef struct cache_t { - unsigned_to_name_map_t *cache; + id_to_name_map_t *cache; int size; } cache_t; @@ -39,7 +39,7 @@ void FAST_FUNC clear_username_cache(void) #if 0 /* more generic, but we don't need that yet */ /* Returns -N-1 if not found. */ /* cp->cache[N] is allocated and must be filled in this case */ -static int get_cached(cache_t *cp, unsigned id) +static int get_cached(cache_t *cp, uid_t id) { int i; for (i = 0; i < cp->size; i++) @@ -52,8 +52,8 @@ static int get_cached(cache_t *cp, unsigned id) } #endif -static char* get_cached(cache_t *cp, long id, - char* FAST_FUNC x2x_utoa(long id)) +static char* get_cached(cache_t *cp, uid_t id, + char* FAST_FUNC x2x_utoa(uid_t id)) { int i; for (i = 0; i < cp->size; i++) -- cgit v1.2.3-55-g6feb From ea6116ee59af0945f4a6ac9ede984930a0ede429 Mon Sep 17 00:00:00 2001 From: Alexey Fomenko Date: Tue, 1 Mar 2011 19:25:49 +0100 Subject: libbb: remove dead code in getopt32. -7 bytes Signed-off-by: Alexey Fomenko Signed-off-by: Denys Vlasenko --- libbb/getopt32.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'libbb') diff --git a/libbb/getopt32.c b/libbb/getopt32.c index f3f1cfcba..18f33c704 100644 --- a/libbb/getopt32.c +++ b/libbb/getopt32.c @@ -542,8 +542,6 @@ getopt32(char **argv, const char *applet_opts, ...) #endif /* optarg = NULL; opterr = 0; optopt = 0; - do we need this?? */ - pargv = NULL; - /* Note: just "getopt() <= 0" will not work well for * "fake" short options, like this one: * wget $'-\203' "Test: test" http://kernel.org/ @@ -574,19 +572,16 @@ getopt32(char **argv, const char *applet_opts, ...) flags ^= trigger; if (on_off->counter) (*(on_off->counter))++; - if (on_off->param_type == PARAM_LIST) { - if (optarg) + if (optarg) { + if (on_off->param_type == PARAM_LIST) { llist_add_to_end((llist_t **)(on_off->optarg), optarg); - } else if (on_off->param_type == PARAM_INT) { - if (optarg) + } else if (on_off->param_type == PARAM_INT) { //TODO: xatoi_positive indirectly pulls in printf machinery *(unsigned*)(on_off->optarg) = xatoi_positive(optarg); - } else if (on_off->optarg) { - if (optarg) + } else if (on_off->optarg) { *(char **)(on_off->optarg) = optarg; + } } - if (pargv != NULL) - break; } /* check depending requires for given options */ -- cgit v1.2.3-55-g6feb From 4a2a86d5e7e7bf284a31af604a738dfa1f1a2240 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 6 Mar 2011 06:02:31 +0100 Subject: improve --install operation in chroot jails Signed-off-by: Denys Vlasenko --- libbb/appletlib.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'libbb') diff --git a/libbb/appletlib.c b/libbb/appletlib.c index fc3e962d5..69cac2e9a 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -713,12 +713,23 @@ static int busybox_main(char **argv) if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) { int use_symbolic_links; const char *busybox; + busybox = xmalloc_readlink(bb_busybox_exec_path); - if (!busybox) - busybox = bb_busybox_exec_path; - /* busybox --install [-s] [DIR]: */ - /* -s: make symlinks */ - /* DIR: directory to install links to */ + if (!busybox) { + /* bb_busybox_exec_path is usually "/proc/self/exe". + * In chroot, readlink("/proc/self/exe") usually fails. + * In such case, better use argv[0] as symlink target + * if it is a full path name. + */ + if (argv[0][0] == '/') + busybox = argv[0]; + else + busybox = bb_busybox_exec_path; + } + /* busybox --install [-s] [DIR]: + * -s: make symlinks + * DIR: directory to install links to + */ use_symbolic_links = (argv[2] && strcmp(argv[2], "-s") == 0 && argv++); install_links(busybox, use_symbolic_links, argv[2]); return 0; -- cgit v1.2.3-55-g6feb From bd74e3d8beb0fedc4c1fdd9469a9de3f1f04c7b5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 6 Mar 2011 18:49:40 +0100 Subject: libbb/login/su: do not sanitize shell name twice function old new delta setup_environment 191 205 +14 login_main 1002 987 -15 su_main 474 458 -16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 14/-31) Total: -17 bytes Signed-off-by: Denys Vlasenko --- libbb/setup_environment.c | 3 +++ loginutils/login.c | 8 ++------ loginutils/su.c | 10 ++-------- 3 files changed, 7 insertions(+), 14 deletions(-) (limited to 'libbb') diff --git a/libbb/setup_environment.c b/libbb/setup_environment.c index a95fbc5bf..73229ca6c 100644 --- a/libbb/setup_environment.c +++ b/libbb/setup_environment.c @@ -32,6 +32,9 @@ void FAST_FUNC setup_environment(const char *shell, int flags, const struct passwd *pw) { + if (!shell || !shell[0]) + shell = DEFAULT_SHELL; + /* Change the current working directory to be the home directory * of the user */ if (chdir(pw->pw_dir)) { diff --git a/loginutils/login.c b/loginutils/login.c index 952b3aadd..028a099b6 100644 --- a/loginutils/login.c +++ b/loginutils/login.c @@ -198,7 +198,6 @@ int login_main(int argc UNUSED_PARAM, char **argv) }; char *fromhost; char username[USERNAME_SIZE]; - const char *shell; int run_by_root; unsigned opt; int count = 0; @@ -391,10 +390,7 @@ int login_main(int argc UNUSED_PARAM, char **argv) run_login_script(pw, full_tty); change_identity(pw); - shell = pw->pw_shell; - if (!shell || !shell[0]) - shell = DEFAULT_SHELL; - setup_environment(shell, + setup_environment(pw->pw_shell, (!(opt & LOGIN_OPT_p) * SETUP_ENV_CLEARENV) + SETUP_ENV_CHANGEENV, pw); @@ -442,7 +438,7 @@ int login_main(int argc UNUSED_PARAM, char **argv) signal(SIGINT, SIG_DFL); /* Exec login shell with no additional parameters */ - run_shell(shell, 1, NULL, NULL); + run_shell(pw->pw_shell, 1, NULL, NULL); /* return EXIT_FAILURE; - not reached */ } diff --git a/loginutils/su.c b/loginutils/su.c index db303af6d..72dd0f06f 100644 --- a/loginutils/su.c +++ b/loginutils/su.c @@ -114,20 +114,14 @@ int su_main(int argc UNUSED_PARAM, char **argv) opt_shell = getenv("SHELL"); } - /* Make sure pw->pw_shell is non-NULL. It may be NULL when NEW_USER - * is a username that is retrieved via NIS (YP), that doesn't have - * a default shell listed. */ - if (!pw->pw_shell || !pw->pw_shell[0]) - pw->pw_shell = (char *)DEFAULT_SHELL; - #if ENABLE_FEATURE_SU_CHECKS_SHELLS - if (opt_shell && cur_uid != 0 && restricted_shell(pw->pw_shell)) { + if (opt_shell && cur_uid != 0 && pw->pw_shell && restricted_shell(pw->pw_shell)) { /* The user being su'd to has a nonstandard shell, and so is * probably a uucp account or has restricted access. Don't * compromise the account by allowing access with a standard * shell. */ bb_error_msg("using restricted shell"); - opt_shell = NULL; + opt_shell = NULL; /* ignore -s PROG */ } /* else: user can run whatever he wants via "su -s PROG USER". * This is safe since PROG is run under user's uid/gid. */ -- cgit v1.2.3-55-g6feb From f8416dc6f64244223fbcb20fe504b7a9a764e698 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 8 Mar 2011 21:02:42 +0100 Subject: forgot to add libbb/get_shell_name.c Signed-off-by: Denys Vlasenko --- libbb/get_shell_name.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 libbb/get_shell_name.c (limited to 'libbb') diff --git a/libbb/get_shell_name.c b/libbb/get_shell_name.c new file mode 100644 index 000000000..c930afd94 --- /dev/null +++ b/libbb/get_shell_name.c @@ -0,0 +1,25 @@ +/* + * Copyright 2011, Denys Vlasenko + * + * Licensed under GPLv2, see file LICENSE in this source tree. + */ + +//kbuild:lib-y += get_shell_name.o + +#include "libbb.h" + +const char *get_shell_name(void) +{ + struct passwd *pw; + char *shell; + + shell = getenv("SHELL"); + if (shell && shell[0]) + return shell; + + pw = getpwuid(getuid()); + if (pw && pw->pw_shell && pw->pw_shell[0]) + return pw->pw_shell; + + return DEFAULT_SHELL; +} -- cgit v1.2.3-55-g6feb From 8345b2bd5ea28bd8d07886e615b9c2d5ab35477d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 12 Mar 2011 02:19:50 +0100 Subject: libbb: make warning go away Signed-off-by: Denys Vlasenko --- libbb/progress.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libbb') diff --git a/libbb/progress.c b/libbb/progress.c index df43dad5c..372feb0c2 100644 --- a/libbb/progress.c +++ b/libbb/progress.c @@ -127,10 +127,12 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p, /* 32-bit CPU and 64-bit off_t. * Use a 40-bit shift, it is easier to do on 32-bit CPU. */ - if (totalsize >= (uoff_t)(1ULL << 54)) { - totalsize = (uint32_t)(totalsize >> 32) >> 8; - beg_size = (uint32_t)(beg_size >> 32) >> 8; - transferred = (uint32_t)(transferred >> 32) >> 8; +/* ONE suppresses "warning: shift count >= width of type" */ +#define ONE (sizeof(off_t) > 4) + if (totalsize >= (uoff_t)(1ULL << 54*ONE)) { + totalsize = (uint32_t)(totalsize >> 32*ONE) >> 8; + beg_size = (uint32_t)(beg_size >> 32*ONE) >> 8; + transferred = (uint32_t)(transferred >> 32*ONE) >> 8; kiloscale = 4; } } -- cgit v1.2.3-55-g6feb From 5c942713b7369d239b1303c0cfc7049d898564d4 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 12 Mar 2011 06:08:28 +0100 Subject: busybox: fail if --install is not given an absolute path Signed-off-by: Denys Vlasenko --- libbb/appletlib.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libbb') diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 69cac2e9a..fc84d36ec 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -721,10 +721,9 @@ static int busybox_main(char **argv) * In such case, better use argv[0] as symlink target * if it is a full path name. */ - if (argv[0][0] == '/') - busybox = argv[0]; - else - busybox = bb_busybox_exec_path; + if (argv[0][0] != '/') + bb_error_msg_and_die("'%s' is not an absolute path", argv[0]); + busybox = argv[0]; } /* busybox --install [-s] [DIR]: * -s: make symlinks -- cgit v1.2.3-55-g6feb From 7f4b769c42f3773ff2e2e749547291dcb7e85d01 Mon Sep 17 00:00:00 2001 From: Vitaly Magerya Date: Tue, 22 Mar 2011 20:14:26 +0100 Subject: don't call freeaddinfo(NULL) Signed-off-by: Vitaly Magerya Signed-off-by: Denys Vlasenko --- libbb/inet_common.c | 16 +++++++++------- libbb/xconnect.c | 5 +++-- networking/nslookup.c | 4 ++-- 3 files changed, 14 insertions(+), 11 deletions(-) (limited to 'libbb') diff --git a/libbb/inet_common.c b/libbb/inet_common.c index 6f585ebd9..207720e96 100644 --- a/libbb/inet_common.c +++ b/libbb/inet_common.c @@ -164,17 +164,17 @@ char* FAST_FUNC INET_rresolve(struct sockaddr_in *s_in, int numeric, uint32_t ne int FAST_FUNC INET6_resolve(const char *name, struct sockaddr_in6 *sin6) { - struct addrinfo req, *ai; + struct addrinfo req, *ai = NULL; int s; - memset(&req, '\0', sizeof req); + memset(&req, 0, sizeof(req)); req.ai_family = AF_INET6; s = getaddrinfo(name, NULL, &req, &ai); - if (s) { + if (s != 0) { bb_error_msg("getaddrinfo: %s: %d", name, s); return -1; } - memcpy(sin6, ai->ai_addr, sizeof(struct sockaddr_in6)); + memcpy(sin6, ai->ai_addr, sizeof(*sin6)); freeaddrinfo(ai); return 0; } @@ -209,9 +209,11 @@ char* FAST_FUNC INET6_rresolve(struct sockaddr_in6 *sin6, int numeric) return xstrdup("*"); } - s = getnameinfo((struct sockaddr *) sin6, sizeof(struct sockaddr_in6), - name, sizeof(name), NULL, 0, 0); - if (s) { + s = getnameinfo((struct sockaddr *) sin6, sizeof(*sin6), + name, sizeof(name), + /*serv,servlen:*/ NULL, 0, + 0); + if (s != 0) { bb_error_msg("getnameinfo failed"); return NULL; } diff --git a/libbb/xconnect.c b/libbb/xconnect.c index 3a6585caa..127e2a5fc 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c @@ -255,7 +255,7 @@ IF_NOT_FEATURE_IPV6(sa_family_t af = AF_INET;) memset(&hint, 0 , sizeof(hint)); hint.ai_family = af; - /* Needed. Or else we will get each address thrice (or more) + /* Need SOCK_STREAM, or else we get each address thrice (or more) * for each possible socket type (tcp,udp,raw...): */ hint.ai_socktype = SOCK_STREAM; hint.ai_flags = ai_flags & ~DIE_ON_ERROR; @@ -285,7 +285,8 @@ IF_NOT_FEATURE_IPV6(sa_family_t af = AF_INET;) set_port: set_nport(r, htons(port)); ret: - freeaddrinfo(result); + if (result) + freeaddrinfo(result); return r; } #if !ENABLE_FEATURE_IPV6 diff --git a/networking/nslookup.c b/networking/nslookup.c index dcac7379e..67fc01547 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c @@ -66,7 +66,7 @@ static int print_host(const char *hostname, const char *header) // hint.ai_flags = AI_CANONNAME; rc = getaddrinfo(hostname, NULL /*service*/, &hint, &result); - if (!rc) { + if (rc == 0) { struct addrinfo *cur = result; unsigned cnt = 0; @@ -94,7 +94,7 @@ static int print_host(const char *hostname, const char *header) bb_error_msg("can't resolve '%s'", hostname); #endif } - if (ENABLE_FEATURE_CLEAN_UP) + if (ENABLE_FEATURE_CLEAN_UP && result) freeaddrinfo(result); return (rc != 0); } -- cgit v1.2.3-55-g6feb From 20704f066250744c0c2b84920c27d0fd0aa9e935 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 23 Mar 2011 17:59:27 +0100 Subject: ash,hush: recheck LANG before every line input Signed-off-by: Denys Vlasenko --- include/unicode.h | 4 ++++ libbb/unicode.c | 28 +++++++++++++++++----------- shell/ash.c | 23 +++++++++++++++-------- shell/hush.c | 25 ++++++++++++++++--------- 4 files changed, 52 insertions(+), 28 deletions(-) (limited to 'libbb') diff --git a/include/unicode.h b/include/unicode.h index dee02e777..0317a2151 100644 --- a/include/unicode.h +++ b/include/unicode.h @@ -27,6 +27,7 @@ enum { # define unicode_strwidth(string) strlen(string) # define unicode_status UNICODE_OFF # define init_unicode() ((void)0) +# define reinit_unicode(LANG) ((void)0) #else @@ -67,6 +68,7 @@ char* FAST_FUNC unicode_conv_to_printable_fixedwidth(/*uni_stat_t *stats,*/ cons extern uint8_t unicode_status; void init_unicode(void) FAST_FUNC; +void reinit_unicode(const char *LANG) FAST_FUNC; # else @@ -75,9 +77,11 @@ void init_unicode(void) FAST_FUNC; # if !ENABLE_FEATURE_CHECK_UNICODE_IN_ENV # define unicode_status UNICODE_ON # define init_unicode() ((void)0) +# define reinit_unicode(LANG) ((void)0) # else extern uint8_t unicode_status; void init_unicode(void) FAST_FUNC; +void reinit_unicode(const char *LANG) FAST_FUNC; # endif # undef MB_CUR_MAX diff --git a/libbb/unicode.c b/libbb/unicode.c index 08a4c7427..d01efd9a2 100644 --- a/libbb/unicode.c +++ b/libbb/unicode.c @@ -23,37 +23,43 @@ uint8_t unicode_status; /* Unicode support using libc locale support. */ -void FAST_FUNC init_unicode(void) +void FAST_FUNC reinit_unicode(const char *LANG UNUSED_PARAM) { static const char unicode_0x394[] = { 0xce, 0x94, 0 }; size_t width; - if (unicode_status != UNICODE_UNKNOWN) - return; +//TODO: call setlocale(LC_ALL, LANG) here? + /* In unicode, this is a one character string */ // can use unicode_strlen(string) too, but otherwise unicode_strlen() is unused width = mbstowcs(NULL, unicode_0x394, INT_MAX); unicode_status = (width == 1 ? UNICODE_ON : UNICODE_OFF); } +void FAST_FUNC init_unicode(void) +{ + if (unicode_status == UNICODE_UNKNOWN) + reinit_unicode(NULL /*getenv("LANG")*/); +} + #else /* Homegrown Unicode support. It knows only C and Unicode locales. */ # if ENABLE_FEATURE_CHECK_UNICODE_IN_ENV -void FAST_FUNC init_unicode(void) +void FAST_FUNC reinit_unicode(const char *LANG) { - char *lang; - - if (unicode_status != UNICODE_UNKNOWN) - return; - unicode_status = UNICODE_OFF; - lang = getenv("LANG"); - if (!lang || !(strstr(lang, ".utf") || strstr(lang, ".UTF"))) + if (!LANG || !(strstr(LANG, ".utf") || strstr(LANG, ".UTF"))) return; unicode_status = UNICODE_ON; } + +void FAST_FUNC init_unicode(void) +{ + if (unicode_status == UNICODE_UNKNOWN) + reinit_unicode(getenv("LANG")); +} # endif static size_t wcrtomb_internal(char *s, wchar_t wc) diff --git a/shell/ash.c b/shell/ash.c index 0baf7c8e5..1520c5ae5 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -36,12 +36,14 @@ #define JOBS ENABLE_ASH_JOB_CONTROL -#include "busybox.h" /* for applet_names */ #include #include #include #include +#include "busybox.h" /* for applet_names */ +#include "unicode.h" + #include "shell_common.h" #if ENABLE_SH_MATH_SUPPORT # include "math.h" @@ -72,13 +74,6 @@ # error "Do not even bother, ash will not run on NOMMU machine" #endif -//applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) -//applet:IF_FEATURE_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, sh)) -//applet:IF_FEATURE_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, bash)) - -//kbuild:lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o shell_common.o -//kbuild:lib-$(CONFIG_ASH_RANDOM_SUPPORT) += random.o - //config:config ASH //config: bool "ash" //config: default y @@ -190,6 +185,13 @@ //config: variable each time it is displayed. //config: +//applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) +//applet:IF_FEATURE_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, sh)) +//applet:IF_FEATURE_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, bash)) + +//kbuild:lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o shell_common.o +//kbuild:lib-$(CONFIG_ASH_RANDOM_SUPPORT) += random.o + /* ============ Hash table sizes. Configurable. */ @@ -9626,6 +9628,11 @@ preadfd(void) # if ENABLE_FEATURE_TAB_COMPLETION line_input_state->path_lookup = pathval(); # endif + /* Unicode support should be activated even if LANG is set + * _during_ shell execution, not only if it was set when + * shell was started. Therefore, re-check LANG every time: + */ + reinit_unicode(lookupvar("LANG")); nr = read_line_input(line_input_state, cmdedit_prompt, buf, IBUFSIZ, timeout); if (nr == 0) { /* Ctrl+C pressed */ diff --git a/shell/hush.c b/shell/hush.c index 64d5e8587..339f3349a 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -81,7 +81,6 @@ * $ "export" i=`echo 'aaa bbb'`; echo "$i" * aaa */ -#include "busybox.h" /* for APPLET_IS_NOFORK/NOEXEC */ #if !(defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \ || defined(__APPLE__) \ ) @@ -93,6 +92,8 @@ # include #endif +#include "busybox.h" /* for APPLET_IS_NOFORK/NOEXEC */ +#include "unicode.h" #include "shell_common.h" #include "math.h" #include "match.h" @@ -105,14 +106,6 @@ # define PIPE_BUF 4096 /* amount of buffering in a pipe */ #endif -//applet:IF_HUSH(APPLET(hush, BB_DIR_BIN, BB_SUID_DROP)) -//applet:IF_MSH(APPLET(msh, BB_DIR_BIN, BB_SUID_DROP)) -//applet:IF_FEATURE_SH_IS_HUSH(APPLET_ODDNAME(sh, hush, BB_DIR_BIN, BB_SUID_DROP, sh)) -//applet:IF_FEATURE_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, BB_DIR_BIN, BB_SUID_DROP, bash)) - -//kbuild:lib-$(CONFIG_HUSH) += hush.o match.o shell_common.o -//kbuild:lib-$(CONFIG_HUSH_RANDOM_SUPPORT) += random.o - //config:config HUSH //config: bool "hush" //config: default y @@ -249,6 +242,14 @@ //config: msh is deprecated and will be removed, please migrate to hush. //config: +//applet:IF_HUSH(APPLET(hush, BB_DIR_BIN, BB_SUID_DROP)) +//applet:IF_MSH(APPLET(msh, BB_DIR_BIN, BB_SUID_DROP)) +//applet:IF_FEATURE_SH_IS_HUSH(APPLET_ODDNAME(sh, hush, BB_DIR_BIN, BB_SUID_DROP, sh)) +//applet:IF_FEATURE_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, BB_DIR_BIN, BB_SUID_DROP, bash)) + +//kbuild:lib-$(CONFIG_HUSH) += hush.o match.o shell_common.o +//kbuild:lib-$(CONFIG_HUSH_RANDOM_SUPPORT) += random.o + /* -i (interactive) and -s (read stdin) are also accepted, * but currently do nothing, therefore aren't shown in help. * NOMMU-specific options are not meant to be used by users, @@ -1906,6 +1907,12 @@ static void get_user_input(struct in_str *i) /* Enable command line editing only while a command line * is actually being read */ do { + /* Unicode support should be activated even if LANG is set + * _during_ shell execution, not only if it was set when + * shell was started. Therefore, re-check LANG every time: + */ + reinit_unicode(get_local_var_value("LANG")); + G.flag_SIGINT = 0; /* buglet: SIGINT will not make new prompt to appear _at once_, * only after . (^C will work) */ -- cgit v1.2.3-55-g6feb