Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
bcc5fa4
fix(install): prevent symlink race condition in install -D (fixes #10…
abendrothj Jan 9, 2026
48cbbab
fix(clippy): fix redundant else, collapsible else-if, format strings,…
abendrothj Jan 9, 2026
e6f4d59
fix(spell-checker): add mkdirat, CREAT, WRONLY, and testdir to ignore…
abendrothj Jan 9, 2026
2f5333c
fix(install): clippy ignore platform dependent cast & restrict SELinu…
abendrothj Jan 9, 2026
b88ba85
fix(clippy): replace panic! with assert! and use inline format string…
abendrothj Jan 9, 2026
a54dd69
fix(test): make race condition test more lenient about error messages
abendrothj Jan 9, 2026
ee025be
fix(test): mark unused output variable
abendrothj Jan 9, 2026
df88387
fix(install): don't print verbose directory creation when -t target i…
abendrothj Jan 15, 2026
5d7dfc9
fix(clippy): collapse nested if and use clone instead of to_path_buf
abendrothj Jan 15, 2026
9a6949b
fix(install): add missing FileTypeExt import in copy_file_safe
abendrothj Jan 20, 2026
5a08a3e
fix: Address reviewed issues and concerns
abendrothj Jan 20, 2026
4b6fb93
fix(install): improve error handling for same file scenario in copy_f…
abendrothj Jan 20, 2026
a3b7d12
fix(install): address PR review comments for symlink race condition fix
abendrothj Jan 21, 2026
c965677
test: add unit tests for safe directory and file operations
abendrothj Jan 21, 2026
ce3c9c0
fix: update spell-checker ignore list for safe_traversal.rs
abendrothj Jan 21, 2026
2dbf17f
fix: update safe traversal to use SymlinkBehavior enum for clarity
abendrothj Jan 26, 2026
e09cd37
fix: simplify match statements in SplitWriter and DirFd implementations
abendrothj Feb 4, 2026
056fcae
fix: code review suggestions fixed + explanation for duplication
abendrothj Feb 4, 2026
a1ef268
fix: add 'openat' to jargon wordlist for spell-checking
abendrothj Feb 6, 2026
89c2d2b
fix: format error message for clarity in open_or_create_subdir function
abendrothj Feb 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/cspell.dictionaries/jargon.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ noxfer
ofile
oflag
oflags
openat
pdeathsig
peekable
performant
Expand Down
10 changes: 5 additions & 5 deletions src/uu/chmod/src/chmod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use uucore::mode;
use uucore::perms::{TraverseSymlinks, configure_symlink_and_recursion};

#[cfg(all(unix, not(target_os = "redox")))]
use uucore::safe_traversal::DirFd;
use uucore::safe_traversal::{DirFd, SymlinkBehavior};
use uucore::{format_usage, show, show_error};

use uucore::translate;
Expand Down Expand Up @@ -473,7 +473,7 @@ impl Chmoder {

// If the path is a directory (or we should follow symlinks), recurse into it using safe traversal
if (!file_path.is_symlink() || should_follow_symlink) && file_path.is_dir() {
match DirFd::open(file_path) {
match DirFd::open(file_path, SymlinkBehavior::Follow) {
Ok(dir_fd) => {
r = self.safe_traverse_dir(&dir_fd, file_path).and(r);
}
Expand Down Expand Up @@ -502,7 +502,7 @@ impl Chmoder {
for entry_name in entries {
let entry_path = dir_path.join(&entry_name);

let dir_meta = dir_fd.metadata_at(&entry_name, should_follow_symlink);
let dir_meta = dir_fd.metadata_at(&entry_name, should_follow_symlink.into());
let Ok(meta) = dir_meta else {
// Handle permission denied with proper file path context
let e = dir_meta.unwrap_err();
Expand All @@ -527,7 +527,7 @@ impl Chmoder {

// Recurse into subdirectories using the existing directory fd
if meta.is_dir() {
match dir_fd.open_subdir(&entry_name) {
match dir_fd.open_subdir(&entry_name, SymlinkBehavior::Follow) {
Ok(child_dir_fd) => {
r = self.safe_traverse_dir(&child_dir_fd, &entry_path).and(r);
}
Expand Down Expand Up @@ -591,7 +591,7 @@ impl Chmoder {

// Use safe traversal to change the mode
let follow_symlinks = self.dereference;
if let Err(_e) = dir_fd.chmod_at(entry_name, new_mode, follow_symlinks) {
if let Err(_e) = dir_fd.chmod_at(entry_name, new_mode, follow_symlinks.into()) {
if self.verbose {
println!(
"failed to change mode of {} to {new_mode:o}",
Expand Down
15 changes: 9 additions & 6 deletions src/uu/du/src/du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use uucore::error::{FromIo, UError, UResult, USimpleError, set_exit_code};
use uucore::fsext::{MetadataTimeField, metadata_get_time};
use uucore::line_ending::LineEnding;
#[cfg(all(unix, not(target_os = "redox")))]
use uucore::safe_traversal::DirFd;
use uucore::safe_traversal::{DirFd, SymlinkBehavior};
use uucore::translate;

use uucore::parser::parse_glob;
Expand Down Expand Up @@ -313,7 +313,7 @@ fn safe_du(
let mut my_stat = if let Some(parent_fd) = parent_fd {
// We have a parent fd, this is a subdirectory - use openat
let dir_name = path.file_name().unwrap_or(path.as_os_str());
match parent_fd.metadata_at(dir_name, false) {
match parent_fd.metadata_at(dir_name, SymlinkBehavior::NoFollow) {
Ok(safe_metadata) => {
// Create Stat from safe metadata
let file_info = safe_metadata.file_info();
Expand Down Expand Up @@ -368,7 +368,7 @@ fn safe_du(
Ok(s) => s,
Err(_e) => {
// Try using our new DirFd method for the root directory
match DirFd::open(path) {
match DirFd::open(path, SymlinkBehavior::Follow) {
Ok(dir_fd) => match Stat::new_from_dirfd(&dir_fd, path) {
Ok(s) => s,
Err(e) => {
Expand Down Expand Up @@ -406,8 +406,11 @@ fn safe_du(

// Open the directory using DirFd
let open_result = match parent_fd {
Some(parent) => parent.open_subdir(path.file_name().unwrap_or(path.as_os_str())),
None => DirFd::open(path),
Some(parent) => parent.open_subdir(
path.file_name().unwrap_or(path.as_os_str()),
SymlinkBehavior::Follow,
),
None => DirFd::open(path, SymlinkBehavior::Follow),
};

let dir_fd = match open_result {
Expand Down Expand Up @@ -435,7 +438,7 @@ fn safe_du(
let entry_path = path.join(&entry_name);

// First get the lstat (without following symlinks) to check if it's a symlink
let lstat = match dir_fd.stat_at(&entry_name, false) {
let lstat = match dir_fd.stat_at(&entry_name, SymlinkBehavior::NoFollow) {
Ok(stat) => stat,
Err(e) => {
print_tx.send(Err(e.map_err_context(
Expand Down
Loading
Loading