5602 Commits

Author SHA1 Message Date
Rob Landley
6f8ea8aafd Minor cleanup. 2025-07-19 21:03:33 -05:00
Rob Landley
791efbf86f setgid() should use gid not uid. (Spotted by ttiinn.)
Only used by login and su outside of pending, so went unnoticed in the
absence of mkroot tests running as root.
2025-07-17 05:37:50 -05:00
Rob Landley
209b2bf85e Make taskset with no args print current mask 2025-07-08 15:42:47 -05:00
Rob Landley
7e65c1fb80 Exclude octal from atolx(), just detect hex and decimal. 2025-07-07 20:46:45 -05:00
Rob Landley
d632ad4aae Minor cleanup, and add -a short option for --all 2025-07-05 15:58:54 -05:00
Jesse Rosenstock
40a81414b0 taskset: Document and add test for 0 PID
Since util-linux/util-linux@6c87a3ac5e (taskset: Accept 0 pid for current
process), util-linux's taskset has accepted a 0 PID for the taskset
process.

Toybox has always had this behavior, inherited from sched_getaffinity(2)
and sched_setaffinity(2).

https://www.man7.org/linux/man-pages/man2/sched_getaffinity.2.html

Document the zero PID behavior and use it to simplify the tests.

Note that toybox and util-linux show different output.  I'm not sure if
this should be considered a bug or not.

% ./toybox taskset 1 ./toybox taskset -p 0
pid 0's current affinity mask: 1
% ./taskset 1 ./taskset -p 0
pid 2140985's current affinity mask: 1
2025-07-04 15:25:34 -05:00
Rob Landley
635f1e0391 Work around another gcc bug, where --as-needed breaks libasan. This
dies with a null pointer dereference calling crypt():

gcc -fsanitize=address -static-libasan -xc - -Wl,--as-needed -lcrypt \
  <<<$'#include<crypt.h>\nint main(void){crypt("one", "two");}' &&
  ./a.out
