3 ms·
There are two checks prohibiting it: • Non-root users aren't allowed to make directory hard links. • Many versions of the userspace program `ln` don't let you
by wizzwizz4 2y ago
There are two checks prohibiting it:
• Non-root users aren't allowed to make directory hard links.
• Many versions of the userspace program `ln` don't let you do it.
But the `link` system call can, at least on Solaris, if called by user 0. (Not sure about Linux: I tried it once and it didn't work, but I was doing weird things with FUSE and also trying to name the link `..`, so I don't know why it failed.)
- deleted 2y ago[deleted]
- ryao 2y agoIt is more nuanced than that. First, the Solaris 11.4 documentation says that this is not allowed: https://docs.oracle.com/cd/E88353_01/html/E72487/link-8.html https://docs.oracle.com/cd/E88353_01/html/E72487/link-8.html The illumos man page is less clear: https://illumos.org/man/8/link https://illumos.org/man/8/link The illumos ZFS driver makes it very clear that this is not allowed under POSIX in a comment and explicitly disallows it in zfs_link(): https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/fs/zfs/zfs_vnops.c#L4476 https://github.com/illumos/illumos-gate/blob/master/usr/src/... However, It appears that the illumos UFS driver supports this: https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/fs/ufs/ufs_vnops.c#L3195 https://github.com/illumos/illumos-gate/blob/master/usr/src/... Presumably, the Solaris 10 UFS driver also supports it (or supported it in older versions of Solaris 10). Given that someone at Oracle likely modified the Solaris man page to differ from the older OpenSolaris man page in illumos, I would expect recent versions of Solaris to disallow this on UFS, but someone would need to check. That said, I have to recant my previous comment. smw likely linked the directory, which is insane, but would have worked on older Solaris versions if we assume the modern illumos UFS driver is unchanged in this regard.