Skip to content

coreutils: resolve utility names through symlink aliases - #15490

Open
limadog9 wants to merge 1 commit into
uutils:mainfrom
limadog9:fix/coreutils-symlink-aliases-10946
Open

limadog9 wants to merge 1 commit into
uutils:mainfrom
limadog9:fix/coreutils-symlink-aliases-10946

Conversation

@limadog9

Copy link
Copy Markdown
Contributor

On Unix, resolve an unrecognized invocation name through its symlink chain, including aliases found through PATH. This allows dummy -> true -> coreutils to run true.

Add coverage for relative links, multiple links, PATH lookup, argument forwarding, and utility exit status. All 18 multicall tests pass.

Closes #10946.

Comment thread src/bin/coreutils.rs Outdated
};
// Follow each link separately: canonicalize would discard the utility name
// in an intermediate link such as dummy -> true -> coreutils.
for _ in 0..40 {

This comment was marked as resolved.

@limadog9
limadog9 force-pushed the fix/coreutils-symlink-aliases-10946 branch 2 times, most recently from f918ead to 7477559 Compare October 18, 2026 17:44
Comment thread src/bin/coreutils.rs Outdated
fn utility_from_symlink<T>(utils: &UtilityMap<T>, binary: &Path) -> Option<&'static str> {
use std::os::unix::fs::PermissionsExt;

// binary_path can return argv[0] on any Unix target; AT_EXECFN is not

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you restrict this to Linux and remove PATH lookup?

@limadog9
limadog9 force-pushed the fix/coreutils-symlink-aliases-10946 branch 2 times, most recently from 37d5117 to ad408e9 Compare October 18, 2026 18:08
Comment thread src/common/validation.rs Outdated
let execfn_bytes = execfn.to_bytes();
let exec_path = Path::new(OsStr::from_bytes(execfn_bytes));
let argv0 = args.next().unwrap();
let same_name = execfn_bytes.rsplit(|&b| b == b'/').next()

This comment was marked as resolved.

@limadog9
limadog9 force-pushed the fix/coreutils-symlink-aliases-10946 branch from ad408e9 to 6dfc6f7 Compare October 18, 2026 18:39
Comment thread tests/test_util_name.rs Outdated
target_env = "gnu",
feature = "true",
feature = "false",
feature = "echo"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need echo only.

@limadog9
limadog9 force-pushed the fix/coreutils-symlink-aliases-10946 branch from 6dfc6f7 to 0355994 Compare October 18, 2026 18:47
On Linux with glibc, resolve an unrecognized invocation name from its
immediate symlink target. Reuse binary_path's kernel invocation path,
retaining its full directory after PATH lookup.

Cover relative and absolute targets, shell PATH invocation, argument
forwarding, and invocation with PATH unset using echo.

Closes uutils#10946.
@limadog9
limadog9 force-pushed the fix/coreutils-symlink-aliases-10946 branch from 0355994 to 72acd75 Compare October 18, 2026 19:02

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

coreutils: Resolve symlink with invalid binary name for better dummy support

2 participants