I cannot seem to work out how to protect a symbolic symlink from being deleted/removed or overwritten. Any ideas?
2 Answers
You need to deny access to the directory where symlink resides.
EDIT:
When you move/rename/delete a file in Unix based operating systems, you are modifying the directory in which they are located, not the files themselves. So permissions on the file don't matter at all.
-
But that would be overkill because there are files in the directory that are being worked with.– hendryDec 8, 2015 at 5:26
-
When you delete a symlink, is the same as you delete a normal file. The only permission checked are on the folder. You can limit access to the folder with a SELinux policy, or other mechanisms. But the main question is what is the real problem you are trying to solve? Dec 8, 2015 at 5:38
-
You cannot change the permissions (or attributes) of a link, trying to do so is meaningless. From the chmod man page
chmod never changes the permissions of symbolic links; the chmod system call cannot change their permissions. This is not a problem since the permissions of symbolic links are never used. However, for each symbolic link listed on the command line, chmod changes the permissions of the pointed-to file.