Commit Graph

19165 Commits

Author SHA1 Message Date
Sylvestre Ledru 2d0e1f3a77 refactor: migrate all utilities from nix to rustix/libc
Migrate 19 utility crates from nix to rustix and direct libc calls:

- kill, timeout, env: signal handling via csignal wrappers + libc
- sync, cat, tail, dd, tsort: file operations via rustix::fs
- touch: futimens via rustix::fs::futimens
- stty, tty: terminal ops via rustix::termios + libc ioctl
- sort: getrlimit via rustix::process, sysconf via libc
- wc, cp, df: stat/fstat via rustix::fs
- nice: priority via rustix::process
- mkfifo, mknod: via direct libc calls

Also add rustix::io::Errno conversions to uucore error.rs.
2026-04-21 00:37:27 +02:00
Sylvestre Ledru 01083b3702 refactor: migrate signals.rs and lib.rs from nix to csignal/rustix
Replace all nix signal and poll APIs in uucore:
- signals.rs: nix::sys::signal -> csignal wrappers
- signals.rs: nix::poll -> rustix::event::poll
- signals.rs: nix::sys::stat -> rustix::fs::fstat + libc constants
- lib.rs: nix sigaction -> csignal::set_signal_action
- dd/progress.rs: update install_sigusr1_handler to use libc::SIGUSR1

Return types change from nix::Result/Errno to std::io::Result.
2026-04-21 00:37:23 +02:00
Sylvestre Ledru eb25c5250f refactor: migrate safe_traversal.rs from nix to rustix
Replace all nix APIs with rustix equivalents in the security-critical
TOCTOU-safe filesystem traversal module:

- nix::dir::Dir -> rustix::fs::Dir (uses Dir::read_from which borrows fd)
- nix::fcntl::{OFlag, openat} -> rustix::fs::{OFlags, openat}
- nix::sys::stat::{fstat, fstatat, fchmod, fchmodat, mkdirat} -> rustix::fs
- nix::unistd::{fchown, fchownat, unlinkat} -> rustix::fs
- FchmodatFlags/UnlinkatFlags -> rustix::fs::AtFlags
- Error handling simplified: rustix Errno implements Into<io::Error>

Also update rm's unix platform code to use the new Stat type.

All 31 safe_traversal unit tests pass.
2026-04-21 00:37:23 +02:00
Sylvestre Ledru 1f91dbacd6 refactor: migrate uucore process.rs from nix to rustix
Replace nix process functions with rustix equivalents:
- geteuid/getegid/getuid/getgid/getpid/getpgrp/getsid -> rustix::process
- kill/test_kill -> rustix::process::kill_process/test_kill_process
- Signal::try_from -> signal_from_raw helper using from_raw_unchecked
- SigHandler for send_signal_group -> csignal wrapper

The getsid return type changes from Result<pid_t, Errno> to
io::Result<pid_t>, which is more idiomatic.
2026-04-21 00:37:23 +02:00
Sylvestre Ledru 9949abb827 refactor: migrate pipes.rs and cat splice.rs from nix to rustix
Replace nix pipe/splice/vmsplice wrappers with rustix equivalents
in uucore's pipes module. Also migrate cat's splice.rs to use
rustix::io::{read, write} instead of nix::unistd.

The return types change from nix::Result to std::io::Result, which
is more idiomatic and compatible with the broader ecosystem.
2026-04-21 00:37:23 +02:00
Josh French 0366d3c657 cksum: fix parsing error with tagged cheksum files (#11704)
* cksum: fix parsing error with tagged cheksum files

When passed the '-c'/'--check' flag, and parsing a checksum file in
the "tagged" format, cksum (symlinked to sha256sum, etc...) expects a
line that looks like this:

ShA256 (file.bin) = da39a3ee5e6b4b0d3255bfef95601890afd80709

If the hash algorithm at the beginning of the line (in the above case
SHA256) is missing, then cksum panics because it is attempts to use the
value of an array at index -1. This fix causes cksum to instead consider
the line a syntax error and ignore it, just as GNU cksum does. I also
added unit and integration tests to check for the above behaviour.

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2026-04-20 23:51:01 +02:00
pre-commit-ci[bot] 6e9a8b8dab [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-04-20 23:49:21 +02:00
venoosoo da9513c4e0 docs: remove hashsum from compiles_table.csv 2026-04-20 23:49:21 +02:00
Daniel Hofstetter f2f3f7b117 unexpand: rename "uflag" to "utf8" 2026-04-20 23:36:24 +02:00
can1357 98f6b0187b tr: fix test to assert rejection of -ct with complemented class 2026-04-20 23:28:28 +02:00
can1357 85af4e8159 tr: fix complemented class truncation ordering 2026-04-20 23:28:28 +02:00
oech3 c48b5fe3c9 wc: avoid pipe() if input is pipe 2026-04-20 23:17:00 +02:00
xtqqczze 4011e6dae6 CI/SizeComment: enhance PR commenting logic to update existing comments 2026-04-20 23:14:55 +02:00
Ibrahim Burak Yorulmaz e5a6b519ad tests/dd: test supplying non-positive bs/ibs/cbs/obs 2026-04-20 23:12:56 +02:00
Ibrahim Burak Yorulmaz 4be5eb9f24 dd: exit when bs/ibs/obs/cbs isn't positive 2026-04-20 23:12:56 +02:00
oech3 36265cb9ee coreutils: --help args is same with --help 2026-04-20 23:05:29 +02:00
Daniel Hofstetter ef5243ea21 stty: add two missing baud rates (#11865) 2026-04-20 22:42:41 +02:00
Devel08 e4987f0dbd pr: exit with code 1 if --column argument is zero (#11750) 2026-04-20 22:41:53 +02:00
xtqqczze ab786f50ef wc: introduce IS_POSIXLY_CORRECT static (#11853) 2026-04-20 22:40:15 +02:00
oech3 dc18b54fb7 cat: call pipe() once with multiple input (#11699) 2026-04-20 22:36:15 +02:00
Aleksandar Janicijevic 6133ef5176 du: Allow command-line argument that appears more than once (#11897)
---------

Co-authored-by: Aleksandar Janicijevic <aleks@vogonsoft.com>
2026-04-20 22:34:11 +02:00
xtqqczze bd76e84ea2 refactor(tee): implement Copy for OutputErrorMode 2026-04-20 22:22:52 +02:00
xtqqczze a78f017cc4 tee: merge logic of flush into write
Co-authored-by: oech3 <79379754+oech3@users.noreply.github.com>
2026-04-20 22:22:52 +02:00
xtqqczze 5aa6c642d2 fix(tee): rename Error parameter in process_error 2026-04-20 22:22:52 +02:00
oech3 34fd4beac3 uucore: remove returned and unused usize 2026-04-20 17:13:49 +02:00