diff options
author | Ron Yorston <rmy@pobox.com> | 2017-07-29 09:55:08 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2017-07-29 09:55:08 +0100 |
commit | 86d60bb0ceb277e500a8daabd995bc713bbdadc9 (patch) | |
tree | 3e439f92d5a3fec2546d526579cc85e98f066e40 /libbb | |
parent | b30c60a9786a1608211a96755996bd6c02951a27 (diff) | |
parent | 69be994de69d794f038f10a3e7a67519b2006581 (diff) | |
download | busybox-w32-86d60bb0ceb277e500a8daabd995bc713bbdadc9.tar.gz busybox-w32-86d60bb0ceb277e500a8daabd995bc713bbdadc9.tar.bz2 busybox-w32-86d60bb0ceb277e500a8daabd995bc713bbdadc9.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/Config.src | 5 | ||||
-rw-r--r-- | libbb/appletlib.c | 41 | ||||
-rw-r--r-- | libbb/lineedit.c | 4 | ||||
-rw-r--r-- | libbb/u_signal_names.c | 2 |
4 files changed, 42 insertions, 10 deletions
diff --git a/libbb/Config.src b/libbb/Config.src index 9da8b65ee..3c1b064b6 100644 --- a/libbb/Config.src +++ b/libbb/Config.src | |||
@@ -11,14 +11,13 @@ choice | |||
11 | prompt "Buffer allocation policy" | 11 | prompt "Buffer allocation policy" |
12 | default FEATURE_BUFFERS_USE_MALLOC | 12 | default FEATURE_BUFFERS_USE_MALLOC |
13 | help | 13 | help |
14 | There are 3 ways BusyBox can handle buffer allocations: | 14 | There are 3 ways busybox can handle buffer allocations: |
15 | - Use malloc. This costs code size for the call to xmalloc. | 15 | - Use malloc. This costs code size for the call to xmalloc. |
16 | - Put them on stack. For some very small machines with limited stack | 16 | - Put them on stack. For some very small machines with limited stack |
17 | space, this can be deadly. For most folks, this works just fine. | 17 | space, this can be deadly. For most folks, this works just fine. |
18 | - Put them in BSS. This works beautifully for computers with a real | 18 | - Put them in BSS. This works beautifully for computers with a real |
19 | MMU (and OS support), but wastes runtime RAM for uCLinux. This | 19 | MMU (and OS support), but wastes runtime RAM for uCLinux. This |
20 | behavior was the only one available for BusyBox versions 0.48 and | 20 | behavior was the only one available for versions 0.48 and earlier. |
21 | earlier. | ||
22 | 21 | ||
23 | config FEATURE_BUFFERS_USE_MALLOC | 22 | config FEATURE_BUFFERS_USE_MALLOC |
24 | bool "Allocate with Malloc" | 23 | bool "Allocate with Malloc" |
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 172c29611..abd9e3243 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -34,6 +34,13 @@ | |||
34 | # include <malloc.h> /* for mallopt */ | 34 | # include <malloc.h> /* for mallopt */ |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | #include <sys/prctl.h> | ||
38 | #ifndef PR_SET_NAME | ||
39 | #define PR_SET_NAME 15 | ||
40 | #endif | ||
41 | #ifndef PR_GET_NAME | ||
42 | #define PR_GET_NAME 16 | ||
43 | #endif | ||
37 | 44 | ||
38 | /* Declare <applet>_main() */ | 45 | /* Declare <applet>_main() */ |
39 | #define PROTOTYPES | 46 | #define PROTOTYPES |
@@ -789,11 +796,26 @@ static void install_links(const char *busybox UNUSED_PARAM, | |||
789 | } | 796 | } |
790 | # endif | 797 | # endif |
791 | 798 | ||
792 | # if ENABLE_BUSYBOX | ||
793 | static void run_applet_and_exit(const char *name, char **argv) NORETURN; | 799 | static void run_applet_and_exit(const char *name, char **argv) NORETURN; |
794 | 800 | ||
795 | /* If we were called as "busybox..." */ | 801 | # if ENABLE_BUSYBOX |
796 | static int busybox_main(char **argv) | 802 | # if ENABLE_FEATURE_SH_STANDALONE && ENABLE_FEATURE_TAB_COMPLETION |
803 | /* | ||
804 | * Insert "busybox" into applet table as well. | ||
805 | * This makes standalone shell tab-complete this name too. | ||
806 | * (Otherwise having "busybox" in applet table is not necessary, | ||
807 | * there is other code which routes "busyboxANY_SUFFIX" name | ||
808 | * to busybox_main()). | ||
809 | */ | ||
810 | //usage:#define busybox_trivial_usage NOUSAGE_STR | ||
811 | //usage:#define busybox_full_usage "" | ||
812 | //applet:IF_BUSYBOX(IF_FEATURE_SH_STANDALONE(IF_FEATURE_TAB_COMPLETION(APPLET(busybox, BB_DIR_BIN, BB_SUID_MAYBE)))) | ||
813 | int busybox_main(int argc, char *argv[]) MAIN_EXTERNALLY_VISIBLE; | ||
814 | # else | ||
815 | # define busybox_main(argc,argv) busybox_main(argv) | ||
816 | static | ||
817 | # endif | ||
818 | int busybox_main(int argc UNUSED_PARAM, char **argv) | ||
797 | { | 819 | { |
798 | if (!argv[1]) { | 820 | if (!argv[1]) { |
799 | /* Called without arguments */ | 821 | /* Called without arguments */ |
@@ -990,7 +1012,7 @@ static NORETURN void run_applet_and_exit(const char *name, char **argv) | |||
990 | { | 1012 | { |
991 | # if ENABLE_BUSYBOX | 1013 | # if ENABLE_BUSYBOX |
992 | if (is_prefixed_with(name, "busybox")) | 1014 | if (is_prefixed_with(name, "busybox")) |
993 | exit(busybox_main(argv)); | 1015 | exit(busybox_main(/*unused:*/ 0, argv)); |
994 | # endif | 1016 | # endif |
995 | # if NUM_APPLETS > 0 | 1017 | # if NUM_APPLETS > 0 |
996 | /* find_applet_by_name() search is more expensive, so goes second */ | 1018 | /* find_applet_by_name() search is more expensive, so goes second */ |
@@ -1124,6 +1146,17 @@ int main(int argc UNUSED_PARAM, char **argv) | |||
1124 | } | 1146 | } |
1125 | } | 1147 | } |
1126 | applet_name = bb_basename(applet_name); | 1148 | applet_name = bb_basename(applet_name); |
1149 | |||
1150 | # if defined(__linux__) | ||
1151 | /* If we are a result of execv("/proc/self/exe"), fix ugly comm of "exe" */ | ||
1152 | if (ENABLE_FEATURE_SH_STANDALONE | ||
1153 | || ENABLE_FEATURE_PREFER_APPLETS | ||
1154 | || !BB_MMU | ||
1155 | ) { | ||
1156 | prctl(PR_SET_NAME, (long)applet_name, 0, 0, 0); | ||
1157 | } | ||
1158 | # endif | ||
1159 | |||
1127 | parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */ | 1160 | parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */ |
1128 | run_applet_and_exit(applet_name, argv); | 1161 | run_applet_and_exit(applet_name, argv); |
1129 | 1162 | ||
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 670a1b194..a28b6ef98 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -834,7 +834,7 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type) | |||
834 | } | 834 | } |
835 | pf_len = strlen(pfind); | 835 | pf_len = strlen(pfind); |
836 | 836 | ||
837 | #if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1 | 837 | # if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1 |
838 | if (type == FIND_EXE_ONLY && !dirbuf) { | 838 | if (type == FIND_EXE_ONLY && !dirbuf) { |
839 | const char *p = applet_names; | 839 | const char *p = applet_names; |
840 | 840 | ||
@@ -845,7 +845,7 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type) | |||
845 | } | 845 | } |
846 | add_partial_match(pfind, "busybox", pf_len); | 846 | add_partial_match(pfind, "busybox", pf_len); |
847 | } | 847 | } |
848 | #endif | 848 | # endif |
849 | 849 | ||
850 | for (i = 0; i < npaths; i++) { | 850 | for (i = 0; i < npaths; i++) { |
851 | DIR *dir; | 851 | DIR *dir; |
diff --git a/libbb/u_signal_names.c b/libbb/u_signal_names.c index bf984a44e..b82a706d8 100644 --- a/libbb/u_signal_names.c +++ b/libbb/u_signal_names.c | |||
@@ -143,7 +143,7 @@ int FAST_FUNC get_signum(const char *name) | |||
143 | unsigned i; | 143 | unsigned i; |
144 | 144 | ||
145 | i = bb_strtou(name, NULL, 10); | 145 | i = bb_strtou(name, NULL, 10); |
146 | if (!errno) | 146 | if (!errno && i < NSIG) /* for shells, we allow 0 too */ |
147 | return i; | 147 | return i; |
148 | if (strncasecmp(name, "SIG", 3) == 0) | 148 | if (strncasecmp(name, "SIG", 3) == 0) |
149 | name += 3; | 149 | name += 3; |