s3: vfs_fruit: Ensure we operate on a copy of the incoming security descriptor.
authorJeremy Allison <jra@samba.org>
Fri, 2 Mar 2018 21:21:37 +0000 (13:21 -0800)
committerRalph Boehme <slow@samba.org>
Wed, 7 Mar 2018 22:11:21 +0000 (23:11 +0100)
This will allow us to modify it in the next commit.

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

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

index 50fbd6cb4470d31655d91ca0a8ef11520f74058d..4f383bc990d45d02ae103f413e2bb8dc558773bc 100644 (file)
@@ -5769,24 +5769,32 @@ static NTSTATUS fruit_fget_nt_acl(vfs_handle_struct *handle,
 static NTSTATUS fruit_fset_nt_acl(vfs_handle_struct *handle,
                                  files_struct *fsp,
                                  uint32_t security_info_sent,
-                                 const struct security_descriptor *psd)
+                                 const struct security_descriptor *orig_psd)
 {
        NTSTATUS status;
        bool do_chmod;
        mode_t ms_nfs_mode = 0;
        int result;
+       struct security_descriptor *psd = NULL;
+
+       psd = security_descriptor_copy(talloc_tos(), orig_psd);
+       if (psd == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
 
        DBG_DEBUG("fruit_fset_nt_acl: %s\n", fsp_str_dbg(fsp));
 
        status = check_ms_nfs(handle, fsp, psd, &ms_nfs_mode, &do_chmod);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(1, ("fruit_fset_nt_acl: check_ms_nfs failed%s\n", fsp_str_dbg(fsp)));
+               TALLOC_FREE(psd);
                return status;
        }
 
        status = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(1, ("fruit_fset_nt_acl: SMB_VFS_NEXT_FSET_NT_ACL failed%s\n", fsp_str_dbg(fsp)));
+               TALLOC_FREE(psd);
                return status;
        }
 
@@ -5804,10 +5812,12 @@ static NTSTATUS fruit_fset_nt_acl(vfs_handle_struct *handle,
                                  result, (unsigned)ms_nfs_mode,
                                  strerror(errno)));
                        status = map_nt_error_from_unix(errno);
+                       TALLOC_FREE(psd);
                        return status;
                }
        }
 
+       TALLOC_FREE(psd);
        return NT_STATUS_OK;
 }