summaryrefslogtreecommitdiff
path: root/include/applets.h
diff options
context:
space:
mode:
authorDenis Vlasenko2007-04-09 03:11:58 +0000
committerDenis Vlasenko2007-04-09 03:11:58 +0000
commitc44ab01b75aba758fe0aff4b34b25d733e370dc2 (patch)
tree7aaff270868ae6e6ff78fb5c42d42f5645a6a67a /include/applets.h
parent95cb3263ae8f9afda0f6af3f777739506a0dfc62 (diff)
downloadbusybox-c44ab01b75aba758fe0aff4b34b25d733e370dc2.zip
busybox-c44ab01b75aba758fe0aff4b34b25d733e370dc2.tar.gz
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/applets.h')
-rw-r--r--include/applets.h48
1 files changed, 27 insertions, 21 deletions
diff --git a/include/applets.h b/include/applets.h
index e8d75b7..f411aa2 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -27,27 +27,32 @@ s - suid type:
# define APPLET(name,l,s) int name##_main(int argc, char **argv);
# define APPLET_NOUSAGE(name,main,l,s) int main##_main(int argc, char **argv);
# define APPLET_ODDNAME(name,main,l,s,name2) int main##_main(int argc, char **argv);
+# define APPLET_NOEXEC(name,main,l,s,name2) int main##_main(int argc, char **argv);
#elif defined(MAKE_USAGE) && ENABLE_FEATURE_VERBOSE_USAGE
# define APPLET(name,l,s) name##_trivial_usage "\n\n" name##_full_usage "\0"
# define APPLET_NOUSAGE(name,main,l,s) "\b\0"
# define APPLET_ODDNAME(name,main,l,s,name2) name2##_trivial_usage "\n\n" name2##_full_usage "\0"
+# define APPLET_NOEXEC(name,main,l,s,name2) name2##_trivial_usage "\n\n" name2##_full_usage "\0"
#elif defined(MAKE_USAGE) && !ENABLE_FEATURE_VERBOSE_USAGE
# define APPLET(name,l,s) name##_trivial_usage "\0"
# define APPLET_NOUSAGE(name,main,l,s) "\b\0"
# define APPLET_ODDNAME(name,main,l,s,name2) name2##_trivial_usage "\0"
+# define APPLET_NOEXEC(name,main,l,s,name2) name2##_trivial_usage "\0"
#elif defined(MAKE_LINKS)
# define APPLET(name,l,c) LINK l name
# define APPLET_NOUSAGE(name,main,l,s) LINK l name
# define APPLET_ODDNAME(name,main,l,s,name2) LINK l name
+# define APPLET_NOEXEC(name,main,l,s,name2) LINK l name
#else
const struct BB_applet applets[] = { /* name,main,location,need_suid */
# define APPLET(name,l,s) {#name,name##_main,l,s},
# define APPLET_NOUSAGE(name,main,l,s) {#name,main##_main,l,s},
# define APPLET_ODDNAME(name,main,l,s,name2) {#name,main##_main,l,s},
+# define APPLET_NOEXEC(name,main,l,s,name2) {#name,main##_main,l,s,1},
#endif
#if ENABLE_INSTALL_NO_USR
@@ -55,7 +60,8 @@ s - suid type:
# define _BB_DIR_USR_SBIN _BB_DIR_SBIN
#endif
-USE_TEST(APPLET_NOUSAGE([, test, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
+
+USE_TEST(APPLET_NOEXEC([, test, _BB_DIR_USR_BIN, _BB_SUID_NEVER, test))
USE_TEST(APPLET_NOUSAGE([[, test, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_ADDGROUP(APPLET(addgroup, _BB_DIR_BIN, _BB_SUID_NEVER))
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))
USE_ARP(APPLET(arp, _BB_DIR_SBIN, _BB_SUID_NEVER))
USE_ARPING(APPLET(arping, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_ASH(APPLET_NOUSAGE(ash, ash, _BB_DIR_BIN, _BB_SUID_NEVER))
-USE_AWK(APPLET(awk, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
+USE_AWK(APPLET_NOEXEC(awk, awk, _BB_DIR_USR_BIN, _BB_SUID_NEVER, awk))
USE_BASENAME(APPLET(basename, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_BBCONFIG(APPLET(bbconfig, _BB_DIR_BIN, _BB_SUID_NEVER))
//USE_BBSH(APPLET(bbsh, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, _BB_DIR_USR_BIN, _BB_SUID_NEVER, bzcat))
USE_CAL(APPLET(cal, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
-USE_CAT(APPLET(cat, _BB_DIR_BIN, _BB_SUID_NEVER))
+USE_CAT(APPLET_NOEXEC(cat, cat, _BB_DIR_BIN, _BB_SUID_NEVER, cat))
USE_CATV(APPLET(catv, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_CHATTR(APPLET(chattr, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_CHCON(APPLET(chcon, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_CHGRP(APPLET(chgrp, _BB_DIR_BIN, _BB_SUID_NEVER))
-USE_CHMOD(APPLET(chmod, _BB_DIR_BIN, _BB_SUID_NEVER))
-USE_CHOWN(APPLET(chown, _BB_DIR_BIN, _BB_SUID_NEVER))
+USE_CHMOD(APPLET_NOEXEC(chmod, chmod, _BB_DIR_BIN, _BB_SUID_NEVER, chmod))
+USE_CHOWN(APPLET_NOEXEC(chown, chown, _BB_DIR_BIN, _BB_SUID_NEVER, chown))
USE_CHPST(APPLET(chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_CHROOT(APPLET(chroot, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
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))
USE_CLEAR(APPLET(clear, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_CMP(APPLET(cmp, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_COMM(APPLET(comm, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
-USE_CP(APPLET(cp, _BB_DIR_BIN, _BB_SUID_NEVER))
+USE_CP(APPLET_NOEXEC(cp, cp, _BB_DIR_BIN, _BB_SUID_NEVER, cp))
USE_CPIO(APPLET(cpio, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_CROND(APPLET(crond, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
USE_CRONTAB(APPLET(crontab, _BB_DIR_USR_BIN, _BB_SUID_ALWAYS))
-USE_CUT(APPLET(cut, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
+USE_CUT(APPLET_NOEXEC(cut, cut, _BB_DIR_USR_BIN, _BB_SUID_NEVER, cut))
USE_DATE(APPLET(date, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_DC(APPLET(dc, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
-USE_DD(APPLET(dd, _BB_DIR_BIN, _BB_SUID_NEVER))
+USE_DD(APPLET_NOEXEC(dd, dd, _BB_DIR_BIN, _BB_SUID_NEVER, dd))
USE_DEALLOCVT(APPLET(deallocvt, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_DELGROUP(APPLET_ODDNAME(delgroup, deluser, _BB_DIR_BIN, _BB_SUID_NEVER, delgroup))
USE_DELUSER(APPLET(deluser, _BB_DIR_BIN, _BB_SUID_NEVER))
@@ -112,7 +118,7 @@ USE_DUMPKMAP(APPLET(dumpkmap, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_APP_DUMPLEASES(APPLET(dumpleases, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
//USE_E2FSCK(APPLET(e2fsck, _BB_DIR_SBIN, _BB_SUID_NEVER))
//USE_E2LABEL(APPLET_NOUSAGE(e2label, tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER))
-USE_ECHO(APPLET(echo, _BB_DIR_BIN, _BB_SUID_NEVER))
+USE_ECHO(APPLET_NOEXEC(echo, echo, _BB_DIR_BIN, _BB_SUID_NEVER, echo))
USE_ED(APPLET(ed, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_FEATURE_GREP_EGREP_ALIAS(APPLET_NOUSAGE(egrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER))
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
USE_FDFORMAT(APPLET(fdformat, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_FDISK(APPLET(fdisk, _BB_DIR_SBIN, _BB_SUID_NEVER))
USE_FEATURE_GREP_FGREP_ALIAS(APPLET_NOUSAGE(fgrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER))
-USE_FIND(APPLET(find, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
+USE_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_NEVER, find))
//USE_FINDFS(APPLET_NOUSAGE(findfs, tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER))
USE_FOLD(APPLET(fold, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
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))
USE_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_NEVER))
USE_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_NEVER))
USE_HEAD(APPLET(head, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
-USE_HEXDUMP(APPLET(hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
+USE_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hexdump))
USE_HOSTID(APPLET(hostid, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_HOSTNAME(APPLET(hostname, _BB_DIR_BIN, _BB_SUID_NEVER))
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))
USE_SETARCH(APPLET_NOUSAGE(linux32, setarch, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_SETARCH(APPLET_NOUSAGE(linux64, setarch, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_FEATURE_INITRD(APPLET_NOUSAGE(linuxrc, init, _BB_DIR_ROOT, _BB_SUID_NEVER))
-USE_LN(APPLET(ln, _BB_DIR_BIN, _BB_SUID_NEVER))
+USE_LN(APPLET_NOEXEC(ln, ln, _BB_DIR_BIN, _BB_SUID_NEVER, ln))
USE_LOAD_POLICY(APPLET(load_policy, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
USE_LOADFONT(APPLET(loadfont, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_LOADKMAP(APPLET(loadkmap, _BB_DIR_SBIN, _BB_SUID_NEVER))
@@ -193,7 +199,7 @@ USE_LOGIN(APPLET(login, _BB_DIR_BIN, _BB_SUID_ALWAYS))
USE_LOGNAME(APPLET(logname, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_LOGREAD(APPLET(logread, _BB_DIR_SBIN, _BB_SUID_NEVER))
USE_LOSETUP(APPLET(losetup, _BB_DIR_SBIN, _BB_SUID_NEVER))
-USE_LS(APPLET(ls, _BB_DIR_BIN, _BB_SUID_NEVER))
+USE_LS(APPLET_NOEXEC(ls, ls, _BB_DIR_BIN, _BB_SUID_NEVER, ls))
USE_LSATTR(APPLET(lsattr, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_LSMOD(APPLET(lsmod, _BB_DIR_SBIN, _BB_SUID_NEVER))
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))
USE_MD5SUM(APPLET_ODDNAME(md5sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, md5sum))
USE_MDEV(APPLET(mdev, _BB_DIR_SBIN, _BB_SUID_NEVER))
USE_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
-USE_MKDIR(APPLET(mkdir, _BB_DIR_BIN, _BB_SUID_NEVER))
+USE_MKDIR(APPLET_NOEXEC(mkdir, mkdir, _BB_DIR_BIN, _BB_SUID_NEVER, mkdir))
//USE_MKE2FS(APPLET(mke2fs, _BB_DIR_SBIN, _BB_SUID_NEVER))
USE_MKFIFO(APPLET(mkfifo, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
//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))
USE_RENICE(APPLET(renice, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_RESET(APPLET(reset, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_RESIZE(APPLET(resize, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
-USE_RM(APPLET(rm, _BB_DIR_BIN, _BB_SUID_NEVER))
+USE_RM(APPLET_NOEXEC(rm, rm, _BB_DIR_BIN, _BB_SUID_NEVER, rm))
USE_RMDIR(APPLET(rmdir, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_RMMOD(APPLET(rmmod, _BB_DIR_SBIN, _BB_SUID_NEVER))
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))
USE_SHA1SUM(APPLET_ODDNAME(sha1sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, sha1sum))
USE_SLEEP(APPLET(sleep, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_SOFTLIMIT(APPLET_ODDNAME(softlimit, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, softlimit))
-USE_SORT(APPLET(sort, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
+USE_SORT(APPLET_NOEXEC(sort, sort, _BB_DIR_USR_BIN, _BB_SUID_NEVER, sort))
USE_SPLIT(APPLET(split, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, _BB_DIR_SBIN, _BB_SUID_NEVER, start_stop_daemon))
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
USE_TEE(APPLET(tee, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_TELNET(APPLET(telnet, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_TELNETD(APPLET(telnetd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
-USE_TEST(APPLET(test, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
+USE_TEST(APPLET_NOEXEC(test, test, _BB_DIR_USR_BIN, _BB_SUID_NEVER, test))
#if ENABLE_FEATURE_TFTP_GET || ENABLE_FEATURE_TFTP_PUT
USE_TFTP(APPLET(tftp, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
#endif
USE_TIME(APPLET(time, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_TOP(APPLET(top, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
-USE_TOUCH(APPLET(touch, _BB_DIR_BIN, _BB_SUID_NEVER))
+USE_TOUCH(APPLET_NOEXEC(touch, touch, _BB_DIR_BIN, _BB_SUID_NEVER, touch))
USE_TR(APPLET(tr, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_TRACEROUTE(APPLET(traceroute, _BB_DIR_USR_BIN, _BB_SUID_MAYBE))
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))
USE_WHICH(APPLET(which, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_WHO(APPLET(who, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_WHOAMI(APPLET(whoami, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
-USE_XARGS(APPLET(xargs, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
+USE_XARGS(APPLET_NOEXEC(xargs, xargs, _BB_DIR_USR_BIN, _BB_SUID_NEVER, xargs))
USE_YES(APPLET(yes, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_GUNZIP(APPLET_ODDNAME(zcat, gunzip, _BB_DIR_BIN, _BB_SUID_NEVER, zcat))
USE_ZCIP(APPLET(zcip, _BB_DIR_SBIN, _BB_SUID_NEVER))
#if !defined(PROTOTYPES) && !defined(MAKE_USAGE)
- { 0,NULL,0,0 }
+ { 0, NULL, 0, 0 }
};
-
#endif
#undef APPLET
#undef APPLET_NOUSAGE
#undef APPLET_ODDNAME
+#undef APPLET_NOEXEC