Why do files with multiple hard links lose 'Authenticated Users' read/write access (and how to make not happen)?
After playing with hard links on a test Win7 system after receiving a fantastic answer by community member Pimp Juice IT to another question (Is there a clever way to group a bunch of files together besides using a folder (for Windows desktop background images)?), I noticed that files with multiple hard links lose their Authenticated Users
read/write access security setting if any of their hard links are placed in the Recycle Bin. This also causes a padlock to appear over all other hard links to the file.
Actually emptying the Recycle Bin makes no difference.
Bypassing the Recycle Bin and directly deleting a hard link does not cause this to happen.
Why does this happen when deleting a hard link to the Recycle Bin (when multiple hard links point to the same object), and is there any way to prevent it from happening?
Here's a quick read on the difference between a Symbolic Link and aa Hard Link.
In the simplest terms (an arrow represents "points to" or a direct pointer):
Shortcut:
Symbolic Link:
Hard Link:
With the little node representing the NTFS equivalent of an inode on the hard drive in which the file resides.
So when you take that hard link, and toss it into the Recycle Bin, just like any other file, Windows is changing permissions and doing things to the file to keep it in a Recycled State (it can only be used again if it is restored, you cannot use it from the Recycle Bin). So when you do this to a hard link, as you can see above, you're really doing it to the core file (as is expected with a hard link), and thus, causing the changes to be reflected in all the other hard links as well.
The solution to your issue would be to either utilize Symbolic Links or shortcuts, or use the del
command from the command line on the hard link you want to remove instead of putting it through the Recycle Bin.
For more information, simply read the Microsoft Documentation on Hard Links:
Note that the attributes on the file are reflected in every hard link to that file, and changes to that file's attributes propagate to all the hard links. For example if you reset the READONLY attribute on a hard link to delete that particular hard link, and there are multiple hard links to the actual file, then you will need to reset the READONLY bit on the file from one of the remaining hard links to bring the file and all remaining hard links back to the READONLY state.