uutils/coreutils

chmod: behavioral divergence from coreutils when the target file is not accessible

Open

#9.789 geöffnet am 23. Dez. 2025

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)Rust (1.852 Forks)batch import
U - chmodgood first issue

Repository-Metriken

Stars
 (23.246 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 9T 14h) (216 gemergte PRs in 30 T)

Beschreibung

Component

chmod

Description

In Chmoder::chmod()

if !file.exists() {
    // .........
}

Path::exists() is used to determine whether a file is existed. Because Path::exists() will return false when there is a metadata access errors, including PermissionDenied, it can misclassify existing but inaccessible paths as non-existent, producing incorrect result.

Test / Reproduction Steps

core_sbx$ sudo mkdir locked
core_sbx$ sudo touch locked/file
core_sbx$ sudo chmod 000 locked
core_sbx$ ../../coreutils/target/release/chmod 000 locked/file
../../coreutils/target/release/chmod: cannot access 'locked/file': No such file or directory
core_sbx$ chmod 000 locked/file
chmod: cannot access 'locked/file': Permission denied

Impact

Behavioral divergence from GNU coreutils: scripts and tooling may treat No such file differently from Permission denied.

Contributor Guide