aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbb/appletlib.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 2d01a3ae7..bb7e905db 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -883,20 +883,21 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv)
883} 883}
884# endif /* NUM_APPLETS > 0 */ 884# endif /* NUM_APPLETS > 0 */
885 885
886# if ENABLE_BUSYBOX || NUM_APPLETS > 0
886static NORETURN void run_applet_and_exit(const char *name, char **argv) 887static NORETURN void run_applet_and_exit(const char *name, char **argv)
887{ 888{
888# if ENABLE_BUSYBOX 889# if ENABLE_BUSYBOX
889 if (is_prefixed_with(name, "busybox")) 890 if (is_prefixed_with(name, "busybox"))
890 exit(busybox_main(argv)); 891 exit(busybox_main(argv));
891# endif 892# endif
892# if NUM_APPLETS > 0 893# if NUM_APPLETS > 0
893 /* find_applet_by_name() search is more expensive, so goes second */ 894 /* find_applet_by_name() search is more expensive, so goes second */
894 { 895 {
895 int applet = find_applet_by_name(name); 896 int applet = find_applet_by_name(name);
896 if (applet >= 0) 897 if (applet >= 0)
897 run_applet_no_and_exit(applet, argv); 898 run_applet_no_and_exit(applet, argv);
898 } 899 }
899# endif 900# endif
900 901
901 /*bb_error_msg_and_die("applet not found"); - links in printf */ 902 /*bb_error_msg_and_die("applet not found"); - links in printf */
902 full_write2_str(applet_name); 903 full_write2_str(applet_name);
@@ -904,11 +905,11 @@ static NORETURN void run_applet_and_exit(const char *name, char **argv)
904 /* POSIX: "If a command is not found, the exit status shall be 127" */ 905 /* POSIX: "If a command is not found, the exit status shall be 127" */
905 exit(127); 906 exit(127);
906} 907}
908# endif
907 909
908#endif /* !defined(SINGLE_APPLET_MAIN) */ 910#endif /* !defined(SINGLE_APPLET_MAIN) */
909 911
910 912
911
912#if ENABLE_BUILD_LIBBUSYBOX 913#if ENABLE_BUILD_LIBBUSYBOX
913int lbb_main(char **argv) 914int lbb_main(char **argv)
914#else 915#else
@@ -960,6 +961,7 @@ int main(int argc UNUSED_PARAM, char **argv)
960#endif 961#endif
961 962
962#if defined(SINGLE_APPLET_MAIN) 963#if defined(SINGLE_APPLET_MAIN)
964
963 /* Only one applet is selected in .config */ 965 /* Only one applet is selected in .config */
964 if (argv[1] && is_prefixed_with(argv[0], "busybox")) { 966 if (argv[1] && is_prefixed_with(argv[0], "busybox")) {
965 /* "busybox <applet> <params>" should still work as expected */ 967 /* "busybox <applet> <params>" should still work as expected */
@@ -968,9 +970,16 @@ int main(int argc UNUSED_PARAM, char **argv)
968 /* applet_names in this case is just "applet\0\0" */ 970 /* applet_names in this case is just "applet\0\0" */
969 lbb_prepare(applet_names IF_FEATURE_INDIVIDUAL(, argv)); 971 lbb_prepare(applet_names IF_FEATURE_INDIVIDUAL(, argv));
970 return SINGLE_APPLET_MAIN(argc, argv); 972 return SINGLE_APPLET_MAIN(argc, argv);
973
974#elif !ENABLE_BUSYBOX && NUM_APPLETS == 0
975
976 full_write2_str(bb_basename(argv[0]));
977 full_write2_str(": no applets enabled\n");
978 exit(127);
979
971#else 980#else
972 lbb_prepare("busybox" IF_FEATURE_INDIVIDUAL(, argv));
973 981
982 lbb_prepare("busybox" IF_FEATURE_INDIVIDUAL(, argv));
974# if !ENABLE_BUSYBOX 983# if !ENABLE_BUSYBOX
975 if (argv[1] && is_prefixed_with(bb_basename(argv[0]), "busybox")) 984 if (argv[1] && is_prefixed_with(bb_basename(argv[0]), "busybox"))
976 argv++; 985 argv++;
@@ -979,9 +988,8 @@ int main(int argc UNUSED_PARAM, char **argv)
979 if (applet_name[0] == '-') 988 if (applet_name[0] == '-')
980 applet_name++; 989 applet_name++;
981 applet_name = bb_basename(applet_name); 990 applet_name = bb_basename(applet_name);
982
983 parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */ 991 parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */
984
985 run_applet_and_exit(applet_name, argv); 992 run_applet_and_exit(applet_name, argv);
993
986#endif 994#endif
987} 995}