]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: use real dirfsp and atname when deleting file in close_remove_share_mode()
authorRalph Boehme <slow@samba.org>
Thu, 21 Jan 2021 15:45:47 +0000 (16:45 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 28 Jan 2021 08:11:49 +0000 (08:11 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/close.c

index 059b9f1518fcd355d26a6c5ef8df0d0a4ff24d8f..ef9cca4e9aa850e180ca538441258f9d791e2225 100644 (file)
@@ -289,6 +289,8 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
        struct file_id id;
        const struct security_unix_token *del_token = NULL;
        const struct security_token *del_nt_token = NULL;
+       struct smb_filename *parent_fname = NULL;
+       struct smb_filename *base_fname = NULL;
        bool got_tokens = false;
        bool normal_close;
        int ret;
@@ -465,11 +467,21 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
                fsp->fsp_flags.kernel_share_modes_taken = false;
        }
 
+       status = parent_pathref(talloc_tos(),
+                               conn->cwd_fsp,
+                               fsp->fsp_name,
+                               &parent_fname,
+                               &base_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               goto done;
+       }
 
        ret = SMB_VFS_UNLINKAT(conn,
-                       conn->cwd_fsp,
-                       fsp->fsp_name,
-                       0);
+                              parent_fname->fsp,
+                              base_fname,
+                              0);
+       TALLOC_FREE(parent_fname);
+       base_fname = NULL;
        if (ret != 0) {
                /*
                 * This call can potentially fail as another smbd may