]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pysmbd: use real dirfsp for SMB_VFS_MKDIRAT()
authorRalph Boehme <slow@samba.org>
Fri, 15 Jan 2021 09:12:29 +0000 (10:12 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 15 Jan 2021 20:56:28 +0000 (20:56 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/pysmbd.c

index 216de7a82fdd55ff4e98c1b924693725832b48e0..042e31b79d6abed2d25b08e89a18c66cb914de9b 100644 (file)
@@ -1026,8 +1026,12 @@ static PyObject *py_smbd_mkdir(PyObject *self, PyObject *args, PyObject *kwargs)
        TALLOC_CTX *frame = talloc_stackframe();
        struct connection_struct *conn = NULL;
        struct smb_filename *smb_fname = NULL;
+       struct smb_filename *parent_fname = NULL;
+       struct smb_filename *base_name = NULL;
+       NTSTATUS status;
        int ret;
        mode_t saved_umask;
+       bool ok;
 
        if (!PyArg_ParseTupleAndKeywords(args,
                                         kwargs,
@@ -1076,13 +1080,33 @@ static PyObject *py_smbd_mkdir(PyObject *self, PyObject *args, PyObject *kwargs)
                return NULL;
        }
 
+       ok = parent_smb_fname(frame,
+                             smb_fname,
+                             &parent_fname,
+                             &base_name);
+       if (!ok) {
+               TALLOC_FREE(frame);
+               return NULL;
+       }
+
+       ret = vfs_stat(conn, parent_fname);
+       if (ret == -1) {
+               TALLOC_FREE(frame);
+               return NULL;
+       }
+       status = openat_pathref_fsp(conn->cwd_fsp, parent_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               TALLOC_FREE(frame);
+               return NULL;
+       }
+
        /* we want total control over the permissions on created files,
           so set our umask to 0 */
        saved_umask = umask(0);
 
        ret = SMB_VFS_MKDIRAT(conn,
-                       conn->cwd_fsp,
-                       smb_fname,
+                       parent_fname->fsp,
+                       base_name,
                        00755);
 
        umask(saved_umask);