nfs4_acls: Add helper function for checking INHERIT flags.
authorChristof Schmitt <cs@samba.org>
Wed, 26 Jun 2019 20:20:17 +0000 (13:20 -0700)
committerChristof Schmitt <cs@samba.org>
Tue, 23 Jul 2019 18:27:26 +0000 (18:27 +0000)
This avoids some code duplication. Do not make this static, as it will
be used in a later patch.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14032

Signed-off-by: Christof Schmit <cs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/nfs4_acls.c
source3/modules/nfs4_acls.h

index b2ba4d1d7019080b5cec51a2754be43302503bf3..bab73a5cb58cdbbc779546bf679baef71f0bff4c 100644 (file)
@@ -255,6 +255,13 @@ bool smbacl4_set_controlflags(struct SMB4ACL_T *acl, uint16_t controlflags)
        return true;
 }
 
+bool nfs_ace_is_inherit(SMB_ACE4PROP_T *ace)
+{
+       return ace->aceFlags & (SMB_ACE4_INHERIT_ONLY_ACE|
+                               SMB_ACE4_FILE_INHERIT_ACE|
+                               SMB_ACE4_DIRECTORY_INHERIT_ACE);
+}
+
 static int smbacl4_GetFileOwner(struct connection_struct *conn,
                                const struct smb_filename *smb_fname,
                                SMB_STRUCT_STAT *psbuf)
@@ -846,9 +853,7 @@ static int smbacl4_substitute_simple(
                if (!(ace->flags & SMB_ACE4_ID_SPECIAL) &&
                    !(ace->aceFlags & SMB_ACE4_IDENTIFIER_GROUP) &&
                    ace->who.uid == ownerUID &&
-                   !(ace->aceFlags & SMB_ACE4_INHERIT_ONLY_ACE) &&
-                   !(ace->aceFlags & SMB_ACE4_FILE_INHERIT_ACE) &&
-                   !(ace->aceFlags & SMB_ACE4_DIRECTORY_INHERIT_ACE)) {
+                   !nfs_ace_is_inherit(ace)) {
                        ace->flags |= SMB_ACE4_ID_SPECIAL;
                        ace->who.special_id = SMB_ACE4_WHO_OWNER;
                        DEBUG(10,("replaced with special owner ace\n"));
@@ -857,9 +862,7 @@ static int smbacl4_substitute_simple(
                if (!(ace->flags & SMB_ACE4_ID_SPECIAL) &&
                    ace->aceFlags & SMB_ACE4_IDENTIFIER_GROUP &&
                    ace->who.gid == ownerGID &&
-                   !(ace->aceFlags & SMB_ACE4_INHERIT_ONLY_ACE) &&
-                   !(ace->aceFlags & SMB_ACE4_FILE_INHERIT_ACE) &&
-                   !(ace->aceFlags & SMB_ACE4_DIRECTORY_INHERIT_ACE)) {
+                   !nfs_ace_is_inherit(ace)) {
                        ace->flags |= SMB_ACE4_ID_SPECIAL;
                        ace->who.special_id = SMB_ACE4_WHO_GROUP;
                        DEBUG(10,("replaced with special group ace\n"));
index a73b3154f0f39e19b3d5286c6b76f68d73fcccaa..d0cf2d0f1fb0c76de2747bbeeb7b3a6f9c36b3f1 100644 (file)
@@ -143,6 +143,8 @@ uint16_t smbacl4_get_controlflags(struct SMB4ACL_T *theacl);
 
 bool smbacl4_set_controlflags(struct SMB4ACL_T *theacl, uint16_t controlflags);
 
+bool nfs_ace_is_inherit(SMB_ACE4PROP_T *ace);
+
 NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp,
        const struct smbacl4_vfs_params *pparams,
        uint32_t security_info,