]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: use openat_pathref_fsp() in call_trans2findfirst()
authorRalph Boehme <slow@samba.org>
Thu, 12 Nov 2020 14:51:59 +0000 (15:51 +0100)
committerRalph Boehme <slow@samba.org>
Wed, 16 Dec 2020 09:08:31 +0000 (09:08 +0000)
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

Also drop pathref fsp from filename_convert() in call_trans2findfirst(), because
the call to filename_convert() is on the path from the client including the
search mask.

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

index 01931962432cddc507721db6455a3bef1806220b..11f98ce349ba92e1988f76562e1235beab423c17 100644 (file)
@@ -2833,6 +2833,19 @@ close_if_end = %d requires_resume_key = %d backup_priv = %d level = 0x%x, max_da
                goto out;
        }
 
+       /*
+        * The above call to filename_convert() is on the path from the client
+        * including the search mask. Until the code that chops of the search
+        * mask from the path below is moved before the call to
+        * filename_convert(), we close a possible pathref fsp to ensure
+        * SMB_VFS_CREATE_FILE() below will internally open a pathref fsp on the
+        * correct path.
+        */
+       if (smb_dname->fsp != NULL) {
+               fsp_free(smb_dname->fsp);
+               smb_dname->fsp = NULL;
+       }
+
        mask = get_original_lcomp(talloc_tos(),
                                conn,
                                directory,
@@ -2951,6 +2964,15 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                goto out;
        }
 
+       ntstatus = openat_pathref_fsp(conn->cwd_fsp, smb_dname);
+       if (NT_STATUS_EQUAL(ntstatus, NT_STATUS_STOPPED_ON_SYMLINK)) {
+               ntstatus = NT_STATUS_OBJECT_NAME_NOT_FOUND;
+       }
+       if (!NT_STATUS_IS_OK(ntstatus)) {
+               reply_nterror(req, ntstatus);
+               goto out;
+       }
+
        /*
         * Open an fsp on this directory for the dptr.
         */