aboutsummaryrefslogtreecommitdiff
path: root/applets
diff options
context:
space:
mode:
Diffstat (limited to 'applets')
-rw-r--r--applets/applets.c53
1 files changed, 25 insertions, 28 deletions
diff --git a/applets/applets.c b/applets/applets.c
index 66f2b821d..3441a7886 100644
--- a/applets/applets.c
+++ b/applets/applets.c
@@ -43,13 +43,13 @@ static const char usage_messages[] =
43#define usage_messages 0 43#define usage_messages 0
44#endif /* SHOW_USAGE */ 44#endif /* SHOW_USAGE */
45 45
46/* Define struct BB_applet applets[] */ 46/* Define struct bb_applet applets[] */
47#include "applets.h" 47#include "applets.h"
48/* The -1 arises because of the {0,NULL,0,-1} entry. */ 48/* The -1 arises because of the {0,NULL,0,-1} entry. */
49const unsigned short NUM_APPLETS = sizeof(applets) / sizeof(struct BB_applet) - 1; 49const unsigned short NUM_APPLETS = sizeof(applets) / sizeof(applets[0]) - 1;
50 50
51 51
52const struct BB_applet *current_applet; 52const struct bb_applet *current_applet;
53const char *applet_name ATTRIBUTE_EXTERNALLY_VISIBLE; 53const char *applet_name ATTRIBUTE_EXTERNALLY_VISIBLE;
54#ifdef BB_NOMMU 54#ifdef BB_NOMMU
55bool re_execed; 55bool re_execed;
@@ -61,7 +61,7 @@ bool re_execed;
61 61
62/* applets[] is const, so we have to define this "override" structure */ 62/* applets[] is const, so we have to define this "override" structure */
63static struct BB_suid_config { 63static struct BB_suid_config {
64 const struct BB_applet *m_applet; 64 const struct bb_applet *m_applet;
65 uid_t m_uid; 65 uid_t m_uid;
66 gid_t m_gid; 66 gid_t m_gid;
67 mode_t m_mode; 67 mode_t m_mode;
@@ -130,7 +130,7 @@ static void parse_config_file(void)
130{ 130{
131 struct BB_suid_config *sct_head; 131 struct BB_suid_config *sct_head;
132 struct BB_suid_config *sct; 132 struct BB_suid_config *sct;
133 const struct BB_applet *applet; 133 const struct bb_applet *applet;
134 FILE *f; 134 FILE *f;
135 const char *errmsg; 135 const char *errmsg;
136 char *s; 136 char *s;
@@ -329,7 +329,7 @@ static void parse_config_file(void)
329 329
330 330
331#if ENABLE_FEATURE_SUID 331#if ENABLE_FEATURE_SUID
332static void check_suid(const struct BB_applet *applet) 332static void check_suid(const struct bb_applet *applet)
333{ 333{
334 uid_t ruid = getuid(); /* real [ug]id */ 334 uid_t ruid = getuid(); /* real [ug]id */
335 uid_t rgid = getgid(); 335 uid_t rgid = getgid();
@@ -464,45 +464,42 @@ void bb_show_usage(void)
464 applet_name, usage_string); 464 applet_name, usage_string);
465 } 465 }
466 466
467 sleep_and_die(); 467 xfunc_die();
468} 468}
469 469
470 470
471static int applet_name_compare(const void *name, const void *vapplet) 471static int applet_name_compare(const void *name, const void *vapplet)
472{ 472{
473 const struct BB_applet *applet = vapplet; 473 const struct bb_applet *applet = vapplet;
474 474
475 return strcmp(name, applet->name); 475 return strcmp(name, applet->name);
476} 476}
477 477
478const struct BB_applet *find_applet_by_name(const char *name) 478const struct bb_applet *find_applet_by_name(const char *name)
479{ 479{
480 /* Do a binary search to find the applet entry given the name. */ 480 /* Do a binary search to find the applet entry given the name. */
481 return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet), 481 return bsearch(name, applets, NUM_APPLETS, sizeof(applets[0]),
482 applet_name_compare); 482 applet_name_compare);
483} 483}
484 484
485 485
486#if ENABLE_FEATURE_INSTALLER 486#if ENABLE_FEATURE_INSTALLER
487/*
488 * directory table
489 * this should be consistent w/ the enum, busybox.h::Location,
490 * or else...
491 */
492static const char usr_bin [] = "/usr/bin";
493static const char usr_sbin[] = "/usr/sbin";
494
495static const char *const install_dir[] = {
496 &usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
497 &usr_bin [4], /* "/bin" */
498 &usr_sbin[4], /* "/sbin" */
499 usr_bin,
500 usr_sbin
501};
502
503/* create (sym)links for each applet */ 487/* create (sym)links for each applet */
504static void install_links(const char *busybox, int use_symbolic_links) 488static void install_links(const char *busybox, int use_symbolic_links)
505{ 489{
490 /* directory table
491 * this should be consistent w/ the enum,
492 * busybox.h::bb_install_loc_t, or else... */
493 static const char usr_bin [] = "/usr/bin";
494 static const char usr_sbin[] = "/usr/sbin";
495 static const char *const install_dir[] = {
496 &usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
497 &usr_bin [4], /* "/bin" */
498 &usr_sbin[4], /* "/sbin" */
499 usr_bin,
500 usr_sbin
501 };
502
506 int (*lf)(const char *, const char *) = link; 503 int (*lf)(const char *, const char *) = link;
507 char *fpc; 504 char *fpc;
508 int i; 505 int i;
@@ -513,7 +510,7 @@ static void install_links(const char *busybox, int use_symbolic_links)
513 510
514 for (i = 0; applets[i].name != NULL; i++) { 511 for (i = 0; applets[i].name != NULL; i++) {
515 fpc = concat_path_file( 512 fpc = concat_path_file(
516 install_dir[applets[i].location], 513 install_dir[applets[i].install_loc],
517 applets[i].name); 514 applets[i].name);
518 rc = lf(busybox, fpc); 515 rc = lf(busybox, fpc);
519 if (rc != 0 && errno != EEXIST) { 516 if (rc != 0 && errno != EEXIST) {
@@ -557,7 +554,7 @@ static int busybox_main(int argc, char **argv)
557 applet_name = argv[2]; 554 applet_name = argv[2];
558 run_applet_by_name(applet_name, 2, argv); 555 run_applet_by_name(applet_name, 2, argv);
559 } else { 556 } else {
560 const struct BB_applet *a; 557 const struct bb_applet *a;
561 int col, output_width; 558 int col, output_width;
562 559
563 output_width = 80 - sizeof("start-stop-daemon, ") - 8; 560 output_width = 80 - sizeof("start-stop-daemon, ") - 8;