Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/include


Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (8 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

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  
    99/*
    1010name  - applet name as it is typed on command line
    11 name2 - applet name, converted to C (ether-wake: name2 = ether_wake)
     11help  - applet name, converted to C (ether-wake: help = ether_wake)
    1212main  - corresponding <applet>_main to call (bzcat: main = bunzip2)
    1313l     - location to install link to: [/usr]/[s]bin
     
    2525#if defined(PROTOTYPES)
    2626# 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 name
    33 # define APPLET_ODDNAME(name,main,l,s,name2) name main##_main name2
    34 # define APPLET_NOEXEC(name,main,l,s,name2)  name main##_main name2
    35 # define APPLET_NOFORK(name,main,l,s,name2)  name main##_main name2
     27# 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
    3636
    3737#elif defined(MAKE_USAGE) && ENABLE_FEATURE_VERBOSE_USAGE
    3838# 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)
    4242
    4343#elif defined(MAKE_USAGE) && !ENABLE_FEATURE_VERBOSE_USAGE
    4444# 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)
    4848
    4949#elif defined(MAKE_LINKS)
    5050# 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
    5460
    5561#else
    5662  static struct bb_applet applets[] = { /*    name, main, location, need_suid */
    5763# 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 },
    6167#endif
    6268
     
    7177IF_TEST(APPLET_NOFORK([[, test, BB_DIR_USR_BIN, BB_SUID_DROP, test))
    7278IF_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))
    7579IF_ADJTIMEX(APPLET(adjtimex, BB_DIR_SBIN, BB_SUID_DROP))
    76 IF_AR(APPLET(ar, BB_DIR_USR_BIN, BB_SUID_DROP))
    7780IF_ARP(APPLET(arp, BB_DIR_SBIN, BB_SUID_DROP))
    7881IF_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))
    8082IF_BASENAME(APPLET_NOFORK(basename, basename, BB_DIR_USR_BIN, BB_SUID_DROP, basename))
    8183IF_BBCONFIG(APPLET(bbconfig, BB_DIR_BIN, BB_SUID_DROP))
     
    8385IF_BLKID(APPLET(blkid, BB_DIR_SBIN, BB_SUID_DROP))
    8486IF_BRCTL(APPLET(brctl, BB_DIR_USR_SBIN, BB_SUID_DROP))
    85 IF_BZIP2(APPLET(bzip2, BB_DIR_USR_BIN, BB_SUID_DROP))
    8687IF_CAL(APPLET(cal, BB_DIR_USR_BIN, BB_SUID_DROP))
    8788IF_CAT(APPLET_NOFORK(cat, cat, BB_DIR_BIN, BB_SUID_DROP, cat))
    8889IF_CATV(APPLET(catv, BB_DIR_BIN, BB_SUID_DROP))
    8990IF_CHAT(APPLET(chat, BB_DIR_USR_SBIN, BB_SUID_DROP))
    90 IF_CHATTR(APPLET(chattr, BB_DIR_BIN, BB_SUID_DROP))
    9191IF_CHCON(APPLET(chcon, BB_DIR_USR_BIN, BB_SUID_DROP))
    9292IF_CHGRP(APPLET_NOEXEC(chgrp, chgrp, BB_DIR_BIN, BB_SUID_DROP, chgrp))
    9393IF_CHMOD(APPLET_NOEXEC(chmod, chmod, BB_DIR_BIN, BB_SUID_DROP, chmod))
    9494IF_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))
    9795IF_CHROOT(APPLET(chroot, BB_DIR_USR_SBIN, BB_SUID_DROP))
    9896IF_CHRT(APPLET(chrt, BB_DIR_USR_BIN, BB_SUID_DROP))
     
    10098IF_CKSUM(APPLET_NOEXEC(cksum, cksum, BB_DIR_USR_BIN, BB_SUID_DROP, cksum))
    10199IF_CLEAR(APPLET(clear, BB_DIR_USR_BIN, BB_SUID_DROP))
    102 IF_CMP(APPLET(cmp, BB_DIR_USR_BIN, BB_SUID_DROP))
    103100IF_COMM(APPLET(comm, BB_DIR_USR_BIN, BB_SUID_DROP))
    104101IF_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))
    107102/* Needs to be run by root or be suid root - needs to change /var/spool/cron* files: */
    108103IF_CRONTAB(APPLET(crontab, BB_DIR_USR_BIN, BB_SUID_REQUIRE))
    109 IF_CRYPTPW(APPLET(cryptpw, BB_DIR_USR_BIN, BB_SUID_DROP))
    110104IF_CUT(APPLET_NOEXEC(cut, cut, BB_DIR_USR_BIN, BB_SUID_DROP, cut))
    111105IF_DC(APPLET(dc, BB_DIR_USR_BIN, BB_SUID_DROP))
    112106IF_DD(APPLET_NOEXEC(dd, dd, BB_DIR_BIN, BB_SUID_DROP, dd))
    113107IF_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))
    116108IF_DEVFSD(APPLET(devfsd, BB_DIR_SBIN, BB_SUID_DROP))
    117109IF_DEVMEM(APPLET(devmem, BB_DIR_SBIN, BB_SUID_DROP))
    118110IF_DF(APPLET(df, BB_DIR_BIN, BB_SUID_DROP))
    119111IF_DHCPRELAY(APPLET(dhcprelay, BB_DIR_USR_SBIN, BB_SUID_DROP))
    120 IF_DIFF(APPLET(diff, BB_DIR_USR_BIN, BB_SUID_DROP))
    121112IF_DIRNAME(APPLET_NOFORK(dirname, dirname, BB_DIR_USR_BIN, BB_SUID_DROP, dirname))
    122113IF_DMESG(APPLET(dmesg, BB_DIR_BIN, BB_SUID_DROP))
     
    124115IF_HOSTNAME(APPLET_ODDNAME(dnsdomainname, hostname, BB_DIR_BIN, BB_SUID_DROP, dnsdomainname))
    125116IF_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))
    128117IF_DU(APPLET(du, BB_DIR_USR_BIN, BB_SUID_DROP))
    129118IF_DUMPKMAP(APPLET(dumpkmap, BB_DIR_BIN, BB_SUID_DROP))
     
    132121//IF_E2LABEL(APPLET_ODDNAME(e2label, tune2fs, BB_DIR_SBIN, BB_SUID_DROP, e2label))
    133122IF_ECHO(APPLET_NOFORK(echo, echo, BB_DIR_BIN, BB_SUID_DROP, echo))
    134 IF_ED(APPLET(ed, BB_DIR_BIN, BB_SUID_DROP))
    135123IF_EJECT(APPLET(eject, BB_DIR_USR_BIN, BB_SUID_DROP))
    136124IF_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))
    139125IF_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, BB_DIR_USR_SBIN, BB_SUID_DROP, ether_wake))
    140126IF_EXPAND(APPLET(expand, BB_DIR_USR_BIN, BB_SUID_DROP))
     
    158144IF_FREE(APPLET(free, BB_DIR_USR_BIN, BB_SUID_DROP))
    159145IF_FREERAMDISK(APPLET(freeramdisk, BB_DIR_SBIN, BB_SUID_DROP))
    160 IF_FSCK(APPLET(fsck, BB_DIR_SBIN, BB_SUID_DROP))
    161146//IF_E2FSCK(APPLET_ODDNAME(fsck.ext2, e2fsck, BB_DIR_SBIN, BB_SUID_DROP, fsck_ext2))
    162147//IF_E2FSCK(APPLET_ODDNAME(fsck.ext3, e2fsck, BB_DIR_SBIN, BB_SUID_DROP, fsck_ext3))
     
    170155IF_GETOPT(APPLET(getopt, BB_DIR_BIN, BB_SUID_DROP))
    171156IF_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))
    175157IF_HD(APPLET_NOEXEC(hd, hexdump, BB_DIR_USR_BIN, BB_SUID_DROP, hd))
    176158IF_HDPARM(APPLET(hdparm, BB_DIR_SBIN, BB_SUID_DROP))
     
    208190IF_KILLALL(APPLET_ODDNAME(killall, kill, BB_DIR_USR_BIN, BB_SUID_DROP, killall))
    209191IF_KILLALL5(APPLET_ODDNAME(killall5, kill, BB_DIR_USR_SBIN, BB_SUID_DROP, killall5))
    210 IF_KLOGD(APPLET(klogd, BB_DIR_SBIN, BB_SUID_DROP))
    211192IF_LAST(APPLET(last, BB_DIR_USR_BIN, BB_SUID_DROP))
    212193//IF_LENGTH(APPLET_NOFORK(length, length, BB_DIR_USR_BIN, BB_SUID_DROP, length))
    213194IF_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))
    216195IF_LN(APPLET_NOEXEC(ln, ln, BB_DIR_BIN, BB_SUID_DROP, ln))
    217196IF_LOAD_POLICY(APPLET(load_policy, BB_DIR_USR_SBIN, BB_SUID_DROP))
    218197IF_LOADFONT(APPLET(loadfont, BB_DIR_USR_SBIN, BB_SUID_DROP))
    219198IF_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))
    223199IF_LOGNAME(APPLET_NOFORK(logname, logname, BB_DIR_USR_BIN, BB_SUID_DROP, logname))
    224 IF_LOGREAD(APPLET(logread, BB_DIR_SBIN, BB_SUID_DROP))
    225200IF_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))
    229201IF_LS(APPLET_NOEXEC(ls, ls, BB_DIR_BIN, BB_SUID_DROP, ls))
    230 IF_LSATTR(APPLET(lsattr, BB_DIR_BIN, BB_SUID_DROP))
    231202IF_LSPCI(APPLET(lspci, BB_DIR_USR_BIN, BB_SUID_DROP))
    232203IF_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))
    237204IF_MAKEDEVS(APPLET(makedevs, BB_DIR_SBIN, BB_SUID_DROP))
    238205IF_MAKEMIME(APPLET(makemime, BB_DIR_BIN, BB_SUID_DROP))
    239 IF_MAN(APPLET(man, BB_DIR_SBIN, BB_SUID_DROP))
     206IF_MAN(APPLET(man, BB_DIR_USR_BIN, BB_SUID_DROP))
    240207IF_MATCHPATHCON(APPLET(matchpathcon, BB_DIR_USR_SBIN, BB_SUID_DROP))
    241208IF_MD5SUM(APPLET_NOEXEC(md5sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, md5sum))
     
    251218IF_MKFS_VFAT(APPLET_ODDNAME(mkfs.vfat, mkfs_vfat, BB_DIR_SBIN, BB_SUID_DROP, mkfs_vfat))
    252219IF_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))
    254220IF_MKSWAP(APPLET(mkswap, BB_DIR_SBIN, BB_SUID_DROP))
    255 IF_MKTEMP(APPLET(mktemp, BB_DIR_BIN, BB_SUID_DROP))
    256221IF_MORE(APPLET(more, BB_DIR_BIN, BB_SUID_DROP))
    257222/* On full-blown systems, requires suid for user mounts.
     
    273238IF_OPENVT(APPLET(openvt, BB_DIR_USR_BIN, BB_SUID_DROP))
    274239//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))
    277240IF_PGREP(APPLET(pgrep, BB_DIR_USR_BIN, BB_SUID_DROP))
    278241IF_PIDOF(APPLET(pidof, BB_DIR_BIN, BB_SUID_DROP))
    279 IF_PIPE_PROGRESS(APPLET(pipe_progress, BB_DIR_BIN, BB_SUID_DROP))
    280242IF_PIVOT_ROOT(APPLET(pivot_root, BB_DIR_SBIN, BB_SUID_DROP))
    281243IF_PKILL(APPLET_ODDNAME(pkill, pgrep, BB_DIR_USR_BIN, BB_SUID_DROP, pkill))
     
    298260IF_RESIZE(APPLET(resize, BB_DIR_USR_BIN, BB_SUID_DROP))
    299261IF_RESTORECON(APPLET_ODDNAME(restorecon, setfiles, BB_DIR_SBIN, BB_SUID_DROP, restorecon))
    300 IF_RFKILL(APPLET(rfkill, BB_DIR_USR_SBIN, BB_SUID_DROP))
    301262IF_RM(APPLET_NOFORK(rm, rm, BB_DIR_BIN, BB_SUID_DROP, rm))
    302263IF_RMDIR(APPLET_NOFORK(rmdir, rmdir, BB_DIR_BIN, BB_SUID_DROP, rmdir))
    303264IF_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))
    306265IF_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))
    308266IF_RUNCON(APPLET(runcon, BB_DIR_USR_BIN, BB_SUID_DROP))
    309267IF_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))
    312268IF_RX(APPLET(rx, BB_DIR_USR_BIN, BB_SUID_DROP))
    313269IF_SCRIPT(APPLET(script, BB_DIR_USR_BIN, BB_SUID_DROP))
    314270IF_SCRIPTREPLAY(APPLET(scriptreplay, BB_DIR_BIN, BB_SUID_DROP))
    315 IF_SED(APPLET(sed, BB_DIR_BIN, BB_SUID_DROP))
    316271IF_SELINUXENABLED(APPLET(selinuxenabled, BB_DIR_USR_SBIN, BB_SUID_DROP))
    317272IF_SENDMAIL(APPLET(sendmail, BB_DIR_USR_SBIN, BB_SUID_DROP))
    318273IF_SEQ(APPLET_NOFORK(seq, seq, BB_DIR_USR_BIN, BB_SUID_DROP, seq))
    319274IF_SESTATUS(APPLET(sestatus, BB_DIR_USR_SBIN, BB_SUID_DROP))
    320 IF_SETARCH(APPLET(setarch, BB_DIR_BIN, BB_SUID_DROP))
    321275IF_SETCONSOLE(APPLET(setconsole, BB_DIR_SBIN, BB_SUID_DROP))
    322276IF_SETENFORCE(APPLET(setenforce, BB_DIR_USR_SBIN, BB_SUID_DROP))
     
    327281IF_SETSEBOOL(APPLET(setsebool, BB_DIR_USR_SBIN, BB_SUID_DROP))
    328282IF_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))
    330283IF_SHA1SUM(APPLET_NOEXEC(sha1sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha1sum))
    331284IF_SHA3SUM(APPLET_NOEXEC(sha3sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha3sum))
     
    336289/* Do not make this applet NOFORK. It breaks ^C-ing of pauses in shells: */
    337290IF_SLEEP(APPLET(sleep, BB_DIR_BIN, BB_SUID_DROP))
    338 IF_SOFTLIMIT(APPLET_ODDNAME(softlimit, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, softlimit))
    339291IF_SORT(APPLET_NOEXEC(sort, sort, BB_DIR_USR_BIN, BB_SUID_DROP, sort))
    340292IF_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))
    342293IF_STAT(APPLET(stat, BB_DIR_BIN, BB_SUID_DROP))
    343294IF_STRINGS(APPLET(strings, BB_DIR_USR_BIN, BB_SUID_DROP))
    344295IF_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))
    348296IF_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))
    351297IF_SWAPONOFF(APPLET_ODDNAME(swapoff, swap_on_off, BB_DIR_SBIN, BB_SUID_DROP, swapoff))
    352298IF_SWAPONOFF(APPLET_ODDNAME(swapon, swap_on_off, BB_DIR_SBIN, BB_SUID_DROP, swapon))
    353299IF_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))
    355300IF_BB_SYSCTL(APPLET(sysctl, BB_DIR_SBIN, BB_SUID_DROP))
    356 IF_SYSLOGD(APPLET(syslogd, BB_DIR_SBIN, BB_SUID_DROP))
    357301IF_TAC(APPLET_NOEXEC(tac, tac, BB_DIR_USR_BIN, BB_SUID_DROP, tac))
    358302IF_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))
    361303/* IF_TC(APPLET(tc, BB_DIR_SBIN, BB_SUID_DROP)) */
    362304IF_TCPSVD(APPLET_ODDNAME(tcpsvd, tcpudpsvd, BB_DIR_USR_BIN, BB_SUID_DROP, tcpsvd))
     
    380322IF_TTYSIZE(APPLET(ttysize, BB_DIR_USR_BIN, BB_SUID_DROP))
    381323IF_TUNCTL(APPLET(tunctl, BB_DIR_SBIN, BB_SUID_DROP))
    382 IF_TUNE2FS(APPLET(tune2fs, BB_DIR_SBIN, BB_SUID_DROP))
    383324IF_UDHCPC(APPLET(udhcpc, BB_DIR_SBIN, BB_SUID_DROP))
    384325IF_UDHCPD(APPLET(udhcpd, BB_DIR_USR_SBIN, BB_SUID_DROP))
     
    386327IF_UMOUNT(APPLET(umount, BB_DIR_BIN, BB_SUID_DROP))
    387328IF_UNAME(APPLET(uname, BB_DIR_BIN, BB_SUID_DROP))
    388 IF_UNCOMPRESS(APPLET(uncompress, BB_DIR_BIN, BB_SUID_DROP))
    389329IF_UNEXPAND(APPLET_ODDNAME(unexpand, expand, BB_DIR_USR_BIN, BB_SUID_DROP, unexpand))
    390330IF_UNIQ(APPLET(uniq, BB_DIR_USR_BIN, BB_SUID_DROP))
    391331IF_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))
    396332IF_UPTIME(APPLET(uptime, BB_DIR_USR_BIN, BB_SUID_DROP))
    397333IF_USLEEP(APPLET_NOFORK(usleep, usleep, BB_DIR_BIN, BB_SUID_DROP, usleep))
     
    399335IF_UUENCODE(APPLET(uuencode, BB_DIR_USR_BIN, BB_SUID_DROP))
    400336IF_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))
    403337IF_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))
    406338IF_WATCH(APPLET(watch, BB_DIR_BIN, BB_SUID_DROP))
    407339IF_WATCHDOG(APPLET(watchdog, BB_DIR_SBIN, BB_SUID_DROP))
    408340IF_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))
    411341IF_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))
    414342IF_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))
    416343IF_ZCIP(APPLET(zcip, BB_DIR_SBIN, BB_SUID_DROP))
    417344
    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)
    419347};
    420348#endif
  • branches/3.3/mindi-busybox/include/bb_archive.h

    r3233 r3621  
    7878
    7979    /* 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
    8083#define PAX_NEXT_FILE 0
    8184#define PAX_GLOBAL    1
     
    9699#if ENABLE_CPIO || ENABLE_RPM2CPIO || ENABLE_RPM
    97100    uoff_t cpio__blocks;
     101    struct bb_uidgid_t cpio__owner;
    98102    struct hardlinks_t *cpio__hardlinks_to_create;
    99103    struct hardlinks_t *cpio__created_hardlinks;
     
    123127#define ARCHIVE_O_TRUNC             (1 << 8)
    124128#define ARCHIVE_REMEMBER_NAMES      (1 << 9)
     129#if ENABLE_RPM
     130#define ARCHIVE_REPLACE_VIA_RENAME  (1 << 10)
     131#endif
    125132
    126133
     
    157164
    158165
     166extern const char cpio_TRAILER[];
     167
    159168
    160169archive_handle_t *init_handle(void) FAST_FUNC;
     
    182191char get_header_tar_bz2(archive_handle_t *archive_handle) FAST_FUNC;
    183192char get_header_tar_lzma(archive_handle_t *archive_handle) FAST_FUNC;
     193char get_header_tar_xz(archive_handle_t *archive_handle) FAST_FUNC;
    184194
    185195void seek_by_jump(int fd, off_t amount) FAST_FUNC;
     
    201211
    202212/* 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 */
     213typedef 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
    205227    off_t    bytes_out;
    206228    off_t    bytes_in;  /* used in unzip code only: needs to know packed size */
    207229    uint32_t crc32;
    208230    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
     233void init_transformer_state(transformer_state_t *xstate) FAST_FUNC;
     234ssize_t transformer_write(transformer_state_t *xstate, const void *buf, size_t bufsize) FAST_FUNC;
     235ssize_t xtransformer_write(transformer_state_t *xstate, const void *buf, size_t bufsize) FAST_FUNC;
     236int check_signature16(transformer_state_t *xstate, unsigned magic16) FAST_FUNC;
     237
     238IF_DESKTOP(long long) int inflate_unzip(transformer_state_t *xstate) FAST_FUNC;
     239IF_DESKTOP(long long) int unpack_Z_stream(transformer_state_t *xstate) FAST_FUNC;
     240IF_DESKTOP(long long) int unpack_gz_stream(transformer_state_t *xstate) FAST_FUNC;
     241IF_DESKTOP(long long) int unpack_bz2_stream(transformer_state_t *xstate) FAST_FUNC;
     242IF_DESKTOP(long long) int unpack_lzma_stream(transformer_state_t *xstate) FAST_FUNC;
     243IF_DESKTOP(long long) int unpack_xz_stream(transformer_state_t *xstate) FAST_FUNC;
    220244
    221245char* append_ext(char *filename, const char *expected_ext) FAST_FUNC;
    222246int 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),
    224248        char* FAST_FUNC (*make_new_name)(char *filename, const char *expected_ext),
    225249        const char *expected_ext
     
    228252void check_errors_in_children(int signo);
    229253#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)
     254void fork_transformer(int fd,
     255    int signature_skipped,
     256    IF_DESKTOP(long long) int FAST_FUNC (*transformer)(transformer_state_t *xstate)
    233257) 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))
    236260#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 */
     261void 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 */
    240264#endif
    241265
  • branches/3.3/mindi-busybox/include/bb_e2fs_defs.h

    r3233 r3621  
    443443};
    444444struct BUG_ext2_super_block {
    445         char bug[sizeof(struct ext2_super_block) == 1024 ? 1 : -1];
     445    char bug[sizeof(struct ext2_super_block) == 1024 ? 1 : -1];
    446446};
    447447
  • branches/3.3/mindi-busybox/include/busybox.h

    r3232 r3621  
    1616extern const char applet_names[] ALIGN1;
    1717extern int (*const applet_main[])(int argc, char **argv);
    18 extern const uint16_t applet_nameofs[];
     18extern const uint8_t applet_flags[] ALIGN1;
     19extern const uint8_t applet_suid[] ALIGN1;
    1920extern const uint8_t applet_install_loc[] ALIGN1;
    2021
    21 #if ENABLE_FEATURE_SUID || ENABLE_FEATURE_PREFER_APPLETS
    22 # define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0x0fff))
    23 #else
    24 # define APPLET_NAME(i) (applet_names + applet_nameofs[i])
    25 #endif
    26 
    2722#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)))
    3025#else
    3126# define APPLET_IS_NOFORK(i) 0
     
    3429
    3530#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))
    3732#endif
    3833
  • branches/3.3/mindi-busybox/include/grp_.h

    r3232 r3621  
    3131 */
    3232#undef endgrent
    33 #define setgrent     bb_internal_setgrent
    3433#define endgrent     bb_internal_endgrent
    35 #define getgrent     bb_internal_getgrent
    36 #define fgetgrent    bb_internal_fgetgrent
    37 #define putgrent     bb_internal_putgrent
    3834#define getgrgid     bb_internal_getgrgid
    3935#define getgrnam     bb_internal_getgrnam
    40 #define getgrent_r   bb_internal_getgrent_r
    41 #define getgrgid_r   bb_internal_getgrgid_r
    42 #define getgrnam_r   bb_internal_getgrnam_r
    43 #define fgetgrent_r  bb_internal_fgetgrent_r
    4436#define getgrouplist bb_internal_getgrouplist
    4537#define initgroups   bb_internal_initgroups
    46 
    4738
    4839/* All function names below should be remapped by #defines above
    4940 * in order to not collide with libc names. */
    5041
    51 
    52 /* Rewind the group-file stream.  */
    53 extern void setgrent(void);
    54 
    5542/* 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
     43void FAST_FUNC endgrent(void);
    6944
    7045/* Search for an entry with a matching group ID.  */
    71 extern struct group *getgrgid(gid_t __gid);
     46struct group* FAST_FUNC getgrgid(gid_t __gid);
    7247
    7348/* Search for an entry with a matching group name.  */
    74 extern struct group *getgrnam(const char *__name);
     49struct group* FAST_FUNC getgrnam(const char *__name);
    7550
    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. */
    10552
    10653/* Store at most *NGROUPS members of the group set for USER into
    10754   *GROUPS.  Also include GROUP.  The actual number of groups found is
    10855   returned in *NGROUPS.  Return -1 if the if *NGROUPS is too small.  */
    109 extern int getgrouplist(const char *__user, gid_t __group,
     56int FAST_FUNC getgrouplist(const char *__user, gid_t __group,
    11057        gid_t *__groups, int *__ngroups);
    11158
     
    11360   by reading the group database and using all groups
    11461   of which USER is a member.  Also include GROUP.  */
    115 extern int initgroups(const char *__user, gid_t __group);
     62int FAST_FUNC initgroups(const char *__user, gid_t __group);
    11663
    11764POP_SAVED_FUNCTION_VISIBILITY
  • branches/3.3/mindi-busybox/include/libbb.h

    r3232 r3621  
    2121#include <setjmp.h>
    2222#include <signal.h>
     23#include <paths.h>
    2324#if defined __UCLIBC__ /* TODO: and glibc? */
    2425/* use inlined versions of these: */
     
    3334#include <stddef.h>
    3435#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! */
    3637/* See the dirname/basename man page for details */
    3738#include <libgen.h> /* dirname,basename */
    3839#undef basename
    3940#define basename dont_use_basename
    40 #include <sys/poll.h>
     41#include <poll.h>
    4142#include <sys/ioctl.h>
    4243#include <sys/mman.h>
     
    8586#endif
    8687#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
    88116#endif
    89117#if ENABLE_LOCALE_SUPPORT
     
    115143#else
    116144# 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!
    125157#endif
    126158#ifndef HAVE_CLEARENV
     
    320352extern const char *bb_mode_string(mode_t mode) FAST_FUNC;
    321353extern 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. */
     354enum {  /* cp.c, mv.c, install.c depend on these values. CAREFUL when changing them! */
    323355    FILEUTILS_PRESERVE_STATUS = 1 << 0, /* -p */
    324356    FILEUTILS_DEREFERENCE     = 1 << 1, /* !-d */
     
    330362    FILEUTILS_DEREF_SOFTLINK  = 1 << 7, /* -L */
    331363    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 */
    332369#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,
    337381};
    338 #define FILEUTILS_CP_OPTSTR "pdRfilsLH" IF_SELINUX("c")
     382#define FILEUTILS_CP_OPTSTR "pdRfilsLHarPvu" IF_SELINUX("c")
    339383extern int remove_file(const char *path, int flags) FAST_FUNC;
    340384/* NB: without FILEUTILS_RECUR in flags, it will basically "cat"
     
    387431/* NB: can violate const-ness (similarly to strchr) */
    388432char *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;
     433const char* endofname(const char *name) FAST_FUNC;
     434char *is_prefixed_with(const char *string, const char *key) FAST_FUNC;
     435char *is_suffixed_with(const char *string, const char *key) FAST_FUNC;
     436
     437int ndelay_on(int fd) FAST_FUNC;
     438int ndelay_off(int fd) FAST_FUNC;
    392439void close_on_exec_on(int fd) FAST_FUNC;
    393440void xdup2(int, int) FAST_FUNC;
     
    461508void xsetgid(gid_t gid) FAST_FUNC;
    462509void xsetuid(uid_t uid) FAST_FUNC;
     510void xsetegid(gid_t egid) FAST_FUNC;
     511void xseteuid(uid_t euid) FAST_FUNC;
    463512void xchdir(const char *path) FAST_FUNC;
     513void xfchdir(int fd) FAST_FUNC;
    464514void xchroot(const char *path) FAST_FUNC;
    465515void xsetenv(const char *key, const char *value) FAST_FUNC;
     
    469519void xstat(const char *pathname, struct stat *buf) FAST_FUNC;
    470520void xfstat(int fd, struct stat *buf, const char *errmsg) FAST_FUNC;
     521int open3_or_warn(const char *pathname, int flags, int mode) FAST_FUNC;
     522int open_or_warn(const char *pathname, int flags) FAST_FUNC;
     523int xopen3(const char *pathname, int flags, int mode) FAST_FUNC;
    471524int xopen(const char *pathname, int flags) FAST_FUNC;
    472525int 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;
     526int xopen_as_uid_gid(const char *pathname, int flags, uid_t u, gid_t g) FAST_FUNC;
    476527int open_or_warn_stdin(const char *pathname) FAST_FUNC;
    477528int xopen_stdin(const char *pathname) FAST_FUNC;
     
    483534
    484535uoff_t FAST_FUNC get_volume_size_in_bytes(int fd,
    485                 const char *override,
    486                 unsigned override_units,
    487                 int extend);
     536        const char *override,
     537        unsigned override_units,
     538        int extend);
    488539
    489540void xpipe(int filedes[2]) FAST_FUNC;
     
    523574void parse_datestr(const char *date_str, struct tm *ptm) FAST_FUNC;
    524575time_t validate_tm_time(const char *date_str, struct tm *ptm) FAST_FUNC;
    525 
     576char *strftime_HHMMSS(char *buf, unsigned len, time_t *tp) FAST_FUNC;
     577char *strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp) FAST_FUNC;
    526578
    527579int xsocket(int domain, int type, int protocol) FAST_FUNC;
     
    531583ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to,
    532584                socklen_t tolen) FAST_FUNC;
     585
     586int setsockopt_int(int fd, int level, int optname, int optval) FAST_FUNC;
     587int setsockopt_1(int fd, int level, int optname) FAST_FUNC;
     588int setsockopt_SOL_SOCKET_int(int fd, int optname, int optval) FAST_FUNC;
     589int setsockopt_SOL_SOCKET_1(int fd, int optname) FAST_FUNC;
    533590/* SO_REUSEADDR allows a server to rebind to an address that is already
    534591 * "in use" by old connections to e.g. previous server instance which is
     
    538595 * Turn it on before you call bind(). */
    539596void setsockopt_reuseaddr(int fd) FAST_FUNC; /* On Linux this never fails. */
     597int setsockopt_keepalive(int fd) FAST_FUNC;
    540598int setsockopt_broadcast(int fd) FAST_FUNC;
    541599int setsockopt_bindtodevice(int fd, const char *iface) FAST_FUNC;
     
    643701char *xstrdup(const char *s) FAST_FUNC RETURNS_MALLOC;
    644702char *xstrndup(const char *s, int n) FAST_FUNC RETURNS_MALLOC;
     703void *xmemdup(const void *s, int n) FAST_FUNC RETURNS_MALLOC;
    645704void overlapping_strcpy(char *dst, const char *src) FAST_FUNC;
    646705char *safe_strncpy(char *dst, const char *src, size_t size) FAST_FUNC;
    647706char *strncpy_IFNAMSIZ(char *dst, const char *src) FAST_FUNC;
     707unsigned count_strstr(const char *str, const char *sub) FAST_FUNC;
     708char *xmalloc_substitute_string(const char *src, int count, const char *sub, const char *repl) FAST_FUNC;
    648709/* Guaranteed to NOT be a macro (smallest code). Saves nearly 2k on uclibc.
    649710 * But potentially slow, don't use in one-billion-times loops */
     
    652713int bb_putchar_stderr(char ch) FAST_FUNC;
    653714char *xasprintf(const char *format, ...) __attribute__ ((format(printf, 1, 2))) FAST_FUNC RETURNS_MALLOC;
     715char *auto_string(char *str) FAST_FUNC;
    654716// gcc-4.1.1 still isn't good enough at optimizing it
    655717// (+200 bytes compared to macro)
     
    677739enum { PRINTABLE_META = 0x100 };
    678740void 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. */
     743enum {
     744    VISIBLE_ENDLINE   = 1 << 0,
     745    VISIBLE_SHOW_TABS = 1 << 1,
     746};
     747void visible(unsigned ch, char *buf, int flags) FAST_FUNC;
    679748
    680749/* dmalloc will redefine these to it's own implementation. It is safe
     
    697766
    698767extern 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;
     768extern ssize_t nonblock_immune_read(int fd, void *buf, size_t count) FAST_FUNC;
    700769// NB: will return short read on error, not -1,
    701770// if some data was read before error occurred
     
    716785extern void *xmalloc_xopen_read_close(const char *filename, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;
    717786
     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) */
     792unsigned bb_arg_max(void) FAST_FUNC;
     793#else
     794/* If all else fails */
     795# define bb_arg_max() ((unsigned)(32 * 1024))
     796#endif
     797unsigned bb_clk_tck(void) FAST_FUNC;
     798
    718799#define SEAMLESS_COMPRESSION (0 \
    719800 || ENABLE_FEATURE_SEAMLESS_XZ \
     
    725806#if SEAMLESS_COMPRESSION
    726807/* 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;
     808extern int setup_unzip_on_fd(int fd, int fail_if_not_compressed) FAST_FUNC;
    728809/* Autodetects .gz etc */
    729 extern int open_zipped(const char *fname) FAST_FUNC;
     810extern int open_zipped(const char *fname, int fail_if_not_compressed) FAST_FUNC;
     811extern void *xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;
    730812#else
    731813# define setup_unzip_on_fd(...) (0)
    732 # define open_zipped(fname)     open((fname), O_RDONLY);
    733 #endif
    734 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
    735817
    736818extern ssize_t safe_write(int fd, const void *buf, size_t count) FAST_FUNC;
     
    807889char *itoa_to_buf(int n, char *buf, unsigned buflen) FAST_FUNC;
    808890/* Intelligent formatters of bignums */
    809 void smart_ulltoa4(unsigned long long ul, char buf[4], const char *scale) FAST_FUNC;
    810 void smart_ulltoa5(unsigned long long ul, char buf[5], const char *scale) FAST_FUNC;
     891char *smart_ulltoa4(unsigned long long ul, char buf[4], const char *scale) FAST_FUNC;
     892char *smart_ulltoa5(unsigned long long ul, char buf[5], const char *scale) FAST_FUNC;
    811893/* If block_size == 0, display size without fractional part,
    812894 * else display (size * block_size) with one decimal digit.
     
    831913    unsigned mult;
    832914};
     915extern const struct suffix_mult bkm_suffixes[];
     916#define km_suffixes (bkm_suffixes + 1)
     917extern const struct suffix_mult cwbkMG_suffixes[];
     918#define kMG_suffixes (cwbkMG_suffixes + 3)
     919
    833920#include "xatonum.h"
    834921/* Specialized: */
     
    854941/* wrapper: allows string to contain numeric uid or gid */
    855942unsigned 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 */
    857943struct bb_uidgid_t {
    858944    uid_t uid;
    859945    gid_t gid;
    860946};
    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 */
     948int get_uidgid(struct bb_uidgid_t*, const char*) FAST_FUNC;
     949/* always sets uid and gid; exits on failure */
    864950void xget_uidgid(struct bb_uidgid_t*, const char*) FAST_FUNC;
    865951/* chown-like handling of "user[:[group]" */
     
    890976void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname);
    891977void FAST_FUNC update_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname);
     978void FAST_FUNC update_utmp_DEAD_PROCESS(pid_t pid);
    892979#else
    893980# define write_new_utmp(pid, new_type, tty_name, username, hostname) ((void)0)
    894981# 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
     986int file_is_executable(const char *name) FAST_FUNC;
     987char *find_executable(const char *filename, char **PATHp) FAST_FUNC;
     988int executable_exists(const char *filename) FAST_FUNC;
    901989
    902990/* BB_EXECxx always execs (it's not doing NOFORK/NOEXEC stuff),
     
    9151003#define BB_EXECLP(prog,cmd,...) execlp(prog,cmd,__VA_ARGS__)
    9161004#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
     1005void BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC;
     1006void exec_prog_or_SHELL(char **argv) NORETURN FAST_FUNC;
     1007
     1008/* xvfork() can't be a _function_, return after vfork in child mangles stack
    9201009 * in the parent. It must be a macro. */
    9211010#define xvfork() \
     
    9291018pid_t xfork(void) FAST_FUNC;
    9301019#endif
     1020void xvfork_parent_waits_and_exits(void) FAST_FUNC;
    9311021
    9321022/* NOMMU friendy fork+exec: */
     
    9451035 */
    9461036int wait4pid(pid_t pid) FAST_FUNC;
     1037int wait_for_exitstatus(pid_t pid) FAST_FUNC;
    9471038/* Same as wait4pid(spawn(argv)), but with NOFORK/NOEXEC if configured: */
    9481039int spawn_and_wait(char **argv) FAST_FUNC;
     
    10581149};
    10591150extern const char *msg_eol;
     1151extern smallint syslog_level;
    10601152extern smallint logmode;
    1061 extern int die_sleep;
    10621153extern uint8_t xfunc_error_retval;
    1063 extern jmp_buf die_jmp;
     1154extern void (*die_func)(void);
    10641155extern void xfunc_die(void) NORETURN FAST_FUNC;
    10651156extern void bb_show_usage(void) NORETURN FAST_FUNC;
     
    10741165extern void bb_perror_nomsg_and_die(void) NORETURN FAST_FUNC;
    10751166extern void bb_perror_nomsg(void) FAST_FUNC;
    1076 extern void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
    10771167extern void bb_verror_msg(const char *s, va_list p, const char *strerr) FAST_FUNC;
     1168extern void bb_logenv_override(void) FAST_FUNC;
    10781169
    10791170/* We need to export XXX_main from libbusybox
     
    11081199
    11091200/* Networking */
    1110 int create_icmp_socket(void) FAST_FUNC;
    1111 int create_icmp6_socket(void) FAST_FUNC;
    1112 /* interface.c */
    11131201/* This structure defines protocol families and their handlers. */
    11141202struct aftype {
     
    11391227extern smallint interface_opt_a;
    11401228int display_interfaces(char *ifname) FAST_FUNC;
     1229int in_ether(const char *bufp, struct sockaddr *sap) FAST_FUNC;
    11411230#if ENABLE_FEATURE_HWIB
    11421231int in_ib(const char *bufp, struct sockaddr *sap) FAST_FUNC;
     
    11511240#ifndef BUILD_INDIVIDUAL
    11521241extern 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;
    11551242extern void run_applet_no_and_exit(int a, char **argv) NORETURN FAST_FUNC;
    11561243#endif
     
    11841271int bb_ask_confirmation(void) FAST_FUNC;
    11851272
    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" */
     1274int bb_parse_mode(const char* s, unsigned cur_mode) FAST_FUNC;
    11871275
    11881276/*
     
    12401328char *bb_simplify_abs_path_inplace(char *path) FAST_FUNC;
    12411329
     1330#ifndef LOGIN_FAIL_DELAY
    12421331#define LOGIN_FAIL_DELAY 3
     1332#endif
    12431333extern void bb_do_delay(int seconds) FAST_FUNC;
    12441334extern void change_identity(const struct passwd *pw) FAST_FUNC;
     
    12621352#endif
    12631353extern void selinux_or_die(void) FAST_FUNC;
    1264 
    1265 
    1266 /* systemd support */
    1267 #define SD_LISTEN_FDS_START 3
    1268 int sd_listen_fds(void);
    12691354
    12701355
     
    12881373#define SETUP_ENV_TO_TMP    (1 << 2)
    12891374#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;
     1375void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC;
     1376void nuke_str(char *str) FAST_FUNC;
     1377int check_password(const struct passwd *pw, const char *plaintext) FAST_FUNC;
     1378int ask_and_check_password_extended(const struct passwd *pw, int timeout, const char *prompt) FAST_FUNC;
     1379int ask_and_check_password(const struct passwd *pw) FAST_FUNC;
    12921380/* Returns a malloced string */
    12931381#if !ENABLE_USE_BB_CRYPT
     
    13321420/* NB: typically you want to pass fd 0, not 1. Think 'applet | grep something' */
    13331421int get_terminal_width_height(int fd, unsigned *width, unsigned *height) FAST_FUNC;
     1422int get_terminal_width(int fd) FAST_FUNC;
    13341423
    13351424int tcsetattr_stdin_TCSANOW(const struct termios *tp) FAST_FUNC;
     
    14351524# if defined CONFIG_FEATURE_EDITING_HISTORY && CONFIG_FEATURE_EDITING_HISTORY > 0
    14361525#  define MAX_HISTORY (CONFIG_FEATURE_EDITING_HISTORY + 0)
    1437 unsigned size_from_HISTFILESIZE(const char *hp);
     1526unsigned size_from_HISTFILESIZE(const char *hp) FAST_FUNC;
    14381527# else
    14391528#  define MAX_HISTORY 0
     
    14771566 */
    14781567int read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize, int timeout) FAST_FUNC;
     1568void show_history(const line_input_t *st) FAST_FUNC;
    14791569# if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT
    14801570void save_history(line_input_t *st);
     
    16891779            uoff_t totalsize) FAST_FUNC;
    16901780
     1781unsigned ubi_devnum_from_devname(const char *str) FAST_FUNC;
     1782int ubi_get_volid_by_name(unsigned ubi_devnum, const char *vol_name) FAST_FUNC;
     1783
    16911784
    16921785extern const char *applet_name;
     
    17121805extern const char bb_msg_you_must_be_root[] ALIGN1;
    17131806extern const char bb_msg_requires_arg[] ALIGN1;
    1714 extern const char bb_msg_invalid_arg[] ALIGN1;
     1807extern const char bb_msg_invalid_arg_to[] ALIGN1;
    17151808extern const char bb_msg_standard_input[] ALIGN1;
    17161809extern const char bb_msg_standard_output[] ALIGN1;
     
    17411834
    17421835extern 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
    17491838/* This struct is deliberately not defined. */
    17501839/* See docs/keep_data_small.txt */
     
    17591848    (*(struct globals**)&ptr_to_globals) = (void*)(x); \
    17601849    barrier(); \
     1850} while (0)
     1851#define FREE_PTR_TO_GLOBALS() do { \
     1852    if (ENABLE_FEATURE_CLEAN_UP) { \
     1853        free(ptr_to_globals); \
     1854    } \
    17611855} while (0)
    17621856
     
    18011895# define VC_5 "/dev/vc/5"
    18021896# define VC_FORMAT "/dev/vc/%d"
    1803 # define LOOP_FORMAT "/dev/loop/%d"
     1897# define LOOP_FORMAT "/dev/loop/%u"
    18041898# define LOOP_NAMESIZE (sizeof("/dev/loop/") + sizeof(int)*3 + 1)
    18051899# define LOOP_NAME "/dev/loop/"
     
    18141908# define VC_5 "/dev/tty5"
    18151909# define VC_FORMAT "/dev/tty%d"
    1816 # define LOOP_FORMAT "/dev/loop%d"
     1910# define LOOP_FORMAT "/dev/loop%u"
    18171911# define LOOP_NAMESIZE (sizeof("/dev/loop") + sizeof(int)*3 + 1)
    18181912# define LOOP_NAME "/dev/loop"
     
    18221916
    18231917#define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
     1918#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
    18241919
    18251920
     
    19072002
    19082003
     2004/* Simple unit-testing framework */
     2005
     2006typedef void (*bbunit_testfunc)(void);
     2007
     2008struct bbunit_listelem {
     2009    const char* name;
     2010    bbunit_testfunc testfunc;
     2011};
     2012
     2013void bbunit_registertest(struct bbunit_listelem* test);
     2014void 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
    19092138POP_SAVED_FUNCTION_VISIBILITY
    19102139
  • branches/3.3/mindi-busybox/include/liblzo_interface.h

    r2725 r3621  
    3131static void die_at(int line)
    3232{
    33         bb_error_msg_and_die("internal error at %d", line);
     33    bb_error_msg_and_die("internal error at %d", line);
    3434}
    3535#define assert(v) if (!(v)) die_at(__LINE__)
  • branches/3.3/mindi-busybox/include/platform.h

    r3232 r3621  
    7676# define UNUSED_PARAM_RESULT
    7777#endif
     78
     79/* used by unit test machinery to run registration functions before calling main() */
     80#define INIT_FUNC __attribute__ ((constructor))
    7881
    7982/* -fwhole-program makes all symbols local. The attribute externally_visible
     
    209212typedef uint16_t bb__aliased_uint16_t FIX_ALIASING;
    210213typedef uint32_t bb__aliased_uint32_t FIX_ALIASING;
     214typedef uint64_t bb__aliased_uint64_t FIX_ALIASING;
    211215
    212216/* NB: unaligned parameter should be a pointer, aligned one -
     
    214218 */
    215219#if defined(i386) || defined(__x86_64__) || defined(__powerpc__)
     220# define BB_UNALIGNED_MEMACCESS_OK 1
    216221# define move_from_unaligned_int(v, intp)  ((v) = *(bb__aliased_int*)(intp))
    217222# define move_from_unaligned_long(v, longp) ((v) = *(bb__aliased_long*)(longp))
     
    222227/* #elif ... - add your favorite arch today! */
    223228#else
     229# define BB_UNALIGNED_MEMACCESS_OK 0
    224230/* performs reasonably well (gcc usually inlines memcpy here) */
    225231# define move_from_unaligned_int(v, intp) (memcpy(&(v), (intp), sizeof(int)))
     
    264270#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
    265271
     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
    266278
    267279/* ---- Miscellaneous --------------------------------------- */
     
    306318 */
    307319#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__)
    310323# define BB_MMU 0
    311324# define USE_FOR_NOMMU(...) __VA_ARGS__
     
    356369#define HAVE_MEMRCHR 1
    357370#define HAVE_MKDTEMP 1
     371#define HAVE_TTYNAME_R 1
    358372#define HAVE_PTSNAME_R 1
    359373#define HAVE_SETBIT 1
    360374#define HAVE_SIGHANDLER_T 1
    361375#define HAVE_STPCPY 1
     376#define HAVE_MEMPCPY 1
    362377#define HAVE_STRCASESTR 1
    363378#define HAVE_STRCHRNUL 1
     
    366381#define HAVE_STRVERSCMP 1
    367382#define HAVE_VASPRINTF 1
     383#define HAVE_USLEEP 1
    368384#define HAVE_UNLOCKED_STDIO 1
    369385#define HAVE_UNLOCKED_LINE_OPS 1
     
    374390#define HAVE_SYS_STATFS_H 1
    375391
    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)
    381394#  undef HAVE_STRVERSCMP
    382395# 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
    387401#endif
    388402
     
    417431#if (defined __digital__ && defined __unix__) \
    418432 || defined __APPLE__ \
    419  || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__
     433 || defined __OpenBSD__ || defined __NetBSD__
    420434# undef HAVE_CLEARENV
    421435# undef HAVE_FDATASYNC
     
    432446#endif
    433447
     448#if defined(__dietlibc__)
     449# undef HAVE_STRCHRNUL
     450#endif
     451
     452#if defined(__APPLE__)
     453# undef HAVE_STRCHRNUL
     454#endif
     455
    434456#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
    436472#endif
    437473
     
    445481
    446482#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
    450498# undef HAVE_STRCHRNUL
    451499# undef HAVE_STRVERSCMP
     
    471519#endif
    472520
     521#ifndef HAVE_TTYNAME_R
     522#define ttyname_r bb_ttyname_r
     523extern int ttyname_r(int fd, char *buf, size_t buflen);
     524#endif
     525
    473526#ifndef HAVE_SETBIT
    474527# define setbit(a, b)  ((a)[(b) >> 3] |= 1 << ((b) & 7))
     
    484537#endif
    485538
     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
     545static ALWAYS_INLINE void *mempcpy(void *dest, const void *src, size_t len)
     546{
     547    return memcpy(dest, src, len) + len;
     548}
     549#endif
     550
    486551#ifndef HAVE_STRCASESTR
    487552extern char *strcasestr(const char *s, const char *pattern) FAST_FUNC;
     
    499564/* Not exactly the same: instead of "Stopped" it shows "STOP" etc */
    500565# define strsignal(sig) get_signame(sig)
     566#endif
     567
     568#ifndef HAVE_USLEEP
     569extern int usleep(unsigned) FAST_FUNC;
    501570#endif
    502571
  • branches/3.3/mindi-busybox/include/pwd_.h

    r3232 r3621  
    3535#define endpwent    bb_internal_endpwent
    3636#define getpwent    bb_internal_getpwent
    37 #define fgetpwent   bb_internal_fgetpwent
    38 #define putpwent    bb_internal_putpwent
    3937#define getpwuid    bb_internal_getpwuid
    4038#define getpwnam    bb_internal_getpwnam
    41 #define getpwent_r  bb_internal_getpwent_r
    42 #define getpwuid_r  bb_internal_getpwuid_r
    4339#define getpwnam_r  bb_internal_getpwnam_r
    44 #define fgetpwent_r bb_internal_fgetpwent_r
    45 
    4640
    4741/* All function names below should be remapped by #defines above
    4842 * in order to not collide with libc names. */
    4943
    50 
    5144/* Rewind the password-file stream.  */
    52 extern void setpwent(void);
     45void FAST_FUNC setpwent(void);
    5346
    5447/* Close the password-file stream.  */
    55 extern void endpwent(void);
     48void FAST_FUNC endpwent(void);
    5649
    57 #ifdef UNUSED_SINCE_WE_AVOID_STATIC_BUFS
    5850/* 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
     51struct passwd* FAST_FUNC getpwent(void);
    6852
    6953/* Search for an entry with a matching user ID.  */
    70 extern struct passwd *getpwuid(uid_t __uid);
     54struct passwd* FAST_FUNC getpwuid(uid_t __uid);
    7155
    7256/* Search for an entry with a matching username.  */
    73 extern struct passwd *getpwnam(const char *__name);
     57struct passwd* FAST_FUNC getpwnam(const char *__name);
    7458
    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. */
     60int FAST_FUNC getpwnam_r(const char *__restrict __name,
    10061        struct passwd *__restrict __resultbuf,
    10162        char *__restrict __buffer, size_t __buflen,
  • branches/3.3/mindi-busybox/include/shadow_.h

    r3232 r3621  
    5858#ifdef UNUSED_FOR_NOW
    5959/* Open database for reading */
    60 extern void setspent(void);
     60void FAST_FUNC setspent(void);
    6161
    6262/* Close database */
    63 extern void endspent(void);
     63void FAST_FUNC endspent(void);
    6464
    6565/* Get next entry from database, perhaps after opening the file */
    66 extern struct spwd *getspent(void);
     66struct spwd* FAST_FUNC getspent(void);
    6767
    6868/* Get shadow entry matching NAME */
    69 extern struct spwd *getspnam(const char *__name);
     69struct spwd* FAST_FUNC getspnam(const char *__name);
    7070
    7171/* Read shadow entry from STRING */
    72 extern struct spwd *sgetspent(const char *__string);
     72struct spwd* FAST_FUNC sgetspent(const char *__string);
    7373
    7474/* Read next shadow entry from STREAM */
    75 extern struct spwd *fgetspent(FILE *__stream);
     75struct spwd* FAST_FUNC fgetspent(FILE *__stream);
    7676
    7777/* Write line containing shadow password entry to stream */
    78 extern int putspent(const struct spwd *__p, FILE *__stream);
     78int FAST_FUNC putspent(const struct spwd *__p, FILE *__stream);
    7979
    8080/* Reentrant versions of some of the functions above */
    81 extern int getspent_r(struct spwd *__result_buf, char *__buffer,
     81int FAST_FUNC getspent_r(struct spwd *__result_buf, char *__buffer,
    8282        size_t __buflen, struct spwd **__result);
    8383#endif
    8484
    85 extern int getspnam_r(const char *__name, struct spwd *__result_buf,
     85int FAST_FUNC getspnam_r(const char *__name, struct spwd *__result_buf,
    8686        char *__buffer, size_t __buflen,
    8787        struct spwd **__result);
    8888
    8989#ifdef UNUSED_FOR_NOW
    90 extern int sgetspent_r(const char *__string, struct spwd *__result_buf,
     90int FAST_FUNC sgetspent_r(const char *__string, struct spwd *__result_buf,
    9191        char *__buffer, size_t __buflen,
    9292        struct spwd **__result);
    9393
    94 extern int fgetspent_r(FILE *__stream, struct spwd *__result_buf,
     94int FAST_FUNC fgetspent_r(FILE *__stream, struct spwd *__result_buf,
    9595        char *__buffer, size_t __buflen,
    9696        struct spwd **__result);
    9797/* Protect password file against multi writers */
    98 extern int lckpwdf(void);
     98int FAST_FUNC lckpwdf(void);
    9999
    100100/* Unlock password file */
    101 extern int ulckpwdf(void);
     101int FAST_FUNC ulckpwdf(void);
    102102#endif
    103103
Note: See TracChangeset for help on using the changeset viewer.