]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Change smb_unix_mknod() to use a real directory fsp for SMB_VFS_MKNODAT().
authorJeremy Allison <jra@samba.org>
Thu, 14 Jan 2021 20:18:50 +0000 (12:18 -0800)
committerJeremy Allison <jra@samba.org>
Fri, 15 Jan 2021 20:56:28 +0000 (20:56 +0000)
New VFS change.

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

index d0cc3b711db615e7f93631b4aae559e8527bfe3c..3c1df4ca3acd15efa4c035924d5d3761e56efddb 100644 (file)
@@ -8114,6 +8114,7 @@ static NTSTATUS smb_unix_mknod(connection_struct *conn,
        mode_t unixmode;
        int ret;
        struct smb_filename *parent_fname = NULL;
+       struct smb_filename *base_name = NULL;
        bool ok;
 
        if (total_data < 100) {
@@ -8174,15 +8175,29 @@ static NTSTATUS smb_unix_mknod(connection_struct *conn,
        ok = parent_smb_fname(talloc_tos(),
                              smb_fname,
                              &parent_fname,
-                             NULL);
+                             &base_name);
        if (!ok) {
                return NT_STATUS_NO_MEMORY;
        }
 
+       ret = vfs_stat(conn, parent_fname);
+       if (ret == -1) {
+               TALLOC_FREE(parent_fname);
+               return map_nt_error_from_unix(errno);
+       }
+       status = openat_pathref_fsp(conn->cwd_fsp, parent_fname);
+       if (NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK)) {
+               status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
+       }
+       if (!NT_STATUS_IS_OK(status)) {
+               TALLOC_FREE(parent_fname);
+               return status;
+       }
+
        /* Ok - do the mknod. */
        ret = SMB_VFS_MKNODAT(conn,
-                       conn->cwd_fsp,
-                       smb_fname,
+                       parent_fname->fsp,
+                       base_name,
                        unixmode,
                        dev);