ali-rantakari / trash

Small command-line program for OS X that moves files or folders to the trash.
574 stars 16 forks source link

trash ignores sudo #18

Closed acook closed 8 years ago

acook commented 8 years ago

If I do sudo trash some_protected_file I get a GUI auth popup.

I'd expected it to not need additional permissions when being involved with sudo.

ali-rantakari commented 8 years ago

This is by design — the Trash folder is user-specific and you probably don't want files to end up in root's Trash folder.

acook commented 8 years ago

The original user is trivially discovered.

ali-rantakari commented 8 years ago

Yep, but knowing who the sudoer is is not the problem — moving the files to that user's trash in a reliable, safe, and consistent manner is. trash specifically does not perform the operation manually, but instead either uses system APIs to do it or delegates it to Finder via Apple Events — in both cases the user of the process determines which Trash folder is used.

In other words, this could be implemented if trash performed the operation manually, but delegating it to the system instead is an explicit design decision that I consider very important.

acook commented 8 years ago

That makes sense. Though it is still possible to execute as another user, I'm not sure what the deal is with trying to trash privileged files being allowed by the API, so I can't provide a workaround.