aboutsummaryrefslogtreecommitdiff
path: root/libbb/appletlib.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2017-07-29 09:55:08 +0100
committerRon Yorston <rmy@pobox.com>2017-07-29 09:55:08 +0100
commit86d60bb0ceb277e500a8daabd995bc713bbdadc9 (patch)
tree3e439f92d5a3fec2546d526579cc85e98f066e40 /libbb/appletlib.c
parentb30c60a9786a1608211a96755996bd6c02951a27 (diff)
parent69be994de69d794f038f10a3e7a67519b2006581 (diff)
downloadbusybox-w32-86d60bb0ceb277e500a8daabd995bc713bbdadc9.tar.gz
busybox-w32-86d60bb0ceb277e500a8daabd995bc713bbdadc9.tar.bz2
busybox-w32-86d60bb0ceb277e500a8daabd995bc713bbdadc9.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb/appletlib.c')
-rw-r--r--libbb/appletlib.c41
1 files changed, 37 insertions, 4 deletions
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
793static void run_applet_and_exit(const char *name, char **argv) NORETURN; 799static void run_applet_and_exit(const char *name, char **argv) NORETURN;
794 800
795/* If we were called as "busybox..." */ 801# if ENABLE_BUSYBOX
796static 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))))
813int busybox_main(int argc, char *argv[]) MAIN_EXTERNALLY_VISIBLE;
814# else
815# define busybox_main(argc,argv) busybox_main(argv)
816static
817# endif
818int 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