2025-07-02 13:04:51 -05:00
Rob Landley
4bf4509984 Go back to the #ifdefs to work around compiler regressions.
While both gcc 12.2 and clang 18.0 compiled weak and non-weak versions
of the same symbol in the same file just fine, newer versions only work
if the weak symbol is in a different compilation unit than the non-weak
one. Otherwise they error out on the "redefinition".
2025-07-02 12:47:17 -05:00
Rob Landley
5ab6c0d5e2 Teach mkroot/mkroot.sh CROSS= to accept multiple comma separated targets. 2025-07-01 17:38:40 -05:00
Rob Landley
1ed82ade2f Fix mkroot.
"make defconfig" calls kconfig twice, and the first one (kconfig -h)
was consuming the KCONFIG_ALLCONFIG=<(echo blah) input so the actual
defconfig generation (kconfig -d) didn't see the PENDING overrides.
2025-07-01 17:24:47 -05:00
Rob Landley
9d27aba79e Remove poke() and friends, just inline the one caller using memcpy(). 2025-07-01 14:30:22 -05:00
Rob Landley
17d77a264a Clang is persnickety about attribute order. 2025-06-30 08:58:10 -05:00
Rob Landley
07a422c559 Xz cleanup: inline several init functions, use xmalloc() and error_exit()
with toys.rebound to continue and accept additional input after error file,
reduce error message granularity (it worked or it didn't),
mark more functions static, use toybuf for input.

Fix tests to not look for specific error messages (fixes TEST_HOST).
2025-06-28 20:18:06 -05:00
Elliott Hughes
1809240ad7 dd: add iflags=direct too.
The way this is going, I'll be back with more later, but for now I'm
still just adding each flag as it's explicitly requested.
2025-06-27 15:02:13 -05:00
Rob Landley
94a0d2b7d7 xzcat cleanup: reorder to remove some function prototypes and
predeclarations, yank unused xz_ret states (using xmalloc() to eliminate
one and just ignore the other), and memeq() is just !memcmp()
2025-06-27 13:21:01 -05:00
Rob Landley
70157e71bb Use weak symbol instead of #else skipping build. 2025-06-24 13:58:32 -05:00
Rob Landley
105a72fd53 Jesse Rosenstock pointed out that long masks would run past toybuf. 2025-06-23 15:16:01 -05:00
Rob Landley
77cb95ab94 Add taskset tests. 2025-06-23 14:59:16 -05:00
Rob Landley
d6bc6b1d8a Add ARM64 BCJ decoder, from Lassee Collin's xz-embedded commit 89094f05f02b 2025-06-22 20:50:24 -05:00
Rob Landley
849e1c2833 Several minor fixes from upstream public domain repo, adapted from
xz-embedded commits 40d291b609d0 f6d1f58f36cd 82078b610912 cfc1499e9fc2

Thanks to Oliver Webb for the triage.
2025-06-22 20:14:29 -05:00
Rob Landley
8433c5d9a4 Redo prefix assignment logic so ! and redirects can interleave.
Move sh_process allocation out of expand_redir() and have caller allocate
and supply it, so multiple expand_redir() calls can append to the
same argv[] and filehandle unredirect context.

Move argv[0] out of ff->arg into TT.argv0 (because $0 is special: shift
and $* don't include it, set can't update it, source and function calls
don't change it...)

Rename call_function() to add_fcall(), because sh_function is function()
definitions and sh_fcall is call stack.

Remove pp->envlen, and replace pp->flags/PFLAG_NOT with pp->not.

Make sh_fcall more sparse: instead of copying fields from parent context
search for them with find_fcall() (convenience wrapper: FIND_FF()) and
get_lineno(). Having one copy greatly simplifies updating the values.

Note: run_command() no longer returns NULL: pp->exit will be nonzero if
setup failed.
2025-06-22 18:28:14 -05:00
Rob Landley
3a5f39b957 Whitespace. 2025-06-22 00:53:21 -05:00
Rob Landley
ecfe2ee305 Don't have help recommend -tL until fixed (there's already a TODO about it). 2025-06-20 13:14:59 -05:00
Rob Landley
8c66925859 Add KCONFIG_ALLCONFIG support (which mkroot needs). 2025-06-11 10:16:32 -05:00
Elliott Hughes
957903785a dd: implement oflag=append and oflag=direct. 2025-06-05 16:59:37 -05:00
Rob Landley
f712314272 Switch debug printfs off with a #define instead of individually
commenting them out. (Sigh, they're checked in either way...)
2025-06-02 16:55:26 -05:00
Rob Landley
73f192010e Fix allnoconfig build. 2025-05-27 01:15:04 -05:00
Rob Landley
e5b284ed9e Fix ftpget bug reported by Hongsheng Peng: every ftp command produces a
response line on the control channel, so ftp_line() having a -1 option
to not read a response line is wrong, and gets the parsing out of sync.
(But must=0 is ok, that means read and return it, but don't require a
specific value.)

This resulted in "ftpget HOST filename" successfully fetching the file,
but reporting error anyway.
2025-05-19 14:14:07 -05:00
Rob Landley
f43c791542 Alias support. 2025-05-09 00:43:54 -05:00
Rob Landley
79cd1a4537 Move allyesconfig, allnoconfig, and randconfig over to new kconfig.c 2025-05-01 14:06:17 -05:00
Rob Landley
5d1fd7a302 Instead of warming, make logpath depend on the multiplexer being disabled. 2025-05-01 14:04:04 -05:00
Rob Landley
5131a2bc6d Don't wildcard expand . and .. 2025-04-29 12:21:18 -05:00
Rob Landley
df570102af Implement chmod -cv 2025-04-28 17:39:27 -05:00
Rob Landley
c8ad718b72 Add a simple no option hd. 2025-04-25 15:18:46 -05:00
Rob Landley
35e26cec34 Move defconfig to new infrastructure. 2025-04-25 12:56:56 -05:00
Rob Landley
ce400bd735 Fix defconfig build. 2025-04-25 12:40:03 -05:00
Rob Landley
c7d8af2a2d Typo. 2025-04-24 07:36:59 -05:00
Rob Landley
e26d27ee81 Update release checklist. 2025-04-23 08:00:02 -05:00
Rob Landley
7e099a6d54 Add TOYFLAG_MOREHELP(CFG_BLAH) to allow annotated help text to drop out
when a second config symbol isn't defined. Use this for various LSM -Z
flags, PASSWD_SAD, sort -g, and wget's https support. This replaces the
old help text merging scripts/config2help.c used to do.

The annotation is a leading !, which removes the next char from usage:
lines and the whole line from the rest of the help text. The ! is always
removed, and the data it marks is only shown if the argument to
TOYFLAG_MOREHELP() is true at compile time.

In theory this plumbing should drop out when not used, like lib/args.c.
2025-04-23 07:35:05 -05:00
Rob Landley
ab1de187e2 Add printf -r NUM to repeat, with -r 0 acting like "yes".
(Note: you can't output a NUL byte with yes, but can with printf.)
2025-04-22 08:06:44 -05:00
Rob Landley
81e1224c1d Update host version for microsoft github's tests, and enable ASAN. 2025-04-21 16:41:51 -05:00
Rob Landley
4b7334eff4 getentropy() added to android API 28 in 2018: not quite 7 years yet. 2025-04-21 16:13:04 -05:00
Rob Landley
84749b1b7f test -nt and -ot treat existing file as always newer than missing. 2025-04-20 13:06:38 -05:00
Rob Landley
66fabe6c31 Allow tar -T /dev/null to create an empty archive. 2025-04-18 11:08:03 -05:00
Rob Landley
1f4ac174cf Silence TEST_HOST complaining about / in member names for "t". 2025-04-18 11:06:42 -05:00
Jeffery Miller
7353a331ff tests/dd: Add conv=nocreat test cases
Check that conv=nocreat errors out and does not
not create a file.

Test: make test_dd
2025-04-17 20:30:45 -05:00
Jeffery Miller
3cdebafe3f dd: Add support for conv=nocreat
With `conv=nocreat` set O_CREAT will not be set when
creating the output file, causing an error if of does
not exist.

Test: dd if=/dev/zero of=/tmp/doesnotexist conv=nocreat count=1
2025-04-17 20:30:30 -05:00
Rob Landley
811d660743 Inline and clean up a function that Dmitry Koroban pointed out was
trying to memcpy of a byte into an int.
2025-04-17 20:08:33 -05:00
Rob Landley
08c7a4b240 Make new kconfig -d write usable defconfig. 2025-04-14 19:56:20 -05:00
Rob Landley
d025058800 More kconfig replacement work, doesn't get defconfig right yet. 2025-04-14 09:08:43 -05:00