$HOME
directory, thinking about your business.$ whoami
> user
$ pwd
> /home/user
$ ls -lah ./left-shoe
---------- 1 root root 4 May 30 13:20 little-rock
root
, Rock Tamer, and only he decides his fate.# bash -c "echo 'You stay here' > /home/user/left-shoe/little-rock"
# chmod 0000 /home/user/left-shoe/little-rock
sudo
. Suddenly, you feel a surge of strength (due to watching Gladiator last night) and decide to put off the phone in order to test your power.$ rm -f ./left-shoe/little-rock
$ ls -lah ./left-shoe/little-rock
ls: cannot access little-rock: No such file or directory
--- --- ---
). No readings, no records, no action from anyone (owner, group, others).$HOME
. And that's why.inode
for the files in this folder, which is crucial in this context, since the deletion process detaches the file.write()
system call. In practice, we don’t need any permissions to delete a file and we don’t care who owns it. The only requirement is to have permissions to write to the parent directory (and the execution flag for the parent directory).$HOME
directory naturally meets both of these requirements from the user's point of view.# chattr +i /home/user/left-shoe/little-rock
The file with the attribute 'i' cannot be changed: it cannot be deleted or renamed, a link cannot be created to this file and no data can be written to it. Only the superuser or process owning CAP_LINUX_IMMUTABLE can set or remove an attribute.
Source: https://habr.com/ru/post/337316/
All Articles