]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbd: let open_directory() also use fd_open_atomic() as reopen_from_procfd() fallback
authorStefan Metzmacher <metze@samba.org>
Wed, 23 Dec 2020 14:38:03 +0000 (15:38 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 14 Jan 2021 11:30:38 +0000 (11:30 +0000)
Calling fd_open_atomic() without O_CREAT is the same as calling
fd_openat() directly, so we can also use it to open an existing
directory.

In the next step we'll move the reopen_from_procfd() fallback logic to
a single helper function.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/open.c

index 956230fdc4b52957d043af3256df605592b08195..e839f406abc86b3adb0c7cf5c5edd82d7dd63768 100644 (file)
@@ -4649,6 +4649,8 @@ static NTSTATUS open_directory(connection_struct *conn,
 
        status = reopen_from_procfd(fsp, smb_dname, flags, 0);
        if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
+               bool __unused_file_created = false;
+
                /*
                 * Close the existing pathref fd and set the fsp flag
                 * is_pathref to false so we get a "normal" fd this
@@ -4661,7 +4663,11 @@ static NTSTATUS open_directory(connection_struct *conn,
 
                fsp->fsp_flags.is_pathref = false;
 
-               status = fd_openat(conn->cwd_fsp, fsp->fsp_name, fsp, flags, 0);
+               /*
+                * Calling fd_open_atomic() without O_CREAT
+                * is like calling fd_openat() directly.
+                */
+               status = fd_open_atomic(fsp, flags, 0, &__unused_file_created);
        }
        if (!NT_STATUS_IS_OK(status)) {
                DBG_INFO("Could not open fd for%s (%s)\n",