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

Getting a trashdir I can't write to #8

Open
fabiosantoscode opened this issue Nov 19, 2020 · 0 comments
Open

Getting a trashdir I can't write to #8

fabiosantoscode opened this issue Nov 19, 2020 · 0 comments

Comments

@fabiosantoscode
Copy link

I've encountered this issue: sindresorhus/trash#92 while trashing something on my /tmp directory, which is placed on the root mount (Ubuntu 20.04 with ZFS support is weird!).

After some investigation I found that this package was returning /.Trash-1000 as the trash directory for that file.

However, even though I have read+write permissions to access /tmp, I don't have write permissions on / without using sudo. /.Trash-1000 doesn't exist either, but it shouldn't matter for this issue.

I realize it's selfish and not cool to just show up on a package that wants to comply to a spec, and ask for a change to stop my build from crashing, so I looked into the spec as well, and noticed it's a bit ambiguous on this topic. Only this paragraph is somewhat related:

When trashing a file or directory, the implementation should check whether the user has the necessary permissions to delete it, before starting the trashing operation itself.

So, while this package is spec-compliant in giving me /.Trash-1000, it's important to consider the package that's going to receive this path. Is it going to mkdir -p it and write to it right away, without checking for permissions? Most likely.

If you consider this issue to be worth a fs.access check before returning a path, I'm willing to send a PR (with or without an opt-in flag)

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

No branches or pull requests

1 participant