Skip to content

rm --preserve-root should work on symlink too#9706

Merged
ChrisDryden merged 1 commit intouutils:mainfrom
sylvestre:rm-preserve
Feb 5, 2026
Merged

rm --preserve-root should work on symlink too#9706
ChrisDryden merged 1 commit intouutils:mainfrom
sylvestre:rm-preserve

Conversation

@sylvestre
Copy link
Copy Markdown
Contributor

Closes: #9705

@sylvestre sylvestre force-pushed the rm-preserve branch 2 times, most recently from a94c698 to 77ab2ed Compare December 18, 2025 21:49
@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/misc/nohup is no longer failing!
Note: The gnu test tests/tail/inotify-dir-recreate is now being skipped but was previously passing.

// Use symlink_metadata to get the actual target's dev/ino
// after following symlinks (we need to follow the symlink to see
// where it points)
if let Ok(metadata) = fs::metadata(path) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the MacOS tests are failing here because its unable to get the metadata even though its root. Adding a canonicalize to here so that in the MacOS case where the tests are failing, even though:

// First check the simple path-based case (e.g., "/")
    let path_looks_like_root = path.has_root() && path.parent().is_none();

This exists, if you can't get the metadata it will still fail if the canonicalize returns a "/" after this step

@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/shuf/shuf-reservoir (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/sort/sort-stale-thread-mem (passes in this run but fails in the 'main' branch)

@sylvestre sylvestre force-pushed the rm-preserve branch 2 times, most recently from 78e1996 to 7474e2a Compare January 27, 2026 20:40
@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)

1 similar comment
@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 1, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 1, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)

} else {
// Path resolves to root but isn't literally "/" (e.g., symlink to /)
show_error!(
"it is dangerous to operate recursively on '{}' (same as '/')",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see the translate file was added for this, I think it was just removed accidentally

@ChrisDryden
Copy link
Copy Markdown
Collaborator

This is not the type of PR that is good to review early in the morning. I was locally validating that the behavior was fixed and started nuking my dev box.

@ChrisDryden ChrisDryden merged commit 5e5968c into uutils:main Feb 5, 2026
156 checks passed
@sylvestre
Copy link
Copy Markdown
Contributor Author

This is not the type of PR that is good to review early in the morning. I was locally validating that the behavior was fixed and started nuking my dev box.

i am so sorry :(

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.

rm --preserve-root can be bypassed via symlink to /

2 participants