Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/include
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (8 years ago)
- Location:
- branches/3.3
- Files:
-
- 5 deleted
- 10 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/include/applets.src.h
r3232 r3621 9 9 /* 10 10 name - applet name as it is typed on command line 11 name2 - applet name, converted to C (ether-wake: name2= ether_wake)11 help - applet name, converted to C (ether-wake: help = ether_wake) 12 12 main - corresponding <applet>_main to call (bzcat: main = bunzip2) 13 13 l - location to install link to: [/usr]/[s]bin … … 25 25 #if defined(PROTOTYPES) 26 26 # define APPLET(name,l,s) int name##_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 27 # define APPLET_ODDNAME(name,main,l,s, name2)int main##_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;28 # define APPLET_NOEXEC(name,main,l,s, name2)int main##_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;29 # define APPLET_NOFORK(name,main,l,s, name2)int main##_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;30 31 #elif defined(NAME_MAIN _CNAME)32 # define APPLET(name,l,s) name name##_main name33 # define APPLET_ODDNAME(name,main,l,s, name2) name main##_main name234 # define APPLET_NOEXEC(name,main,l,s, name2) name main##_main name235 # define APPLET_NOFORK(name,main,l,s, name2) name main##_main name227 # define APPLET_ODDNAME(name,main,l,s,help) int main##_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 28 # define APPLET_NOEXEC(name,main,l,s,help) int main##_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 29 # define APPLET_NOFORK(name,main,l,s,help) int main##_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 30 31 #elif defined(NAME_MAIN) 32 # define APPLET(name,l,s) name name##_main 33 # define APPLET_ODDNAME(name,main,l,s,help) name main##_main 34 # define APPLET_NOEXEC(name,main,l,s,help) name main##_main 35 # define APPLET_NOFORK(name,main,l,s,help) name main##_main 36 36 37 37 #elif defined(MAKE_USAGE) && ENABLE_FEATURE_VERBOSE_USAGE 38 38 # define APPLET(name,l,s) MAKE_USAGE(#name, name##_trivial_usage name##_full_usage) 39 # define APPLET_ODDNAME(name,main,l,s, name2) MAKE_USAGE(#name, name2##_trivial_usage name2##_full_usage)40 # define APPLET_NOEXEC(name,main,l,s, name2) MAKE_USAGE(#name, name2##_trivial_usage name2##_full_usage)41 # define APPLET_NOFORK(name,main,l,s, name2) MAKE_USAGE(#name, name2##_trivial_usage name2##_full_usage)39 # define APPLET_ODDNAME(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage help##_full_usage) 40 # define APPLET_NOEXEC(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage help##_full_usage) 41 # define APPLET_NOFORK(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage help##_full_usage) 42 42 43 43 #elif defined(MAKE_USAGE) && !ENABLE_FEATURE_VERBOSE_USAGE 44 44 # define APPLET(name,l,s) MAKE_USAGE(#name, name##_trivial_usage) 45 # define APPLET_ODDNAME(name,main,l,s, name2) MAKE_USAGE(#name, name2##_trivial_usage)46 # define APPLET_NOEXEC(name,main,l,s, name2) MAKE_USAGE(#name, name2##_trivial_usage)47 # define APPLET_NOFORK(name,main,l,s, name2) MAKE_USAGE(#name, name2##_trivial_usage)45 # define APPLET_ODDNAME(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage) 46 # define APPLET_NOEXEC(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage) 47 # define APPLET_NOFORK(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage) 48 48 49 49 #elif defined(MAKE_LINKS) 50 50 # define APPLET(name,l,c) LINK l name 51 # define APPLET_ODDNAME(name,main,l,s,name2) LINK l name 52 # define APPLET_NOEXEC(name,main,l,s,name2) LINK l name 53 # define APPLET_NOFORK(name,main,l,s,name2) LINK l name 51 # define APPLET_ODDNAME(name,main,l,s,help) LINK l name 52 # define APPLET_NOEXEC(name,main,l,s,help) LINK l name 53 # define APPLET_NOFORK(name,main,l,s,help) LINK l name 54 55 #elif defined(MAKE_SUID) 56 # define APPLET(name,l,s) SUID s l name 57 # define APPLET_ODDNAME(name,main,l,s,help) SUID s l name 58 # define APPLET_NOEXEC(name,main,l,s,help) SUID s l name 59 # define APPLET_NOFORK(name,main,l,s,help) SUID s l name 54 60 55 61 #else 56 62 static struct bb_applet applets[] = { /* name, main, location, need_suid */ 57 63 # define APPLET(name,l,s) { #name, #name, l, s }, 58 # define APPLET_ODDNAME(name,main,l,s, name2){ #name, #main, l, s },59 # define APPLET_NOEXEC(name,main,l,s, name2){ #name, #main, l, s, 1 },60 # define APPLET_NOFORK(name,main,l,s, name2){ #name, #main, l, s, 1, 1 },64 # define APPLET_ODDNAME(name,main,l,s,help) { #name, #main, l, s }, 65 # define APPLET_NOEXEC(name,main,l,s,help) { #name, #main, l, s, 1 }, 66 # define APPLET_NOFORK(name,main,l,s,help) { #name, #main, l, s, 1, 1 }, 61 67 #endif 62 68 … … 71 77 IF_TEST(APPLET_NOFORK([[, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) 72 78 IF_ACPID(APPLET(acpid, BB_DIR_SBIN, BB_SUID_DROP)) 73 IF_ADDGROUP(APPLET(addgroup, BB_DIR_USR_SBIN, BB_SUID_DROP))74 IF_ADDUSER(APPLET(adduser, BB_DIR_USR_SBIN, BB_SUID_DROP))75 79 IF_ADJTIMEX(APPLET(adjtimex, BB_DIR_SBIN, BB_SUID_DROP)) 76 IF_AR(APPLET(ar, BB_DIR_USR_BIN, BB_SUID_DROP))77 80 IF_ARP(APPLET(arp, BB_DIR_SBIN, BB_SUID_DROP)) 78 81 IF_ARPING(APPLET(arping, BB_DIR_USR_SBIN, BB_SUID_DROP)) 79 IF_AWK(APPLET_NOEXEC(awk, awk, BB_DIR_USR_BIN, BB_SUID_DROP, awk))80 82 IF_BASENAME(APPLET_NOFORK(basename, basename, BB_DIR_USR_BIN, BB_SUID_DROP, basename)) 81 83 IF_BBCONFIG(APPLET(bbconfig, BB_DIR_BIN, BB_SUID_DROP)) … … 83 85 IF_BLKID(APPLET(blkid, BB_DIR_SBIN, BB_SUID_DROP)) 84 86 IF_BRCTL(APPLET(brctl, BB_DIR_USR_SBIN, BB_SUID_DROP)) 85 IF_BZIP2(APPLET(bzip2, BB_DIR_USR_BIN, BB_SUID_DROP))86 87 IF_CAL(APPLET(cal, BB_DIR_USR_BIN, BB_SUID_DROP)) 87 88 IF_CAT(APPLET_NOFORK(cat, cat, BB_DIR_BIN, BB_SUID_DROP, cat)) 88 89 IF_CATV(APPLET(catv, BB_DIR_BIN, BB_SUID_DROP)) 89 90 IF_CHAT(APPLET(chat, BB_DIR_USR_SBIN, BB_SUID_DROP)) 90 IF_CHATTR(APPLET(chattr, BB_DIR_BIN, BB_SUID_DROP))91 91 IF_CHCON(APPLET(chcon, BB_DIR_USR_BIN, BB_SUID_DROP)) 92 92 IF_CHGRP(APPLET_NOEXEC(chgrp, chgrp, BB_DIR_BIN, BB_SUID_DROP, chgrp)) 93 93 IF_CHMOD(APPLET_NOEXEC(chmod, chmod, BB_DIR_BIN, BB_SUID_DROP, chmod)) 94 94 IF_CHOWN(APPLET_NOEXEC(chown, chown, BB_DIR_BIN, BB_SUID_DROP, chown)) 95 IF_CHPASSWD(APPLET(chpasswd, BB_DIR_USR_SBIN, BB_SUID_DROP))96 IF_CHPST(APPLET(chpst, BB_DIR_USR_BIN, BB_SUID_DROP))97 95 IF_CHROOT(APPLET(chroot, BB_DIR_USR_SBIN, BB_SUID_DROP)) 98 96 IF_CHRT(APPLET(chrt, BB_DIR_USR_BIN, BB_SUID_DROP)) … … 100 98 IF_CKSUM(APPLET_NOEXEC(cksum, cksum, BB_DIR_USR_BIN, BB_SUID_DROP, cksum)) 101 99 IF_CLEAR(APPLET(clear, BB_DIR_USR_BIN, BB_SUID_DROP)) 102 IF_CMP(APPLET(cmp, BB_DIR_USR_BIN, BB_SUID_DROP))103 100 IF_COMM(APPLET(comm, BB_DIR_USR_BIN, BB_SUID_DROP)) 104 101 IF_CP(APPLET_NOEXEC(cp, cp, BB_DIR_BIN, BB_SUID_DROP, cp)) 105 IF_CPIO(APPLET(cpio, BB_DIR_BIN, BB_SUID_DROP))106 IF_CROND(APPLET(crond, BB_DIR_USR_SBIN, BB_SUID_DROP))107 102 /* Needs to be run by root or be suid root - needs to change /var/spool/cron* files: */ 108 103 IF_CRONTAB(APPLET(crontab, BB_DIR_USR_BIN, BB_SUID_REQUIRE)) 109 IF_CRYPTPW(APPLET(cryptpw, BB_DIR_USR_BIN, BB_SUID_DROP))110 104 IF_CUT(APPLET_NOEXEC(cut, cut, BB_DIR_USR_BIN, BB_SUID_DROP, cut)) 111 105 IF_DC(APPLET(dc, BB_DIR_USR_BIN, BB_SUID_DROP)) 112 106 IF_DD(APPLET_NOEXEC(dd, dd, BB_DIR_BIN, BB_SUID_DROP, dd)) 113 107 IF_DEALLOCVT(APPLET(deallocvt, BB_DIR_USR_BIN, BB_SUID_DROP)) 114 IF_DELGROUP(APPLET_ODDNAME(delgroup, deluser, BB_DIR_USR_SBIN, BB_SUID_DROP, delgroup))115 IF_DELUSER(APPLET(deluser, BB_DIR_USR_SBIN, BB_SUID_DROP))116 108 IF_DEVFSD(APPLET(devfsd, BB_DIR_SBIN, BB_SUID_DROP)) 117 109 IF_DEVMEM(APPLET(devmem, BB_DIR_SBIN, BB_SUID_DROP)) 118 110 IF_DF(APPLET(df, BB_DIR_BIN, BB_SUID_DROP)) 119 111 IF_DHCPRELAY(APPLET(dhcprelay, BB_DIR_USR_SBIN, BB_SUID_DROP)) 120 IF_DIFF(APPLET(diff, BB_DIR_USR_BIN, BB_SUID_DROP))121 112 IF_DIRNAME(APPLET_NOFORK(dirname, dirname, BB_DIR_USR_BIN, BB_SUID_DROP, dirname)) 122 113 IF_DMESG(APPLET(dmesg, BB_DIR_BIN, BB_SUID_DROP)) … … 124 115 IF_HOSTNAME(APPLET_ODDNAME(dnsdomainname, hostname, BB_DIR_BIN, BB_SUID_DROP, dnsdomainname)) 125 116 IF_DOS2UNIX(APPLET_NOEXEC(dos2unix, dos2unix, BB_DIR_USR_BIN, BB_SUID_DROP, dos2unix)) 126 IF_DPKG(APPLET(dpkg, BB_DIR_USR_BIN, BB_SUID_DROP))127 IF_DPKG_DEB(APPLET_ODDNAME(dpkg-deb, dpkg_deb, BB_DIR_USR_BIN, BB_SUID_DROP, dpkg_deb))128 117 IF_DU(APPLET(du, BB_DIR_USR_BIN, BB_SUID_DROP)) 129 118 IF_DUMPKMAP(APPLET(dumpkmap, BB_DIR_BIN, BB_SUID_DROP)) … … 132 121 //IF_E2LABEL(APPLET_ODDNAME(e2label, tune2fs, BB_DIR_SBIN, BB_SUID_DROP, e2label)) 133 122 IF_ECHO(APPLET_NOFORK(echo, echo, BB_DIR_BIN, BB_SUID_DROP, echo)) 134 IF_ED(APPLET(ed, BB_DIR_BIN, BB_SUID_DROP))135 123 IF_EJECT(APPLET(eject, BB_DIR_USR_BIN, BB_SUID_DROP)) 136 124 IF_ENV(APPLET_NOEXEC(env, env, BB_DIR_USR_BIN, BB_SUID_DROP, env)) 137 IF_ENVDIR(APPLET_ODDNAME(envdir, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envdir))138 IF_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envuidgid))139 125 IF_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, BB_DIR_USR_SBIN, BB_SUID_DROP, ether_wake)) 140 126 IF_EXPAND(APPLET(expand, BB_DIR_USR_BIN, BB_SUID_DROP)) … … 158 144 IF_FREE(APPLET(free, BB_DIR_USR_BIN, BB_SUID_DROP)) 159 145 IF_FREERAMDISK(APPLET(freeramdisk, BB_DIR_SBIN, BB_SUID_DROP)) 160 IF_FSCK(APPLET(fsck, BB_DIR_SBIN, BB_SUID_DROP))161 146 //IF_E2FSCK(APPLET_ODDNAME(fsck.ext2, e2fsck, BB_DIR_SBIN, BB_SUID_DROP, fsck_ext2)) 162 147 //IF_E2FSCK(APPLET_ODDNAME(fsck.ext3, e2fsck, BB_DIR_SBIN, BB_SUID_DROP, fsck_ext3)) … … 170 155 IF_GETOPT(APPLET(getopt, BB_DIR_BIN, BB_SUID_DROP)) 171 156 IF_GETSEBOOL(APPLET(getsebool, BB_DIR_USR_SBIN, BB_SUID_DROP)) 172 IF_GETTY(APPLET(getty, BB_DIR_SBIN, BB_SUID_DROP))173 IF_GUNZIP(APPLET(gunzip, BB_DIR_BIN, BB_SUID_DROP))174 IF_GZIP(APPLET(gzip, BB_DIR_BIN, BB_SUID_DROP))175 157 IF_HD(APPLET_NOEXEC(hd, hexdump, BB_DIR_USR_BIN, BB_SUID_DROP, hd)) 176 158 IF_HDPARM(APPLET(hdparm, BB_DIR_SBIN, BB_SUID_DROP)) … … 208 190 IF_KILLALL(APPLET_ODDNAME(killall, kill, BB_DIR_USR_BIN, BB_SUID_DROP, killall)) 209 191 IF_KILLALL5(APPLET_ODDNAME(killall5, kill, BB_DIR_USR_SBIN, BB_SUID_DROP, killall5)) 210 IF_KLOGD(APPLET(klogd, BB_DIR_SBIN, BB_SUID_DROP))211 192 IF_LAST(APPLET(last, BB_DIR_USR_BIN, BB_SUID_DROP)) 212 193 //IF_LENGTH(APPLET_NOFORK(length, length, BB_DIR_USR_BIN, BB_SUID_DROP, length)) 213 194 IF_LESS(APPLET(less, BB_DIR_USR_BIN, BB_SUID_DROP)) 214 IF_SETARCH(APPLET_ODDNAME(linux32, setarch, BB_DIR_BIN, BB_SUID_DROP, linux32))215 IF_SETARCH(APPLET_ODDNAME(linux64, setarch, BB_DIR_BIN, BB_SUID_DROP, linux64))216 195 IF_LN(APPLET_NOEXEC(ln, ln, BB_DIR_BIN, BB_SUID_DROP, ln)) 217 196 IF_LOAD_POLICY(APPLET(load_policy, BB_DIR_USR_SBIN, BB_SUID_DROP)) 218 197 IF_LOADFONT(APPLET(loadfont, BB_DIR_USR_SBIN, BB_SUID_DROP)) 219 198 IF_LOADKMAP(APPLET(loadkmap, BB_DIR_SBIN, BB_SUID_DROP)) 220 IF_LOGGER(APPLET(logger, BB_DIR_USR_BIN, BB_SUID_DROP))221 /* Needs to be run by root or be suid root - needs to change uid and gid: */222 IF_LOGIN(APPLET(login, BB_DIR_BIN, BB_SUID_REQUIRE))223 199 IF_LOGNAME(APPLET_NOFORK(logname, logname, BB_DIR_USR_BIN, BB_SUID_DROP, logname)) 224 IF_LOGREAD(APPLET(logread, BB_DIR_SBIN, BB_SUID_DROP))225 200 IF_LOSETUP(APPLET(losetup, BB_DIR_SBIN, BB_SUID_DROP)) 226 IF_LPD(APPLET(lpd, BB_DIR_USR_SBIN, BB_SUID_DROP))227 IF_LPQ(APPLET_ODDNAME(lpq, lpqr, BB_DIR_USR_BIN, BB_SUID_DROP, lpq))228 IF_LPR(APPLET_ODDNAME(lpr, lpqr, BB_DIR_USR_BIN, BB_SUID_DROP, lpr))229 201 IF_LS(APPLET_NOEXEC(ls, ls, BB_DIR_BIN, BB_SUID_DROP, ls)) 230 IF_LSATTR(APPLET(lsattr, BB_DIR_BIN, BB_SUID_DROP))231 202 IF_LSPCI(APPLET(lspci, BB_DIR_USR_BIN, BB_SUID_DROP)) 232 203 IF_LSUSB(APPLET(lsusb, BB_DIR_USR_BIN, BB_SUID_DROP)) 233 IF_UNLZMA(APPLET_ODDNAME(lzcat, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzcat))234 IF_LZMA(APPLET_ODDNAME(lzma, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzma))235 IF_LZOP(APPLET(lzop, BB_DIR_BIN, BB_SUID_DROP))236 IF_LZOP(APPLET_ODDNAME(lzopcat, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, lzopcat))237 204 IF_MAKEDEVS(APPLET(makedevs, BB_DIR_SBIN, BB_SUID_DROP)) 238 205 IF_MAKEMIME(APPLET(makemime, BB_DIR_BIN, BB_SUID_DROP)) 239 IF_MAN(APPLET(man, BB_DIR_ SBIN, BB_SUID_DROP))206 IF_MAN(APPLET(man, BB_DIR_USR_BIN, BB_SUID_DROP)) 240 207 IF_MATCHPATHCON(APPLET(matchpathcon, BB_DIR_USR_SBIN, BB_SUID_DROP)) 241 208 IF_MD5SUM(APPLET_NOEXEC(md5sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, md5sum)) … … 251 218 IF_MKFS_VFAT(APPLET_ODDNAME(mkfs.vfat, mkfs_vfat, BB_DIR_SBIN, BB_SUID_DROP, mkfs_vfat)) 252 219 IF_MKNOD(APPLET_NOEXEC(mknod, mknod, BB_DIR_BIN, BB_SUID_DROP, mknod)) 253 IF_CRYPTPW(APPLET_ODDNAME(mkpasswd, cryptpw, BB_DIR_USR_BIN, BB_SUID_DROP, mkpasswd))254 220 IF_MKSWAP(APPLET(mkswap, BB_DIR_SBIN, BB_SUID_DROP)) 255 IF_MKTEMP(APPLET(mktemp, BB_DIR_BIN, BB_SUID_DROP))256 221 IF_MORE(APPLET(more, BB_DIR_BIN, BB_SUID_DROP)) 257 222 /* On full-blown systems, requires suid for user mounts. … … 273 238 IF_OPENVT(APPLET(openvt, BB_DIR_USR_BIN, BB_SUID_DROP)) 274 239 //IF_PARSE(APPLET(parse, BB_DIR_USR_BIN, BB_SUID_DROP)) 275 /* Needs to be run by root or be suid root - needs to change /etc/{passwd,shadow}: */276 IF_PASSWD(APPLET(passwd, BB_DIR_USR_BIN, BB_SUID_REQUIRE))277 240 IF_PGREP(APPLET(pgrep, BB_DIR_USR_BIN, BB_SUID_DROP)) 278 241 IF_PIDOF(APPLET(pidof, BB_DIR_BIN, BB_SUID_DROP)) 279 IF_PIPE_PROGRESS(APPLET(pipe_progress, BB_DIR_BIN, BB_SUID_DROP))280 242 IF_PIVOT_ROOT(APPLET(pivot_root, BB_DIR_SBIN, BB_SUID_DROP)) 281 243 IF_PKILL(APPLET_ODDNAME(pkill, pgrep, BB_DIR_USR_BIN, BB_SUID_DROP, pkill)) … … 298 260 IF_RESIZE(APPLET(resize, BB_DIR_USR_BIN, BB_SUID_DROP)) 299 261 IF_RESTORECON(APPLET_ODDNAME(restorecon, setfiles, BB_DIR_SBIN, BB_SUID_DROP, restorecon)) 300 IF_RFKILL(APPLET(rfkill, BB_DIR_USR_SBIN, BB_SUID_DROP))301 262 IF_RM(APPLET_NOFORK(rm, rm, BB_DIR_BIN, BB_SUID_DROP, rm)) 302 263 IF_RMDIR(APPLET_NOFORK(rmdir, rmdir, BB_DIR_BIN, BB_SUID_DROP, rmdir)) 303 264 IF_ROUTE(APPLET(route, BB_DIR_SBIN, BB_SUID_DROP)) 304 IF_RPM(APPLET(rpm, BB_DIR_BIN, BB_SUID_DROP))305 IF_RPM2CPIO(APPLET(rpm2cpio, BB_DIR_USR_BIN, BB_SUID_DROP))306 265 IF_RTCWAKE(APPLET(rtcwake, BB_DIR_USR_SBIN, BB_SUID_DROP)) 307 IF_RUN_PARTS(APPLET_ODDNAME(run-parts, run_parts, BB_DIR_BIN, BB_SUID_DROP, run_parts))308 266 IF_RUNCON(APPLET(runcon, BB_DIR_USR_BIN, BB_SUID_DROP)) 309 267 IF_RUNLEVEL(APPLET(runlevel, BB_DIR_SBIN, BB_SUID_DROP)) 310 IF_RUNSV(APPLET(runsv, BB_DIR_USR_BIN, BB_SUID_DROP))311 IF_RUNSVDIR(APPLET(runsvdir, BB_DIR_USR_BIN, BB_SUID_DROP))312 268 IF_RX(APPLET(rx, BB_DIR_USR_BIN, BB_SUID_DROP)) 313 269 IF_SCRIPT(APPLET(script, BB_DIR_USR_BIN, BB_SUID_DROP)) 314 270 IF_SCRIPTREPLAY(APPLET(scriptreplay, BB_DIR_BIN, BB_SUID_DROP)) 315 IF_SED(APPLET(sed, BB_DIR_BIN, BB_SUID_DROP))316 271 IF_SELINUXENABLED(APPLET(selinuxenabled, BB_DIR_USR_SBIN, BB_SUID_DROP)) 317 272 IF_SENDMAIL(APPLET(sendmail, BB_DIR_USR_SBIN, BB_SUID_DROP)) 318 273 IF_SEQ(APPLET_NOFORK(seq, seq, BB_DIR_USR_BIN, BB_SUID_DROP, seq)) 319 274 IF_SESTATUS(APPLET(sestatus, BB_DIR_USR_SBIN, BB_SUID_DROP)) 320 IF_SETARCH(APPLET(setarch, BB_DIR_BIN, BB_SUID_DROP))321 275 IF_SETCONSOLE(APPLET(setconsole, BB_DIR_SBIN, BB_SUID_DROP)) 322 276 IF_SETENFORCE(APPLET(setenforce, BB_DIR_USR_SBIN, BB_SUID_DROP)) … … 327 281 IF_SETSEBOOL(APPLET(setsebool, BB_DIR_USR_SBIN, BB_SUID_DROP)) 328 282 IF_SETSID(APPLET(setsid, BB_DIR_USR_BIN, BB_SUID_DROP)) 329 IF_SETUIDGID(APPLET_ODDNAME(setuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, setuidgid))330 283 IF_SHA1SUM(APPLET_NOEXEC(sha1sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha1sum)) 331 284 IF_SHA3SUM(APPLET_NOEXEC(sha3sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha3sum)) … … 336 289 /* Do not make this applet NOFORK. It breaks ^C-ing of pauses in shells: */ 337 290 IF_SLEEP(APPLET(sleep, BB_DIR_BIN, BB_SUID_DROP)) 338 IF_SOFTLIMIT(APPLET_ODDNAME(softlimit, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, softlimit))339 291 IF_SORT(APPLET_NOEXEC(sort, sort, BB_DIR_USR_BIN, BB_SUID_DROP, sort)) 340 292 IF_SPLIT(APPLET(split, BB_DIR_USR_BIN, BB_SUID_DROP)) 341 IF_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, BB_DIR_SBIN, BB_SUID_DROP, start_stop_daemon))342 293 IF_STAT(APPLET(stat, BB_DIR_BIN, BB_SUID_DROP)) 343 294 IF_STRINGS(APPLET(strings, BB_DIR_USR_BIN, BB_SUID_DROP)) 344 295 IF_STTY(APPLET(stty, BB_DIR_BIN, BB_SUID_DROP)) 345 /* Needs to be run by root or be suid root - needs to change uid and gid: */346 IF_SU(APPLET(su, BB_DIR_BIN, BB_SUID_REQUIRE))347 IF_SULOGIN(APPLET(sulogin, BB_DIR_SBIN, BB_SUID_DROP))348 296 IF_SUM(APPLET(sum, BB_DIR_USR_BIN, BB_SUID_DROP)) 349 IF_SV(APPLET(sv, BB_DIR_USR_BIN, BB_SUID_DROP))350 IF_SVLOGD(APPLET(svlogd, BB_DIR_USR_SBIN, BB_SUID_DROP))351 297 IF_SWAPONOFF(APPLET_ODDNAME(swapoff, swap_on_off, BB_DIR_SBIN, BB_SUID_DROP, swapoff)) 352 298 IF_SWAPONOFF(APPLET_ODDNAME(swapon, swap_on_off, BB_DIR_SBIN, BB_SUID_DROP, swapon)) 353 299 IF_SWITCH_ROOT(APPLET(switch_root, BB_DIR_SBIN, BB_SUID_DROP)) 354 IF_SYNC(APPLET_NOFORK(sync, sync, BB_DIR_BIN, BB_SUID_DROP, sync))355 300 IF_BB_SYSCTL(APPLET(sysctl, BB_DIR_SBIN, BB_SUID_DROP)) 356 IF_SYSLOGD(APPLET(syslogd, BB_DIR_SBIN, BB_SUID_DROP))357 301 IF_TAC(APPLET_NOEXEC(tac, tac, BB_DIR_USR_BIN, BB_SUID_DROP, tac)) 358 302 IF_TAIL(APPLET(tail, BB_DIR_USR_BIN, BB_SUID_DROP)) 359 IF_TAR(APPLET(tar, BB_DIR_BIN, BB_SUID_DROP))360 IF_TASKSET(APPLET(taskset, BB_DIR_USR_BIN, BB_SUID_DROP))361 303 /* IF_TC(APPLET(tc, BB_DIR_SBIN, BB_SUID_DROP)) */ 362 304 IF_TCPSVD(APPLET_ODDNAME(tcpsvd, tcpudpsvd, BB_DIR_USR_BIN, BB_SUID_DROP, tcpsvd)) … … 380 322 IF_TTYSIZE(APPLET(ttysize, BB_DIR_USR_BIN, BB_SUID_DROP)) 381 323 IF_TUNCTL(APPLET(tunctl, BB_DIR_SBIN, BB_SUID_DROP)) 382 IF_TUNE2FS(APPLET(tune2fs, BB_DIR_SBIN, BB_SUID_DROP))383 324 IF_UDHCPC(APPLET(udhcpc, BB_DIR_SBIN, BB_SUID_DROP)) 384 325 IF_UDHCPD(APPLET(udhcpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) … … 386 327 IF_UMOUNT(APPLET(umount, BB_DIR_BIN, BB_SUID_DROP)) 387 328 IF_UNAME(APPLET(uname, BB_DIR_BIN, BB_SUID_DROP)) 388 IF_UNCOMPRESS(APPLET(uncompress, BB_DIR_BIN, BB_SUID_DROP))389 329 IF_UNEXPAND(APPLET_ODDNAME(unexpand, expand, BB_DIR_USR_BIN, BB_SUID_DROP, unexpand)) 390 330 IF_UNIQ(APPLET(uniq, BB_DIR_USR_BIN, BB_SUID_DROP)) 391 331 IF_UNIX2DOS(APPLET_NOEXEC(unix2dos, dos2unix, BB_DIR_USR_BIN, BB_SUID_DROP, unix2dos)) 392 IF_UNXZ(APPLET(unxz, BB_DIR_USR_BIN, BB_SUID_DROP))393 IF_UNLZMA(APPLET(unlzma, BB_DIR_USR_BIN, BB_SUID_DROP))394 IF_LZOP(APPLET_ODDNAME(unlzop, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, unlzop))395 IF_UNZIP(APPLET(unzip, BB_DIR_USR_BIN, BB_SUID_DROP))396 332 IF_UPTIME(APPLET(uptime, BB_DIR_USR_BIN, BB_SUID_DROP)) 397 333 IF_USLEEP(APPLET_NOFORK(usleep, usleep, BB_DIR_BIN, BB_SUID_DROP, usleep)) … … 399 335 IF_UUENCODE(APPLET(uuencode, BB_DIR_USR_BIN, BB_SUID_DROP)) 400 336 IF_VCONFIG(APPLET(vconfig, BB_DIR_SBIN, BB_SUID_DROP)) 401 /* Needs to be run by root or be suid root - needs to change uid and gid: */402 IF_VLOCK(APPLET(vlock, BB_DIR_USR_BIN, BB_SUID_REQUIRE))403 337 IF_VOLNAME(APPLET(volname, BB_DIR_USR_BIN, BB_SUID_DROP)) 404 /* Needs to be run by root or be suid root - needs to write to /dev/TTY: */405 IF_WALL(APPLET(wall, BB_DIR_USR_BIN, BB_SUID_REQUIRE))406 338 IF_WATCH(APPLET(watch, BB_DIR_BIN, BB_SUID_DROP)) 407 339 IF_WATCHDOG(APPLET(watchdog, BB_DIR_SBIN, BB_SUID_DROP)) 408 340 IF_WC(APPLET(wc, BB_DIR_USR_BIN, BB_SUID_DROP)) 409 IF_WGET(APPLET(wget, BB_DIR_USR_BIN, BB_SUID_DROP))410 IF_WHICH(APPLET(which, BB_DIR_USR_BIN, BB_SUID_DROP))411 341 IF_WHOAMI(APPLET_NOFORK(whoami, whoami, BB_DIR_USR_BIN, BB_SUID_DROP, whoami)) 412 IF_UNXZ(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat))413 IF_XZ(APPLET_ODDNAME(xz, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xz))414 342 IF_YES(APPLET_NOFORK(yes, yes, BB_DIR_USR_BIN, BB_SUID_DROP, yes)) 415 IF_GUNZIP(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat))416 343 IF_ZCIP(APPLET(zcip, BB_DIR_SBIN, BB_SUID_DROP)) 417 344 418 #if !defined(PROTOTYPES) && !defined(NAME_MAIN_CNAME) && !defined(MAKE_USAGE) 345 #if !defined(PROTOTYPES) && !defined(NAME_MAIN) && !defined(MAKE_USAGE) \ 346 && !defined(MAKE_LINKS) && !defined(MAKE_SUID) 419 347 }; 420 348 #endif -
branches/3.3/mindi-busybox/include/bb_archive.h
r3233 r3621 78 78 79 79 /* Archiver specific. Can make it a union if it ever gets big */ 80 #if ENABLE_FEATURE_TAR_LONG_OPTIONS 81 unsigned tar__strip_components; 82 #endif 80 83 #define PAX_NEXT_FILE 0 81 84 #define PAX_GLOBAL 1 … … 96 99 #if ENABLE_CPIO || ENABLE_RPM2CPIO || ENABLE_RPM 97 100 uoff_t cpio__blocks; 101 struct bb_uidgid_t cpio__owner; 98 102 struct hardlinks_t *cpio__hardlinks_to_create; 99 103 struct hardlinks_t *cpio__created_hardlinks; … … 123 127 #define ARCHIVE_O_TRUNC (1 << 8) 124 128 #define ARCHIVE_REMEMBER_NAMES (1 << 9) 129 #if ENABLE_RPM 130 #define ARCHIVE_REPLACE_VIA_RENAME (1 << 10) 131 #endif 125 132 126 133 … … 157 164 158 165 166 extern const char cpio_TRAILER[]; 167 159 168 160 169 archive_handle_t *init_handle(void) FAST_FUNC; … … 182 191 char get_header_tar_bz2(archive_handle_t *archive_handle) FAST_FUNC; 183 192 char get_header_tar_lzma(archive_handle_t *archive_handle) FAST_FUNC; 193 char get_header_tar_xz(archive_handle_t *archive_handle) FAST_FUNC; 184 194 185 195 void seek_by_jump(int fd, off_t amount) FAST_FUNC; … … 201 211 202 212 /* Meaning and direction (input/output) of the fields are transformer-specific */ 203 typedef struct transformer_aux_data_t { 204 smallint check_signature; /* most often referenced member */ 213 typedef struct transformer_state_t { 214 smallint signature_skipped; /* most often referenced member */ 215 216 IF_DESKTOP(long long) int FAST_FUNC (*xformer)(struct transformer_state_t *xstate); 217 USE_FOR_NOMMU(const char *xformer_prog;) 218 219 /* Source */ 220 int src_fd; 221 /* Output */ 222 int dst_fd; 223 size_t mem_output_size_max; /* if non-zero, decompress to RAM instead of fd */ 224 size_t mem_output_size; 225 char *mem_output_buf; 226 205 227 off_t bytes_out; 206 228 off_t bytes_in; /* used in unzip code only: needs to know packed size */ 207 229 uint32_t crc32; 208 230 time_t mtime; /* gunzip code may set this on exit */ 209 } transformer_aux_data_t; 210 211 void init_transformer_aux_data(transformer_aux_data_t *aux) FAST_FUNC; 212 int FAST_FUNC check_signature16(transformer_aux_data_t *aux, int src_fd, unsigned magic16) FAST_FUNC; 213 214 IF_DESKTOP(long long) int inflate_unzip(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; 215 IF_DESKTOP(long long) int unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; 216 IF_DESKTOP(long long) int unpack_gz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; 217 IF_DESKTOP(long long) int unpack_bz2_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; 218 IF_DESKTOP(long long) int unpack_lzma_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; 219 IF_DESKTOP(long long) int unpack_xz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) FAST_FUNC; 231 } transformer_state_t; 232 233 void init_transformer_state(transformer_state_t *xstate) FAST_FUNC; 234 ssize_t transformer_write(transformer_state_t *xstate, const void *buf, size_t bufsize) FAST_FUNC; 235 ssize_t xtransformer_write(transformer_state_t *xstate, const void *buf, size_t bufsize) FAST_FUNC; 236 int check_signature16(transformer_state_t *xstate, unsigned magic16) FAST_FUNC; 237 238 IF_DESKTOP(long long) int inflate_unzip(transformer_state_t *xstate) FAST_FUNC; 239 IF_DESKTOP(long long) int unpack_Z_stream(transformer_state_t *xstate) FAST_FUNC; 240 IF_DESKTOP(long long) int unpack_gz_stream(transformer_state_t *xstate) FAST_FUNC; 241 IF_DESKTOP(long long) int unpack_bz2_stream(transformer_state_t *xstate) FAST_FUNC; 242 IF_DESKTOP(long long) int unpack_lzma_stream(transformer_state_t *xstate) FAST_FUNC; 243 IF_DESKTOP(long long) int unpack_xz_stream(transformer_state_t *xstate) FAST_FUNC; 220 244 221 245 char* append_ext(char *filename, const char *expected_ext) FAST_FUNC; 222 246 int bbunpack(char **argv, 223 IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(transformer_ aux_data_t *aux),247 IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(transformer_state_t *xstate), 224 248 char* FAST_FUNC (*make_new_name)(char *filename, const char *expected_ext), 225 249 const char *expected_ext … … 228 252 void check_errors_in_children(int signo); 229 253 #if BB_MMU 230 void open_transformer(int fd,231 int check_signature,232 IF_DESKTOP(long long) int FAST_FUNC (*transformer)(transformer_ aux_data_t *aux, int src_fd, int dst_fd)254 void fork_transformer(int fd, 255 int signature_skipped, 256 IF_DESKTOP(long long) int FAST_FUNC (*transformer)(transformer_state_t *xstate) 233 257 ) FAST_FUNC; 234 #define open_transformer_with_sig(fd, transformer, transform_prog) open_transformer((fd), 1, (transformer))235 #define open_transformer_with_no_sig(fd, transformer) open_transformer((fd), 0, (transformer))258 #define fork_transformer_with_sig(fd, transformer, transform_prog) fork_transformer((fd), 0, (transformer)) 259 #define fork_transformer_with_no_sig(fd, transformer) fork_transformer((fd), 1, (transformer)) 236 260 #else 237 void open_transformer(int fd, const char *transform_prog) FAST_FUNC;238 #define open_transformer_with_sig(fd, transformer, transform_prog) open_transformer((fd), (transform_prog))239 /* open_transformer_with_no_sig() does not exist on NOMMU */261 void fork_transformer(int fd, const char *transform_prog) FAST_FUNC; 262 #define fork_transformer_with_sig(fd, transformer, transform_prog) fork_transformer((fd), (transform_prog)) 263 /* fork_transformer_with_no_sig() does not exist on NOMMU */ 240 264 #endif 241 265 -
branches/3.3/mindi-busybox/include/bb_e2fs_defs.h
r3233 r3621 443 443 }; 444 444 struct BUG_ext2_super_block { 445 445 char bug[sizeof(struct ext2_super_block) == 1024 ? 1 : -1]; 446 446 }; 447 447 -
branches/3.3/mindi-busybox/include/busybox.h
r3232 r3621 16 16 extern const char applet_names[] ALIGN1; 17 17 extern int (*const applet_main[])(int argc, char **argv); 18 extern const uint16_t applet_nameofs[]; 18 extern const uint8_t applet_flags[] ALIGN1; 19 extern const uint8_t applet_suid[] ALIGN1; 19 20 extern const uint8_t applet_install_loc[] ALIGN1; 20 21 21 #if ENABLE_FEATURE_SUID || ENABLE_FEATURE_PREFER_APPLETS22 # define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0x0fff))23 #else24 # define APPLET_NAME(i) (applet_names + applet_nameofs[i])25 #endif26 27 22 #if ENABLE_FEATURE_PREFER_APPLETS 28 # define APPLET_IS_NOFORK(i) (applet_ nameofs[i] & (1 << 12))29 # define APPLET_IS_NOEXEC(i) (applet_ nameofs[i] & (1 << 13))23 # define APPLET_IS_NOFORK(i) (applet_flags[(i)/4] & (1 << (2 * ((i)%4)))) 24 # define APPLET_IS_NOEXEC(i) (applet_flags[(i)/4] & (1 << ((2 * ((i)%4))+1))) 30 25 #else 31 26 # define APPLET_IS_NOFORK(i) 0 … … 34 29 35 30 #if ENABLE_FEATURE_SUID 36 # define APPLET_SUID(i) ((applet_ nameofs[i] >> 14) & 0x3)31 # define APPLET_SUID(i) ((applet_suid[(i)/4] >> (2 * ((i)%4)) & 3)) 37 32 #endif 38 33 -
branches/3.3/mindi-busybox/include/grp_.h
r3232 r3621 31 31 */ 32 32 #undef endgrent 33 #define setgrent bb_internal_setgrent34 33 #define endgrent bb_internal_endgrent 35 #define getgrent bb_internal_getgrent36 #define fgetgrent bb_internal_fgetgrent37 #define putgrent bb_internal_putgrent38 34 #define getgrgid bb_internal_getgrgid 39 35 #define getgrnam bb_internal_getgrnam 40 #define getgrent_r bb_internal_getgrent_r41 #define getgrgid_r bb_internal_getgrgid_r42 #define getgrnam_r bb_internal_getgrnam_r43 #define fgetgrent_r bb_internal_fgetgrent_r44 36 #define getgrouplist bb_internal_getgrouplist 45 37 #define initgroups bb_internal_initgroups 46 47 38 48 39 /* All function names below should be remapped by #defines above 49 40 * in order to not collide with libc names. */ 50 41 51 52 /* Rewind the group-file stream. */53 extern void setgrent(void);54 55 42 /* Close the group-file stream. */ 56 extern void endgrent(void); 57 58 #ifdef UNUSED_SINCE_WE_AVOID_STATIC_BUFS 59 /* Read an entry from the group-file stream, opening it if necessary. */ 60 extern struct group *getgrent(void); 61 62 /* Read a group entry from STREAM. */ 63 extern struct group *fgetgrent(FILE *__stream); 64 65 /* Write the given entry onto the given stream. */ 66 extern int putgrent(const struct group *__restrict __p, 67 FILE *__restrict __f); 68 #endif 43 void FAST_FUNC endgrent(void); 69 44 70 45 /* Search for an entry with a matching group ID. */ 71 extern struct group *getgrgid(gid_t __gid);46 struct group* FAST_FUNC getgrgid(gid_t __gid); 72 47 73 48 /* Search for an entry with a matching group name. */ 74 extern struct group *getgrnam(const char *__name);49 struct group* FAST_FUNC getgrnam(const char *__name); 75 50 76 /* Reentrant versions of some of the functions above. 77 78 PLEASE NOTE: the `getgrent_r' function is not (yet) standardized. 79 The interface may change in later versions of this library. But 80 the interface is designed following the principals used for the 81 other reentrant functions so the chances are good this is what the 82 POSIX people would choose. */ 83 84 extern int getgrent_r(struct group *__restrict __resultbuf, 85 char *__restrict __buffer, size_t __buflen, 86 struct group **__restrict __result); 87 88 /* Search for an entry with a matching group ID. */ 89 extern int getgrgid_r(gid_t __gid, struct group *__restrict __resultbuf, 90 char *__restrict __buffer, size_t __buflen, 91 struct group **__restrict __result); 92 93 /* Search for an entry with a matching group name. */ 94 extern int getgrnam_r(const char *__restrict __name, 95 struct group *__restrict __resultbuf, 96 char *__restrict __buffer, size_t __buflen, 97 struct group **__restrict __result); 98 99 /* Read a group entry from STREAM. This function is not standardized 100 an probably never will. */ 101 extern int fgetgrent_r(FILE *__restrict __stream, 102 struct group *__restrict __resultbuf, 103 char *__restrict __buffer, size_t __buflen, 104 struct group **__restrict __result); 51 /* Reentrant versions of some of the functions above. */ 105 52 106 53 /* Store at most *NGROUPS members of the group set for USER into 107 54 *GROUPS. Also include GROUP. The actual number of groups found is 108 55 returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. */ 109 extern intgetgrouplist(const char *__user, gid_t __group,56 int FAST_FUNC getgrouplist(const char *__user, gid_t __group, 110 57 gid_t *__groups, int *__ngroups); 111 58 … … 113 60 by reading the group database and using all groups 114 61 of which USER is a member. Also include GROUP. */ 115 extern intinitgroups(const char *__user, gid_t __group);62 int FAST_FUNC initgroups(const char *__user, gid_t __group); 116 63 117 64 POP_SAVED_FUNCTION_VISIBILITY -
branches/3.3/mindi-busybox/include/libbb.h
r3232 r3621 21 21 #include <setjmp.h> 22 22 #include <signal.h> 23 #include <paths.h> 23 24 #if defined __UCLIBC__ /* TODO: and glibc? */ 24 25 /* use inlined versions of these: */ … … 33 34 #include <stddef.h> 34 35 #include <string.h> 35 /* There are two incompatible basename's, let not use them! */36 /* There are two incompatible basename's, let's not use them! */ 36 37 /* See the dirname/basename man page for details */ 37 38 #include <libgen.h> /* dirname,basename */ 38 39 #undef basename 39 40 #define basename dont_use_basename 40 #include < sys/poll.h>41 #include <poll.h> 41 42 #include <sys/ioctl.h> 42 43 #include <sys/mman.h> … … 85 86 #endif 86 87 #if ENABLE_FEATURE_UTMP 87 # include <utmp.h> 88 # if defined __UCLIBC__ && ( \ 89 (UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 32) \ 90 && UCLIBC_VERSION < KERNEL_VERSION(0, 9, 34) \ 91 && defined __UCLIBC_HAS_UTMPX__ \ 92 ) || ( \ 93 UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 34) \ 94 ) \ 95 ) 96 # include <utmpx.h> 97 # elif defined __UCLIBC__ 98 # include <utmp.h> 99 # define utmpx utmp 100 # define setutxent setutent 101 # define endutxent endutent 102 # define getutxent getutent 103 # define getutxid getutid 104 # define getutxline getutline 105 # define pututxline pututline 106 # define utmpxname utmpname 107 # define updwtmpx updwtmp 108 # define _PATH_UTMPX _PATH_UTMP 109 # else 110 # include <utmp.h> 111 # include <utmpx.h> 112 # if defined _PATH_UTMP && !defined _PATH_UTMPX 113 # define _PATH_UTMPX _PATH_UTMP 114 # endif 115 # endif 88 116 #endif 89 117 #if ENABLE_LOCALE_SUPPORT … … 115 143 #else 116 144 # include <arpa/inet.h> 117 # if !defined(__socklen_t_defined) && !defined(_SOCKLEN_T_DECLARED) 118 /* We #define socklen_t *after* includes, otherwise we get 119 * typedef redefinition errors from system headers 120 * (in case "is it defined already" detection above failed) 121 */ 122 # define socklen_t bb_socklen_t 123 typedef unsigned socklen_t; 124 # endif 145 //This breaks on bionic: 146 //# if !defined(__socklen_t_defined) && !defined(_SOCKLEN_T_DECLARED) 147 ///* We #define socklen_t *after* includes, otherwise we get 148 // * typedef redefinition errors from system headers 149 // * (in case "is it defined already" detection above failed) 150 // */ 151 //# define socklen_t bb_socklen_t 152 // typedef unsigned socklen_t; 153 //# endif 154 //if this is still needed, add a fix along the lines of 155 // ifdef SPECIFIC_BROKEN_LIBC_CHECK / typedef socklen_t / endif 156 //in platform.h instead! 125 157 #endif 126 158 #ifndef HAVE_CLEARENV … … 320 352 extern const char *bb_mode_string(mode_t mode) FAST_FUNC; 321 353 extern int is_directory(const char *name, int followLinks) FAST_FUNC; 322 enum { /* DO NOT CHANGE THESE VALUES! cp.c, mv.c, install.c depend on them.*/354 enum { /* cp.c, mv.c, install.c depend on these values. CAREFUL when changing them! */ 323 355 FILEUTILS_PRESERVE_STATUS = 1 << 0, /* -p */ 324 356 FILEUTILS_DEREFERENCE = 1 << 1, /* !-d */ … … 330 362 FILEUTILS_DEREF_SOFTLINK = 1 << 7, /* -L */ 331 363 FILEUTILS_DEREFERENCE_L0 = 1 << 8, /* -H */ 364 /* -a = -pdR (mapped in cp.c) */ 365 /* -r = -dR (mapped in cp.c) */ 366 /* -P = -d (mapped in cp.c) */ 367 FILEUTILS_VERBOSE = (1 << 12) * ENABLE_FEATURE_VERBOSE, /* -v */ 368 FILEUTILS_UPDATE = 1 << 13, /* -u */ 332 369 #if ENABLE_SELINUX 333 FILEUTILS_PRESERVE_SECURITY_CONTEXT = 1 << 9, /* -c */ 334 FILEUTILS_SET_SECURITY_CONTEXT = 1 << 10, 335 #endif 336 FILEUTILS_IGNORE_CHMOD_ERR = 1 << 11, 370 FILEUTILS_PRESERVE_SECURITY_CONTEXT = 1 << 14, /* -c */ 371 #endif 372 FILEUTILS_RMDEST = 1 << (15 - !ENABLE_SELINUX), /* --remove-destination */ 373 /* 374 * Hole. cp may have some bits set here, 375 * they should not affect remove_file()/copy_file() 376 */ 377 #if ENABLE_SELINUX 378 FILEUTILS_SET_SECURITY_CONTEXT = 1 << 30, 379 #endif 380 FILEUTILS_IGNORE_CHMOD_ERR = 1 << 31, 337 381 }; 338 #define FILEUTILS_CP_OPTSTR "pdRfilsLH " IF_SELINUX("c")382 #define FILEUTILS_CP_OPTSTR "pdRfilsLHarPvu" IF_SELINUX("c") 339 383 extern int remove_file(const char *path, int flags) FAST_FUNC; 340 384 /* NB: without FILEUTILS_RECUR in flags, it will basically "cat" … … 387 431 /* NB: can violate const-ness (similarly to strchr) */ 388 432 char *last_char_is(const char *s, int c) FAST_FUNC; 389 390 void ndelay_on(int fd) FAST_FUNC; 391 void ndelay_off(int fd) FAST_FUNC; 433 const char* endofname(const char *name) FAST_FUNC; 434 char *is_prefixed_with(const char *string, const char *key) FAST_FUNC; 435 char *is_suffixed_with(const char *string, const char *key) FAST_FUNC; 436 437 int ndelay_on(int fd) FAST_FUNC; 438 int ndelay_off(int fd) FAST_FUNC; 392 439 void close_on_exec_on(int fd) FAST_FUNC; 393 440 void xdup2(int, int) FAST_FUNC; … … 461 508 void xsetgid(gid_t gid) FAST_FUNC; 462 509 void xsetuid(uid_t uid) FAST_FUNC; 510 void xsetegid(gid_t egid) FAST_FUNC; 511 void xseteuid(uid_t euid) FAST_FUNC; 463 512 void xchdir(const char *path) FAST_FUNC; 513 void xfchdir(int fd) FAST_FUNC; 464 514 void xchroot(const char *path) FAST_FUNC; 465 515 void xsetenv(const char *key, const char *value) FAST_FUNC; … … 469 519 void xstat(const char *pathname, struct stat *buf) FAST_FUNC; 470 520 void xfstat(int fd, struct stat *buf, const char *errmsg) FAST_FUNC; 521 int open3_or_warn(const char *pathname, int flags, int mode) FAST_FUNC; 522 int open_or_warn(const char *pathname, int flags) FAST_FUNC; 523 int xopen3(const char *pathname, int flags, int mode) FAST_FUNC; 471 524 int xopen(const char *pathname, int flags) FAST_FUNC; 472 525 int xopen_nonblocking(const char *pathname) FAST_FUNC; 473 int xopen3(const char *pathname, int flags, int mode) FAST_FUNC; 474 int open_or_warn(const char *pathname, int flags) FAST_FUNC; 475 int open3_or_warn(const char *pathname, int flags, int mode) FAST_FUNC; 526 int xopen_as_uid_gid(const char *pathname, int flags, uid_t u, gid_t g) FAST_FUNC; 476 527 int open_or_warn_stdin(const char *pathname) FAST_FUNC; 477 528 int xopen_stdin(const char *pathname) FAST_FUNC; … … 483 534 484 535 uoff_t FAST_FUNC get_volume_size_in_bytes(int fd, 485 486 487 536 const char *override, 537 unsigned override_units, 538 int extend); 488 539 489 540 void xpipe(int filedes[2]) FAST_FUNC; … … 523 574 void parse_datestr(const char *date_str, struct tm *ptm) FAST_FUNC; 524 575 time_t validate_tm_time(const char *date_str, struct tm *ptm) FAST_FUNC; 525 576 char *strftime_HHMMSS(char *buf, unsigned len, time_t *tp) FAST_FUNC; 577 char *strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp) FAST_FUNC; 526 578 527 579 int xsocket(int domain, int type, int protocol) FAST_FUNC; … … 531 583 ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to, 532 584 socklen_t tolen) FAST_FUNC; 585 586 int setsockopt_int(int fd, int level, int optname, int optval) FAST_FUNC; 587 int setsockopt_1(int fd, int level, int optname) FAST_FUNC; 588 int setsockopt_SOL_SOCKET_int(int fd, int optname, int optval) FAST_FUNC; 589 int setsockopt_SOL_SOCKET_1(int fd, int optname) FAST_FUNC; 533 590 /* SO_REUSEADDR allows a server to rebind to an address that is already 534 591 * "in use" by old connections to e.g. previous server instance which is … … 538 595 * Turn it on before you call bind(). */ 539 596 void setsockopt_reuseaddr(int fd) FAST_FUNC; /* On Linux this never fails. */ 597 int setsockopt_keepalive(int fd) FAST_FUNC; 540 598 int setsockopt_broadcast(int fd) FAST_FUNC; 541 599 int setsockopt_bindtodevice(int fd, const char *iface) FAST_FUNC; … … 643 701 char *xstrdup(const char *s) FAST_FUNC RETURNS_MALLOC; 644 702 char *xstrndup(const char *s, int n) FAST_FUNC RETURNS_MALLOC; 703 void *xmemdup(const void *s, int n) FAST_FUNC RETURNS_MALLOC; 645 704 void overlapping_strcpy(char *dst, const char *src) FAST_FUNC; 646 705 char *safe_strncpy(char *dst, const char *src, size_t size) FAST_FUNC; 647 706 char *strncpy_IFNAMSIZ(char *dst, const char *src) FAST_FUNC; 707 unsigned count_strstr(const char *str, const char *sub) FAST_FUNC; 708 char *xmalloc_substitute_string(const char *src, int count, const char *sub, const char *repl) FAST_FUNC; 648 709 /* Guaranteed to NOT be a macro (smallest code). Saves nearly 2k on uclibc. 649 710 * But potentially slow, don't use in one-billion-times loops */ … … 652 713 int bb_putchar_stderr(char ch) FAST_FUNC; 653 714 char *xasprintf(const char *format, ...) __attribute__ ((format(printf, 1, 2))) FAST_FUNC RETURNS_MALLOC; 715 char *auto_string(char *str) FAST_FUNC; 654 716 // gcc-4.1.1 still isn't good enough at optimizing it 655 717 // (+200 bytes compared to macro) … … 677 739 enum { PRINTABLE_META = 0x100 }; 678 740 void fputc_printable(int ch, FILE *file) FAST_FUNC; 741 /* Return a string that is the printable representation of character ch. 742 * Buffer must hold at least four characters. */ 743 enum { 744 VISIBLE_ENDLINE = 1 << 0, 745 VISIBLE_SHOW_TABS = 1 << 1, 746 }; 747 void visible(unsigned ch, char *buf, int flags) FAST_FUNC; 679 748 680 749 /* dmalloc will redefine these to it's own implementation. It is safe … … 697 766 698 767 extern ssize_t safe_read(int fd, void *buf, size_t count) FAST_FUNC; 699 extern ssize_t nonblock_immune_read(int fd, void *buf, size_t count , int loop_on_EINTR) FAST_FUNC;768 extern ssize_t nonblock_immune_read(int fd, void *buf, size_t count) FAST_FUNC; 700 769 // NB: will return short read on error, not -1, 701 770 // if some data was read before error occurred … … 716 785 extern void *xmalloc_xopen_read_close(const char *filename, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; 717 786 787 #if defined(ARG_MAX) && (ARG_MAX >= 60*1024 || !defined(_SC_ARG_MAX)) 788 /* Use _constant_ maximum if: defined && (big enough || no variable one exists) */ 789 # define bb_arg_max() ((unsigned)ARG_MAX) 790 #elif defined(_SC_ARG_MAX) 791 /* Else use variable one (a bit more expensive) */ 792 unsigned bb_arg_max(void) FAST_FUNC; 793 #else 794 /* If all else fails */ 795 # define bb_arg_max() ((unsigned)(32 * 1024)) 796 #endif 797 unsigned bb_clk_tck(void) FAST_FUNC; 798 718 799 #define SEAMLESS_COMPRESSION (0 \ 719 800 || ENABLE_FEATURE_SEAMLESS_XZ \ … … 725 806 #if SEAMLESS_COMPRESSION 726 807 /* Autodetects gzip/bzip2 formats. fd may be in the middle of the file! */ 727 extern int setup_unzip_on_fd(int fd, int fail_if_not_ detected) FAST_FUNC;808 extern int setup_unzip_on_fd(int fd, int fail_if_not_compressed) FAST_FUNC; 728 809 /* Autodetects .gz etc */ 729 extern int open_zipped(const char *fname) FAST_FUNC; 810 extern int open_zipped(const char *fname, int fail_if_not_compressed) FAST_FUNC; 811 extern void *xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; 730 812 #else 731 813 # define setup_unzip_on_fd(...) (0) 732 # define open_zipped(fname )open((fname), O_RDONLY);733 # endif734 extern void *xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; 814 # define open_zipped(fname, fail_if_not_compressed) open((fname), O_RDONLY); 815 # define xmalloc_open_zipped_read_close(fname, maxsz_p) xmalloc_open_read_close((fname), (maxsz_p)) 816 #endif 735 817 736 818 extern ssize_t safe_write(int fd, const void *buf, size_t count) FAST_FUNC; … … 807 889 char *itoa_to_buf(int n, char *buf, unsigned buflen) FAST_FUNC; 808 890 /* Intelligent formatters of bignums */ 809 voidsmart_ulltoa4(unsigned long long ul, char buf[4], const char *scale) FAST_FUNC;810 voidsmart_ulltoa5(unsigned long long ul, char buf[5], const char *scale) FAST_FUNC;891 char *smart_ulltoa4(unsigned long long ul, char buf[4], const char *scale) FAST_FUNC; 892 char *smart_ulltoa5(unsigned long long ul, char buf[5], const char *scale) FAST_FUNC; 811 893 /* If block_size == 0, display size without fractional part, 812 894 * else display (size * block_size) with one decimal digit. … … 831 913 unsigned mult; 832 914 }; 915 extern const struct suffix_mult bkm_suffixes[]; 916 #define km_suffixes (bkm_suffixes + 1) 917 extern const struct suffix_mult cwbkMG_suffixes[]; 918 #define kMG_suffixes (cwbkMG_suffixes + 3) 919 833 920 #include "xatonum.h" 834 921 /* Specialized: */ … … 854 941 /* wrapper: allows string to contain numeric uid or gid */ 855 942 unsigned long get_ug_id(const char *s, long FAST_FUNC (*xname2id)(const char *)) FAST_FUNC; 856 /* from chpst. Does not die, returns 0 on failure */857 943 struct bb_uidgid_t { 858 944 uid_t uid; 859 945 gid_t gid; 860 946 }; 861 /* always sets uid and gid */862 int get_uidgid(struct bb_uidgid_t*, const char* , int numeric_ok) FAST_FUNC;863 /* always sets uid and gid , allows numeric; exits on failure */947 /* always sets uid and gid; returns 0 on failure */ 948 int get_uidgid(struct bb_uidgid_t*, const char*) FAST_FUNC; 949 /* always sets uid and gid; exits on failure */ 864 950 void xget_uidgid(struct bb_uidgid_t*, const char*) FAST_FUNC; 865 951 /* chown-like handling of "user[:[group]" */ … … 890 976 void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname); 891 977 void FAST_FUNC update_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname); 978 void FAST_FUNC update_utmp_DEAD_PROCESS(pid_t pid); 892 979 #else 893 980 # define write_new_utmp(pid, new_type, tty_name, username, hostname) ((void)0) 894 981 # define update_utmp(pid, new_type, tty_name, username, hostname) ((void)0) 895 #endif 896 897 898 int execable_file(const char *name) FAST_FUNC; 899 char *find_execable(const char *filename, char **PATHp) FAST_FUNC; 900 int exists_execable(const char *filename) FAST_FUNC; 982 # define update_utmp_DEAD_PROCESS(pid) ((void)0) 983 #endif 984 985 986 int file_is_executable(const char *name) FAST_FUNC; 987 char *find_executable(const char *filename, char **PATHp) FAST_FUNC; 988 int executable_exists(const char *filename) FAST_FUNC; 901 989 902 990 /* BB_EXECxx always execs (it's not doing NOFORK/NOEXEC stuff), … … 915 1003 #define BB_EXECLP(prog,cmd,...) execlp(prog,cmd,__VA_ARGS__) 916 1004 #endif 917 int BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC; 918 919 /* xvfork() can't be a _function_, return after vfork mangles stack 1005 void BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC; 1006 void exec_prog_or_SHELL(char **argv) NORETURN FAST_FUNC; 1007 1008 /* xvfork() can't be a _function_, return after vfork in child mangles stack 920 1009 * in the parent. It must be a macro. */ 921 1010 #define xvfork() \ … … 929 1018 pid_t xfork(void) FAST_FUNC; 930 1019 #endif 1020 void xvfork_parent_waits_and_exits(void) FAST_FUNC; 931 1021 932 1022 /* NOMMU friendy fork+exec: */ … … 945 1035 */ 946 1036 int wait4pid(pid_t pid) FAST_FUNC; 1037 int wait_for_exitstatus(pid_t pid) FAST_FUNC; 947 1038 /* Same as wait4pid(spawn(argv)), but with NOFORK/NOEXEC if configured: */ 948 1039 int spawn_and_wait(char **argv) FAST_FUNC; … … 1058 1149 }; 1059 1150 extern const char *msg_eol; 1151 extern smallint syslog_level; 1060 1152 extern smallint logmode; 1061 extern int die_sleep;1062 1153 extern uint8_t xfunc_error_retval; 1063 extern jmp_buf die_jmp;1154 extern void (*die_func)(void); 1064 1155 extern void xfunc_die(void) NORETURN FAST_FUNC; 1065 1156 extern void bb_show_usage(void) NORETURN FAST_FUNC; … … 1074 1165 extern void bb_perror_nomsg_and_die(void) NORETURN FAST_FUNC; 1075 1166 extern void bb_perror_nomsg(void) FAST_FUNC; 1076 extern void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;1077 1167 extern void bb_verror_msg(const char *s, va_list p, const char *strerr) FAST_FUNC; 1168 extern void bb_logenv_override(void) FAST_FUNC; 1078 1169 1079 1170 /* We need to export XXX_main from libbusybox … … 1108 1199 1109 1200 /* Networking */ 1110 int create_icmp_socket(void) FAST_FUNC;1111 int create_icmp6_socket(void) FAST_FUNC;1112 /* interface.c */1113 1201 /* This structure defines protocol families and their handlers. */ 1114 1202 struct aftype { … … 1139 1227 extern smallint interface_opt_a; 1140 1228 int display_interfaces(char *ifname) FAST_FUNC; 1229 int in_ether(const char *bufp, struct sockaddr *sap) FAST_FUNC; 1141 1230 #if ENABLE_FEATURE_HWIB 1142 1231 int in_ib(const char *bufp, struct sockaddr *sap) FAST_FUNC; … … 1151 1240 #ifndef BUILD_INDIVIDUAL 1152 1241 extern int find_applet_by_name(const char *name) FAST_FUNC; 1153 /* Returns only if applet is not found. */1154 extern void run_applet_and_exit(const char *name, char **argv) FAST_FUNC;1155 1242 extern void run_applet_no_and_exit(int a, char **argv) NORETURN FAST_FUNC; 1156 1243 #endif … … 1184 1271 int bb_ask_confirmation(void) FAST_FUNC; 1185 1272 1186 int bb_parse_mode(const char* s, mode_t* theMode) FAST_FUNC; 1273 /* Returns -1 if input is invalid. current_mode is a base for e.g. "u+rw" */ 1274 int bb_parse_mode(const char* s, unsigned cur_mode) FAST_FUNC; 1187 1275 1188 1276 /* … … 1240 1328 char *bb_simplify_abs_path_inplace(char *path) FAST_FUNC; 1241 1329 1330 #ifndef LOGIN_FAIL_DELAY 1242 1331 #define LOGIN_FAIL_DELAY 3 1332 #endif 1243 1333 extern void bb_do_delay(int seconds) FAST_FUNC; 1244 1334 extern void change_identity(const struct passwd *pw) FAST_FUNC; … … 1262 1352 #endif 1263 1353 extern void selinux_or_die(void) FAST_FUNC; 1264 1265 1266 /* systemd support */1267 #define SD_LISTEN_FDS_START 31268 int sd_listen_fds(void);1269 1354 1270 1355 … … 1288 1373 #define SETUP_ENV_TO_TMP (1 << 2) 1289 1374 #define SETUP_ENV_NO_CHDIR (1 << 4) 1290 extern void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC; 1291 extern int correct_password(const struct passwd *pw) FAST_FUNC; 1375 void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC; 1376 void nuke_str(char *str) FAST_FUNC; 1377 int check_password(const struct passwd *pw, const char *plaintext) FAST_FUNC; 1378 int ask_and_check_password_extended(const struct passwd *pw, int timeout, const char *prompt) FAST_FUNC; 1379 int ask_and_check_password(const struct passwd *pw) FAST_FUNC; 1292 1380 /* Returns a malloced string */ 1293 1381 #if !ENABLE_USE_BB_CRYPT … … 1332 1420 /* NB: typically you want to pass fd 0, not 1. Think 'applet | grep something' */ 1333 1421 int get_terminal_width_height(int fd, unsigned *width, unsigned *height) FAST_FUNC; 1422 int get_terminal_width(int fd) FAST_FUNC; 1334 1423 1335 1424 int tcsetattr_stdin_TCSANOW(const struct termios *tp) FAST_FUNC; … … 1435 1524 # if defined CONFIG_FEATURE_EDITING_HISTORY && CONFIG_FEATURE_EDITING_HISTORY > 0 1436 1525 # define MAX_HISTORY (CONFIG_FEATURE_EDITING_HISTORY + 0) 1437 unsigned size_from_HISTFILESIZE(const char *hp) ;1526 unsigned size_from_HISTFILESIZE(const char *hp) FAST_FUNC; 1438 1527 # else 1439 1528 # define MAX_HISTORY 0 … … 1477 1566 */ 1478 1567 int read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize, int timeout) FAST_FUNC; 1568 void show_history(const line_input_t *st) FAST_FUNC; 1479 1569 # if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT 1480 1570 void save_history(line_input_t *st); … … 1689 1779 uoff_t totalsize) FAST_FUNC; 1690 1780 1781 unsigned ubi_devnum_from_devname(const char *str) FAST_FUNC; 1782 int ubi_get_volid_by_name(unsigned ubi_devnum, const char *vol_name) FAST_FUNC; 1783 1691 1784 1692 1785 extern const char *applet_name; … … 1712 1805 extern const char bb_msg_you_must_be_root[] ALIGN1; 1713 1806 extern const char bb_msg_requires_arg[] ALIGN1; 1714 extern const char bb_msg_invalid_arg [] ALIGN1;1807 extern const char bb_msg_invalid_arg_to[] ALIGN1; 1715 1808 extern const char bb_msg_standard_input[] ALIGN1; 1716 1809 extern const char bb_msg_standard_output[] ALIGN1; … … 1741 1834 1742 1835 extern const int const_int_0; 1743 extern const int const_int_1; 1744 1745 1746 /* Providing hard guarantee on minimum size (think of BUFSIZ == 128) */ 1747 enum { COMMON_BUFSIZE = (BUFSIZ >= 256*sizeof(void*) ? BUFSIZ+1 : 256*sizeof(void*)) }; 1748 extern char bb_common_bufsiz1[COMMON_BUFSIZE]; 1836 //extern const int const_int_1; 1837 1749 1838 /* This struct is deliberately not defined. */ 1750 1839 /* See docs/keep_data_small.txt */ … … 1759 1848 (*(struct globals**)&ptr_to_globals) = (void*)(x); \ 1760 1849 barrier(); \ 1850 } while (0) 1851 #define FREE_PTR_TO_GLOBALS() do { \ 1852 if (ENABLE_FEATURE_CLEAN_UP) { \ 1853 free(ptr_to_globals); \ 1854 } \ 1761 1855 } while (0) 1762 1856 … … 1801 1895 # define VC_5 "/dev/vc/5" 1802 1896 # define VC_FORMAT "/dev/vc/%d" 1803 # define LOOP_FORMAT "/dev/loop/% d"1897 # define LOOP_FORMAT "/dev/loop/%u" 1804 1898 # define LOOP_NAMESIZE (sizeof("/dev/loop/") + sizeof(int)*3 + 1) 1805 1899 # define LOOP_NAME "/dev/loop/" … … 1814 1908 # define VC_5 "/dev/tty5" 1815 1909 # define VC_FORMAT "/dev/tty%d" 1816 # define LOOP_FORMAT "/dev/loop% d"1910 # define LOOP_FORMAT "/dev/loop%u" 1817 1911 # define LOOP_NAMESIZE (sizeof("/dev/loop") + sizeof(int)*3 + 1) 1818 1912 # define LOOP_NAME "/dev/loop" … … 1822 1916 1823 1917 #define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0]))) 1918 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) 1824 1919 1825 1920 … … 1907 2002 1908 2003 2004 /* Simple unit-testing framework */ 2005 2006 typedef void (*bbunit_testfunc)(void); 2007 2008 struct bbunit_listelem { 2009 const char* name; 2010 bbunit_testfunc testfunc; 2011 }; 2012 2013 void bbunit_registertest(struct bbunit_listelem* test); 2014 void bbunit_settestfailed(void); 2015 2016 #define BBUNIT_DEFINE_TEST(NAME) \ 2017 static void bbunit_##NAME##_test(void); \ 2018 static struct bbunit_listelem bbunit_##NAME##_elem = { \ 2019 .name = #NAME, \ 2020 .testfunc = bbunit_##NAME##_test, \ 2021 }; \ 2022 static void INIT_FUNC bbunit_##NAME##_register(void) \ 2023 { \ 2024 bbunit_registertest(&bbunit_##NAME##_elem); \ 2025 } \ 2026 static void bbunit_##NAME##_test(void) 2027 2028 /* 2029 * Both 'goto bbunit_end' and 'break' are here only to get rid 2030 * of compiler warnings. 2031 */ 2032 #define BBUNIT_ENDTEST \ 2033 do { \ 2034 goto bbunit_end; \ 2035 bbunit_end: \ 2036 break; \ 2037 } while (0) 2038 2039 #define BBUNIT_PRINTASSERTFAIL \ 2040 do { \ 2041 bb_error_msg( \ 2042 "[ERROR] Assertion failed in file %s, line %d", \ 2043 __FILE__, __LINE__); \ 2044 } while (0) 2045 2046 #define BBUNIT_ASSERTION_FAILED \ 2047 do { \ 2048 bbunit_settestfailed(); \ 2049 goto bbunit_end; \ 2050 } while (0) 2051 2052 /* 2053 * Assertions. 2054 * For now we only offer assertions which cause tests to fail 2055 * immediately. In the future 'expects' might be added too - 2056 * similar to those offered by the gtest framework. 2057 */ 2058 #define BBUNIT_ASSERT_EQ(EXPECTED, ACTUAL) \ 2059 do { \ 2060 if ((EXPECTED) != (ACTUAL)) { \ 2061 BBUNIT_PRINTASSERTFAIL; \ 2062 bb_error_msg("[ERROR] '%s' isn't equal to '%s'", \ 2063 #EXPECTED, #ACTUAL); \ 2064 BBUNIT_ASSERTION_FAILED; \ 2065 } \ 2066 } while (0) 2067 2068 #define BBUNIT_ASSERT_NOTEQ(EXPECTED, ACTUAL) \ 2069 do { \ 2070 if ((EXPECTED) == (ACTUAL)) { \ 2071 BBUNIT_PRINTASSERTFAIL; \ 2072 bb_error_msg("[ERROR] '%s' is equal to '%s'", \ 2073 #EXPECTED, #ACTUAL); \ 2074 BBUNIT_ASSERTION_FAILED; \ 2075 } \ 2076 } while (0) 2077 2078 #define BBUNIT_ASSERT_NOTNULL(PTR) \ 2079 do { \ 2080 if ((PTR) == NULL) { \ 2081 BBUNIT_PRINTASSERTFAIL; \ 2082 bb_error_msg("[ERROR] '%s' is NULL!", #PTR); \ 2083 BBUNIT_ASSERTION_FAILED; \ 2084 } \ 2085 } while (0) 2086 2087 #define BBUNIT_ASSERT_NULL(PTR) \ 2088 do { \ 2089 if ((PTR) != NULL) { \ 2090 BBUNIT_PRINTASSERTFAIL; \ 2091 bb_error_msg("[ERROR] '%s' is not NULL!", #PTR); \ 2092 BBUNIT_ASSERTION_FAILED; \ 2093 } \ 2094 } while (0) 2095 2096 #define BBUNIT_ASSERT_FALSE(STATEMENT) \ 2097 do { \ 2098 if ((STATEMENT)) { \ 2099 BBUNIT_PRINTASSERTFAIL; \ 2100 bb_error_msg("[ERROR] Statement '%s' evaluated to true!", \ 2101 #STATEMENT); \ 2102 BBUNIT_ASSERTION_FAILED; \ 2103 } \ 2104 } while (0) 2105 2106 #define BBUNIT_ASSERT_TRUE(STATEMENT) \ 2107 do { \ 2108 if (!(STATEMENT)) { \ 2109 BBUNIT_PRINTASSERTFAIL; \ 2110 bb_error_msg("[ERROR] Statement '%s' evaluated to false!", \ 2111 #STATEMENT); \ 2112 BBUNIT_ASSERTION_FAILED; \ 2113 } \ 2114 } while (0) 2115 2116 #define BBUNIT_ASSERT_STREQ(STR1, STR2) \ 2117 do { \ 2118 if (strcmp(STR1, STR2) != 0) { \ 2119 BBUNIT_PRINTASSERTFAIL; \ 2120 bb_error_msg("[ERROR] Strings '%s' and '%s' " \ 2121 "are not the same", STR1, STR2); \ 2122 BBUNIT_ASSERTION_FAILED; \ 2123 } \ 2124 } while (0) 2125 2126 #define BBUNIT_ASSERT_STRNOTEQ(STR1, STR2) \ 2127 do { \ 2128 if (strcmp(STR1, STR2) == 0) { \ 2129 BBUNIT_PRINTASSERTFAIL; \ 2130 bb_error_msg("[ERROR] Strings '%s' and '%s' " \ 2131 "are the same, but were " \ 2132 "expected to differ", STR1, STR2); \ 2133 BBUNIT_ASSERTION_FAILED; \ 2134 } \ 2135 } while (0) 2136 2137 1909 2138 POP_SAVED_FUNCTION_VISIBILITY 1910 2139 -
branches/3.3/mindi-busybox/include/liblzo_interface.h
r2725 r3621 31 31 static void die_at(int line) 32 32 { 33 33 bb_error_msg_and_die("internal error at %d", line); 34 34 } 35 35 #define assert(v) if (!(v)) die_at(__LINE__) -
branches/3.3/mindi-busybox/include/platform.h
r3232 r3621 76 76 # define UNUSED_PARAM_RESULT 77 77 #endif 78 79 /* used by unit test machinery to run registration functions before calling main() */ 80 #define INIT_FUNC __attribute__ ((constructor)) 78 81 79 82 /* -fwhole-program makes all symbols local. The attribute externally_visible … … 209 212 typedef uint16_t bb__aliased_uint16_t FIX_ALIASING; 210 213 typedef uint32_t bb__aliased_uint32_t FIX_ALIASING; 214 typedef uint64_t bb__aliased_uint64_t FIX_ALIASING; 211 215 212 216 /* NB: unaligned parameter should be a pointer, aligned one - … … 214 218 */ 215 219 #if defined(i386) || defined(__x86_64__) || defined(__powerpc__) 220 # define BB_UNALIGNED_MEMACCESS_OK 1 216 221 # define move_from_unaligned_int(v, intp) ((v) = *(bb__aliased_int*)(intp)) 217 222 # define move_from_unaligned_long(v, longp) ((v) = *(bb__aliased_long*)(longp)) … … 222 227 /* #elif ... - add your favorite arch today! */ 223 228 #else 229 # define BB_UNALIGNED_MEMACCESS_OK 0 224 230 /* performs reasonably well (gcc usually inlines memcpy here) */ 225 231 # define move_from_unaligned_int(v, intp) (memcpy(&(v), (intp), sizeof(int))) … … 264 270 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 265 271 272 #ifdef __UCLIBC__ 273 # define UCLIBC_VERSION KERNEL_VERSION(__UCLIBC_MAJOR__, __UCLIBC_MINOR__, __UCLIBC_SUBLEVEL__) 274 #else 275 # define UCLIBC_VERSION 0 276 #endif 277 266 278 267 279 /* ---- Miscellaneous --------------------------------------- */ … … 306 318 */ 307 319 #if ENABLE_NOMMU || \ 308 (defined __UCLIBC__ && __UCLIBC_MAJOR__ >= 0 && __UCLIBC_MINOR__ >= 9 && \ 309 __UCLIBC_SUBLEVEL__ > 28 && !defined __ARCH_USE_MMU__) 320 (defined __UCLIBC__ && \ 321 UCLIBC_VERSION > KERNEL_VERSION(0, 9, 28) && \ 322 !defined __ARCH_USE_MMU__) 310 323 # define BB_MMU 0 311 324 # define USE_FOR_NOMMU(...) __VA_ARGS__ … … 356 369 #define HAVE_MEMRCHR 1 357 370 #define HAVE_MKDTEMP 1 371 #define HAVE_TTYNAME_R 1 358 372 #define HAVE_PTSNAME_R 1 359 373 #define HAVE_SETBIT 1 360 374 #define HAVE_SIGHANDLER_T 1 361 375 #define HAVE_STPCPY 1 376 #define HAVE_MEMPCPY 1 362 377 #define HAVE_STRCASESTR 1 363 378 #define HAVE_STRCHRNUL 1 … … 366 381 #define HAVE_STRVERSCMP 1 367 382 #define HAVE_VASPRINTF 1 383 #define HAVE_USLEEP 1 368 384 #define HAVE_UNLOCKED_STDIO 1 369 385 #define HAVE_UNLOCKED_LINE_OPS 1 … … 374 390 #define HAVE_SYS_STATFS_H 1 375 391 376 #if defined(__UCLIBC_MAJOR__) 377 # if __UCLIBC_MAJOR__ == 0 \ 378 && ( __UCLIBC_MINOR__ < 9 \ 379 || (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ < 32) \ 380 ) 392 #if defined(__UCLIBC__) 393 # if UCLIBC_VERSION < KERNEL_VERSION(0, 9, 32) 381 394 # undef HAVE_STRVERSCMP 382 395 # endif 383 #endif 384 385 #if defined(__dietlibc__) 386 # undef HAVE_STRCHRNUL 396 # if UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 30) 397 # ifndef __UCLIBC_SUSV3_LEGACY__ 398 # undef HAVE_USLEEP 399 # endif 400 # endif 387 401 #endif 388 402 … … 417 431 #if (defined __digital__ && defined __unix__) \ 418 432 || defined __APPLE__ \ 419 || defined __ FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__433 || defined __OpenBSD__ || defined __NetBSD__ 420 434 # undef HAVE_CLEARENV 421 435 # undef HAVE_FDATASYNC … … 432 446 #endif 433 447 448 #if defined(__dietlibc__) 449 # undef HAVE_STRCHRNUL 450 #endif 451 452 #if defined(__APPLE__) 453 # undef HAVE_STRCHRNUL 454 #endif 455 434 456 #if defined(__FreeBSD__) 435 # undef HAVE_STRCHRNUL 457 /* users say mempcpy is not present in FreeBSD 9.x */ 458 # undef HAVE_MEMPCPY 459 # undef HAVE_CLEARENV 460 # undef HAVE_FDATASYNC 461 # undef HAVE_MNTENT_H 462 # undef HAVE_PTSNAME_R 463 # undef HAVE_SYS_STATFS_H 464 # undef HAVE_SIGHANDLER_T 465 # undef HAVE_STRVERSCMP 466 # undef HAVE_XTABS 467 # undef HAVE_UNLOCKED_LINE_OPS 468 # include <osreldate.h> 469 # if __FreeBSD_version < 1000029 470 # undef HAVE_STRCHRNUL /* FreeBSD added strchrnul() between 1000028 and 1000029 */ 471 # endif 436 472 #endif 437 473 … … 445 481 446 482 #if defined(ANDROID) || defined(__ANDROID__) 447 # undef HAVE_DPRINTF 448 # undef HAVE_GETLINE 449 # undef HAVE_STPCPY 483 # if __ANDROID_API__ < 8 484 /* ANDROID < 8 has no [f]dprintf at all */ 485 # undef HAVE_DPRINTF 486 # elif __ANDROID_API__ < 21 487 /* ANDROID < 21 has fdprintf */ 488 # define dprintf fdprintf 489 # else 490 /* ANDROID >= 21 has standard dprintf */ 491 # endif 492 # if __ANDROID_API__ < 21 493 # undef HAVE_TTYNAME_R 494 # undef HAVE_GETLINE 495 # undef HAVE_STPCPY 496 # endif 497 # undef HAVE_MEMPCPY 450 498 # undef HAVE_STRCHRNUL 451 499 # undef HAVE_STRVERSCMP … … 471 519 #endif 472 520 521 #ifndef HAVE_TTYNAME_R 522 #define ttyname_r bb_ttyname_r 523 extern int ttyname_r(int fd, char *buf, size_t buflen); 524 #endif 525 473 526 #ifndef HAVE_SETBIT 474 527 # define setbit(a, b) ((a)[(b) >> 3] |= 1 << ((b) & 7)) … … 484 537 #endif 485 538 539 #ifndef HAVE_MEMPCPY 540 #include <string.h> 541 /* In case we are wrong about !HAVE_MEMPCPY, and toolchain _does_ have 542 * mempcpy(), avoid colliding with it: 543 */ 544 #define mempcpy bb__mempcpy 545 static ALWAYS_INLINE void *mempcpy(void *dest, const void *src, size_t len) 546 { 547 return memcpy(dest, src, len) + len; 548 } 549 #endif 550 486 551 #ifndef HAVE_STRCASESTR 487 552 extern char *strcasestr(const char *s, const char *pattern) FAST_FUNC; … … 499 564 /* Not exactly the same: instead of "Stopped" it shows "STOP" etc */ 500 565 # define strsignal(sig) get_signame(sig) 566 #endif 567 568 #ifndef HAVE_USLEEP 569 extern int usleep(unsigned) FAST_FUNC; 501 570 #endif 502 571 -
branches/3.3/mindi-busybox/include/pwd_.h
r3232 r3621 35 35 #define endpwent bb_internal_endpwent 36 36 #define getpwent bb_internal_getpwent 37 #define fgetpwent bb_internal_fgetpwent38 #define putpwent bb_internal_putpwent39 37 #define getpwuid bb_internal_getpwuid 40 38 #define getpwnam bb_internal_getpwnam 41 #define getpwent_r bb_internal_getpwent_r42 #define getpwuid_r bb_internal_getpwuid_r43 39 #define getpwnam_r bb_internal_getpwnam_r 44 #define fgetpwent_r bb_internal_fgetpwent_r45 46 40 47 41 /* All function names below should be remapped by #defines above 48 42 * in order to not collide with libc names. */ 49 43 50 51 44 /* Rewind the password-file stream. */ 52 extern voidsetpwent(void);45 void FAST_FUNC setpwent(void); 53 46 54 47 /* Close the password-file stream. */ 55 extern voidendpwent(void);48 void FAST_FUNC endpwent(void); 56 49 57 #ifdef UNUSED_SINCE_WE_AVOID_STATIC_BUFS58 50 /* Read an entry from the password-file stream, opening it if necessary. */ 59 extern struct passwd *getpwent(void); 60 61 /* Read an entry from STREAM. */ 62 extern struct passwd *fgetpwent(FILE *__stream); 63 64 /* Write the given entry onto the given stream. */ 65 extern int putpwent(const struct passwd *__restrict __p, 66 FILE *__restrict __f); 67 #endif 51 struct passwd* FAST_FUNC getpwent(void); 68 52 69 53 /* Search for an entry with a matching user ID. */ 70 extern struct passwd *getpwuid(uid_t __uid);54 struct passwd* FAST_FUNC getpwuid(uid_t __uid); 71 55 72 56 /* Search for an entry with a matching username. */ 73 extern struct passwd *getpwnam(const char *__name);57 struct passwd* FAST_FUNC getpwnam(const char *__name); 74 58 75 /* Reentrant versions of some of the functions above. 76 77 PLEASE NOTE: the `getpwent_r' function is not (yet) standardized. 78 The interface may change in later versions of this library. But 79 the interface is designed following the principals used for the 80 other reentrant functions so the chances are good this is what the 81 POSIX people would choose. */ 82 83 extern int getpwent_r(struct passwd *__restrict __resultbuf, 84 char *__restrict __buffer, size_t __buflen, 85 struct passwd **__restrict __result); 86 87 extern int getpwuid_r(uid_t __uid, 88 struct passwd *__restrict __resultbuf, 89 char *__restrict __buffer, size_t __buflen, 90 struct passwd **__restrict __result); 91 92 extern int getpwnam_r(const char *__restrict __name, 93 struct passwd *__restrict __resultbuf, 94 char *__restrict __buffer, size_t __buflen, 95 struct passwd **__restrict __result); 96 97 /* Read an entry from STREAM. This function is not standardized and 98 probably never will. */ 99 extern int fgetpwent_r(FILE *__restrict __stream, 59 /* Reentrant versions of some of the functions above. */ 60 int FAST_FUNC getpwnam_r(const char *__restrict __name, 100 61 struct passwd *__restrict __resultbuf, 101 62 char *__restrict __buffer, size_t __buflen, -
branches/3.3/mindi-busybox/include/shadow_.h
r3232 r3621 58 58 #ifdef UNUSED_FOR_NOW 59 59 /* Open database for reading */ 60 extern voidsetspent(void);60 void FAST_FUNC setspent(void); 61 61 62 62 /* Close database */ 63 extern voidendspent(void);63 void FAST_FUNC endspent(void); 64 64 65 65 /* Get next entry from database, perhaps after opening the file */ 66 extern struct spwd *getspent(void);66 struct spwd* FAST_FUNC getspent(void); 67 67 68 68 /* Get shadow entry matching NAME */ 69 extern struct spwd *getspnam(const char *__name);69 struct spwd* FAST_FUNC getspnam(const char *__name); 70 70 71 71 /* Read shadow entry from STRING */ 72 extern struct spwd *sgetspent(const char *__string);72 struct spwd* FAST_FUNC sgetspent(const char *__string); 73 73 74 74 /* Read next shadow entry from STREAM */ 75 extern struct spwd *fgetspent(FILE *__stream);75 struct spwd* FAST_FUNC fgetspent(FILE *__stream); 76 76 77 77 /* Write line containing shadow password entry to stream */ 78 extern intputspent(const struct spwd *__p, FILE *__stream);78 int FAST_FUNC putspent(const struct spwd *__p, FILE *__stream); 79 79 80 80 /* Reentrant versions of some of the functions above */ 81 extern intgetspent_r(struct spwd *__result_buf, char *__buffer,81 int FAST_FUNC getspent_r(struct spwd *__result_buf, char *__buffer, 82 82 size_t __buflen, struct spwd **__result); 83 83 #endif 84 84 85 extern intgetspnam_r(const char *__name, struct spwd *__result_buf,85 int FAST_FUNC getspnam_r(const char *__name, struct spwd *__result_buf, 86 86 char *__buffer, size_t __buflen, 87 87 struct spwd **__result); 88 88 89 89 #ifdef UNUSED_FOR_NOW 90 extern intsgetspent_r(const char *__string, struct spwd *__result_buf,90 int FAST_FUNC sgetspent_r(const char *__string, struct spwd *__result_buf, 91 91 char *__buffer, size_t __buflen, 92 92 struct spwd **__result); 93 93 94 extern intfgetspent_r(FILE *__stream, struct spwd *__result_buf,94 int FAST_FUNC fgetspent_r(FILE *__stream, struct spwd *__result_buf, 95 95 char *__buffer, size_t __buflen, 96 96 struct spwd **__result); 97 97 /* Protect password file against multi writers */ 98 extern intlckpwdf(void);98 int FAST_FUNC lckpwdf(void); 99 99 100 100 /* Unlock password file */ 101 extern intulckpwdf(void);101 int FAST_FUNC ulckpwdf(void); 102 102 #endif 103 103
Note:
See TracChangeset
for help on using the changeset viewer.