diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-09 03:11:58 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-09 03:11:58 +0000 |
commit | c44ab01b75aba758fe0aff4b34b25d733e370dc2 (patch) | |
tree | 7aaff270868ae6e6ff78fb5c42d42f5645a6a67a | |
parent | 95cb3263ae8f9afda0f6af3f777739506a0dfc62 (diff) | |
download | busybox-w32-c44ab01b75aba758fe0aff4b34b25d733e370dc2.tar.gz busybox-w32-c44ab01b75aba758fe0aff4b34b25d733e370dc2.tar.bz2 busybox-w32-c44ab01b75aba758fe0aff4b34b25d733e370dc2.zip |
Improve STANDALONE_SHELL. "safe" applets are renamed NOEXEC applets
and now this fact is recorded in applets.h, not ash.c.
Several fixes to "--help + STANDALONE_SHELL" scenarios.
function old new delta
run_current_applet_and_exit - 355 +355
arith 2064 2073 +9
refresh 1148 1156 +8
getopt32 1068 1073 +5
telnet_main 1510 1514 +4
md5_sha1_sum_main 565 566 +1
xstrtoul_range_sfx 255 251 -4
packed_usage 22523 22514 -9
tryexec 255 203 -52
static.safe_applets 152 - -152
.rodata 131320 131128 -192
run_applet_by_name 869 506 -363
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 5/5 up/down: 382/-772) Total: -390 bytes
./busybox ash -c 'i=20000; while test $i != 0; do touch z; i=$((i-1)); done'
runs more than twice as fast with STANDALONE_SHELL versus without.
-rw-r--r-- | applets/applets.c | 35 | ||||
-rw-r--r-- | include/applets.h | 48 | ||||
-rw-r--r-- | include/busybox.h | 11 | ||||
-rw-r--r-- | include/libbb.h | 5 | ||||
-rw-r--r-- | shell/ash.c | 59 |
5 files changed, 65 insertions, 93 deletions
diff --git a/applets/applets.c b/applets/applets.c index 8acfd95a9..c8e85cdb1 100644 --- a/applets/applets.c +++ b/applets/applets.c | |||
@@ -49,7 +49,7 @@ static const char usage_messages[] = | |||
49 | const unsigned short NUM_APPLETS = sizeof(applets) / sizeof(struct BB_applet) - 1; | 49 | const unsigned short NUM_APPLETS = sizeof(applets) / sizeof(struct BB_applet) - 1; |
50 | 50 | ||
51 | 51 | ||
52 | static struct BB_applet *current_applet; | 52 | const struct BB_applet *current_applet; |
53 | const char *applet_name ATTRIBUTE_EXTERNALLY_VISIBLE; | 53 | const char *applet_name ATTRIBUTE_EXTERNALLY_VISIBLE; |
54 | #ifdef BB_NOMMU | 54 | #ifdef BB_NOMMU |
55 | smallint re_execed; | 55 | smallint re_execed; |
@@ -60,14 +60,11 @@ smallint re_execed; | |||
60 | #if ENABLE_FEATURE_SUID_CONFIG | 60 | #if ENABLE_FEATURE_SUID_CONFIG |
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 */ |
63 | static struct BB_suid_config | 63 | static struct BB_suid_config { |
64 | { | 64 | const struct BB_applet *m_applet; |
65 | struct BB_applet *m_applet; | ||
66 | |||
67 | uid_t m_uid; | 65 | uid_t m_uid; |
68 | gid_t m_gid; | 66 | gid_t m_gid; |
69 | mode_t m_mode; | 67 | mode_t m_mode; |
70 | |||
71 | struct BB_suid_config *m_next; | 68 | struct BB_suid_config *m_next; |
72 | } *suid_config; | 69 | } *suid_config; |
73 | 70 | ||
@@ -133,7 +130,7 @@ static void parse_config_file(void) | |||
133 | { | 130 | { |
134 | struct BB_suid_config *sct_head; | 131 | struct BB_suid_config *sct_head; |
135 | struct BB_suid_config *sct; | 132 | struct BB_suid_config *sct; |
136 | struct BB_applet *applet; | 133 | const struct BB_applet *applet; |
137 | FILE *f; | 134 | FILE *f; |
138 | const char *errmsg; | 135 | const char *errmsg; |
139 | char *s; | 136 | char *s; |
@@ -330,7 +327,7 @@ static void parse_config_file(void) | |||
330 | 327 | ||
331 | 328 | ||
332 | #if ENABLE_FEATURE_SUID | 329 | #if ENABLE_FEATURE_SUID |
333 | static void check_suid(struct BB_applet *applet) | 330 | static void check_suid(const struct BB_applet *applet) |
334 | { | 331 | { |
335 | uid_t ruid = getuid(); /* real [ug]id */ | 332 | uid_t ruid = getuid(); /* real [ug]id */ |
336 | uid_t rgid = getgid(); | 333 | uid_t rgid = getgid(); |
@@ -476,7 +473,7 @@ static int applet_name_compare(const void *name, const void *vapplet) | |||
476 | return strcmp(name, applet->name); | 473 | return strcmp(name, applet->name); |
477 | } | 474 | } |
478 | 475 | ||
479 | struct BB_applet *find_applet_by_name(const char *name) | 476 | const struct BB_applet *find_applet_by_name(const char *name) |
480 | { | 477 | { |
481 | /* Do a binary search to find the applet entry given the name. */ | 478 | /* Do a binary search to find the applet entry given the name. */ |
482 | return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet), | 479 | return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet), |
@@ -599,17 +596,21 @@ static int busybox_main(int argc, char **argv) | |||
599 | bb_error_msg_and_die("applet not found"); | 596 | bb_error_msg_and_die("applet not found"); |
600 | } | 597 | } |
601 | 598 | ||
599 | void run_current_applet_and_exit(int argc, char **argv) | ||
600 | { | ||
601 | applet_name = current_applet->name; | ||
602 | if (argc == 2 && !strcmp(argv[1], "--help")) | ||
603 | bb_show_usage(); | ||
604 | if (ENABLE_FEATURE_SUID) | ||
605 | check_suid(current_applet); | ||
606 | exit(current_applet->main(argc, argv)); | ||
607 | } | ||
608 | |||
602 | void run_applet_by_name(const char *name, int argc, char **argv) | 609 | void run_applet_by_name(const char *name, int argc, char **argv) |
603 | { | 610 | { |
604 | current_applet = find_applet_by_name(name); | 611 | current_applet = find_applet_by_name(name); |
605 | if (current_applet) { | 612 | if (current_applet) |
606 | applet_name = current_applet->name; | 613 | run_current_applet_and_exit(argc, argv); |
607 | if (argc == 2 && !strcmp(argv[1], "--help")) | ||
608 | bb_show_usage(); | ||
609 | if (ENABLE_FEATURE_SUID) | ||
610 | check_suid(current_applet); | ||
611 | exit(current_applet->main(argc, argv)); | ||
612 | } | ||
613 | if (!strncmp(name, "busybox", 7)) | 614 | if (!strncmp(name, "busybox", 7)) |
614 | exit(busybox_main(argc, argv)); | 615 | exit(busybox_main(argc, argv)); |
615 | } | 616 | } |
diff --git a/include/applets.h b/include/applets.h index e8d75b7d7..f411aa258 100644 --- a/include/applets.h +++ b/include/applets.h | |||
@@ -27,27 +27,32 @@ s - suid type: | |||
27 | # define APPLET(name,l,s) int name##_main(int argc, char **argv); | 27 | # define APPLET(name,l,s) int name##_main(int argc, char **argv); |
28 | # define APPLET_NOUSAGE(name,main,l,s) int main##_main(int argc, char **argv); | 28 | # define APPLET_NOUSAGE(name,main,l,s) int main##_main(int argc, char **argv); |
29 | # define APPLET_ODDNAME(name,main,l,s,name2) int main##_main(int argc, char **argv); | 29 | # define APPLET_ODDNAME(name,main,l,s,name2) int main##_main(int argc, char **argv); |
30 | # define APPLET_NOEXEC(name,main,l,s,name2) int main##_main(int argc, char **argv); | ||
30 | 31 | ||
31 | #elif defined(MAKE_USAGE) && ENABLE_FEATURE_VERBOSE_USAGE | 32 | #elif defined(MAKE_USAGE) && ENABLE_FEATURE_VERBOSE_USAGE |
32 | # define APPLET(name,l,s) name##_trivial_usage "\n\n" name##_full_usage "\0" | 33 | # define APPLET(name,l,s) name##_trivial_usage "\n\n" name##_full_usage "\0" |
33 | # define APPLET_NOUSAGE(name,main,l,s) "\b\0" | 34 | # define APPLET_NOUSAGE(name,main,l,s) "\b\0" |
34 | # define APPLET_ODDNAME(name,main,l,s,name2) name2##_trivial_usage "\n\n" name2##_full_usage "\0" | 35 | # define APPLET_ODDNAME(name,main,l,s,name2) name2##_trivial_usage "\n\n" name2##_full_usage "\0" |
36 | # define APPLET_NOEXEC(name,main,l,s,name2) name2##_trivial_usage "\n\n" name2##_full_usage "\0" | ||
35 | 37 | ||
36 | #elif defined(MAKE_USAGE) && !ENABLE_FEATURE_VERBOSE_USAGE | 38 | #elif defined(MAKE_USAGE) && !ENABLE_FEATURE_VERBOSE_USAGE |
37 | # define APPLET(name,l,s) name##_trivial_usage "\0" | 39 | # define APPLET(name,l,s) name##_trivial_usage "\0" |
38 | # define APPLET_NOUSAGE(name,main,l,s) "\b\0" | 40 | # define APPLET_NOUSAGE(name,main,l,s) "\b\0" |
39 | # define APPLET_ODDNAME(name,main,l,s,name2) name2##_trivial_usage "\0" | 41 | # define APPLET_ODDNAME(name,main,l,s,name2) name2##_trivial_usage "\0" |
42 | # define APPLET_NOEXEC(name,main,l,s,name2) name2##_trivial_usage "\0" | ||
40 | 43 | ||
41 | #elif defined(MAKE_LINKS) | 44 | #elif defined(MAKE_LINKS) |
42 | # define APPLET(name,l,c) LINK l name | 45 | # define APPLET(name,l,c) LINK l name |
43 | # define APPLET_NOUSAGE(name,main,l,s) LINK l name | 46 | # define APPLET_NOUSAGE(name,main,l,s) LINK l name |
44 | # define APPLET_ODDNAME(name,main,l,s,name2) LINK l name | 47 | # define APPLET_ODDNAME(name,main,l,s,name2) LINK l name |
48 | # define APPLET_NOEXEC(name,main,l,s,name2) LINK l name | ||
45 | 49 | ||
46 | #else | 50 | #else |
47 | const struct BB_applet applets[] = { /* name,main,location,need_suid */ | 51 | const struct BB_applet applets[] = { /* name,main,location,need_suid */ |
48 | # define APPLET(name,l,s) {#name,name##_main,l,s}, | 52 | # define APPLET(name,l,s) {#name,name##_main,l,s}, |
49 | # define APPLET_NOUSAGE(name,main,l,s) {#name,main##_main,l,s}, | 53 | # define APPLET_NOUSAGE(name,main,l,s) {#name,main##_main,l,s}, |
50 | # define APPLET_ODDNAME(name,main,l,s,name2) {#name,main##_main,l,s}, | 54 | # define APPLET_ODDNAME(name,main,l,s,name2) {#name,main##_main,l,s}, |
55 | # define APPLET_NOEXEC(name,main,l,s,name2) {#name,main##_main,l,s,1}, | ||
51 | #endif | 56 | #endif |
52 | 57 | ||
53 | #if ENABLE_INSTALL_NO_USR | 58 | #if ENABLE_INSTALL_NO_USR |
@@ -55,7 +60,8 @@ s - suid type: | |||
55 | # define _BB_DIR_USR_SBIN _BB_DIR_SBIN | 60 | # define _BB_DIR_USR_SBIN _BB_DIR_SBIN |
56 | #endif | 61 | #endif |
57 | 62 | ||
58 | USE_TEST(APPLET_NOUSAGE([, test, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 63 | |
64 | USE_TEST(APPLET_NOEXEC([, test, _BB_DIR_USR_BIN, _BB_SUID_NEVER, test)) | ||
59 | USE_TEST(APPLET_NOUSAGE([[, test, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 65 | USE_TEST(APPLET_NOUSAGE([[, test, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
60 | USE_ADDGROUP(APPLET(addgroup, _BB_DIR_BIN, _BB_SUID_NEVER)) | 66 | USE_ADDGROUP(APPLET(addgroup, _BB_DIR_BIN, _BB_SUID_NEVER)) |
61 | USE_ADDUSER(APPLET(adduser, _BB_DIR_BIN, _BB_SUID_NEVER)) | 67 | USE_ADDUSER(APPLET(adduser, _BB_DIR_BIN, _BB_SUID_NEVER)) |
@@ -64,20 +70,20 @@ USE_AR(APPLET(ar, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | |||
64 | USE_ARP(APPLET(arp, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 70 | USE_ARP(APPLET(arp, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
65 | USE_ARPING(APPLET(arping, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 71 | USE_ARPING(APPLET(arping, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
66 | USE_ASH(APPLET_NOUSAGE(ash, ash, _BB_DIR_BIN, _BB_SUID_NEVER)) | 72 | USE_ASH(APPLET_NOUSAGE(ash, ash, _BB_DIR_BIN, _BB_SUID_NEVER)) |
67 | USE_AWK(APPLET(awk, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 73 | USE_AWK(APPLET_NOEXEC(awk, awk, _BB_DIR_USR_BIN, _BB_SUID_NEVER, awk)) |
68 | USE_BASENAME(APPLET(basename, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 74 | USE_BASENAME(APPLET(basename, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
69 | USE_BBCONFIG(APPLET(bbconfig, _BB_DIR_BIN, _BB_SUID_NEVER)) | 75 | USE_BBCONFIG(APPLET(bbconfig, _BB_DIR_BIN, _BB_SUID_NEVER)) |
70 | //USE_BBSH(APPLET(bbsh, _BB_DIR_BIN, _BB_SUID_NEVER)) | 76 | //USE_BBSH(APPLET(bbsh, _BB_DIR_BIN, _BB_SUID_NEVER)) |
71 | USE_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 77 | USE_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
72 | USE_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, _BB_DIR_USR_BIN, _BB_SUID_NEVER, bzcat)) | 78 | USE_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, _BB_DIR_USR_BIN, _BB_SUID_NEVER, bzcat)) |
73 | USE_CAL(APPLET(cal, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 79 | USE_CAL(APPLET(cal, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
74 | USE_CAT(APPLET(cat, _BB_DIR_BIN, _BB_SUID_NEVER)) | 80 | USE_CAT(APPLET_NOEXEC(cat, cat, _BB_DIR_BIN, _BB_SUID_NEVER, cat)) |
75 | USE_CATV(APPLET(catv, _BB_DIR_BIN, _BB_SUID_NEVER)) | 81 | USE_CATV(APPLET(catv, _BB_DIR_BIN, _BB_SUID_NEVER)) |
76 | USE_CHATTR(APPLET(chattr, _BB_DIR_BIN, _BB_SUID_NEVER)) | 82 | USE_CHATTR(APPLET(chattr, _BB_DIR_BIN, _BB_SUID_NEVER)) |
77 | USE_CHCON(APPLET(chcon, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 83 | USE_CHCON(APPLET(chcon, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
78 | USE_CHGRP(APPLET(chgrp, _BB_DIR_BIN, _BB_SUID_NEVER)) | 84 | USE_CHGRP(APPLET(chgrp, _BB_DIR_BIN, _BB_SUID_NEVER)) |
79 | USE_CHMOD(APPLET(chmod, _BB_DIR_BIN, _BB_SUID_NEVER)) | 85 | USE_CHMOD(APPLET_NOEXEC(chmod, chmod, _BB_DIR_BIN, _BB_SUID_NEVER, chmod)) |
80 | USE_CHOWN(APPLET(chown, _BB_DIR_BIN, _BB_SUID_NEVER)) | 86 | USE_CHOWN(APPLET_NOEXEC(chown, chown, _BB_DIR_BIN, _BB_SUID_NEVER, chown)) |
81 | USE_CHPST(APPLET(chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 87 | USE_CHPST(APPLET(chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
82 | USE_CHROOT(APPLET(chroot, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) | 88 | USE_CHROOT(APPLET(chroot, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) |
83 | USE_CHRT(APPLET(chrt, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 89 | USE_CHRT(APPLET(chrt, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
@@ -86,14 +92,14 @@ USE_CKSUM(APPLET(cksum, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | |||
86 | USE_CLEAR(APPLET(clear, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 92 | USE_CLEAR(APPLET(clear, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
87 | USE_CMP(APPLET(cmp, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 93 | USE_CMP(APPLET(cmp, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
88 | USE_COMM(APPLET(comm, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 94 | USE_COMM(APPLET(comm, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
89 | USE_CP(APPLET(cp, _BB_DIR_BIN, _BB_SUID_NEVER)) | 95 | USE_CP(APPLET_NOEXEC(cp, cp, _BB_DIR_BIN, _BB_SUID_NEVER, cp)) |
90 | USE_CPIO(APPLET(cpio, _BB_DIR_BIN, _BB_SUID_NEVER)) | 96 | USE_CPIO(APPLET(cpio, _BB_DIR_BIN, _BB_SUID_NEVER)) |
91 | USE_CROND(APPLET(crond, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) | 97 | USE_CROND(APPLET(crond, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) |
92 | USE_CRONTAB(APPLET(crontab, _BB_DIR_USR_BIN, _BB_SUID_ALWAYS)) | 98 | USE_CRONTAB(APPLET(crontab, _BB_DIR_USR_BIN, _BB_SUID_ALWAYS)) |
93 | USE_CUT(APPLET(cut, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 99 | USE_CUT(APPLET_NOEXEC(cut, cut, _BB_DIR_USR_BIN, _BB_SUID_NEVER, cut)) |
94 | USE_DATE(APPLET(date, _BB_DIR_BIN, _BB_SUID_NEVER)) | 100 | USE_DATE(APPLET(date, _BB_DIR_BIN, _BB_SUID_NEVER)) |
95 | USE_DC(APPLET(dc, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 101 | USE_DC(APPLET(dc, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
96 | USE_DD(APPLET(dd, _BB_DIR_BIN, _BB_SUID_NEVER)) | 102 | USE_DD(APPLET_NOEXEC(dd, dd, _BB_DIR_BIN, _BB_SUID_NEVER, dd)) |
97 | USE_DEALLOCVT(APPLET(deallocvt, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 103 | USE_DEALLOCVT(APPLET(deallocvt, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
98 | USE_DELGROUP(APPLET_ODDNAME(delgroup, deluser, _BB_DIR_BIN, _BB_SUID_NEVER, delgroup)) | 104 | USE_DELGROUP(APPLET_ODDNAME(delgroup, deluser, _BB_DIR_BIN, _BB_SUID_NEVER, delgroup)) |
99 | USE_DELUSER(APPLET(deluser, _BB_DIR_BIN, _BB_SUID_NEVER)) | 105 | USE_DELUSER(APPLET(deluser, _BB_DIR_BIN, _BB_SUID_NEVER)) |
@@ -112,7 +118,7 @@ USE_DUMPKMAP(APPLET(dumpkmap, _BB_DIR_BIN, _BB_SUID_NEVER)) | |||
112 | USE_APP_DUMPLEASES(APPLET(dumpleases, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 118 | USE_APP_DUMPLEASES(APPLET(dumpleases, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
113 | //USE_E2FSCK(APPLET(e2fsck, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 119 | //USE_E2FSCK(APPLET(e2fsck, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
114 | //USE_E2LABEL(APPLET_NOUSAGE(e2label, tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 120 | //USE_E2LABEL(APPLET_NOUSAGE(e2label, tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
115 | USE_ECHO(APPLET(echo, _BB_DIR_BIN, _BB_SUID_NEVER)) | 121 | USE_ECHO(APPLET_NOEXEC(echo, echo, _BB_DIR_BIN, _BB_SUID_NEVER, echo)) |
116 | USE_ED(APPLET(ed, _BB_DIR_BIN, _BB_SUID_NEVER)) | 122 | USE_ED(APPLET(ed, _BB_DIR_BIN, _BB_SUID_NEVER)) |
117 | USE_FEATURE_GREP_EGREP_ALIAS(APPLET_NOUSAGE(egrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER)) | 123 | USE_FEATURE_GREP_EGREP_ALIAS(APPLET_NOUSAGE(egrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER)) |
118 | USE_EJECT(APPLET(eject, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 124 | USE_EJECT(APPLET(eject, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
@@ -128,7 +134,7 @@ USE_FDFLUSH(APPLET_ODDNAME(fdflush, freeramdisk, _BB_DIR_BIN, _BB_SUID_NEVER, fd | |||
128 | USE_FDFORMAT(APPLET(fdformat, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 134 | USE_FDFORMAT(APPLET(fdformat, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
129 | USE_FDISK(APPLET(fdisk, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 135 | USE_FDISK(APPLET(fdisk, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
130 | USE_FEATURE_GREP_FGREP_ALIAS(APPLET_NOUSAGE(fgrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER)) | 136 | USE_FEATURE_GREP_FGREP_ALIAS(APPLET_NOUSAGE(fgrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER)) |
131 | USE_FIND(APPLET(find, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 137 | USE_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_NEVER, find)) |
132 | //USE_FINDFS(APPLET_NOUSAGE(findfs, tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 138 | //USE_FINDFS(APPLET_NOUSAGE(findfs, tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
133 | USE_FOLD(APPLET(fold, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 139 | USE_FOLD(APPLET(fold, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
134 | USE_FREE(APPLET(free, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 140 | USE_FREE(APPLET(free, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
@@ -150,7 +156,7 @@ USE_GZIP(APPLET(gzip, _BB_DIR_BIN, _BB_SUID_NEVER)) | |||
150 | USE_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 156 | USE_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
151 | USE_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 157 | USE_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
152 | USE_HEAD(APPLET(head, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 158 | USE_HEAD(APPLET(head, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
153 | USE_HEXDUMP(APPLET(hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 159 | USE_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hexdump)) |
154 | USE_HOSTID(APPLET(hostid, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 160 | USE_HOSTID(APPLET(hostid, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
155 | USE_HOSTNAME(APPLET(hostname, _BB_DIR_BIN, _BB_SUID_NEVER)) | 161 | USE_HOSTNAME(APPLET(hostname, _BB_DIR_BIN, _BB_SUID_NEVER)) |
156 | USE_HTTPD(APPLET(httpd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) | 162 | USE_HTTPD(APPLET(httpd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) |
@@ -184,7 +190,7 @@ USE_LESS(APPLET(less, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | |||
184 | USE_SETARCH(APPLET_NOUSAGE(linux32, setarch, _BB_DIR_BIN, _BB_SUID_NEVER)) | 190 | USE_SETARCH(APPLET_NOUSAGE(linux32, setarch, _BB_DIR_BIN, _BB_SUID_NEVER)) |
185 | USE_SETARCH(APPLET_NOUSAGE(linux64, setarch, _BB_DIR_BIN, _BB_SUID_NEVER)) | 191 | USE_SETARCH(APPLET_NOUSAGE(linux64, setarch, _BB_DIR_BIN, _BB_SUID_NEVER)) |
186 | USE_FEATURE_INITRD(APPLET_NOUSAGE(linuxrc, init, _BB_DIR_ROOT, _BB_SUID_NEVER)) | 192 | USE_FEATURE_INITRD(APPLET_NOUSAGE(linuxrc, init, _BB_DIR_ROOT, _BB_SUID_NEVER)) |
187 | USE_LN(APPLET(ln, _BB_DIR_BIN, _BB_SUID_NEVER)) | 193 | USE_LN(APPLET_NOEXEC(ln, ln, _BB_DIR_BIN, _BB_SUID_NEVER, ln)) |
188 | USE_LOAD_POLICY(APPLET(load_policy, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) | 194 | USE_LOAD_POLICY(APPLET(load_policy, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) |
189 | USE_LOADFONT(APPLET(loadfont, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 195 | USE_LOADFONT(APPLET(loadfont, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
190 | USE_LOADKMAP(APPLET(loadkmap, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 196 | USE_LOADKMAP(APPLET(loadkmap, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
@@ -193,7 +199,7 @@ USE_LOGIN(APPLET(login, _BB_DIR_BIN, _BB_SUID_ALWAYS)) | |||
193 | USE_LOGNAME(APPLET(logname, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 199 | USE_LOGNAME(APPLET(logname, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
194 | USE_LOGREAD(APPLET(logread, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 200 | USE_LOGREAD(APPLET(logread, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
195 | USE_LOSETUP(APPLET(losetup, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 201 | USE_LOSETUP(APPLET(losetup, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
196 | USE_LS(APPLET(ls, _BB_DIR_BIN, _BB_SUID_NEVER)) | 202 | USE_LS(APPLET_NOEXEC(ls, ls, _BB_DIR_BIN, _BB_SUID_NEVER, ls)) |
197 | USE_LSATTR(APPLET(lsattr, _BB_DIR_BIN, _BB_SUID_NEVER)) | 203 | USE_LSATTR(APPLET(lsattr, _BB_DIR_BIN, _BB_SUID_NEVER)) |
198 | USE_LSMOD(APPLET(lsmod, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 204 | USE_LSMOD(APPLET(lsmod, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
199 | USE_UNLZMA(APPLET_ODDNAME(lzmacat, unlzma, _BB_DIR_USR_BIN, _BB_SUID_NEVER, lzmacat)) | 205 | USE_UNLZMA(APPLET_ODDNAME(lzmacat, unlzma, _BB_DIR_USR_BIN, _BB_SUID_NEVER, lzmacat)) |
@@ -202,7 +208,7 @@ USE_MAKEDEVS(APPLET(makedevs, _BB_DIR_SBIN, _BB_SUID_NEVER)) | |||
202 | USE_MD5SUM(APPLET_ODDNAME(md5sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, md5sum)) | 208 | USE_MD5SUM(APPLET_ODDNAME(md5sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, md5sum)) |
203 | USE_MDEV(APPLET(mdev, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 209 | USE_MDEV(APPLET(mdev, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
204 | USE_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 210 | USE_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
205 | USE_MKDIR(APPLET(mkdir, _BB_DIR_BIN, _BB_SUID_NEVER)) | 211 | USE_MKDIR(APPLET_NOEXEC(mkdir, mkdir, _BB_DIR_BIN, _BB_SUID_NEVER, mkdir)) |
206 | //USE_MKE2FS(APPLET(mke2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 212 | //USE_MKE2FS(APPLET(mke2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
207 | USE_MKFIFO(APPLET(mkfifo, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 213 | USE_MKFIFO(APPLET(mkfifo, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
208 | //USE_MKE2FS(APPLET_NOUSAGE(mkfs.ext2, mke2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 214 | //USE_MKE2FS(APPLET_NOUSAGE(mkfs.ext2, mke2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
@@ -249,7 +255,7 @@ USE_HALT(APPLET_ODDNAME(reboot, halt, _BB_DIR_SBIN, _BB_SUID_NEVER, reboot)) | |||
249 | USE_RENICE(APPLET(renice, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 255 | USE_RENICE(APPLET(renice, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
250 | USE_RESET(APPLET(reset, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 256 | USE_RESET(APPLET(reset, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
251 | USE_RESIZE(APPLET(resize, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 257 | USE_RESIZE(APPLET(resize, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
252 | USE_RM(APPLET(rm, _BB_DIR_BIN, _BB_SUID_NEVER)) | 258 | USE_RM(APPLET_NOEXEC(rm, rm, _BB_DIR_BIN, _BB_SUID_NEVER, rm)) |
253 | USE_RMDIR(APPLET(rmdir, _BB_DIR_BIN, _BB_SUID_NEVER)) | 259 | USE_RMDIR(APPLET(rmdir, _BB_DIR_BIN, _BB_SUID_NEVER)) |
254 | USE_RMMOD(APPLET(rmmod, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 260 | USE_RMMOD(APPLET(rmmod, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
255 | USE_ROUTE(APPLET(route, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 261 | USE_ROUTE(APPLET(route, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
@@ -278,7 +284,7 @@ USE_FEATURE_SH_IS_MSH(APPLET_NOUSAGE(sh, msh, _BB_DIR_BIN, _BB_SUID_NEVER)) | |||
278 | USE_SHA1SUM(APPLET_ODDNAME(sha1sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, sha1sum)) | 284 | USE_SHA1SUM(APPLET_ODDNAME(sha1sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, sha1sum)) |
279 | USE_SLEEP(APPLET(sleep, _BB_DIR_BIN, _BB_SUID_NEVER)) | 285 | USE_SLEEP(APPLET(sleep, _BB_DIR_BIN, _BB_SUID_NEVER)) |
280 | USE_SOFTLIMIT(APPLET_ODDNAME(softlimit, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, softlimit)) | 286 | USE_SOFTLIMIT(APPLET_ODDNAME(softlimit, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, softlimit)) |
281 | USE_SORT(APPLET(sort, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 287 | USE_SORT(APPLET_NOEXEC(sort, sort, _BB_DIR_USR_BIN, _BB_SUID_NEVER, sort)) |
282 | USE_SPLIT(APPLET(split, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 288 | USE_SPLIT(APPLET(split, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
283 | USE_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, _BB_DIR_SBIN, _BB_SUID_NEVER, start_stop_daemon)) | 289 | USE_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, _BB_DIR_SBIN, _BB_SUID_NEVER, start_stop_daemon)) |
284 | USE_STAT(APPLET(stat, _BB_DIR_BIN, _BB_SUID_NEVER)) | 290 | USE_STAT(APPLET(stat, _BB_DIR_BIN, _BB_SUID_NEVER)) |
@@ -302,13 +308,13 @@ USE_TCPSVD(APPLET_ODDNAME(tcpsvd, tcpudpsvd, _BB_DIR_USR_BIN, _BB_SUID_NEVER, tc | |||
302 | USE_TEE(APPLET(tee, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 308 | USE_TEE(APPLET(tee, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
303 | USE_TELNET(APPLET(telnet, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 309 | USE_TELNET(APPLET(telnet, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
304 | USE_TELNETD(APPLET(telnetd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) | 310 | USE_TELNETD(APPLET(telnetd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) |
305 | USE_TEST(APPLET(test, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 311 | USE_TEST(APPLET_NOEXEC(test, test, _BB_DIR_USR_BIN, _BB_SUID_NEVER, test)) |
306 | #if ENABLE_FEATURE_TFTP_GET || ENABLE_FEATURE_TFTP_PUT | 312 | #if ENABLE_FEATURE_TFTP_GET || ENABLE_FEATURE_TFTP_PUT |
307 | USE_TFTP(APPLET(tftp, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 313 | USE_TFTP(APPLET(tftp, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
308 | #endif | 314 | #endif |
309 | USE_TIME(APPLET(time, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 315 | USE_TIME(APPLET(time, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
310 | USE_TOP(APPLET(top, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 316 | USE_TOP(APPLET(top, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
311 | USE_TOUCH(APPLET(touch, _BB_DIR_BIN, _BB_SUID_NEVER)) | 317 | USE_TOUCH(APPLET_NOEXEC(touch, touch, _BB_DIR_BIN, _BB_SUID_NEVER, touch)) |
312 | USE_TR(APPLET(tr, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 318 | USE_TR(APPLET(tr, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
313 | USE_TRACEROUTE(APPLET(traceroute, _BB_DIR_USR_BIN, _BB_SUID_MAYBE)) | 319 | USE_TRACEROUTE(APPLET(traceroute, _BB_DIR_USR_BIN, _BB_SUID_MAYBE)) |
314 | USE_TRUE(APPLET(true, _BB_DIR_BIN, _BB_SUID_NEVER)) | 320 | USE_TRUE(APPLET(true, _BB_DIR_BIN, _BB_SUID_NEVER)) |
@@ -338,17 +344,17 @@ USE_WGET(APPLET(wget, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | |||
338 | USE_WHICH(APPLET(which, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 344 | USE_WHICH(APPLET(which, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
339 | USE_WHO(APPLET(who, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 345 | USE_WHO(APPLET(who, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
340 | USE_WHOAMI(APPLET(whoami, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 346 | USE_WHOAMI(APPLET(whoami, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
341 | USE_XARGS(APPLET(xargs, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 347 | USE_XARGS(APPLET_NOEXEC(xargs, xargs, _BB_DIR_USR_BIN, _BB_SUID_NEVER, xargs)) |
342 | USE_YES(APPLET(yes, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 348 | USE_YES(APPLET(yes, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
343 | USE_GUNZIP(APPLET_ODDNAME(zcat, gunzip, _BB_DIR_BIN, _BB_SUID_NEVER, zcat)) | 349 | USE_GUNZIP(APPLET_ODDNAME(zcat, gunzip, _BB_DIR_BIN, _BB_SUID_NEVER, zcat)) |
344 | USE_ZCIP(APPLET(zcip, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 350 | USE_ZCIP(APPLET(zcip, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
345 | 351 | ||
346 | #if !defined(PROTOTYPES) && !defined(MAKE_USAGE) | 352 | #if !defined(PROTOTYPES) && !defined(MAKE_USAGE) |
347 | { 0,NULL,0,0 } | 353 | { 0, NULL, 0, 0 } |
348 | }; | 354 | }; |
349 | |||
350 | #endif | 355 | #endif |
351 | 356 | ||
352 | #undef APPLET | 357 | #undef APPLET |
353 | #undef APPLET_NOUSAGE | 358 | #undef APPLET_NOUSAGE |
354 | #undef APPLET_ODDNAME | 359 | #undef APPLET_ODDNAME |
360 | #undef APPLET_NOEXEC | ||
diff --git a/include/busybox.h b/include/busybox.h index 988137497..6f4808778 100644 --- a/include/busybox.h +++ b/include/busybox.h | |||
@@ -27,8 +27,15 @@ enum SUIDRoot { | |||
27 | struct BB_applet { | 27 | struct BB_applet { |
28 | const char *name; | 28 | const char *name; |
29 | int (*main) (int argc, char **argv); | 29 | int (*main) (int argc, char **argv); |
30 | __extension__ enum Location location:4; | 30 | __extension__ enum Location location:8; |
31 | __extension__ enum SUIDRoot need_suid:4; | 31 | __extension__ enum SUIDRoot need_suid:8; |
32 | /* true if instead if fork(); exec("applet"); waitpid(); | ||
33 | * one can do fork(); exit(applet_main(argc,argv)); waitpid(); */ | ||
34 | unsigned char noexec; | ||
35 | /* Even nicer */ | ||
36 | /* true if instead if fork(); exec("applet"); waitpid(); | ||
37 | * one can simply call applet_main(argc,argv); */ | ||
38 | unsigned char nofork; | ||
32 | }; | 39 | }; |
33 | 40 | ||
34 | /* Defined in applet.c */ | 41 | /* Defined in applet.c */ |
diff --git a/include/libbb.h b/include/libbb.h index 8f43aeafc..4fc5d183f 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -662,9 +662,11 @@ const struct hwtype *get_hwntype(int type); | |||
662 | 662 | ||
663 | 663 | ||
664 | #ifndef BUILD_INDIVIDUAL | 664 | #ifndef BUILD_INDIVIDUAL |
665 | extern struct BB_applet *find_applet_by_name(const char *name); | 665 | struct BB_applet; |
666 | extern const struct BB_applet *find_applet_by_name(const char *name); | ||
666 | /* Returns only if applet is not found. */ | 667 | /* Returns only if applet is not found. */ |
667 | extern void run_applet_by_name(const char *name, int argc, char **argv); | 668 | extern void run_applet_by_name(const char *name, int argc, char **argv); |
669 | extern void run_current_applet_and_exit(int argc, char **argv) ATTRIBUTE_NORETURN; | ||
668 | #endif | 670 | #endif |
669 | 671 | ||
670 | extern int match_fstype(const struct mntent *mt, const char *fstypes); | 672 | extern int match_fstype(const struct mntent *mt, const char *fstypes); |
@@ -870,6 +872,7 @@ enum { /* DO NOT CHANGE THESE VALUES! cp.c, mv.c, install.c depend on them. */ | |||
870 | }; | 872 | }; |
871 | 873 | ||
872 | #define FILEUTILS_CP_OPTSTR "pdRfils" USE_SELINUX("c") | 874 | #define FILEUTILS_CP_OPTSTR "pdRfils" USE_SELINUX("c") |
875 | extern const struct BB_applet *current_applet; | ||
873 | extern const char *applet_name; | 876 | extern const char *applet_name; |
874 | extern const char BB_BANNER[]; | 877 | extern const char BB_BANNER[]; |
875 | 878 | ||
diff --git a/shell/ash.c b/shell/ash.c index 950cdaa02..f98fc4178 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -6468,43 +6468,6 @@ casematch(union node *pattern, char *val) | |||
6468 | 6468 | ||
6469 | /* ============ find_command */ | 6469 | /* ============ find_command */ |
6470 | 6470 | ||
6471 | #if ENABLE_FEATURE_SH_STANDALONE_SHELL | ||
6472 | static int | ||
6473 | is_safe_applet(char *name) | ||
6474 | { | ||
6475 | /* It isn't a bug to have non-existent applet here... */ | ||
6476 | /* ...just a waste of space... */ | ||
6477 | static const char safe_applets[][8] = { | ||
6478 | "[" | ||
6479 | USE_AWK (, "awk" ) | ||
6480 | USE_CAT (, "cat" ) | ||
6481 | USE_CHMOD (, "chmod" ) | ||
6482 | USE_CHOWN (, "chown" ) | ||
6483 | USE_CP (, "cp" ) | ||
6484 | USE_CUT (, "cut" ) | ||
6485 | USE_DD (, "dd" ) | ||
6486 | USE_ECHO (, "echo" ) | ||
6487 | USE_FIND (, "find" ) | ||
6488 | USE_HEXDUMP(, "hexdump") | ||
6489 | USE_LN (, "ln" ) | ||
6490 | USE_LS (, "ls" ) | ||
6491 | USE_MKDIR (, "mkdir" ) | ||
6492 | USE_RM (, "rm" ) | ||
6493 | USE_SORT (, "sort" ) | ||
6494 | USE_TEST (, "test" ) | ||
6495 | USE_TOUCH (, "touch" ) | ||
6496 | USE_XARGS (, "xargs" ) | ||
6497 | }; | ||
6498 | int n = sizeof(safe_applets) / sizeof(safe_applets[0]); | ||
6499 | int i; | ||
6500 | for (i = 0; i < n; i++) | ||
6501 | if (strcmp(safe_applets[i], name) == 0) | ||
6502 | return 1; | ||
6503 | |||
6504 | return 0; | ||
6505 | } | ||
6506 | #endif | ||
6507 | |||
6508 | struct builtincmd { | 6471 | struct builtincmd { |
6509 | const char *name; | 6472 | const char *name; |
6510 | int (*builtin)(int, char **); | 6473 | int (*builtin)(int, char **); |
@@ -6570,17 +6533,15 @@ tryexec(char *cmd, char **argv, char **envp) | |||
6570 | 6533 | ||
6571 | #if ENABLE_FEATURE_SH_STANDALONE_SHELL | 6534 | #if ENABLE_FEATURE_SH_STANDALONE_SHELL |
6572 | if (strchr(cmd, '/') == NULL) { | 6535 | if (strchr(cmd, '/') == NULL) { |
6573 | struct BB_applet *a; | 6536 | const struct BB_applet *a; |
6574 | char **c; | ||
6575 | 6537 | ||
6576 | a = find_applet_by_name(cmd); | 6538 | a = find_applet_by_name(cmd); |
6577 | if (a) { | 6539 | if (a) { |
6578 | if (is_safe_applet(cmd)) { | 6540 | if (a->noexec) { |
6579 | c = argv; | 6541 | char **c = argv; |
6580 | while (*c) | 6542 | while (*c) c++; |
6581 | c++; | 6543 | current_applet = a; |
6582 | applet_name = cmd; | 6544 | run_current_applet_and_exit(c - argv, argv); |
6583 | exit(a->main(c - argv, argv)); | ||
6584 | } | 6545 | } |
6585 | /* re-exec ourselves with the new arguments */ | 6546 | /* re-exec ourselves with the new arguments */ |
6586 | execve(CONFIG_BUSYBOX_EXEC_PATH, argv, envp); | 6547 | execve(CONFIG_BUSYBOX_EXEC_PATH, argv, envp); |
@@ -6608,7 +6569,7 @@ tryexec(char *cmd, char **argv, char **envp) | |||
6608 | ; | 6569 | ; |
6609 | ap = new = ckmalloc((ap - argv + 2) * sizeof(char *)); | 6570 | ap = new = ckmalloc((ap - argv + 2) * sizeof(char *)); |
6610 | ap[1] = cmd; | 6571 | ap[1] = cmd; |
6611 | *ap = cmd = (char *)DEFAULT_SHELL; | 6572 | ap[0] = cmd = (char *)DEFAULT_SHELL; |
6612 | ap += 2; | 6573 | ap += 2; |
6613 | argv++; | 6574 | argv++; |
6614 | while ((*ap++ = *argv++)) | 6575 | while ((*ap++ = *argv++)) |
@@ -11161,12 +11122,6 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) | |||
11161 | entry->u.index = -1; | 11122 | entry->u.index = -1; |
11162 | return; | 11123 | return; |
11163 | } | 11124 | } |
11164 | /* Already caught above | ||
11165 | if (is_safe_applet(name)) { | ||
11166 | entry->cmdtype = CMDNORMAL; | ||
11167 | entry->u.index = -1; | ||
11168 | return; | ||
11169 | }*/ | ||
11170 | #endif | 11125 | #endif |
11171 | 11126 | ||
11172 | updatetbl = (path == pathval()); | 11127 | updatetbl = (path == pathval()); |