Commit Graph
5027 Commits
Author SHA1 Message Date
b22013ab79 ls: ls -lF symlink target indicators (#11554)
---------

Co-authored-by: Guillem L. Jara <4lon3ly0@tutanota.com>
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2026-05-28 13:08:08 +02:00
AnthonyandGitHub 179b977b93 ln: add WASI support via symlink_path (#11713) 2026-05-28 12:53:59 +02:00
Dima GerasimovandDaniel Hofstetter 565f118f8c sort: add a test reproducing failure during sort --merge
sort -m takes: 3 lines, 96003 bytes

and emits: 4 lines, 96004 bytes

The output line lengths before the fix are:

```
a x 32000
b x 23809
b x 8191
c x 32000
```

So it splits one of the lines into two (23809 + 8191 = 32000).

In addition, the output becomes unsorted because the shorter 'b' fragment sorts before the longer 'b' fragment.

The issue is that in `chunks.rs`, `sep_iter` is relatve to `search_start`. But the returned value needs to be absolute position relative to the `buffer`.

We end up with these particular numbers because
- in merge.rs, initial chunk is created as `RecycledChunk::new(8 * 1024)` (8192 bytes)
- `search_start = 8192`; newline is at absolute buffer index `32000`
- `memchr_iter` returns `32000 - 8192 = 23808`, and newline adds + 1 byte
2026-05-28 10:38:12 +02:00
Daniel HofstetterandSylvestre Ledru 2c37153c7e mktemp: ensure that "-q XX" shows error msg 2026-05-27 20:39:52 +02:00
yor1xdandDaniel Hofstetter 9d3bafc23e mktemp: fix hidden file creation with dot prefix 2026-05-26 15:52:32 +02:00
Etienne CordonnierandDaniel Hofstetter 76c63ee6fd install: update comments and tests
Fix doc comments in safe_traversal that still described the old behavior
of replacing symlinks with real directories. Rename and deduplicate tests
that were originally written as race-condition regression tests but now
just verify symlink-following behavior.

Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
2026-05-26 10:14:21 +02:00
Jake AbendrothandGitHub 21fda8cd9f fix(install): follow symlink components in destination path with -D
## Summary

Fixes #11469

`install -D` was replacing pre-existing symlinks in the destination path with real directories instead of following them. This broke any workflow where part of the install prefix is a symlink; including BOSH deployments, Homebrew, Nix, stow, and any `make install` targeting a symlinked prefix.

**Reproduction (from the issue):**
```sh
mkdir -p /tmp/target
ln -s /tmp/target /tmp/link
echo hello > /tmp/file.txt
install -D -m 644 /tmp/file.txt /tmp/link/subdir/file.txt
# GNU coreutils 8.32: /tmp/link stays a symlink, file lands in /tmp/target/subdir/file.txt
# uutils 0.7.0:       /tmp/link is replaced with a real directory — wrong
```

## Root cause

PR #10140 introduced `create_dir_all_safe()` in `safe_traversal.rs` to prevent TOCTOU symlink race conditions. The fix was correct in intent but too aggressive: `open_or_create_subdir()` unconditionally unlinked and recreated any symlink it encountered, including pre-existing legitimate ones.

## Changes

**`src/uucore/src/lib/features/safe_traversal.rs`**
- `open_or_create_subdir`: when `stat_at` returns `S_IFLNK`, call `open_subdir(Follow)` instead of `unlink_at + mkdir_at`. The `O_DIRECTORY` flag already in `open_subdir` means dangling or non-directory symlinks still return an error cleanly.
- `find_existing_ancestor`: switch from `fs::symlink_metadata` to `fs::metadata` so that a symlink-to-directory is recognised as an existing ancestor rather than a component to recreate (this was already the stated intent in the function's doc comment).

**`src/uu/install/src/install.rs`**
- Align the `dir_exists` check and the `DirFd::open` call to also follow symlinks, consistent with the above.

**`tests/by-util/test_install.rs`**
- Update the two tests added by #10140 — they were asserting the buggy behavior (symlink replaced). Flip the assertions to document the correct GNU behavior.
- Add `test_install_d_follows_symlink_prefix` as a direct regression test for the issue's reproduction case.

## TOCTOU / security note

The true TOCTOU race (a symlink *injected during the operation* into a not-yet-existing path component) is still blocked: `mkdirat` fails with `EEXIST` if an attacker creates a symlink between `stat_at` returning `ENOENT` and our `mkdir_at`. Newly-created directories are still opened with `O_NOFOLLOW`.

What changes is that *pre-existing* symlinks are now followed — which is exactly what GNU coreutils 8.32 does. The previous behavior was stricter than GNU in this regard.
2026-05-25 22:11:50 +02:00
oech3andEtienne Cordonnier db7b8a6e58 stdbuf: build on Windows (depending on cygwin dll) 2026-05-25 12:23:51 +02:00
Sylvestre LedruandDorian Péron a8d51a2cfd mkdir: simplify umask shaping and add regression tests 2026-05-25 11:11:48 +02:00
John ChittumandSylvestre Ledru 8296884cf5 mkdir: acl and permission inheritance with -p
Workflow for permission setting and ACLs failed in several scenarios,
most notable when passing -p. Parent directories in the mkdir call would
not appropriately set ACLs and could end up with more open permissions.
Generally, there was a misunderstanding that GNU coreutils was setting
umask (0) and that was the default -- the real flow was using a shaped
umask that takes current umask and ensures that the user has the ability
to execute mkdir commands through the tree. The umask (0) call was part
of a read setup for the equivalent of our UmaskGuard. New workflow
focuses on safe defaults, shaped umask, and allowing the Kernel to do
to apply ACLs. Adds a test specifically to guard against regression,
ensuring a more restrictive ACL is respected with mkdir -p
2026-05-24 18:36:28 +02:00
xtqqczzeandDaniel Hofstetter 24e3d0d39e fix(selinux): add missing os checks 2026-05-21 09:13:41 +02:00
oech3andSylvestre Ledru a2d29c0216 dd: fix OOM panic with skip=1 2026-05-20 17:14:07 +02:00
wuyangfanandDaniel Hofstetter 43c1e7b111 fix(sort): reject leading '+' in numeric (-n) sort
GNU sort -n does not treat '+' as a number sign. Skip f64 parsing for
lines with a leading plus so they sort lexicographically like GNU.

Fixes #10315
2026-05-20 11:52:38 +02:00
Eyüp Can AkmanandGitHub 5807760aa2 du: honor LC_NUMERIC for decimal separator (#12357)
* du: honor LC_NUMERIC for decimal separator

Route the fractional digit in `uucore::format::human::format_prefixed`
through `locale_decimal_separator()`, the same helper #11941 added for
`numfmt`. Fixes #11956.

* du: spell-check: ignore `replacen`

Matches the directive in `src/uu/numfmt/src/format.rs` for the same
helper introduced by #11941.
2026-05-20 10:38:12 +02:00
xtqqczzeandDaniel Hofstetter 57135cb9bd refactor: replace rustix::pipe with std::io::pipe 2026-05-19 16:11:49 +02:00
xtqqczzeandDaniel Hofstetter 7449705a98 fix(tests): refine feature checks for SELinux 2026-05-19 11:19:55 +02:00
xtqqczzeandDaniel Hofstetter fb8e4b1612 fix: correct feature flag name for SELinux context test 2026-05-19 11:19:55 +02:00
oech3andDaniel Hofstetter 7cd4bbeee2 tests_tail.rs: remove nix 2026-05-19 10:33:29 +02:00
oech3andDaniel Hofstetter 1db0a453eb tests_sort.rs: remove nix 2026-05-19 10:20:53 +02:00
oech3andDaniel Hofstetter a9cf501870 tests_ls.rs: remove nix 2026-05-19 08:59:12 +02:00
Sylvestre Ledru 515d74b995 mv: atomically replace existing dest when moving symlinks cross-device (#10010)
EXDEV fallback now catches AlreadyExists and replaces the destination
via temp-name + fs::rename. Matches GNU mv.
2026-05-17 13:03:17 +02:00
Cả thế giới là RustandGitHub 34e71a6208 test(tail): fix flaky test_follow_name_multiple on macOS (#9636)
Increase timeout from 500ms to 1300ms on macOS to account for file system
caching delays when reading redirected output from temp files.
2026-05-16 23:08:53 +02:00
Daniel HofstetterandGitHub f1e051b8d8 nl: continue if a file can't be opened (#11983) 2026-05-16 22:20:02 +02:00
oech3andGitHub e408b5ac88 uucore::pipes: merge pipe_with_size to pipe and catch fcntl err (#12285) 2026-05-16 22:19:01 +02:00
oech3andGitHub ab328d170e coreutils: fix panic on linux < 6.4 when /proc is not mounted (#12104) 2026-05-16 22:12:43 +02:00