Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux: Prevent target file from being trashed when trashing symlink #22704

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

0xtimsb
Copy link
Contributor

@0xtimsb 0xtimsb commented Jan 6, 2025

Closes #22399

Currently, the target file is being trashed when trashing a symlink, and the symlink remains intact. Symlinks are not handled separately yet, so when open is used on a symlink, it gets resolved to the target file.

To fix this, we can get the file descriptor of the symlink by passing libc::O_PATH | libc::O_NOFOLLOW flags to open, and then pass this file descriptor to the existing trash::trash_file from ashpd. However, this would result in an error because ashpd currently does not support trashing symlink files. I have created an issue for it here: bilelmoussaoui/ashpd#255.

For the time being, this PR partially fixes the issue by removing the symlink without trashing so that the target file won't be affected. Once the upstream bug is fixed, we can switch this remove action back to trashing.

Release Notes:

  • Fixed target file from being trashed when trashing symlink on Linux.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 6, 2025
@zed-industries-bot
Copy link

Messages
📖

This PR includes links to the following GitHub Issues: #bilelmoussaoui/ashpd#255
If this PR aims to close an issue, please include a Closes #ISSUE line at the top of the PR body.

Generated by 🚫 dangerJS against 0c7de42

@mikayla-maki
Copy link
Contributor

Thanks!

@mikayla-maki mikayla-maki added this pull request to the merge queue Jan 7, 2025
Merged via the queue into zed-industries:main with commit 7d0c571 Jan 7, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Linux Trashing a symlink to a directory will trash the target directory not the symlink
3 participants