Try this code
root /home/user $ touch hehehe
then as a normal user
user ~ $ rm -f hehehe
Our user can remove a root-owned file inside of their home directory. This works not only in their home directory, but inside of any directory writable by them.
root /home/user $ mkdir -p testdir
user ~ $ rm -rf testdir
Works too. However:
root /home/user $ mkdir -p testdir/childdir user ~ $ rm -rf testdir/childdir
fails, so our user apparently cannot delete non-empty non-writable directories inside writable directories.
By my understanding, all three of these test cases should have failed. But apparently when a directory is writable, that endows a user with some non-trivial capabilities with regard to its contents.
What are the exact rules regarding which of the primitive filesystem operations (
delete, etc.)` may be performed with respect to the filesystem permissions that a user has?