diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/applets.h | 13 | ||||
-rw-r--r-- | include/busybox.h | 46 | ||||
-rw-r--r-- | include/libbb.h | 11 |
3 files changed, 34 insertions, 36 deletions
diff --git a/include/applets.h b/include/applets.h index 2f31a587f..f35a1d80b 100644 --- a/include/applets.h +++ b/include/applets.h | |||
@@ -59,12 +59,12 @@ s - suid type: | |||
59 | # define APPLET_NOFORK(name,main,l,s,name2) LINK l name | 59 | # define APPLET_NOFORK(name,main,l,s,name2) LINK l name |
60 | 60 | ||
61 | #else | 61 | #else |
62 | const struct bb_applet applets[] = { /* name, main, location, need_suid */ | 62 | static struct bb_applet applets[] = { /* name, main, location, need_suid */ |
63 | # define APPLET(name,l,s) { #name, name##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) }, | 63 | # define APPLET(name,l,s) { #name, #name, l, s }, |
64 | # define APPLET_NOUSAGE(name,main,l,s) { #name, main##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) }, | 64 | # define APPLET_NOUSAGE(name,main,l,s) { #name, #main, l, s }, |
65 | # define APPLET_ODDNAME(name,main,l,s,name2) { #name, main##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) }, | 65 | # define APPLET_ODDNAME(name,main,l,s,name2) { #name, #main, l, s }, |
66 | # define APPLET_NOEXEC(name,main,l,s,name2) { #name, main##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) USE_FEATURE_PREFER_APPLETS(,1) }, | 66 | # define APPLET_NOEXEC(name,main,l,s,name2) { #name, #main, l, s, 1 }, |
67 | # define APPLET_NOFORK(name,main,l,s,name2) { #name, main##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) USE_FEATURE_PREFER_APPLETS(,1 ,1) }, | 67 | # define APPLET_NOFORK(name,main,l,s,name2) { #name, #main, l, s, 1, 1 }, |
68 | #endif | 68 | #endif |
69 | 69 | ||
70 | #if ENABLE_INSTALL_NO_USR | 70 | #if ENABLE_INSTALL_NO_USR |
@@ -385,7 +385,6 @@ USE_GUNZIP(APPLET_ODDNAME(zcat, gunzip, _BB_DIR_BIN, _BB_SUID_NEVER, zcat)) | |||
385 | USE_ZCIP(APPLET(zcip, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 385 | USE_ZCIP(APPLET(zcip, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
386 | 386 | ||
387 | #if !defined(PROTOTYPES) && !defined(NAME_MAIN_CNAME) && !defined(MAKE_USAGE) | 387 | #if !defined(PROTOTYPES) && !defined(NAME_MAIN_CNAME) && !defined(MAKE_USAGE) |
388 | { NULL } | ||
389 | }; | 388 | }; |
390 | #endif | 389 | #endif |
391 | 390 | ||
diff --git a/include/busybox.h b/include/busybox.h index 7ef36901a..f99901aa3 100644 --- a/include/busybox.h +++ b/include/busybox.h | |||
@@ -9,8 +9,7 @@ | |||
9 | 9 | ||
10 | #include "libbb.h" | 10 | #include "libbb.h" |
11 | 11 | ||
12 | #if ENABLE_FEATURE_INSTALLER | 12 | /* order matters: used as index into "install_dir[]" in appletlib.c */ |
13 | /* order matters: used as index into "install_dir[]" in busybox.c */ | ||
14 | typedef enum bb_install_loc_t { | 13 | typedef enum bb_install_loc_t { |
15 | _BB_DIR_ROOT = 0, | 14 | _BB_DIR_ROOT = 0, |
16 | _BB_DIR_BIN, | 15 | _BB_DIR_BIN, |
@@ -18,40 +17,41 @@ typedef enum bb_install_loc_t { | |||
18 | _BB_DIR_USR_BIN, | 17 | _BB_DIR_USR_BIN, |
19 | _BB_DIR_USR_SBIN | 18 | _BB_DIR_USR_SBIN |
20 | } bb_install_loc_t; | 19 | } bb_install_loc_t; |
21 | #endif | ||
22 | 20 | ||
23 | #if ENABLE_FEATURE_SUID | ||
24 | typedef enum bb_suid_t { | 21 | typedef enum bb_suid_t { |
25 | _BB_SUID_NEVER = 0, | 22 | _BB_SUID_NEVER = 0, |
26 | _BB_SUID_MAYBE, | 23 | _BB_SUID_MAYBE, |
27 | _BB_SUID_ALWAYS | 24 | _BB_SUID_ALWAYS |
28 | } bb_suid_t; | 25 | } bb_suid_t; |
29 | #endif | ||
30 | 26 | ||
31 | struct bb_applet { | 27 | |
32 | const char *name; | 28 | /* Defined in appletlib.c (by including generated applet_tables.h) */ |
33 | int (*main) (int argc, char **argv); | 29 | /* Keep in sync with applets/applet_tables.c! */ |
34 | #if ENABLE_FEATURE_INSTALLER | 30 | extern const char applet_names[]; |
35 | __extension__ enum bb_install_loc_t install_loc:8; | 31 | extern int (*const applet_mains[])(int argc, char **argv); |
32 | |||
33 | #if ENABLE_FEATURE_INSTALLER || ENABLE_FEATURE_PREFER_APPLETS | ||
34 | extern const uint32_t applet_nameofs[]; | ||
35 | #else | ||
36 | extern const uint16_t applet_nameofs[]; | ||
36 | #endif | 37 | #endif |
38 | |||
37 | #if ENABLE_FEATURE_SUID | 39 | #if ENABLE_FEATURE_SUID |
38 | __extension__ enum bb_suid_t need_suid:8; | 40 | #define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0x3fff)) |
41 | #define APPLET_SUID(i) ((applet_nameofs[i] >> 14) & 0x3) | ||
42 | #else | ||
43 | #define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0xffff)) | ||
39 | #endif | 44 | #endif |
40 | #if ENABLE_FEATURE_PREFER_APPLETS | 45 | |
41 | /* true if instead of fork(); exec("applet"); waitpid(); | 46 | #if ENABLE_FEATURE_INSTALLER |
42 | * one can do fork(); exit(applet_main(argc,argv)); waitpid(); */ | 47 | #define APPLET_INSTALL_LOC(i) ((applet_nameofs[i] >> 16) & 0x7) |
43 | unsigned char noexec; | ||
44 | /* Even nicer */ | ||
45 | /* true if instead of fork(); exec("applet"); waitpid(); | ||
46 | * one can simply call applet_main(argc,argv); */ | ||
47 | unsigned char nofork; | ||
48 | #endif | 48 | #endif |
49 | }; | ||
50 | 49 | ||
50 | #if ENABLE_FEATURE_PREFER_APPLETS | ||
51 | #define APPLET_IS_NOFORK(i) (applet_nameofs[i] & (1 << 19)) | ||
52 | #define APPLET_IS_NOEXEC(i) (applet_nameofs[i] & (1 << 20)) | ||
53 | #endif | ||
51 | 54 | ||
52 | /* Defined in appletlib.c */ | ||
53 | extern const struct bb_applet applets[]; | ||
54 | extern const unsigned short NUM_APPLETS; | ||
55 | 55 | ||
56 | /* Length of these names has effect on size of libbusybox | 56 | /* Length of these names has effect on size of libbusybox |
57 | * and "individual" binaries. Keep them short. | 57 | * and "individual" binaries. Keep them short. |
diff --git a/include/libbb.h b/include/libbb.h index 095647dd4..2b928215f 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -550,7 +550,6 @@ void clear_username_cache(void); | |||
550 | enum { USERNAME_MAX_SIZE = 16 - sizeof(int) }; | 550 | enum { USERNAME_MAX_SIZE = 16 - sizeof(int) }; |
551 | 551 | ||
552 | 552 | ||
553 | struct bb_applet; | ||
554 | int execable_file(const char *name); | 553 | int execable_file(const char *name); |
555 | char *find_execable(const char *filename); | 554 | char *find_execable(const char *filename); |
556 | int exists_execable(const char *filename); | 555 | int exists_execable(const char *filename); |
@@ -562,7 +561,7 @@ int exists_execable(const char *filename); | |||
562 | int bb_execvp(const char *file, char *const argv[]); | 561 | int bb_execvp(const char *file, char *const argv[]); |
563 | #define BB_EXECVP(prog,cmd) bb_execvp(prog,cmd) | 562 | #define BB_EXECVP(prog,cmd) bb_execvp(prog,cmd) |
564 | #define BB_EXECLP(prog,cmd,...) \ | 563 | #define BB_EXECLP(prog,cmd,...) \ |
565 | execlp((find_applet_by_name(prog)) ? CONFIG_BUSYBOX_EXEC_PATH : prog, \ | 564 | execlp((find_applet_by_name(prog) >= 0) ? CONFIG_BUSYBOX_EXEC_PATH : prog, \ |
566 | cmd, __VA_ARGS__) | 565 | cmd, __VA_ARGS__) |
567 | #else | 566 | #else |
568 | #define BB_EXECVP(prog,cmd) execvp(prog,cmd) | 567 | #define BB_EXECVP(prog,cmd) execvp(prog,cmd) |
@@ -600,8 +599,8 @@ struct nofork_save_area { | |||
600 | void save_nofork_data(struct nofork_save_area *save); | 599 | void save_nofork_data(struct nofork_save_area *save); |
601 | void restore_nofork_data(struct nofork_save_area *save); | 600 | void restore_nofork_data(struct nofork_save_area *save); |
602 | /* Does NOT check that applet is NOFORK, just blindly runs it */ | 601 | /* Does NOT check that applet is NOFORK, just blindly runs it */ |
603 | int run_nofork_applet(const struct bb_applet *a, char **argv); | 602 | int run_nofork_applet(int applet_no, char **argv); |
604 | int run_nofork_applet_prime(struct nofork_save_area *old, const struct bb_applet *a, char **argv); | 603 | int run_nofork_applet_prime(struct nofork_save_area *old, int applet_no, char **argv); |
605 | 604 | ||
606 | /* Helpers for daemonization. | 605 | /* Helpers for daemonization. |
607 | * | 606 | * |
@@ -786,10 +785,10 @@ const struct hwtype *get_hwntype(int type); | |||
786 | 785 | ||
787 | 786 | ||
788 | #ifndef BUILD_INDIVIDUAL | 787 | #ifndef BUILD_INDIVIDUAL |
789 | extern const struct bb_applet *find_applet_by_name(const char *name); | 788 | extern int find_applet_by_name(const char *name); |
790 | /* Returns only if applet is not found. */ | 789 | /* Returns only if applet is not found. */ |
791 | extern void run_applet_and_exit(const char *name, char **argv); | 790 | extern void run_applet_and_exit(const char *name, char **argv); |
792 | extern void run_appletstruct_and_exit(const struct bb_applet *a, char **argv) ATTRIBUTE_NORETURN; | 791 | extern void run_applet_no_and_exit(int a, char **argv) ATTRIBUTE_NORETURN; |
793 | #endif | 792 | #endif |
794 | 793 | ||
795 | extern int match_fstype(const struct mntent *mt, const char *fstypes); | 794 | extern int match_fstype(const struct mntent *mt, const char *fstypes); |