Changeset View
Changeset View
Standalone View
Standalone View
sys/contrib/openzfs/module/os/freebsd/zfs/zfs_acl.c
| Show First 20 Lines • Show All 2,351 Lines • ▼ Show 20 Lines | zfs_zaccess(znode_t *zp, int mode, int flags, boolean_t skipaclchk, cred_t *cr, | ||||
| uid_t owner; | uid_t owner; | ||||
| is_attr = ((zp->z_pflags & ZFS_XATTR) && (ZTOV(zp)->v_type == VDIR)); | is_attr = ((zp->z_pflags & ZFS_XATTR) && (ZTOV(zp)->v_type == VDIR)); | ||||
| /* | /* | ||||
| * In FreeBSD, we don't care about permissions of individual ADS. | * In FreeBSD, we don't care about permissions of individual ADS. | ||||
| * Note that not checking them is not just an optimization - without | * Note that not checking them is not just an optimization - without | ||||
| * this shortcut, EA operations may bogusly fail with EACCES. | * this shortcut, EA operations may bogusly fail with EACCES. | ||||
| * | |||||
| * If this is a named attribute lookup, do the checks. | |||||
| */ | */ | ||||
| if (zp->z_pflags & ZFS_XATTR) | if ((zp->z_pflags & ZFS_XATTR) | ||||
| #if __FreeBSD_version >= 1500040 | |||||
| && (flags & V_NAMEDATTR) == 0 | |||||
| #endif | |||||
| ) | |||||
| return (0); | return (0); | ||||
| /* | |||||
| * If a named attribute directory then validate against base file | |||||
| */ | |||||
| if (is_attr) { | |||||
| if ((error = zfs_zget(ZTOZSB(zp), | |||||
| zp->z_xattr_parent, &xzp)) != 0) { | |||||
| return (error); | |||||
| } | |||||
| check_zp = xzp; | |||||
| /* | |||||
| * fixup mode to map to xattr perms | |||||
| */ | |||||
| if (mode & (ACE_WRITE_DATA|ACE_APPEND_DATA)) { | |||||
| mode &= ~(ACE_WRITE_DATA|ACE_APPEND_DATA); | |||||
| mode |= ACE_WRITE_NAMED_ATTRS; | |||||
| } | |||||
| if (mode & (ACE_READ_DATA|ACE_EXECUTE)) { | |||||
| mode &= ~(ACE_READ_DATA|ACE_EXECUTE); | |||||
| mode |= ACE_READ_NAMED_ATTRS; | |||||
| } | |||||
| } | |||||
| owner = zfs_fuid_map_id(zp->z_zfsvfs, zp->z_uid, cr, ZFS_OWNER); | owner = zfs_fuid_map_id(zp->z_zfsvfs, zp->z_uid, cr, ZFS_OWNER); | ||||
| /* | /* | ||||
| * Map the bits required to the standard vnode flags VREAD|VWRITE|VEXEC | * Map the bits required to the standard vnode flags VREAD|VWRITE|VEXEC | ||||
| * in needed_bits. Map the bits mapped by working_mode (currently | * in needed_bits. Map the bits mapped by working_mode (currently | ||||
| * missing) in missing_bits. | * missing) in missing_bits. | ||||
| * Call secpolicy_vnode_access2() with (needed_bits & ~checkmode), | * Call secpolicy_vnode_access2() with (needed_bits & ~checkmode), | ||||
| * needed_bits. | * needed_bits. | ||||
| ▲ Show 20 Lines • Show All 305 Lines • Show Last 20 Lines | |||||