]> granicus.if.org Git - zfs/commitdiff
Don't perform ACL-to-mode translation on empty ACL
authorTim Chase <tim@chase2k.com>
Tue, 7 Oct 2014 13:01:01 +0000 (08:01 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 21 Oct 2014 16:23:27 +0000 (09:23 -0700)
In zfs_acl_chown_setattr(), the zfs_mode_comput() function is used to
create a traditional mode value based on an ACL.  If no ACL exists, this
processing shouldn't be done.  Problems caused by this were most evident
on version 4 filesystems which not only don't have system attributes,
and also frequently have empty ACLs. On such filesystems, performing a
chown() operation could have the effect of dirtying the mode bits in
memory but not on the file system as follows:

# create a file with typical mode of 664
echo test > test
chown anyuser test
ls -l test

and the mode will show up as all zeroes.  Unmounting/mounting and/or
exporting/importing the filesystem will reveal the proper mode again.

Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1264

module/zfs/zfs_acl.c

index 89b624528deffa2522ec27f3a99ed3157c07d0b9..f3eb6c3dd85da77d2c45afd04687feb22e613ae0 100644 (file)
@@ -1162,7 +1162,8 @@ zfs_acl_chown_setattr(znode_t *zp)
        ASSERT(MUTEX_HELD(&zp->z_lock));
        ASSERT(MUTEX_HELD(&zp->z_acl_lock));
 
-       if ((error = zfs_acl_node_read(zp, B_TRUE, &aclp, B_FALSE)) == 0)
+       error = zfs_acl_node_read(zp, B_TRUE, &aclp, B_FALSE);
+       if (error == 0 && aclp->z_acl_count > 0)
                zp->z_mode = zfs_mode_compute(zp->z_mode, aclp,
                    &zp->z_pflags, zp->z_uid, zp->z_gid);