summaryrefslogtreecommitdiffstats
path: root/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2009-07-20 19:16:42 +0000
committertrasz <trasz@FreeBSD.org>2009-07-20 19:16:42 +0000
commit2e0ead9bff63a683d717b2a523d25b3ccd790998 (patch)
tree3f19606bb95c9209da69a7a8e8a3301a94ec569d /sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
parent0dabd4da957e96805f21216cc44bc94439647949 (diff)
downloadFreeBSD-src-2e0ead9bff63a683d717b2a523d25b3ccd790998.zip
FreeBSD-src-2e0ead9bff63a683d717b2a523d25b3ccd790998.tar.gz
Fix permission handling for extended attributes in ZFS. Without
this change, ZFS uses SunOS Alternate Data Streams semantics - each EA has its own permissions, which are set at EA creation time and - unlike SunOS - invisible to the user and impossible to change. From the user point of view, it's just broken: sometimes access is granted when it shouldn't be, sometimes it's denied when it shouldn't be. This patch makes it behave just like UFS, i.e. depend on current file permissions. Also, it fixes returned error codes (ENOATTR instead of ENOENT) and makes listextattr(2) return 0 instead of EPERM where there is no EA directory (i.e. the file never had any EA). Reviewed by: pjd (idea, not actual code) Approved by: re (kib)
Diffstat (limited to 'sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c')
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
index dfbebc2..d466273 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
@@ -2360,6 +2360,15 @@ zfs_zaccess(znode_t *zp, int mode, int flags, boolean_t skipaclchk, cred_t *cr)
is_attr = ((zp->z_phys->zp_flags & ZFS_XATTR) &&
(ZTOV(zp)->v_type == VDIR));
+#ifdef __FreeBSD__
+ /*
+ * In FreeBSD, we don't care about permissions of individual ADS.
+ * Note that not checking them is not just an optimization - without
+ * this shortcut, EA operations may bogusly fail with EACCES.
+ */
+ if (zp->z_phys->zp_flags & ZFS_XATTR)
+ return (0);
+#else
/*
* If attribute then validate against base file
*/
@@ -2385,6 +2394,7 @@ zfs_zaccess(znode_t *zp, int mode, int flags, boolean_t skipaclchk, cred_t *cr)
mode |= ACE_READ_NAMED_ATTRS;
}
}
+#endif
if ((error = zfs_zaccess_common(check_zp, mode, &working_mode,
&check_privs, skipaclchk, cr)) == 0) {
OpenPOWER on IntegriCloud