aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2015-03-21Patch from David Halls to fix mac/ios portability issue.Rob Landley
2015-03-16Fix mount -a segfault without -O, reported by Janus Troelsen.Rob Landley
2015-03-16Rename a function to better describe what it does.Rob Landley
2015-03-12Factor out xgetgrnamid() and xgetpwnamid() into xwrap.c.Rob Landley
2015-03-09Upgrade oneit with -r (restart), -3 (send exiting PID values to child), and ↵Rob Landley
signal handling.
2015-03-01Only switch on printf format warnings for error_exit() and friends when ↵Rob Landley
TOYBOX_DEBUG enabled. One again gcc manages to be incompetent about producing warnings. For example, in bzcat we error_exit() with a message that's an error code fed into an array of string constants, and apparently dereferencing an array of string literals doesn't give you a string literal according to -Wformat-security. Not breaking the code to humor the compiler here, the compiler is wrong.
2015-03-01let the compiler check format stringsElliott Hughes
i'll be AFK for a week, so here's the patch i've been using this evening to find other format string mistakes. BSD uses __printflike and takes two arguments instead of hard-coding (1,2), but i figured that as long as you don't need the generality you'd prefer not to have it. and it's easy enough to retrofit if we ever do have a formatting function that takes other arguments.
2015-03-01Patches from Elliott Hughes to add missing arguments to error_exit() calls.Rob Landley
2015-02-09Cleanup/refactoring pass on hwclock.Rob Landley
Inline open_wall_clock_rtc() into rtc_open(), factor out xtzset(), inline set_sysclock_from_hwclock(), set_hwclock_from_sysclock(), and set_sysclock_timezone(). /etc/adjtime is short enough we don't need to bother with a break. The final "else" case in main() should always trigger because >0 in optstr says "at most zero arguments", so the || at the end is always true, so take the test off.
2015-02-07Remove xexec_optargs().Rob Landley
2015-02-06Alright, the Android guys agree with the musl guys: ↵Rob Landley
faccessat(AT_SYMLINK_NOFOLLOW) is not supported.
2015-01-18Remove trailing whitespace.Rob Landley
2015-01-18Lift the basename/libgen.h shenanigans back out of portability.c and make it ↵Rob Landley
a static inline in portability.h, and prototype dirname() while we're at it.
2015-01-18fix non-glibc basename(3) usageElliott Hughes
I considered a #else on the big #ifdef __GLIBC__ above, but that seemed harder to follow.
2015-01-16Move pty.h back to toys.h (under LSB 4.1 headers).Rob Landley
2015-01-16AOSP master has <pty.h> and builds netcat/nc.Elliott Hughes
2015-01-16id.c #ifdefectomy. (ifdefs belong in headers, not in C code.)Rob Landley
2015-01-16This patch adds a TOYBOX_SELINUX configuration option to control bothElliott Hughes
the SELinux commands (such as chcon) and the SELinux-specific options to regular commands (such as ls -Z). This lets us #include <selinux/selinux.h> in portability.h. I've also fixed chcon to insist on being given the a context argument. This patch also adds -Z to id and fixes id's regular output (-G should be separated by spaces, non-G output should be separated by commas, and you don't want a double comma where the egid is omitted from the list of groups).
2015-01-03Move fflush() checking to xexit() and have exit paths in main() call that.Rob Landley
2015-01-01strtol() doesn't return error indicator for overflow, it just sets errno. So ↵Rob Landley
add estrtol() (which clears errno first), and xstrtol() (which error_exit()s on overflow).
2015-01-01Debris from flag handling rewrite: don't allow -^A to actually trigger.Rob Landley
2014-12-31Redo option parsing infrastructure so #define FORCE_FLAGS can unzero flag ↵Rob Landley
macros for a disabled command (needed when multiple commands share infrastructure with a common set of flags). This means the flag space is no longer packed, but leaves gaps where the zeroes go. (Actual flag bit positions are the same for all configs.) Since the option parsing needs to know where the holes are, the OPTSTR values are now generated as part of flags.h with ascii 1 values for the disabled values. (So generated/oldflags.h went away.) This also means that the option string argument for OLDTOY() went away, it now uses the same arguments as the NEWTOY() it references.
2014-12-31When you include the posix header libgen.h, glibc #defines basename to some ↵Rob Landley
random other symbol name (because gnu) and this screws up nontrivial macro expansions of NEWTOY(basename), so work around it in portability.h.
2014-12-22Allocate space for null terminator.Rob Landley
2014-12-13Forgot to check in a header file for base64.Rob Landley
2014-12-13Add base64.Rob Landley
The tizen guys wanted this. Yeah, I know there's base64 code in uuencode/uudecode, but that this has -i, input lines aren't of fixed length, encode/decode are in same file, there's no prefix/suffix code, it always writes to stdout... Eliminating the code duplication wouldn't be worth the if/else I'd have to add, so I just did a new one. Factored out the base64 table init into lib.c though: that was worth sharing.
2014-12-13Remove more strncpy() calls.Rob Landley
The semantics of strncat() and strncpy() are non-obvious, so let's not use 'em. Both zero all their remaining buffer space, and with strncat() the size is the space left at the _end_ of the string (not the size of the buffer) so it's way too easy to stomp memory you don't own. As long as we have to measure stuff ourselves to get it right, just use memcpy().
2014-12-04Work with buildroot's extensively patched uClibc, and for nommu support move ↵Rob Landley
xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
2014-12-04Implement xstrncat() and fix xstrndup().Rob Landley
2014-11-28Make sendfile use libbuf.Rob Landley
2014-11-22As long as Android's going to require fortify, fixup the warnings it generates.Rob Landley
2014-11-21A patch against your current ToT that builds in AOSP master.Elliott Hughes
2014-11-21Don't include asm/* files directly.Rob Landley
2014-11-21Patch from Elliott Hughes for Android/bionic build.Rob Landley
2014-11-19Fixups for the android/bionic build probes patch.Rob Landley
The CFG_* symbols are always defined so if() can use them as compile-time constants, so don't if defined() them. Doing USE_BLAH() around variable definitions opens up the same potential for config-dependent build breaks as #ifdefs do, just make the whole command depend on the symbol for now, factor out the utmpx infrastructure later. The PTY probe was always failing because it used NULL without #including the header that defines it. Substitute 0 instead.
2014-11-19probe for getspnam(), forkpty(), utmpx, replace sethostname()Isaac Dunham
Android is missing all of these; we need to probe for some so we have a config symbol to depend on. sethostname() is easily replaced. We got termios.h via pty.h; now it's not included in configure-step tools, so we need termios.h to generate globals.
2014-11-11Remove unnecessary assignment spotted by Cynt Rynt.Rob Landley
2014-10-27O_CLOEXEC was confusing the O_RDONLY test in loopfiles(), resulting in ↵Rob Landley
attempts to read from stdout instead of stdin for "-" or no arguments.
2014-10-20More static analysis fixes from Ashwini Sharma.Rob Landley
2014-10-20Add TOYBOX_NORECURSE so xexec() won't make internal function calls.Rob Landley
2014-10-18Factor out printf-style escape parsing logic from echo.c.Rob Landley
2014-10-14Use O_CLOEXEC instead of O_RDONLY to signal loopfiles_rw() to close filehandles.Rob Landley
2014-10-02Workaround for musl's faccessat bug (the rm -r "error: is a directory" thing).0.5.0Rob Landley
The Linux man page says I can use AT_SYMLINK_NOFOLLOW. It works in glibc, uclibc, and klibc, but musl returns -EINVAL any time you pass in that flag and the maintainer says that's not a bug and insists the man page and those other libraries all change to match musl's behavior. Toybox uses it to avoid scheduling unnecessary metadata writes for things we're about to delete (have to chmod unreadable directories so we can descend into them to delete their contents, the chmod happens before we descend so the disk I/O has plenty of time to be scheduled) because the extra writes wear out SSD faster. It's just an optimization and I don't really care if it works _well_ (the fchmodat call _also_ takes AT_SYMLINK_NOFOLLOW so that's covered), but musl's behavior uniquely makes the check always error and thus breaks normal "rm -r". Yes this workaround is checking #ifdef __MUSL__ which the library does not supply (because its code is perfect and will thus never need to be worked around). You can CFLAGS=-D__MUSL__ if you don't echo "#define __MUSL__" >> include/features.h when installing the library.
2014-09-28Brown paper bag time: comma_scan() didn't work for anything but the last entry.Rob Landley
2014-09-27Don't segfault for --help of single.sh build of OLDTOY commands that use ↵Rob Landley
another command's help.
2014-09-26The only illegal characters in a username are ":" (field separator), "\n" ↵Rob Landley
(line separator), and "/" (filename separator). Restricting usernames to the legacy posix character allowed set (for filenames, so the $HOME directory is creatable on VFAT and similar) means you can't have UTF-8 usernames. Linux allows any character but / and NUL in filenames. Since root is creating these entries, we assume root knows what it's doing.
2014-09-22Respond to two static analysis issues in dirtree_path() reported by Ashwini ↵Rob Landley
Sharma. dirtree->name is an array, not a pointer, so can't be zero. Remove the test. We dereference plen without checking it for null but calling dirtree_path(0, 0) is pilot error: only the _first_ call can have plen = 0. Add a comment.
2014-09-20Tweak portability.h for uClibc version in buildroot defconfig.Rob Landley
I've been locally patching uClibc to not violate posix-2008 (you don't need to define a GNU macro to get a posix function), but uClibc is obsolete and moribund (development peaked in 2006, last bugfix release was over 2 years ago), and the largest remaining user (buildroot) doesn't bother to apply such a patch. Since even buildroot is slowly migrating to musl-libc, just do the portability tweak for what the last release of the old thing actually did.
2014-09-14Second attempt at one way xpopen().Rob Landley
2014-09-14Split xpopen() into xpopen_both(), xpopen(), and xrun() depending on whether ↵Rob Landley
we want to redirect both, one, or neither of stdin/stdout.