aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
AgeCommit message (Collapse)Author
2015-08-31ls -l user/group/security context should be left-aligned.Elliott Hughes
Right-aligned looks pretty good to me, but it's not what anyone else does.
2015-08-30Fix mv on overwrite.Elliott Hughes
We need to remove the destination, not the source, to be able to overwrite.
2015-08-25Static analysis from Hyejin Kim found possible pointer underflow.Rob Landley
Now that the kernel's 128k environment size has been lifted, it might be possible to feed in a gigabyte of suffix so argv[2] is enough larger than argv[1] that char *s decrements past NULL and points to arbitrary high memory (I.E. strlen(suffix) > (long)base), at which point the base > s test is defeated and we strcmp() against a wild pointer. Which is read only anyway and on 64 bit you probably couldn't hit any interesting addresses, but the fix is easy enough: compare strlen values instead of pointers. So do that instead.
2015-08-15Kylie McClain pointed out that env should clear variables with NAME= by itself.Rob Landley
2015-08-11Fix more date bugs.Elliott Hughes
Correctly and portably check for non-normal dates, and explicitly show the "before" and "after" dates (in the format of the user's choosing). Clear the struct tm in date_main rather than parse_default because on one path the struct tm is actually initialized. Explicitly clear the tm_sec field in parse_default because -- experiment shows -- that should not be preserved. Only do the "what does this 2-digit year mean?" dance if we actually parsed a 2-digit year. Show the right string in the error message if strptime fails. Also add more tests, and use UTC in the tests to avoid flakiness.
2015-08-11Bugfixes from Elliott Hughes: debug code got checked in (oops) andRob Landley
uninitialized trash in struct tm fields could segfault glibc's strftime().
2015-08-08Different tools have different ideas about what human-readable outputElliott Hughes
looks like. dd uses "7 MB" where du uses "7M", for example. this patch adds flags, similar to the BSD humanize_number. most callers will pass 0.
2015-08-08Fix ls -l user/group field ordering.Elliott Hughes
It's user then group, not the other way round.
2015-08-08Teach date @unixtime[.fraction], switch -s to be -D (matching busybox andRob Landley
not stomping on gnu's "an extra argument tells it to set the time so let's add -s to do the same thing" extension). Nanoseconds aren't uniformly supported by these apis, so had to stick it in GLOBALS() and pull it out later. Awkward, open to suggestions for a better way. (Also, the setting API is microseconds, not nanoseconds. Collect nano, convert to micro so we can switch APIs later without changing date's external UI again.) Oh, and shrink really_long_name_mktime() with a for() loop (and rename it) although I may go back and redo that for portability to hypothetical libraries if I can convert this mess to struct timespec with proper nanoseconds support. But that needs an extended strptime() which needs an extended struct tm, and between us and that is convincing posix computers got fast enough to care about fractions of a second. (Yes, I'm aware gnu added %N to date without adding it to strptime, implying they reimplemented strptime longhand inside date. I'm not doing that.)
2015-08-08Reject invalid dates in date(1).Elliott Hughes
Humans get upset when date(1) lets mktime(3) work out what the 99th day of the 99th month would be rather than rejecting the invalid date. For the subtly wrong cases, rather than get into the leap year business, let's rely on localtime_r(3).
2015-08-02Mark command-local functions static.Rob Landley
2015-08-01Replace xcheckrange() with atolx_range()Rob Landley
2015-08-01Move strlower() from find to lib.Rob Landley
2015-07-13Produce an error message for "cat /mnt", not just return code.Rob Landley
2015-07-10find: add -inum optionGreg Hackmann
-inum is a commonly implemented extension to search by inode number. Linux's fs-layer tracepoints log many events in terms of inodes, so "find -inum" is useful for mapping those events back to specific files.
2015-07-09There is a typo in mkfifo.c for __Z__ option.Sameer Pradhan
2015-07-06Avoid integer overflow with insane input data.Rob Landley
2015-07-05Kylie McClain pointed out that -z affects both input and output.Rob Landley
Can't say I'm happy with the API (-z and -Z to keep them independent would be nice), but compatibility with what exists trumps having a good API...
2015-07-04Actually set time with touch -d and -t when you don't specify nanonseconds.Rob Landley
There's a nanoseconds field value that says use current time, which I set but forgot to clear in the right places. (Oops.)
2015-07-03First pass on cp --preserveRob Landley
2015-07-01Improve -Z error reporting.Elliott Hughes
The most likely reason for setfscreatecon to fail is that you don't have permission, and that's reported by the write return EACCES. There isn't really a "bad" context; they're just strings. Before: $ adb shell mkdir -Z x y mkdir: bad -Z 'x' After: $ adb shell mkdir -Z x y mkdir: -Z 'x' failed: Permission denied Other than this, the ToT mkdir works fine with SELinux.
2015-06-29mkfifo -ZRob Landley
2015-06-23Don't segfault if none of the file arguments to ls exists.Rob Landley
2015-06-23Don't depend on malloc(0) to return non-null.Rob Landley
2015-06-23Fix ls so spacing is right for ls -l, -o, -g, -og, -ogZ, -lZ, -gZ, and -oZ.Rob Landley
2015-06-06Last grep commit broke non -r use of grep. Oops.Rob Landley
2015-06-02Make "printf --" and "printf ---" work.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-21ls -lZ wasn't putting a space before the xattr output.Rob Landley
2015-05-21mkdir: Fix argument of option -ZJosé Bollo
2015-05-20Make "grep -r regex" work on implicit "." if no files specified.Rob Landley
2015-05-19Add -Z support to mkdir, based on a patch from Jose Bollo.Rob Landley
I have no idea why -Z isn't showing up in mkdir --help when enabled, I need to look at that...
2015-05-19Adapted patch from José Bollo to do the "tonight we're gonna api likeRob Landley
it's 1999 and every path ever is from cwd or root" api versions for sockets and as a fallback of the open fails. There are still some holes (symlink to socket with -L will give you info about the symlink, not the socket, and symlink to a file you can't open will give you info about the symlink, not the file) but the correct fix is to make O_PATH work in the kernel for the LSM functions. (If we can read this data by path, we should be able to read it by O_PATH. We should not need two codepaths for this.)
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-18Fix "ls -Z . toys" segfaulting, because preprocessing skipped.Rob Landley
strwidth() got called on ->extra which was NULL. Had some other bad effects ala "ls -sk file1 file2 file3" ignored the -k. This should fix that too.
2015-05-18Recent commit broke ls -R (test reversed), and "ls -R singledir" shouldRob Landley
show label: at the start (yes, even "ls -R" in an empty dir).
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-13Fix bug (len[7] wasn't zeroed if -Z off, thus -C overestimated entry lengths),Rob Landley
and some cleanups while I was there.
2015-05-10Cleanups of dirtree_start() calls. (Don't need to feed in flag values, justRob Landley
symfollow true/false.)
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-06Re-enable catv command now that flag infrastructure is updated.Rob Landley
2015-05-04Implement SELinux ls -Z support.Elliott Hughes
This patch uses lgetfilecon rather than fgetfilecon because dirtree_parentfd always seems to return -1 in this function. If/when the SMACK code is fixed to work with dirtree_parentfd, I'll send a matching patch for SELinux. In the meantime, this works, and although ls -h is still on my to-do list, I think this patch is sufficient to let us replace toolbox ls with toybox ls.
2015-04-30More ls cleanups from squinting at Jose's most recent smack patch.Rob Landley
Behavior change in flags: allow -long to work together, and -l1 work like -l not -1. I didn't make ls -gCl remember the g, though. (Because -Cg and -gC take the last one: I'll preserve explicit state but not implicit state. And if -1Cl and -lC1 aren't going to behave the same, it wasn't consistent anyway.)
2015-04-30Wild guess at cleaning up smack support. Don't have a test environment yet.Rob Landley
2015-04-29ls: Add -Z (Smack) optionJan Cybulski
Option triggers printing security context, for smack that is file's access smack label. Change-Id: I9054d9bcfe4d149e8fbfa0831b6ab50165d2bd91 Signed-off-by: Jan Cybulski <j.cybulski@samsung.com> Signed-off-by: José Bollo <jose.bollo@open.eurogiciel.org>
2015-04-27Fix ls -s and -i indentation in -C and -x modes. (Spotted by Jan Cybulski.)Rob Landley
2015-04-04To ensure that toybox can be installed alongside busybox withoutPaul Barker
confusing update-alternatives, the paths of the links installed by toybox should match those installed by busybox. This is accomplished by changing the flags of a few tools within toybox.
2015-03-29Fix head bug pointed out by felix janda (recent -123 code broke first file ↵Rob Landley
argument of -n).
2015-03-28Fix sed bug David Halls hit trying to compile libiconv.Rob Landley