562 Commits

Author SHA1 Message Date
Sylvestre Ledru ef5d752282 cp: open source and dest with O_NOFOLLOW in no-dereference mode (#10017)
In `-P` / no-dereference mode, cp now opens the source file with
`O_NOFOLLOW`, matching GNU cp. This closes a TOCTOU window where an
attacker who can swap the source path between cp's `lstat` check and
the subsequent open could redirect the read through a symlink to a
sensitive file (e.g. /etc/shadow). With `O_NOFOLLOW` the open fails
with `ELOOP` instead.

The same flag is propagated to `safe_copy::create_dest_restrictive`,
so the destination open also refuses to follow a symlink in
no-dereference mode. Without that, an attacker who plants the dest
path as a symlink between the caller's check and the open could
redirect the truncate (and the subsequent write) to any file the
caller has permission to write — the symmetric attack to the source
side. With `nofollow=true` the dest open returns `ELOOP` and the
victim file is left untouched.

`copy_on_write` gains a `nofollow` parameter threaded from
`copy_helper`, set to `!options.dereference(source_in_command_line)`.
In deref mode the flag is false and behavior is unchanged — cp still
follows symlinks, matching GNU.

Extends `util/check-safe-traversal.sh` with a cp -P strace check so
the invariant is locked in: future changes that drop `O_NOFOLLOW`
here will fail the smoke test.
2026-05-06 11:47:38 +02:00
Sylvestre Ledru 681030bca3 cp: create destination with restrictive 0o600 initial mode (#10011)
cp previously created the destination with mode 0o666 masked by umask
(typically 0o644), then later applied the final permissions via
set_permissions. In a shared directory like /tmp this opened an
observable window where another user could open the destination with
the intermediate broad mode before cp narrowed it, leaking file
contents that were intended to stay private.

Create dest with 0o600 initially in every non-symlink code path —
clone, sparse_copy, sparse_copy_without_hole, fs_copy, the stream
path, and the non-Linux fs::copy fallback. The existing
set_permissions call in copy_file applies the real final mode after
the content is written, so user-visible end state is unchanged; only
the intermediate mode is tightened. Matches GNU cp.

Extend `util/check-safe-traversal.sh` with a cp strace check that
asserts the destination openat carries mode 0600 so a future change
that reintroduces 0666 fails the smoke test.
2026-05-06 11:47:38 +02:00
mattsu b195b1de88 chmod: fix TOCTOU race in recursive traversal (#11918)
* chmod: fix TOCTOU race in recursive traversal

Use fchmodat2 (Linux 6.6+) with AT_SYMLINK_NOFOLLOW to prevent an
attacker from replacing a directory entry with a symlink between the
stat and chmod calls. Falls back to fchmodat on older kernels.

- Restrict fchmodat2 (syscall 452) to asm-generic architectures only
  (x86_64, x86, arm, aarch64, riscv)
- Add SAFETY comment on unsafe syscall block per project convention
- Add O_PATH + /proc/self/fd fallback for musl on kernel < 6.6
- Cache ENOSYS result with AtomicBool to skip fchmodat2 on old kernels
- Remove unnecessary nix::Mode round-trip on the fchmodat2 path
- safe_chmod_file() takes explicit SymlinkBehavior parameter
- Always pass NoFollow for regular entries during recursion
- Document residual TOCTOU in symlink branch as intentional for -L
- Add test verifying NoFollow chmod doesn't modify symlink target
- Update check-safe-traversal.sh to recognize fchmodat2
2026-05-05 22:06:06 +02:00
Sylvestre Ledru b2c4e0c125 factor: emit GNU 9.11 'is not a valid positive integer' for stdin input (#12137)
* factor: emit GNU's 'X is not a valid positive integer' wording

GNU's factor.c routes both stdin and command-line input through the same
print_factors() and reports invalid input as
  factor: 'X' is not a valid positive integer
Match that wording exactly so the new GNU 9.11 'nul4' test passes and
the 'cont' test no longer needs the warning/invalid-digit hunk in
tests_factor_factor.pl.patch.

* Add 'cmdline' to spell-checker ignore list
2026-05-04 09:31:59 +02:00
Sylvestre Ledru 9de73ef9be tests: patch GNU numfmt 'neg-arg-not-option' to accept clap-style error (#12123) 2026-05-03 09:56:18 +02:00
karanabe 3057b7d9da rm: fix inaccessible GNU test adaptation (#12127) 2026-05-03 09:53:27 +02:00
karanabe 37ac49ee35 cp: fix fail-perm GNU test adaptation
GNU coreutils 9.11 changed fail-perm.sh to use the EACCES helper
in the expected diagnostics. Match the full diagnostic line so the
existing uutils message adaptation still applies.
2026-05-02 14:34:47 +02:00
oech3 dad3249a58 GnuTests: bump GNU version to 9.11 (#11922) 2026-04-23 08:38:58 +02:00
Daniel Hofstetter 2be465a572 Revert "fix: replace apt with apt-get in scripts"
This reverts commit 6f939edb72.
2026-04-16 07:16:50 +02:00
xtqqczze 6f939edb72 fix: replace apt with apt-get in scripts
fix warning:

```
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
```
2026-04-14 22:56:39 +02:00
oech3 9f50c8b42e tee: fix input with sleep 2026-04-12 16:30:35 +02:00
oech3 d7f969c008 GnuTests: mask an equivalent df test 2026-04-12 14:48:54 +02:00
Sylvestre Ledru 56210f1137 test: add unit tests for compare_size_results.py
Mirrors test_compare_test_results.py: covers human_kb formatting,
load_sizes (date-keyed and flat), compare() including threshold
boundaries on both growth and shrinkage, format_report, and an
end-to-end main() check that the comment file is only written when
something significant is reported.

Wired into code-quality.yml alongside the existing compare_test_results
unit tests.
2026-04-11 16:02:00 +02:00
Sylvestre Ledru 9dfc7294cc ci: add compare_size_results.py to flag binary size changes
Per-binary comparison script that reads the existing
individual-size-result.json format (date-keyed with sha + sizes-in-KB)
and reports binaries whose size changed by both >=5% and >=4 KB.

This is the size-tracking counterpart of compare_test_results.py: it
emits GitHub workflow annotations and writes a PR comment body to its
--output path only when there is something significant to report.
2026-04-11 16:02:00 +02:00
Sylvestre Ledru 8d03a6aaf9 numfmt: add GNU test patch for devdebug, help-1, and field-range errors
GNU test: numfmt.pl devdebug-*, help-1, field-1, field-range-err-*
2026-04-04 23:24:46 +02:00
Sylvestre Ledru 864e95a253 numfmt: buffer output in non-abort invalid modes and re-enable GNU tests
Buffer formatted output so that --invalid=fail does not duplicate lines
on error, and --invalid=abort streams directly for partial output.

Fixes GNU numfmt.pl test: field-3. Re-enables the full numfmt.pl test
suite by removing the skip list added earlier in the stack.
2026-04-04 23:24:46 +02:00
Sylvestre Ledru a39921e206 tests: skip unsupported GNU numfmt cases and force symlink refresh
Skip GNU numfmt.pl tests not yet supported: unit-sep-22-fail, grp-1,
grp-2, delim-7, field-1, field-range-err-{1-4,6-13}, strtod-6,
strtod-6.1, leading-4, debug-2, devdebug-{1-7,9-11}, help-1,
fmt-err-9, fmt-err-11, fmt-15, ign-err-5, ign-err-m2.2, ign-err-m3.1.

Also unconditionally refresh binary symlinks to avoid stale builds.
2026-04-04 23:24:46 +02:00
Sylvestre Ledru 9ccd9ada9a github action: move the clippy management into a script 2026-04-03 12:15:40 +02:00
Sylvestre Ledru aa7a88640f tests: ensure getlimits is on PATH for reused GNU builds 2026-04-01 10:46:15 +02:00
oech3 572f3a2416 yes, coreutils: backport(enable) 2 GnuTests (#11480) 2026-03-25 08:24:32 +01:00
Sylvestre Ledru c794796c44 update-version.sh: update Cargo.lock files after version bump 2026-03-22 17:58:57 +01:00
Sylvestre Ledru 2c82462c66 prepare release 0.8.0 2026-03-22 17:58:57 +01:00
oech3 209bb97072 run-gnu-tests-smack-ci.sh: Use alpine busybox 2026-03-21 11:53:10 +01:00
oech3 e37c158aab run-gnu-tests-smack-ci.sh: copy kernel from Ubuntu runner (#11376) 2026-03-17 23:06:06 +01:00
Daniel Hofstetter 8cfb32714c cut: improve some error messages (#11338) 2026-03-15 23:34:07 +01:00
Sylvestre Ledru 5a912a7fa1 adjust the publish script to ship src/uu/checksum_common 2026-03-10 09:26:09 +01:00
Sylvestre Ledru 80ef0d7d71 Revert "Cargo.toml: Avoid huge diff generation at version bump (#11131)" (#11259)
This reverts commit 70ce572bcf.
2026-03-09 22:17:28 +01:00
oech3 5e24462b26 coreutils: Fix 2>/dev/full aborts & drop a sed for GnuTests (#10740) 2026-03-07 09:56:35 +01:00
oech3 70ce572bcf Cargo.toml: Avoid huge diff generation at version bump (#11131)
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2026-02-26 21:54:36 +01:00
Sylvestre Ledru dc3a9a5bca prepare release 0.7.0 (#11128) 2026-02-26 20:41:46 +01:00
oech3 72ec8cf7f0 GnuTests: Use our libstdbuf.so 2026-02-24 23:45:54 +01:00
oech3 d3639dbd6e Mark date-locale-hour flakey & drop a useless cache action (#11093) 2026-02-24 10:38:26 -05:00
Christopher Dryden de5c827d99 Prevent make check from rebuilding GNU binaries over uutils ones 2026-02-21 19:40:08 +01:00
oech3 918484bff9 Avoid non reproducible cache generation at codcov (#10926) 2026-02-19 10:06:33 +01:00
xtqqczze 5d505ca6b9 chore: use consistent copyright header in .rs files (#11020) 2026-02-19 07:33:28 +01:00
Sylvestre Ledru a9ac09966b Revert "build-gnu: disable date-debug test. It is dev focussed. (#10965)" (#10967) 2026-02-15 16:54:02 -05:00
Sylvestre Ledru 87c292f624 build-gnu: disable date-debug test. It is dev focussed. (#10965) 2026-02-15 16:08:55 -05:00
Christopher Dryden 395dd8181e Fix non-exhaustive pattern in selinux doc test 2026-02-15 22:07:40 +01:00
Christopher Dryden 102c94fa78 cp: fix SELinux context handling for cp-a-selinux GNU test 2026-02-15 22:07:40 +01:00
Chris Dryden fb4b55e5cd build-gnu: fix factor tests being re-added by automake during make check (#10907) 2026-02-15 10:50:14 +01:00
mattsu eea061db56 ls:fix ls dired reports (#10527)
* refactor: simplify DisplayItemName struct and improve dired position handling

This commit refactors the `display_item_name` function to return a `DisplayItemName` struct containing both the displayed name and its dired length, rather than just the OsString. This change simplifies the code by:

1. Eliminating the need to call `dired_name_len()` separately after getting the displayed name
2. Reducing redundant length calculations in the dired position handling
3. Making the code more maintainable by encapsulating related data together

The change also fixes an issue where dired positions were being calculated incorrectly for symlink names that required quoting, ensuring proper highlighting in dired mode.

Closes: #10248
2026-02-14 10:50:11 +01:00
Chris Dryden b4a4a38b9a paste: support multi-byte delimiters and GNU escape sequences (#10840)
* paste: support multi-byte delimiters and GNU escape sequences

* paste: address review comments - avoid OsString clone and guard mb_char_len
2026-02-10 09:25:11 +01:00
oech3 dc982b1444 GnuTests: 9.10, remove a bunch of backported tests (#10721) 2026-02-07 18:11:26 +01:00
Aaron Ang c9c78b2415 chore: run pre-commit on all files (#10119) 2026-02-04 22:12:53 +01:00
oech3 4854ba692e tests/misc/coreutils.sh: Fail with invalid binary name (#10258) 2026-02-04 22:11:52 +01:00
oech3 7a8af9e69d Additional hashsum cleanup 2026-02-01 00:44:36 +09:00
Dorian Peron ade6e8c632 Remove mentions to hashsum 2026-01-31 14:37:33 +01:00
Etienne Cordonnier d6c793c09a build-gnu.sh: remove workaround for timeout/yes
Now that https://github.com/uutils/coreutils/issues/7252 is fixed this workaround is not needed any more:

This is a partial revert of https://github.com/uutils/coreutils/commit/fac6c2951d5ae22eed1517bff28169ebdb37ef3d ("util/build-gnu.sh: Bypass timeout/yes SIGPIPE handling bug")
This is a revert of https://github.com/uutils/coreutils/commit/5004d4b45870a5b2e7cc90c87b04e85f7f725f30 ("build-gnu: replace `timeout` for `tests/tail/follow-stdin.sh`")

Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
2026-01-27 10:32:38 +01:00
Daniel Hofstetter 1ce8990141 ci/android: use --locked when installing nextest (#10467) 2026-01-24 19:33:55 +01:00
oech3 53d3176f6c Reduce duplicated management of supported utils 2026-01-21 20:16:17 +09:00