TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Delete files owned by root, without being root

13 pointsby mustpaxalmost 13 years ago

7 comments

NelsonMinaralmost 13 years ago
Maybe my brain has been twisted by too many years of using Unix, but that's exactly how it's supposed to work. "rm" is really editing the directory, not the file, so the owner of the directory is what matters. The file may not actually even be deleted; if there's a hard link to it from another directory the file will still be there in the other places. inodes are awesome.
评论 #4121028 未加载
评论 #4138606 未加载
评论 #4121036 未加载
saurikalmost 13 years ago
If you leave a locked safe in my locked house, I cannot open the safe but I can easily dispose of it. I would argue that this behavior is intuitive.
评论 #4120997 未加载
majkealmost 13 years ago
Relevant `unlink` attack:<p><a href="http://lcamtuf.coredump.cx/tmp_paper.txt" rel="nofollow">http://lcamtuf.coredump.cx/tmp_paper.txt</a>
评论 #4120993 未加载
zdwalmost 13 years ago
If you want to modify this behavior, ACL's or "Extended Attributes" are your friends:<p><a href="http://en.wikipedia.org/wiki/Extended_file_attributes" rel="nofollow">http://en.wikipedia.org/wiki/Extended_file_attributes</a><p>See also the "chattr" or "xattr" commands, depending on your unix variant
wglbalmost 13 years ago
And this is common knowledge.
评论 #4121004 未加载
makomkalmost 13 years ago
This is of course intentional. As far as I can tell, though, you can't delete a non-empty subdirectory owned by root containing files that are also owned by root, even if you own the directory containing that subdirectory. In order to delete the subdirectory you need to delete the files in it, and you can't do that unless you have permission to modify that subdirectory.
gavingalmost 13 years ago
Delete files in directory owned by root, without being root <a href="http://en.wikipedia.org/wiki/Sticky_bit" rel="nofollow">http://en.wikipedia.org/wiki/Sticky_bit</a>