1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069 |
- #include "busybox.h"
- #if !(defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \
- || defined(__APPLE__) \
- )
- # include <malloc.h> /* for mallopt */
- #endif
- #define PROTOTYPES
- #include "applets.h"
- #undef PROTOTYPES
- #include "applet_tables.h"
- #ifdef SINGLE_APPLET_MAIN
- # undef ENABLE_FEATURE_INDIVIDUAL
- # define ENABLE_FEATURE_INDIVIDUAL 1
- # undef IF_FEATURE_INDIVIDUAL
- # define IF_FEATURE_INDIVIDUAL(...) __VA_ARGS__
- #endif
- #include "usage_compressed.h"
- #if UNPACKED_USAGE_LENGTH < 4*1024 \
- && !(ENABLE_FEATURE_SEAMLESS_BZ2 && ENABLE_TAR) \
- && !(ENABLE_FEATURE_SEAMLESS_BZ2 && ENABLE_MODPROBE) \
- && !(ENABLE_FEATURE_SEAMLESS_BZ2 && ENABLE_INSMOD) \
- && !(ENABLE_FEATURE_SEAMLESS_BZ2 && ENABLE_DEPMOD) \
- && !(ENABLE_FEATURE_SEAMLESS_BZ2 && ENABLE_MAN) \
- && !ENABLE_BUNZIP2 \
- && !ENABLE_BZCAT
- # undef ENABLE_FEATURE_COMPRESS_USAGE
- # define ENABLE_FEATURE_COMPRESS_USAGE 0
- #endif
- unsigned FAST_FUNC string_array_len(char **argv)
- {
- char **start = argv;
- while (*argv)
- argv++;
- return argv - start;
- }
- #if ENABLE_SHOW_USAGE && !ENABLE_FEATURE_COMPRESS_USAGE
- static const char usage_messages[] ALIGN1 = UNPACKED_USAGE;
- #else
- # define usage_messages 0
- #endif
- #if ENABLE_FEATURE_COMPRESS_USAGE
- static const char packed_usage[] ALIGN1 = { PACKED_USAGE };
- # include "bb_archive.h"
- static const char *unpack_usage_messages(void)
- {
- char *outbuf = NULL;
- bunzip_data *bd;
- int i;
- i = start_bunzip(&bd,
- -1,
- packed_usage,
- sizeof(packed_usage));
-
- if (!i) {
-
- outbuf = malloc_or_warn(sizeof(UNPACKED_USAGE));
- if (outbuf)
- read_bunzip(bd, outbuf, sizeof(UNPACKED_USAGE));
- }
- dealloc_bunzip(bd);
- return outbuf;
- }
- # define dealloc_usage_messages(s) free(s)
- #else
- # define unpack_usage_messages() usage_messages
- # define dealloc_usage_messages(s) ((void)(s))
- #endif
- void FAST_FUNC bb_show_usage(void)
- {
- if (ENABLE_SHOW_USAGE) {
- #ifdef SINGLE_APPLET_STR
-
- const char *usage_string = unpack_usage_messages();
- if (*usage_string == '\b') {
- full_write2_str("No help available.\n\n");
- } else {
- full_write2_str("Usage: "SINGLE_APPLET_STR" ");
- full_write2_str(usage_string);
- full_write2_str("\n\n");
- }
- if (ENABLE_FEATURE_CLEAN_UP)
- dealloc_usage_messages((char*)usage_string);
- #else
- const char *p;
- const char *usage_string = p = unpack_usage_messages();
- int ap = find_applet_by_name(applet_name);
- if (ap < 0)
- xfunc_die();
- while (ap) {
- while (*p++) continue;
- ap--;
- }
- full_write2_str(bb_banner);
- full_write2_str(" multi-call binary.\n");
- if (*p == '\b')
- full_write2_str("\nNo help available.\n\n");
- else {
- full_write2_str("\nUsage: ");
- full_write2_str(applet_name);
- full_write2_str(" ");
- full_write2_str(p);
- full_write2_str("\n");
- }
- if (ENABLE_FEATURE_CLEAN_UP)
- dealloc_usage_messages((char*)usage_string);
- #endif
- }
- xfunc_die();
- }
- int FAST_FUNC find_applet_by_name(const char *name)
- {
- unsigned i, max;
- int j;
- const char *p;
- #if 0
- uint32_t n32;
-
- if (name[0] == '\0')
- return -1;
- if (name[1] == '\0') {
- if (!ENABLE_TEST)
- return -1;
- if (name[0] != ']')
- return -1;
-
- return 0;
- }
- #endif
- p = applet_names;
- i = 0;
- #if KNOWN_APPNAME_OFFSETS <= 0
- max = NUM_APPLETS;
- #else
- max = NUM_APPLETS * KNOWN_APPNAME_OFFSETS;
- for (j = ARRAY_SIZE(applet_nameofs)-1; j >= 0; j--) {
- const char *pp = applet_names + applet_nameofs[j];
- if (strcmp(name, pp) >= 0) {
-
- p = pp;
- i = max - NUM_APPLETS;
- break;
- }
- max -= NUM_APPLETS;
- }
- max /= (unsigned)KNOWN_APPNAME_OFFSETS;
- i /= (unsigned)KNOWN_APPNAME_OFFSETS;
-
- #endif
-
- #if 0
-
- if (ENABLE_TEST && LONE_CHAR(p, '['))
- i++, p += 2;
-
-
- n32 = (name[0] << 0) | (name[1] << 8) | (name[2] << 16);
- while (i < max) {
- uint32_t p32;
- char ch;
-
- move_from_unaligned32(p32, p);
- p += 3;
- if ((p32 & 0x00ffffff) != n32) {
-
- i++;
- if ((p32 & 0x00ff0000) == '\0')
- continue;
- p++;
- if ((p32 & 0xff000000) == '\0')
- continue;
-
- while (*p++ != '\0')
- continue;
- continue;
- }
-
- if ((p32 & 0x00ff0000) == '\0') {
-
-
- return i;
- }
-
- ch = (p32 >> 24);
- j = 3;
- while (ch == name[j]) {
- if (ch == '\0') {
-
- return i;
- }
- ch = *++p;
- j++;
- }
-
- while (ch != '\0')
- ch = *++p;
- p++;
- i++;
- }
- return -1;
- #else
- while (i < max) {
- char ch;
- j = 0;
-
- while ((ch = *p) == name[j]) {
- if (ch == '\0') {
-
- return i;
- }
- p++;
- j++;
- }
-
- while (ch != '\0')
- ch = *++p;
- p++;
- i++;
- }
- return -1;
- #endif
- }
- void lbb_prepare(const char *applet
- IF_FEATURE_INDIVIDUAL(, char **argv))
- MAIN_EXTERNALLY_VISIBLE;
- void lbb_prepare(const char *applet
- IF_FEATURE_INDIVIDUAL(, char **argv))
- {
- #ifdef __GLIBC__
- (*(int **)&bb_errno) = __errno_location();
- barrier();
- #endif
- applet_name = applet;
- if (ENABLE_LOCALE_SUPPORT)
- setlocale(LC_ALL, "");
- #if ENABLE_FEATURE_INDIVIDUAL
-
- if (argv[1]
- && !argv[2]
- && strcmp(argv[1], "--help") == 0
- && !is_prefixed_with(applet, "busybox")
- ) {
-
- if (!ENABLE_TEST || strcmp(applet_name, "test") != 0)
- bb_show_usage();
- }
- #endif
- }
- const char *applet_name;
- #if !BB_MMU
- bool re_execed;
- #endif
- #if !defined(SINGLE_APPLET_MAIN)
- IF_FEATURE_SUID(static uid_t ruid;)
- # if ENABLE_FEATURE_SUID_CONFIG
- static struct suid_config_t {
-
- struct suid_config_t *m_next;
- struct bb_uidgid_t m_ugid;
- int m_applet;
- mode_t m_mode;
- } *suid_config;
- static bool suid_cfg_readable;
- static char *get_trimmed_slice(char *s, char *e)
- {
-
- while (e-- > s) {
- if (!isspace(*e)) {
- break;
- }
- }
- e[1] = '\0';
-
- return skip_whitespace(s);
- }
- static void parse_config_file(void)
- {
-
- static const char config_file[] ALIGN1 = "/etc/busybox.conf";
- struct suid_config_t *sct_head;
- int applet_no;
- FILE *f;
- const char *errmsg;
- unsigned lc;
- smallint section;
- struct stat st;
- ruid = getuid();
- if (ruid == 0)
- return;
- if ((stat(config_file, &st) != 0)
- || !S_ISREG(st.st_mode)
- || (st.st_uid != 0)
- || (st.st_mode & (S_IWGRP | S_IWOTH))
- || !(f = fopen_for_read(config_file))
- ) {
- return;
- }
- suid_cfg_readable = 1;
- sct_head = NULL;
- section = lc = 0;
- while (1) {
- char buffer[256];
- char *s;
- if (!fgets(buffer, sizeof(buffer), f)) {
-
-
-
-
-
- fclose(f);
- suid_config = sct_head;
- return;
- }
- s = buffer;
- lc++;
-
- if (!strchr(s, '\n') && !feof(f)) {
- errmsg = "line too long";
- goto pe_label;
- }
-
- s = get_trimmed_slice(s, strchrnul(s, '#'));
- if (!*s) {
- continue;
- }
-
- if (*s == '[') {
-
- char *e = strchr(s, ']');
- if (!e
- || e[1]
- || !*(s = get_trimmed_slice(s+1, e))
- ) {
- errmsg = "section header";
- goto pe_label;
- }
-
- if (strcasecmp(s, "SUID") == 0) {
- section = 1;
- continue;
- }
- section = -1;
- continue;
- }
-
- if (section == 1) {
-
-
- char *e = strchr(s, '=');
- if (e) {
- s = get_trimmed_slice(s, e);
- }
- if (!e || !*s) {
- errmsg = "keyword";
- goto pe_label;
- }
-
- applet_no = find_applet_by_name(s);
- if (applet_no >= 0) {
- unsigned i;
- struct suid_config_t *sct;
-
- sct = xzalloc(sizeof(*sct));
- sct->m_applet = applet_no;
-
- sct->m_next = sct_head;
- sct_head = sct;
-
- e = skip_whitespace(e+1);
- for (i = 0; i < 3; i++) {
-
- static const char mode_chars[] ALIGN1 = "Ssx-" "Ssx-" "x-xx";
- static const unsigned short mode_mask[] ALIGN2 = {
- S_ISUID, S_ISUID|S_IXUSR, S_IXUSR, 0,
- S_ISGID, S_ISGID|S_IXGRP, S_IXGRP, 0,
- S_IXOTH, 0
- };
- const char *q = strchrnul(mode_chars + 4*i, *e);
- unsigned idx = q - (mode_chars + 4*i);
- if (idx > 3) {
- errmsg = "mode";
- goto pe_label;
- }
- sct->m_mode |= mode_mask[q - mode_chars];
- e++;
- }
-
- s = skip_whitespace(e);
-
- if (*s) {
-
- if ((s == e) || !(e = strchr(s, '.'))) {
- errmsg = "uid.gid";
- goto pe_label;
- }
- *e = ':';
- if (get_uidgid(&sct->m_ugid, s) == 0) {
- errmsg = "unknown user/group";
- goto pe_label;
- }
- }
- }
- continue;
- }
-
-
- if (!section) {
- errmsg = "keyword outside section";
- goto pe_label;
- }
- }
- pe_label:
- fclose(f);
- bb_error_msg("parse error in %s, line %u: %s", config_file, lc, errmsg);
-
- llist_free((llist_t*)sct_head, NULL);
- }
- # else
- static inline void parse_config_file(void)
- {
- IF_FEATURE_SUID(ruid = getuid();)
- }
- # endif
- # if ENABLE_FEATURE_SUID && NUM_APPLETS > 0
- # if ENABLE_FEATURE_SUID_CONFIG
- static int ingroup(uid_t u, gid_t g)
- {
- struct group *grp = getgrgid(g);
- if (grp) {
- char **mem;
- for (mem = grp->gr_mem; *mem; mem++) {
- struct passwd *pwd = getpwnam(*mem);
- if (pwd && (pwd->pw_uid == u))
- return 1;
- }
- }
- return 0;
- }
- # endif
- static void check_suid(int applet_no)
- {
- gid_t rgid;
- if (ruid == 0)
- return;
- rgid = getgid();
- # if ENABLE_FEATURE_SUID_CONFIG
- if (suid_cfg_readable) {
- uid_t uid;
- struct suid_config_t *sct;
- mode_t m;
- for (sct = suid_config; sct; sct = sct->m_next) {
- if (sct->m_applet == applet_no)
- goto found;
- }
- goto check_need_suid;
- found:
-
- m = sct->m_mode;
- if (sct->m_ugid.uid == ruid)
-
- m >>= 6;
- else if ((sct->m_ugid.gid == rgid) || ingroup(ruid, sct->m_ugid.gid))
-
- m >>= 3;
- if (!(m & S_IXOTH))
- bb_error_msg_and_die("you have no permission to run this applet");
-
-
- if (sct->m_mode & S_ISGID)
- rgid = sct->m_ugid.gid;
-
- if (setresgid(-1, rgid, rgid))
- bb_perror_msg_and_die("setresgid");
-
- uid = ruid;
- if (sct->m_mode & S_ISUID)
- uid = sct->m_ugid.uid;
-
- if (setresuid(-1, uid, uid))
- bb_perror_msg_and_die("setresuid");
- goto ret;
- }
- # if !ENABLE_FEATURE_SUID_CONFIG_QUIET
- {
- static bool onetime = 0;
- if (!onetime) {
- onetime = 1;
- bb_error_msg("using fallback suid method");
- }
- }
- # endif
- check_need_suid:
- # endif
- if (APPLET_SUID(applet_no) == BB_SUID_REQUIRE) {
-
- if (geteuid())
- bb_error_msg_and_die("must be suid to work properly");
- } else if (APPLET_SUID(applet_no) == BB_SUID_DROP) {
-
- setgid(rgid);
- setuid(ruid);
- }
- # if ENABLE_FEATURE_SUID_CONFIG
- ret: ;
- llist_free((llist_t*)suid_config, NULL);
- # endif
- }
- # else
- # define check_suid(x) ((void)0)
- # endif
- # if ENABLE_FEATURE_INSTALLER
- static const char usr_bin [] ALIGN1 = "/usr/bin/";
- static const char usr_sbin[] ALIGN1 = "/usr/sbin/";
- static const char *const install_dir[] = {
- &usr_bin [8],
- &usr_bin [4],
- &usr_sbin[4]
- # if !ENABLE_INSTALL_NO_USR
- ,usr_bin
- ,usr_sbin
- # endif
- };
- static void install_links(const char *busybox, int use_symbolic_links,
- char *custom_install_dir)
- {
-
- int (*lf)(const char *, const char *);
- char *fpc;
- const char *appname = applet_names;
- unsigned i;
- int rc;
- lf = link;
- if (use_symbolic_links)
- lf = symlink;
- for (i = 0; i < ARRAY_SIZE(applet_main); i++) {
- fpc = concat_path_file(
- custom_install_dir ? custom_install_dir : install_dir[APPLET_INSTALL_LOC(i)],
- appname);
-
-
- rc = lf(busybox, fpc);
- if (rc != 0 && errno != EEXIST) {
- bb_simple_perror_msg(fpc);
- }
- free(fpc);
- while (*appname++ != '\0')
- continue;
- }
- }
- # elif ENABLE_BUSYBOX
- static void install_links(const char *busybox UNUSED_PARAM,
- int use_symbolic_links UNUSED_PARAM,
- char *custom_install_dir UNUSED_PARAM)
- {
- }
- # endif
- static void run_applet_and_exit(const char *name, char **argv) NORETURN;
- # if ENABLE_BUSYBOX
- # if ENABLE_FEATURE_SH_STANDALONE && ENABLE_FEATURE_TAB_COMPLETION
-
- int busybox_main(int argc, char *argv[]) MAIN_EXTERNALLY_VISIBLE;
- # else
- # define busybox_main(argc,argv) busybox_main(argv)
- static
- # endif
- int busybox_main(int argc UNUSED_PARAM, char **argv)
- {
- if (!argv[1]) {
-
- const char *a;
- int col;
- unsigned output_width;
- help:
- output_width = get_terminal_width(2);
- dup2(1, 2);
- full_write2_str(bb_banner);
- full_write2_str(" multi-call binary.\n");
- full_write2_str(
- "BusyBox is copyrighted by many authors between 1998-2015.\n"
- "Licensed under GPLv2. See source distribution for detailed\n"
- "copyright notices.\n"
- "\n"
- "Usage: busybox [function [arguments]...]\n"
- " or: busybox --list"IF_FEATURE_INSTALLER("[-full]")"\n"
- IF_FEATURE_INSTALLER(
- " or: busybox --install [-s] [DIR]\n"
- )
- " or: function [arguments]...\n"
- "\n"
- IF_NOT_FEATURE_SH_STANDALONE(
- "\tBusyBox is a multi-call binary that combines many common Unix\n"
- "\tutilities into a single executable. Most people will create a\n"
- "\tlink to busybox for each function they wish to use and BusyBox\n"
- "\twill act like whatever it was invoked as.\n"
- )
- IF_FEATURE_SH_STANDALONE(
- "\tBusyBox is a multi-call binary that combines many common Unix\n"
- "\tutilities into a single executable. The shell in this build\n"
- "\tis configured to run built-in utilities without $PATH search.\n"
- "\tYou don't need to install a link to busybox for each utility.\n"
- "\tTo run external program, use full path (/sbin/ip instead of ip).\n"
- )
- "\n"
- "Currently defined functions:\n"
- );
- col = 0;
- a = applet_names;
-
- output_width--;
- while (*a) {
- int len2 = strlen(a) + 2;
- if (col >= (int)output_width - len2) {
- full_write2_str(",\n");
- col = 0;
- }
- if (col == 0) {
- col = 6;
- full_write2_str("\t");
- } else {
- full_write2_str(", ");
- }
- full_write2_str(a);
- col += len2;
- a += len2 - 1;
- }
- full_write2_str("\n");
- return 0;
- }
- if (is_prefixed_with(argv[1], "--list")) {
- unsigned i = 0;
- const char *a = applet_names;
- dup2(1, 2);
- while (*a) {
- # if ENABLE_FEATURE_INSTALLER
- if (argv[1][6])
- full_write2_str(install_dir[APPLET_INSTALL_LOC(i)] + 1);
- # endif
- full_write2_str(a);
- full_write2_str("\n");
- i++;
- while (*a++ != '\0')
- continue;
- }
- return 0;
- }
- 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) {
-
- if (argv[0][0] != '/')
- bb_error_msg_and_die("'%s' is not an absolute path", argv[0]);
- busybox = argv[0];
- }
-
- use_symbolic_links = (argv[2] && strcmp(argv[2], "-s") == 0 && ++argv);
- install_links(busybox, use_symbolic_links, argv[2]);
- return 0;
- }
- if (strcmp(argv[1], "--help") == 0) {
-
- if (!argv[2])
- goto help;
-
- argv[0] = argv[2];
- argv[2] = NULL;
- } else {
-
- argv++;
- }
-
- applet_name = bb_get_last_path_component_nostrip(argv[0]);
- run_applet_and_exit(applet_name, argv);
- }
- # endif
- # if NUM_APPLETS > 0
- void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **argv)
- {
- int argc = string_array_len(argv);
-
- applet_name = name;
-
- if (1
- # if defined APPLET_NO_test
- && applet_no != APPLET_NO_test
- # endif
- # if defined APPLET_NO_true
- && applet_no != APPLET_NO_true
- # endif
- # if defined APPLET_NO_false
- && applet_no != APPLET_NO_false
- # endif
- ) {
- if (argc == 2 && strcmp(argv[1], "--help") == 0) {
-
- xfunc_error_retval = 0;
- bb_show_usage();
- }
- }
- if (ENABLE_FEATURE_SUID)
- check_suid(applet_no);
- xfunc_error_retval = applet_main[applet_no](argc, argv);
-
- xfunc_die();
- }
- # endif
- # if ENABLE_BUSYBOX || NUM_APPLETS > 0
- static NORETURN void run_applet_and_exit(const char *name, char **argv)
- {
- # if ENABLE_BUSYBOX
- if (is_prefixed_with(name, "busybox"))
- exit(busybox_main( 0, argv));
- # endif
- # if NUM_APPLETS > 0
-
- {
- int applet = find_applet_by_name(name);
- if (applet >= 0)
- run_applet_no_and_exit(applet, name, argv);
- }
- # endif
-
- full_write2_str(applet_name);
- full_write2_str(": applet not found\n");
-
- exit(127);
- }
- # endif
- #endif
- #if ENABLE_BUILD_LIBBUSYBOX
- int lbb_main(char **argv)
- #else
- int main(int argc UNUSED_PARAM, char **argv)
- #endif
- {
- #if 0
-
- extern char _end[] __attribute__((weak));
- unsigned end_len = (-(int)_end) & 0xfff;
- printf("_end:%p %u bytes\n", &_end, end_len);
- #endif
-
- #ifdef M_TRIM_THRESHOLD
-
- mallopt(M_TRIM_THRESHOLD, 8 * 1024);
- #endif
- #ifdef M_MMAP_THRESHOLD
-
- mallopt(M_MMAP_THRESHOLD, 32 * 1024 - 256);
- #endif
- #if 0
-
- mallopt(M_TOP_PAD, 8 * 1024);
- #endif
- #if !BB_MMU
-
- if (argv[0][0] & 0x80) {
- re_execed = 1;
- argv[0][0] &= 0x7f;
- }
- #endif
- #if defined(SINGLE_APPLET_MAIN)
-
- if (argv[1] && is_prefixed_with(argv[0], "busybox")) {
-
- argv++;
- }
-
- lbb_prepare(applet_names IF_FEATURE_INDIVIDUAL(, argv));
- # if ENABLE_BUILD_LIBBUSYBOX
- return SINGLE_APPLET_MAIN(string_array_len(argv), argv);
- # else
- return SINGLE_APPLET_MAIN(argc, argv);
- # endif
- #elif !ENABLE_BUSYBOX && NUM_APPLETS == 0
- full_write2_str(bb_basename(argv[0]));
- full_write2_str(": no applets enabled\n");
- exit(127);
- #else
- lbb_prepare("busybox" IF_FEATURE_INDIVIDUAL(, argv));
- # if !ENABLE_BUSYBOX
- if (argv[1] && is_prefixed_with(bb_basename(argv[0]), "busybox"))
- argv++;
- # endif
- applet_name = argv[0];
- if (applet_name[0] == '-')
- applet_name++;
- applet_name = bb_basename(applet_name);
-
- if (ENABLE_FEATURE_SH_STANDALONE
- || ENABLE_FEATURE_PREFER_APPLETS
- || !BB_MMU
- ) {
- if (NUM_APPLETS > 1)
- set_task_comm(applet_name);
- }
- parse_config_file();
- run_applet_and_exit(applet_name, argv);
- #endif
- }
|