aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2015-07-10Add a basename_r() and use it in names_to_pid() to avoid basename() overwritingRob Landley
itself on some inputs. (Which makes killall really impolite. Bug report from Nicholas Noury via Elliott Hughes.)
2015-07-10Move comment about TOYBOX_DEBUG to start of file so it's more obvious.Rob Landley
2015-07-03Probe for fork() instead of relying on a distro-specific #define.Rob Landley
2015-07-01Fix segfault with "mount -o ro,remount".Elliott Hughes
Or any call to comma_scan where 'opt' appears as the last item in 'optlist'.
2015-06-26Factor out more not-curses infrastructure into lib.Rob Landley
2015-05-31Move the magic list of commands needing cleanup from toys/pending/READMERob Landley
to greppable TODO annotations in the individual files. (grep -riw TODO)
2015-05-28Attempt to fix the mkdir LSM race.Rob Landley
Doing a world writeable mkdir and _then_ adding a label seems like a race window, so set the global "create stuff with these labels" context, then do the creates.
2015-05-18Switch id over to new infrastructure, switch id to use FORCE_FLAGS, andRob Landley
make lib/lsm.h auto-include from toys.h.
2015-05-18More ls -Z upgrading. Move TOYBOX_SELINUX and TOYBOX_SMACK support fromRob Landley
portability.h to new lib/lsm.h. Update ls.c to use it. Fix "ls . toys" (two directories when one is . or ..), which was filtering out the . as something we shouldn't recurse into even though it was explicitly listed on the command line. For some reason "ls -Z . toys" is still segfaulting though (but "ls -Z ." isn't), need to figure out why...
2015-05-14Promote reset (actually write a new one using the simple man 4 console_codesRob Landley
terminal reset escape sequence) and add gettty() function to lib so terminal gets reset even when we redirect stdout/stderr. (This is apparently the expected behavior.)
2015-05-09Add DIRTREE_SHUTUP to disable dirtree warnings if file vanishes out fromRob Landley
under traversal. Pass through full flag set in dirtree_add_node(), add dirtree_start() wrapper to provide symlink-only behavior (avoiding a lot of DIRTREE_SYMFOLLOW*!!(logic) repeated in callers).
2015-05-08Move not-curses code into interstingtimes.cRob Landley
2015-05-03Move a prototype to the start of portability.h (suggested by Elliott Hughes)Rob Landley
2015-05-01Portability bits for the recent ls smack changes.Rob Landley
2015-04-30And remove the header part too.Rob Landley
2015-04-30Remove redundant numlen.Rob Landley
2015-04-27Some infrastructure hexedit needs. (Poor man's curses.)Rob Landley
2015-04-19Cleanup getprop, add qstrcmp() to lib for qsort (because posix-2008 brokeRob Landley
alphasort), add compile-time probe for config symbol TOYBOX_ON_ANDROID.
2015-04-17Link against libattr and libsmack.Xavier Roche
2015-04-16terminal_size should use LINES, not ROWS.Elliott Hughes
The shell's pseudo-variable is called LINES. This is true of at least bash and mksh.
2015-04-15Put SELINUX in a a menu, and add config option for SMACK.Rob Landley
2015-04-03Add readfileat() to libRob Landley
2015-03-23Tweak of Elliott Hughes's fix for an off by one error in human_readableRob Landley
(137 returned "137 KB".)
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().