VFS: cap: Fixup cap_mknodat() to cope with translating dirfsp path.
authorJeremy Allison <jra@samba.org>
Wed, 20 Jan 2021 19:33:03 +0000 (11:33 -0800)
committerJeremy Allison <jra@samba.org>
Thu, 21 Jan 2021 21:48:30 +0000 (21:48 +0000)
Missed in my original fixes.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
source3/modules/vfs_cap.c

index b7cdd0d81311214576d802074b6a687b43e9b8fa..3593ef589d8ce685a431fac84ee6e239f78ae138 100644 (file)
@@ -629,12 +629,22 @@ static int cap_mknodat(vfs_handle_struct *handle,
                mode_t mode,
                SMB_DEV_T dev)
 {
+       struct smb_filename *full_fname = NULL;
        struct smb_filename *cap_smb_fname = NULL;
-       char *cappath = capencode(talloc_tos(), smb_fname->base_name);
+       char *cappath = NULL;
        int ret;
        int saved_errno = 0;
 
+       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;
        }
@@ -645,18 +655,20 @@ static int cap_mknodat(vfs_handle_struct *handle,
                                        smb_fname->twrp,
                                        smb_fname->flags);
        if (cap_smb_fname == NULL) {
+               TALLOC_FREE(full_fname);
                TALLOC_FREE(cappath);
                errno = ENOMEM;
                return -1;
        }
        ret = SMB_VFS_NEXT_MKNODAT(handle,
-                       dirfsp,
+                       handle->conn->cwd_fsp,
                        cap_smb_fname,
                        mode,
                        dev);
        if (ret == -1) {
                saved_errno = errno;
        }
+       TALLOC_FREE(full_fname);
        TALLOC_FREE(cappath);
        TALLOC_FREE(cap_smb_fname);
        if (saved_errno != 0) {