From d6949f0f93ff0a1f6292395fbbd9c07b12fe9336 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 23 Dec 2020 15:38:03 +0100 Subject: [PATCH] s3:smbd: let open_directory() also use fd_open_atomic() as reopen_from_procfd() fallback 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 Reviewed-by: Volker Lendecke Reviewed-by: Ralph Boehme --- source3/smbd/open.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 956230fdc4b..e839f406abc 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -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", -- 2.47.2