mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Cross-platform acltype
The acltype property is currently hidden on FreeBSD and does not reflect the NFSv4 style ZFS ACLs used on the platform. This makes it difficult to observe that a pool imported from FreeBSD on Linux has a different type of ACL that is being ignored, and vice versa. Add an nfsv4 acltype and expose the property on FreeBSD. Make the default acltype nfsv4 on FreeBSD. Setting acltype to an unhanded style is treated the same as setting it to off. The ACLs will not be removed, but they will be ignored. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ryan Moeller <ryan@iXsystems.com> Closes #10520
This commit is contained in:
@@ -2494,7 +2494,7 @@ zfs_zaccess(znode_t *zp, int mode, int flags, boolean_t skipaclchk, cred_t *cr)
|
||||
|
||||
/*
|
||||
* Translate traditional unix VREAD/VWRITE/VEXEC mode into
|
||||
* native ACL format and call zfs_zaccess()
|
||||
* NFSv4-style ZFS ACL format and call zfs_zaccess()
|
||||
*/
|
||||
int
|
||||
zfs_zaccess_rwx(znode_t *zp, mode_t mode, int flags, cred_t *cr)
|
||||
|
||||
@@ -592,6 +592,14 @@ acl_inherit_changed_cb(void *arg, uint64_t newval)
|
||||
zfsvfs->z_acl_inherit = newval;
|
||||
}
|
||||
|
||||
static void
|
||||
acl_type_changed_cb(void *arg, uint64_t newval)
|
||||
{
|
||||
zfsvfs_t *zfsvfs = arg;
|
||||
|
||||
zfsvfs->z_acl_type = newval;
|
||||
}
|
||||
|
||||
static int
|
||||
zfs_register_callbacks(vfs_t *vfsp)
|
||||
{
|
||||
@@ -722,6 +730,8 @@ zfs_register_callbacks(vfs_t *vfsp)
|
||||
zfs_prop_to_name(ZFS_PROP_EXEC), exec_changed_cb, zfsvfs);
|
||||
error = error ? error : dsl_prop_register(ds,
|
||||
zfs_prop_to_name(ZFS_PROP_SNAPDIR), snapdir_changed_cb, zfsvfs);
|
||||
error = error ? error : dsl_prop_register(ds,
|
||||
zfs_prop_to_name(ZFS_PROP_ACLTYPE), acl_type_changed_cb, zfsvfs);
|
||||
error = error ? error : dsl_prop_register(ds,
|
||||
zfs_prop_to_name(ZFS_PROP_ACLMODE), acl_mode_changed_cb, zfsvfs);
|
||||
error = error ? error : dsl_prop_register(ds,
|
||||
@@ -797,6 +807,11 @@ zfsvfs_init(zfsvfs_t *zfsvfs, objset_t *os)
|
||||
return (error);
|
||||
zfsvfs->z_case = (uint_t)val;
|
||||
|
||||
error = zfs_get_zplprop(os, ZFS_PROP_ACLTYPE, &val);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
zfsvfs->z_acl_type = (uint_t)val;
|
||||
|
||||
/*
|
||||
* Fold case on file systems that are always or sometimes case
|
||||
* insensitive.
|
||||
@@ -1232,6 +1247,10 @@ zfs_domount(vfs_t *vfsp, char *osname)
|
||||
"xattr", &pval, NULL)))
|
||||
goto out;
|
||||
xattr_changed_cb(zfsvfs, pval);
|
||||
if ((error = dsl_prop_get_integer(osname,
|
||||
"acltype", &pval, NULL)))
|
||||
goto out;
|
||||
acl_type_changed_cb(zfsvfs, pval);
|
||||
zfsvfs->z_issnap = B_TRUE;
|
||||
zfsvfs->z_os->os_sync = ZFS_SYNC_DISABLED;
|
||||
|
||||
@@ -2220,6 +2239,9 @@ zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value)
|
||||
case ZFS_PROP_CASE:
|
||||
*value = ZFS_CASE_SENSITIVE;
|
||||
break;
|
||||
case ZFS_PROP_ACLTYPE:
|
||||
*value = ZFS_ACLTYPE_NFSV4;
|
||||
break;
|
||||
default:
|
||||
return (error);
|
||||
}
|
||||
|
||||
@@ -4744,6 +4744,8 @@ static int
|
||||
zfs_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr,
|
||||
caller_context_t *ct)
|
||||
{
|
||||
znode_t *zp;
|
||||
zfsvfs_t *zfsvfs;
|
||||
|
||||
switch (cmd) {
|
||||
case _PC_LINK_MAX:
|
||||
@@ -4757,11 +4759,25 @@ zfs_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr,
|
||||
*valp = (int)SPA_MINBLOCKSIZE;
|
||||
return (0);
|
||||
case _PC_ACL_EXTENDED:
|
||||
#if 0 /* POSIX ACLs are not implemented for ZFS on FreeBSD yet. */
|
||||
zp = VTOZ(vp);
|
||||
zfsvfs = zp->z_zfsvfs;
|
||||
ZFS_ENTER(zfsvfs);
|
||||
ZFS_VERIFY_ZP(zp);
|
||||
*valp = zfsvfs->z_acl_type == ZFSACLTYPE_POSIX ? 1 : 0;
|
||||
ZFS_EXIT(zfsvfs);
|
||||
#else
|
||||
*valp = 0;
|
||||
#endif
|
||||
return (0);
|
||||
|
||||
case _PC_ACL_NFS4:
|
||||
*valp = 1;
|
||||
zp = VTOZ(vp);
|
||||
zfsvfs = zp->z_zfsvfs;
|
||||
ZFS_ENTER(zfsvfs);
|
||||
ZFS_VERIFY_ZP(zp);
|
||||
*valp = zfsvfs->z_acl_type == ZFS_ACLTYPE_NFSV4 ? 1 : 0;
|
||||
ZFS_EXIT(zfsvfs);
|
||||
return (0);
|
||||
|
||||
case _PC_ACL_PATH_MAX:
|
||||
|
||||
@@ -2666,7 +2666,7 @@ zfs_zaccess(znode_t *zp, int mode, int flags, boolean_t skipaclchk, cred_t *cr)
|
||||
|
||||
/*
|
||||
* Translate traditional unix S_IRUSR/S_IWUSR/S_IXUSR mode into
|
||||
* native ACL format and call zfs_zaccess()
|
||||
* NFSv4-style ZFS ACL format and call zfs_zaccess()
|
||||
*/
|
||||
int
|
||||
zfs_zaccess_rwx(znode_t *zp, mode_t mode, int flags, cred_t *cr)
|
||||
|
||||
@@ -352,6 +352,7 @@ acltype_changed_cb(void *arg, uint64_t newval)
|
||||
zfsvfs_t *zfsvfs = arg;
|
||||
|
||||
switch (newval) {
|
||||
case ZFS_ACLTYPE_NFSV4:
|
||||
case ZFS_ACLTYPE_OFF:
|
||||
zfsvfs->z_acl_type = ZFS_ACLTYPE_OFF;
|
||||
zfsvfs->z_sb->s_flags &= ~SB_POSIXACL;
|
||||
|
||||
@@ -254,6 +254,7 @@ zfs_prop_init(void)
|
||||
static zprop_index_t acltype_table[] = {
|
||||
{ "off", ZFS_ACLTYPE_OFF },
|
||||
{ "posix", ZFS_ACLTYPE_POSIX },
|
||||
{ "nfsv4", ZFS_ACLTYPE_NFSV4 },
|
||||
{ "disabled", ZFS_ACLTYPE_OFF }, /* bkwrd compatibility */
|
||||
{ "noacl", ZFS_ACLTYPE_OFF }, /* bkwrd compatibility */
|
||||
{ "posixacl", ZFS_ACLTYPE_POSIX }, /* bkwrd compatibility */
|
||||
@@ -428,11 +429,15 @@ zfs_prop_init(void)
|
||||
PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
|
||||
"discard | groupmask | passthrough | restricted", "ACLMODE",
|
||||
acl_mode_table);
|
||||
#ifndef __FreeBSD__
|
||||
zprop_register_index(ZFS_PROP_ACLTYPE, "acltype", ZFS_ACLTYPE_OFF,
|
||||
PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
|
||||
"off | posix", "ACLTYPE", acltype_table);
|
||||
zprop_register_index(ZFS_PROP_ACLTYPE, "acltype",
|
||||
#ifdef __linux__
|
||||
/* Linux doesn't natively support ZFS's NFSv4-style ACLs. */
|
||||
ZFS_ACLTYPE_OFF,
|
||||
#else
|
||||
ZFS_ACLTYPE_NFSV4,
|
||||
#endif
|
||||
PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
|
||||
"off | nfsv4 | posix", "ACLTYPE", acltype_table);
|
||||
zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit",
|
||||
ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
|
||||
"discard | noallow | restricted | passthrough | passthrough-x",
|
||||
@@ -702,12 +707,6 @@ zfs_prop_init(void)
|
||||
* that we don't have to change the values of the zfs_prop_t enum, or
|
||||
* have NULL pointers in the zfs_prop_table[].
|
||||
*/
|
||||
#ifdef __FreeBSD__
|
||||
zprop_register_impl(ZFS_PROP_ACLTYPE, "acltype", PROP_TYPE_INDEX,
|
||||
ZFS_ACLTYPE_OFF, NULL, PROP_INHERIT,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
|
||||
"off | posix", "ACLTYPE", B_FALSE, B_FALSE, acltype_table);
|
||||
#endif
|
||||
zprop_register_hidden(ZFS_PROP_REMAPTXG, "remaptxg", PROP_TYPE_NUMBER,
|
||||
PROP_READONLY, ZFS_TYPE_DATASET, "REMAPTXG");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user