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 /include | |
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.
Diffstat (limited to 'include')
-rw-r--r-- | include/applets.h | 48 | ||||
-rw-r--r-- | include/busybox.h | 11 | ||||
-rw-r--r-- | include/libbb.h | 5 |
3 files changed, 40 insertions, 24 deletions
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 | ||