Implement sysctls to restrict a user's ability to hardlink files owned by
authorMatthew Dillon <dillon@dragonflybsd.org>
Thu, 29 Sep 2005 20:59:30 +0000 (20:59 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Thu, 29 Sep 2005 20:59:30 +0000 (20:59 +0000)
commit8c40f81e4dc1ed5192c4964ae97bd3be7c2f34c2
treefaadb1b8234afef347ea746a3d6a6271adb93cf8
parentd41cbec35e34b2af14cf5c53ed60c8f01428158d
Implement sysctls to restrict a user's ability to hardlink files owned by
other users or groups.  These sysctls are in addition to checks already made
(that the user must also be able to write to the file via user, group,
or world perms).

kern.hardlink_check_uid If set the user must own the file to
be able to create a hardlink, or be root.

kern.hardlink_check_gid If set the user must either own the file
or be a member of the same group as the
file, or be root.

Setting both flags is equivalent to just
setting the uid flag.

Taken from FreeBSD with slightly different semantics for hardlink_check_gid.
In DragonFly, if hardlink_check_gid is set, the file can still be hardlinked
if the user is not a member of the file's group if the user owns the file.
non-group membership is quite common due to group inheritance from the
parent directory when a file or directory is created by the user and
disallowing the case would make hardlink_check_gid non-useful.

Submitted-by: Matthias Schmidt <schmidtm@mathematik.uni-marburg.de>
sys/kern/vfs_syscalls.c