appletlib.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Utility routines.
  4. *
  5. * Copyright (C) tons of folks. Tracking down who wrote what
  6. * isn't something I'm going to worry about... If you wrote something
  7. * here, please feel free to acknowledge your work.
  8. *
  9. * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
  10. * Permission has been granted to redistribute this code under the GPL.
  11. *
  12. * Licensed under GPLv2 or later, see file License in this tarball for details.
  13. */
  14. #include <assert.h>
  15. #include "busybox.h"
  16. /* Declare <applet>_main() */
  17. #define PROTOTYPES
  18. #include "applets.h"
  19. #undef PROTOTYPES
  20. #if ENABLE_SHOW_USAGE && !ENABLE_FEATURE_COMPRESS_USAGE
  21. /* Define usage_messages[] */
  22. static const char usage_messages[] ALIGN1 = ""
  23. #define MAKE_USAGE
  24. #include "usage.h"
  25. #include "applets.h"
  26. ;
  27. #undef MAKE_USAGE
  28. #else
  29. #define usage_messages 0
  30. #endif /* SHOW_USAGE */
  31. /* Include generated applet names, pointers to <applet>_main, etc */
  32. #include "applet_tables.h"
  33. #if ENABLE_FEATURE_COMPRESS_USAGE
  34. #include "usage_compressed.h"
  35. #include "unarchive.h"
  36. static const char *unpack_usage_messages(void)
  37. {
  38. char *outbuf = NULL;
  39. bunzip_data *bd;
  40. int i;
  41. i = start_bunzip(&bd,
  42. /* src_fd: */ -1,
  43. /* inbuf: */ packed_usage,
  44. /* len: */ sizeof(packed_usage));
  45. /* read_bunzip can longjmp to start_bunzip, and ultimately
  46. * end up here with i != 0 on read data errors! Not trivial */
  47. if (!i) {
  48. /* Cannot use xmalloc: will leak bd in NOFORK case! */
  49. outbuf = malloc_or_warn(SIZEOF_usage_messages);
  50. if (outbuf)
  51. read_bunzip(bd, outbuf, SIZEOF_usage_messages);
  52. }
  53. dealloc_bunzip(bd);
  54. return outbuf;
  55. }
  56. #define dealloc_usage_messages(s) free(s)
  57. #else
  58. #define unpack_usage_messages() usage_messages
  59. #define dealloc_usage_messages(s) ((void)(s))
  60. #endif /* FEATURE_COMPRESS_USAGE */
  61. void bb_show_usage(void)
  62. {
  63. if (ENABLE_SHOW_USAGE) {
  64. const char *format_string;
  65. const char *p;
  66. const char *usage_string = p = unpack_usage_messages();
  67. int ap = find_applet_by_name(applet_name);
  68. if (ap < 0) /* never happens, paranoia */
  69. xfunc_die();
  70. while (ap) {
  71. while (*p++) continue;
  72. ap--;
  73. }
  74. fprintf(stderr, "%s multi-call binary\n", bb_banner);
  75. format_string = "\nUsage: %s %s\n\n";
  76. if (*p == '\b')
  77. format_string = "\nNo help available.\n\n";
  78. fprintf(stderr, format_string, applet_name, p);
  79. dealloc_usage_messages((char*)usage_string);
  80. }
  81. xfunc_die();
  82. }
  83. /* NB: any char pointer will work as well, not necessarily applet_names */
  84. static int applet_name_compare(const void *name, const void *v)
  85. {
  86. int i = (const char *)v - applet_names;
  87. return strcmp(name, APPLET_NAME(i));
  88. }
  89. int find_applet_by_name(const char *name)
  90. {
  91. /* Do a binary search to find the applet entry given the name. */
  92. const char *p;
  93. p = bsearch(name, applet_names, ARRAY_SIZE(applet_main), 1, applet_name_compare);
  94. if (!p)
  95. return -1;
  96. return p - applet_names;
  97. }
  98. #ifdef __GLIBC__
  99. /* Make it reside in R/W memory: */
  100. int *const bb_errno __attribute__ ((section (".data")));
  101. #endif
  102. void lbb_prepare(const char *applet
  103. USE_FEATURE_INDIVIDUAL(, char **argv))
  104. {
  105. #ifdef __GLIBC__
  106. (*(int **)&bb_errno) = __errno_location();
  107. barrier();
  108. #endif
  109. applet_name = applet;
  110. /* Set locale for everybody except 'init' */
  111. if (ENABLE_LOCALE_SUPPORT && getpid() != 1)
  112. setlocale(LC_ALL, "");
  113. #if ENABLE_FEATURE_INDIVIDUAL
  114. /* Redundant for busybox (run_applet_and_exit covers that case)
  115. * but needed for "individual applet" mode */
  116. if (argv[1] && strcmp(argv[1], "--help") == 0)
  117. bb_show_usage();
  118. #endif
  119. }
  120. /* The code below can well be in applets/applets.c, as it is used only
  121. * for busybox binary, not "individual" binaries.
  122. * However, keeping it here and linking it into libbusybox.so
  123. * (together with remaining tiny applets/applets.o)
  124. * makes it possible to avoid --whole-archive at link time.
  125. * This makes (shared busybox) + libbusybox smaller.
  126. * (--gc-sections would be even better....)
  127. */
  128. const char *applet_name;
  129. #if !BB_MMU
  130. bool re_execed;
  131. #endif
  132. USE_FEATURE_SUID(static uid_t ruid;) /* real uid */
  133. #if ENABLE_FEATURE_SUID_CONFIG
  134. /* applets[] is const, so we have to define this "override" structure */
  135. static struct BB_suid_config {
  136. int m_applet;
  137. uid_t m_uid;
  138. gid_t m_gid;
  139. mode_t m_mode;
  140. struct BB_suid_config *m_next;
  141. } *suid_config;
  142. static bool suid_cfg_readable;
  143. /* check if u is member of group g */
  144. static int ingroup(uid_t u, gid_t g)
  145. {
  146. struct group *grp = getgrgid(g);
  147. if (grp) {
  148. char **mem;
  149. for (mem = grp->gr_mem; *mem; mem++) {
  150. struct passwd *pwd = getpwnam(*mem);
  151. if (pwd && (pwd->pw_uid == u))
  152. return 1;
  153. }
  154. }
  155. return 0;
  156. }
  157. /* This should probably be a libbb routine. In that case,
  158. * I'd probably rename it to something like bb_trimmed_slice.
  159. */
  160. static char *get_trimmed_slice(char *s, char *e)
  161. {
  162. /* First, consider the value at e to be nul and back up until we
  163. * reach a non-space char. Set the char after that (possibly at
  164. * the original e) to nul. */
  165. while (e-- > s) {
  166. if (!isspace(*e)) {
  167. break;
  168. }
  169. }
  170. e[1] = '\0';
  171. /* Next, advance past all leading space and return a ptr to the
  172. * first non-space char; possibly the terminating nul. */
  173. return skip_whitespace(s);
  174. }
  175. /* Don't depend on the tools to combine strings. */
  176. static const char config_file[] ALIGN1 = "/etc/busybox.conf";
  177. /* We don't supply a value for the nul, so an index adjustment is
  178. * necessary below. Also, we use unsigned short here to save some
  179. * space even though these are really mode_t values. */
  180. static const unsigned short mode_mask[] ALIGN2 = {
  181. /* SST sst xxx --- */
  182. S_ISUID, S_ISUID|S_IXUSR, S_IXUSR, 0, /* user */
  183. S_ISGID, S_ISGID|S_IXGRP, S_IXGRP, 0, /* group */
  184. 0, S_IXOTH, S_IXOTH, 0 /* other */
  185. };
  186. #define parse_error(x) do { errmsg = x; goto pe_label; } while (0)
  187. static void parse_config_file(void)
  188. {
  189. struct BB_suid_config *sct_head;
  190. struct BB_suid_config *sct;
  191. int applet_no;
  192. FILE *f;
  193. const char *errmsg;
  194. char *s;
  195. char *e;
  196. int i;
  197. unsigned lc;
  198. smallint section;
  199. char buffer[256];
  200. struct stat st;
  201. assert(!suid_config); /* Should be set to NULL by bss init. */
  202. ruid = getuid();
  203. if (ruid == 0) /* run by root - don't need to even read config file */
  204. return;
  205. if ((stat(config_file, &st) != 0) /* No config file? */
  206. || !S_ISREG(st.st_mode) /* Not a regular file? */
  207. || (st.st_uid != 0) /* Not owned by root? */
  208. || (st.st_mode & (S_IWGRP | S_IWOTH)) /* Writable by non-root? */
  209. || !(f = fopen(config_file, "r")) /* Cannot open? */
  210. ) {
  211. return;
  212. }
  213. suid_cfg_readable = 1;
  214. sct_head = NULL;
  215. section = lc = 0;
  216. while (1) {
  217. s = buffer;
  218. if (!fgets(s, sizeof(buffer), f)) { /* Are we done? */
  219. // why?
  220. if (ferror(f)) { /* Make sure it wasn't a read error. */
  221. parse_error("reading");
  222. }
  223. fclose(f);
  224. suid_config = sct_head; /* Success, so set the pointer. */
  225. return;
  226. }
  227. lc++; /* Got a (partial) line. */
  228. /* If a line is too long for our buffer, we consider it an error.
  229. * The following test does mistreat one corner case though.
  230. * If the final line of the file does not end with a newline and
  231. * yet exactly fills the buffer, it will be treated as too long
  232. * even though there isn't really a problem. But it isn't really
  233. * worth adding code to deal with such an unlikely situation, and
  234. * we do err on the side of caution. Besides, the line would be
  235. * too long if it did end with a newline. */
  236. if (!strchr(s, '\n') && !feof(f)) {
  237. parse_error("line too long");
  238. }
  239. /* Trim leading and trailing whitespace, ignoring comments, and
  240. * check if the resulting string is empty. */
  241. s = get_trimmed_slice(s, strchrnul(s, '#'));
  242. if (!*s) {
  243. continue;
  244. }
  245. /* Check for a section header. */
  246. if (*s == '[') {
  247. /* Unlike the old code, we ignore leading and trailing
  248. * whitespace for the section name. We also require that
  249. * there are no stray characters after the closing bracket. */
  250. e = strchr(s, ']');
  251. if (!e /* Missing right bracket? */
  252. || e[1] /* Trailing characters? */
  253. || !*(s = get_trimmed_slice(s+1, e)) /* Missing name? */
  254. ) {
  255. parse_error("section header");
  256. }
  257. /* Right now we only have one section so just check it.
  258. * If more sections are added in the future, please don't
  259. * resort to cascading ifs with multiple strcasecmp calls.
  260. * That kind of bloated code is all too common. A loop
  261. * and a string table would be a better choice unless the
  262. * number of sections is very small. */
  263. if (strcasecmp(s, "SUID") == 0) {
  264. section = 1;
  265. continue;
  266. }
  267. section = -1; /* Unknown section so set to skip. */
  268. continue;
  269. }
  270. /* Process sections. */
  271. if (section == 1) { /* SUID */
  272. /* Since we trimmed leading and trailing space above, we're
  273. * now looking for strings of the form
  274. * <key>[::space::]*=[::space::]*<value>
  275. * where both key and value could contain inner whitespace. */
  276. /* First get the key (an applet name in our case). */
  277. e = strchr(s, '=');
  278. if (e) {
  279. s = get_trimmed_slice(s, e);
  280. }
  281. if (!e || !*s) { /* Missing '=' or empty key. */
  282. parse_error("keyword");
  283. }
  284. /* Ok, we have an applet name. Process the rhs if this
  285. * applet is currently built in and ignore it otherwise.
  286. * Note: this can hide config file bugs which only pop
  287. * up when the busybox configuration is changed. */
  288. applet_no = find_applet_by_name(s);
  289. if (applet_no >= 0) {
  290. /* Note: We currently don't check for duplicates!
  291. * The last config line for each applet will be the
  292. * one used since we insert at the head of the list.
  293. * I suppose this could be considered a feature. */
  294. sct = xmalloc(sizeof(struct BB_suid_config));
  295. sct->m_applet = applet_no;
  296. sct->m_mode = 0;
  297. sct->m_next = sct_head;
  298. sct_head = sct;
  299. /* Get the specified mode. */
  300. e = skip_whitespace(e+1);
  301. for (i = 0; i < 3; i++) {
  302. /* There are 4 chars + 1 nul for each of user/group/other. */
  303. static const char mode_chars[] ALIGN1 = "Ssx-\0" "Ssx-\0" "Ttx-";
  304. const char *q;
  305. q = strchrnul(mode_chars + 5*i, *e++);
  306. if (!*q) {
  307. parse_error("mode");
  308. }
  309. /* Adjust by -i to account for nul. */
  310. sct->m_mode |= mode_mask[(q - mode_chars) - i];
  311. }
  312. /* Now get the the user/group info. */
  313. s = skip_whitespace(e);
  314. /* Note: we require whitespace between the mode and the
  315. * user/group info. */
  316. if ((s == e) || !(e = strchr(s, '.'))) {
  317. parse_error("<uid>.<gid>");
  318. }
  319. *e++ = '\0';
  320. /* We can't use get_ug_id here since it would exit()
  321. * if a uid or gid was not found. Oh well... */
  322. sct->m_uid = bb_strtoul(s, NULL, 10);
  323. if (errno) {
  324. struct passwd *pwd = getpwnam(s);
  325. if (!pwd) {
  326. parse_error("user");
  327. }
  328. sct->m_uid = pwd->pw_uid;
  329. }
  330. sct->m_gid = bb_strtoul(e, NULL, 10);
  331. if (errno) {
  332. struct group *grp;
  333. grp = getgrnam(e);
  334. if (!grp) {
  335. parse_error("group");
  336. }
  337. sct->m_gid = grp->gr_gid;
  338. }
  339. }
  340. continue;
  341. }
  342. /* Unknown sections are ignored. */
  343. /* Encountering configuration lines prior to seeing a
  344. * section header is treated as an error. This is how
  345. * the old code worked, but it may not be desirable.
  346. * We may want to simply ignore such lines in case they
  347. * are used in some future version of busybox. */
  348. if (!section) {
  349. parse_error("keyword outside section");
  350. }
  351. } /* while (1) */
  352. pe_label:
  353. fprintf(stderr, "Parse error in %s, line %d: %s\n",
  354. config_file, lc, errmsg);
  355. fclose(f);
  356. /* Release any allocated memory before returning. */
  357. while (sct_head) {
  358. sct = sct_head->m_next;
  359. free(sct_head);
  360. sct_head = sct;
  361. }
  362. }
  363. #else
  364. static inline void parse_config_file(void)
  365. {
  366. USE_FEATURE_SUID(ruid = getuid();)
  367. }
  368. #endif /* FEATURE_SUID_CONFIG */
  369. #if ENABLE_FEATURE_SUID
  370. static void check_suid(int applet_no)
  371. {
  372. gid_t rgid; /* real gid */
  373. if (ruid == 0) /* set by parse_config_file() */
  374. return; /* run by root - no need to check more */
  375. rgid = getgid();
  376. #if ENABLE_FEATURE_SUID_CONFIG
  377. if (suid_cfg_readable) {
  378. uid_t uid;
  379. struct BB_suid_config *sct;
  380. mode_t m;
  381. for (sct = suid_config; sct; sct = sct->m_next) {
  382. if (sct->m_applet == applet_no)
  383. goto found;
  384. }
  385. goto check_need_suid;
  386. found:
  387. m = sct->m_mode;
  388. if (sct->m_uid == ruid)
  389. /* same uid */
  390. m >>= 6;
  391. else if ((sct->m_gid == rgid) || ingroup(ruid, sct->m_gid))
  392. /* same group / in group */
  393. m >>= 3;
  394. if (!(m & S_IXOTH)) /* is x bit not set ? */
  395. bb_error_msg_and_die("you have no permission to run this applet!");
  396. /* _both_ sgid and group_exec have to be set for setegid */
  397. if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
  398. rgid = sct->m_gid;
  399. /* else (no setegid) we will set egid = rgid */
  400. /* We set effective AND saved ids. If saved-id is not set
  401. * like we do below, seteiud(0) can still later succeed! */
  402. if (setresgid(-1, rgid, rgid))
  403. bb_perror_msg_and_die("setresgid");
  404. /* do we have to set effective uid? */
  405. uid = ruid;
  406. if (sct->m_mode & S_ISUID)
  407. uid = sct->m_uid;
  408. /* else (no seteuid) we will set euid = ruid */
  409. if (setresuid(-1, uid, uid))
  410. bb_perror_msg_and_die("setresuid");
  411. return;
  412. }
  413. #if !ENABLE_FEATURE_SUID_CONFIG_QUIET
  414. {
  415. static bool onetime = 0;
  416. if (!onetime) {
  417. onetime = 1;
  418. fprintf(stderr, "Using fallback suid method\n");
  419. }
  420. }
  421. #endif
  422. check_need_suid:
  423. #endif
  424. if (APPLET_SUID(applet_no) == _BB_SUID_ALWAYS) {
  425. /* Real uid is not 0. If euid isn't 0 too, suid bit
  426. * is most probably not set on our executable */
  427. if (geteuid())
  428. bb_error_msg_and_die("must be suid to work properly");
  429. } else if (APPLET_SUID(applet_no) == _BB_SUID_NEVER) {
  430. xsetgid(rgid); /* drop all privileges */
  431. xsetuid(ruid);
  432. }
  433. }
  434. #else
  435. #define check_suid(x) ((void)0)
  436. #endif /* FEATURE_SUID */
  437. #if ENABLE_FEATURE_INSTALLER
  438. /* create (sym)links for each applet */
  439. static void install_links(const char *busybox, int use_symbolic_links)
  440. {
  441. /* directory table
  442. * this should be consistent w/ the enum,
  443. * busybox.h::bb_install_loc_t, or else... */
  444. static const char usr_bin [] ALIGN1 = "/usr/bin";
  445. static const char usr_sbin[] ALIGN1 = "/usr/sbin";
  446. static const char *const install_dir[] = {
  447. &usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
  448. &usr_bin [4], /* "/bin" */
  449. &usr_sbin[4], /* "/sbin" */
  450. usr_bin,
  451. usr_sbin
  452. };
  453. int (*lf)(const char *, const char *);
  454. char *fpc;
  455. int i;
  456. int rc;
  457. lf = link;
  458. if (use_symbolic_links)
  459. lf = symlink;
  460. for (i = 0; i < ARRAY_SIZE(applet_main); i++) {
  461. fpc = concat_path_file(
  462. install_dir[APPLET_INSTALL_LOC(i)],
  463. APPLET_NAME(i));
  464. // debug: bb_error_msg("%slinking %s to busybox",
  465. // use_symbolic_links ? "sym" : "", fpc);
  466. rc = lf(busybox, fpc);
  467. if (rc != 0 && errno != EEXIST) {
  468. bb_simple_perror_msg(fpc);
  469. }
  470. free(fpc);
  471. }
  472. }
  473. #else
  474. #define install_links(x,y) ((void)0)
  475. #endif /* FEATURE_INSTALLER */
  476. /* If we were called as "busybox..." */
  477. static int busybox_main(char **argv)
  478. {
  479. if (!argv[1]) {
  480. /* Called without arguments */
  481. const char *a;
  482. int col, output_width;
  483. help:
  484. output_width = 80;
  485. if (ENABLE_FEATURE_AUTOWIDTH) {
  486. /* Obtain the terminal width */
  487. get_terminal_width_height(0, &output_width, NULL);
  488. }
  489. /* leading tab and room to wrap */
  490. output_width -= sizeof("start-stop-daemon, ") + 8;
  491. printf("%s multi-call binary\n", bb_banner); /* reuse const string... */
  492. printf("Copyright (C) 1998-2007 Erik Andersen, Rob Landley, Denys Vlasenko\n"
  493. "and others. Licensed under GPLv2.\n"
  494. "See source distribution for full notice.\n"
  495. "\n"
  496. "Usage: busybox [function] [arguments]...\n"
  497. " or: function [arguments]...\n"
  498. "\n"
  499. "\tBusyBox is a multi-call binary that combines many common Unix\n"
  500. "\tutilities into a single executable. Most people will create a\n"
  501. "\tlink to busybox for each function they wish to use and BusyBox\n"
  502. "\twill act like whatever it was invoked as!\n"
  503. "\n"
  504. "Currently defined functions:\n");
  505. col = 0;
  506. a = applet_names;
  507. while (*a) {
  508. if (col > output_width) {
  509. puts(",");
  510. col = 0;
  511. }
  512. col += printf("%s%s", (col ? ", " : "\t"), a);
  513. a += strlen(a) + 1;
  514. }
  515. puts("\n");
  516. return 0;
  517. }
  518. if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) {
  519. const char *busybox;
  520. busybox = xmalloc_readlink(bb_busybox_exec_path);
  521. if (!busybox)
  522. busybox = bb_busybox_exec_path;
  523. /* -s makes symlinks */
  524. install_links(busybox, argv[2] && strcmp(argv[2], "-s") == 0);
  525. return 0;
  526. }
  527. if (strcmp(argv[1], "--help") == 0) {
  528. /* "busybox --help [<applet>]" */
  529. if (!argv[2])
  530. goto help;
  531. /* convert to "<applet> --help" */
  532. argv[0] = argv[2];
  533. argv[2] = NULL;
  534. } else {
  535. /* "busybox <applet> arg1 arg2 ..." */
  536. argv++;
  537. }
  538. /* We support "busybox /a/path/to/applet args..." too. Allows for
  539. * "#!/bin/busybox"-style wrappers */
  540. applet_name = bb_get_last_path_component_nostrip(argv[0]);
  541. run_applet_and_exit(applet_name, argv);
  542. bb_error_msg_and_die("applet not found");
  543. }
  544. void run_applet_no_and_exit(int applet_no, char **argv)
  545. {
  546. int argc = 1;
  547. while (argv[argc])
  548. argc++;
  549. /* Reinit some shared global data */
  550. xfunc_error_retval = EXIT_FAILURE;
  551. applet_name = APPLET_NAME(applet_no);
  552. if (argc == 2 && !strcmp(argv[1], "--help"))
  553. bb_show_usage();
  554. if (ENABLE_FEATURE_SUID)
  555. check_suid(applet_no);
  556. exit(applet_main[applet_no](argc, argv));
  557. }
  558. void run_applet_and_exit(const char *name, char **argv)
  559. {
  560. int applet = find_applet_by_name(name);
  561. if (applet >= 0)
  562. run_applet_no_and_exit(applet, argv);
  563. if (!strncmp(name, "busybox", 7))
  564. exit(busybox_main(argv));
  565. }
  566. #if ENABLE_BUILD_LIBBUSYBOX
  567. int lbb_main(char **argv)
  568. #else
  569. int main(int argc ATTRIBUTE_UNUSED, char **argv)
  570. #endif
  571. {
  572. lbb_prepare("busybox" USE_FEATURE_INDIVIDUAL(, argv));
  573. #if !BB_MMU
  574. /* NOMMU re-exec trick sets high-order bit in first byte of name */
  575. if (argv[0][0] & 0x80) {
  576. re_execed = 1;
  577. argv[0][0] &= 0x7f;
  578. }
  579. #endif
  580. applet_name = argv[0];
  581. if (applet_name[0] == '-')
  582. applet_name++;
  583. applet_name = bb_basename(applet_name);
  584. parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */
  585. run_applet_and_exit(applet_name, argv);
  586. bb_error_msg_and_die("applet not found");
  587. }