s3: VFS: posixacl: Fix the fallback code in posixacl_sys_acl_set_fd().
authorJeremy Allison <jra@samba.org>
Wed, 9 Jun 2021 00:36:50 +0000 (17:36 -0700)
committerRalph Boehme <slow@samba.org>
Wed, 9 Jun 2021 13:14:29 +0000 (13:14 +0000)
We weren't maping or using the incoming SMB_ACL_TYPE_T type
parameter correctly.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_posixacl.c

index 4a3dc1b825807c2cc86dcca402d8d915c91043a3..534248a6b6420e8d06b52cc6e98951aab42b0395 100644 (file)
@@ -142,12 +142,26 @@ int posixacl_sys_acl_set_fd(vfs_handle_struct *handle,
 {
        int res;
        acl_t acl = smb_acl_to_posix(theacl);
+       acl_type_t acl_type;
        int fd = fsp_get_pathref_fd(fsp);
 
        if (acl == NULL) {
                return -1;
        }
 
+       switch(type) {
+       case SMB_ACL_TYPE_ACCESS:
+               acl_type = ACL_TYPE_ACCESS;
+               break;
+       case SMB_ACL_TYPE_DEFAULT:
+               acl_type = ACL_TYPE_DEFAULT;
+               break;
+       default:
+               acl_free(acl);
+               errno = EINVAL;
+               return -1;
+       }
+
        if (!fsp->fsp_flags.is_pathref && type == SMB_ACL_TYPE_ACCESS) {
                res = acl_set_fd(fd, acl);
        } else if (fsp->fsp_flags.have_proc_fds) {
@@ -159,13 +173,13 @@ int posixacl_sys_acl_set_fd(vfs_handle_struct *handle,
                        acl_free(acl);
                        return -1;
                }
-               res = acl_set_file(proc_fd_path, type, acl);
+               res = acl_set_file(proc_fd_path, acl_type, acl);
        } else {
                /*
                 * This is no longer a handle based call.
                 */
                res = acl_set_file(fsp->fsp_name->base_name,
-                                  type,
+                                  acl_type,
                                   acl);
        }