]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_cap: support real dirfsps in cap_unlinkat()
authorRalph Boehme <slow@samba.org>
Wed, 20 Jan 2021 13:57:39 +0000 (14:57 +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/modules/vfs_cap.c

index 597e0293fd3d69504745089aaef13a4fb1eb89d3..c2df73a7fe4b348113d3750d2dcec87afab7d759 100644 (file)
@@ -295,18 +295,28 @@ static int cap_unlinkat(vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname,
                        int flags)
 {
+       struct smb_filename *full_fname = NULL;
        struct smb_filename *smb_fname_tmp = NULL;
        char *cappath = NULL;
        int ret;
 
-       cappath = capencode(talloc_tos(), smb_fname->base_name);
+       full_fname = full_path_from_dirfsp_atname(talloc_tos(),
+                                                 dirfsp,
+                                                 smb_fname);
+       if (full_fname == NULL) {
+               return -1;
+       }
+
+       cappath = capencode(talloc_tos(), full_fname->base_name);
        if (!cappath) {
+               TALLOC_FREE(full_fname);
                errno = ENOMEM;
                return -1;
        }
 
        /* Setup temporary smb_filename structs. */
-       smb_fname_tmp = cp_smb_filename(talloc_tos(), smb_fname);
+       smb_fname_tmp = cp_smb_filename(talloc_tos(), full_fname);
+       TALLOC_FREE(full_fname);
        if (smb_fname_tmp == NULL) {
                errno = ENOMEM;
                return -1;
@@ -315,7 +325,7 @@ static int cap_unlinkat(vfs_handle_struct *handle,
        smb_fname_tmp->base_name = cappath;
 
        ret = SMB_VFS_NEXT_UNLINKAT(handle,
-                       dirfsp,
+                       dirfsp->conn->cwd_fsp,
                        smb_fname_tmp,
                        flags);