Skip to content

Commit

Permalink
FreeBSD: handle UF_NOUNLINK chflags fflag
Browse files Browse the repository at this point in the history
The `UF_NOUNLINK` chflags fflag is analogous to `SF_NOUNLINK`, but instead
of requiring superuser privileges when setting `SF_NOUNLINK`, unprivileged
users (in addition to root) can set `UF_NOUNLINK` on compatible paths.

This makes commands like `chflags uunlink <foo>` work on FreeBSD.

This closes openzfs#16809.

Signed-off-by: Enji Cooper <[email protected]>
  • Loading branch information
ngie-eign committed Nov 29, 2024
1 parent 0ffa6f3 commit d9bb3d0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion module/os/freebsd/zfs/zfs_vnops_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -4750,6 +4750,8 @@ zfs_freebsd_getattr(struct vop_getattr_args *ap)
xvap.xva_xoptattrs.xoa_archive);
FLAG_CHECK(UF_NODUMP, XAT_NODUMP,
xvap.xva_xoptattrs.xoa_nodump);
FLAG_CHECK(UF_NOUNLINK, XAT_NOUNLINK,
xvap.xva_xoptattrs.xoa_nounlink);
FLAG_CHECK(UF_READONLY, XAT_READONLY,
xvap.xva_xoptattrs.xoa_readonly);
FLAG_CHECK(UF_SYSTEM, XAT_SYSTEM,
Expand Down Expand Up @@ -4812,7 +4814,7 @@ zfs_freebsd_setattr(struct vop_setattr_args *ap)
*/
if ((fflags & ~(SF_IMMUTABLE|SF_APPEND|SF_NOUNLINK|UF_ARCHIVE|
UF_NODUMP|UF_SYSTEM|UF_HIDDEN|UF_READONLY|UF_REPARSE|
UF_OFFLINE|UF_SPARSE)) != 0)
UF_OFFLINE|UF_SPARSE|UF_NOUNLINK)) != 0)
return (EOPNOTSUPP);
/*
* Unprivileged processes are not permitted to unset system
Expand Down Expand Up @@ -4869,6 +4871,8 @@ zfs_freebsd_setattr(struct vop_setattr_args *ap)
xvap.xva_xoptattrs.xoa_archive);
FLAG_CHANGE(UF_NODUMP, ZFS_NODUMP, XAT_NODUMP,
xvap.xva_xoptattrs.xoa_nodump);
FLAG_CHANGE(UF_NOUNLINK, ZFS_NOUNLINK, XAT_NOUNLINK,
xvap.xva_xoptattrs.xoa_nounlink);
FLAG_CHANGE(UF_READONLY, ZFS_READONLY, XAT_READONLY,
xvap.xva_xoptattrs.xoa_readonly);
FLAG_CHANGE(UF_SYSTEM, ZFS_SYSTEM, XAT_SYSTEM,
Expand Down

0 comments on commit d9bb3d0

Please sign in to comment.