From 48464c66f8f1259b21082ba9d0d63b3f034332b7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 9 Oct 2024 07:35:26 +0200 Subject: [PATCH] smbd: Simplify smbd_smb2_query_directory_send() Use reopen_from_fsp(), this will use the /proc/self/fd/ trick if available, no need to go through non_widelink_open Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- source3/smbd/smb2_query_directory.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/source3/smbd/smb2_query_directory.c b/source3/smbd/smb2_query_directory.c index cfdcc52e936..2c8fb4a97c7 100644 --- a/source3/smbd/smb2_query_directory.c +++ b/source3/smbd/smb2_query_directory.c @@ -381,21 +381,17 @@ static struct tevent_req *smbd_smb2_query_directory_send(TALLOC_CTX *mem_ctx, if (in_flags & SMB2_CONTINUE_FLAG_REOPEN) { struct vfs_open_how how = { .flags = O_RDONLY, }; - - status = fd_close(fsp); - if (tevent_req_nterror(req, status)) { - return tevent_req_post(req, ev); - } - - /* - * fd_close() will close and invalidate the fsp's file - * descriptor. So we have to reopen it. - */ + bool file_was_created; #ifdef O_DIRECTORY how.flags |= O_DIRECTORY; #endif - status = fd_openat(conn->cwd_fsp, fsp->fsp_name, fsp, &how); + + status = reopen_from_fsp(conn->cwd_fsp, + fsp->fsp_name, + fsp, + &how, + &file_was_created); if (tevent_req_nterror(req, status)) { return tevent_req_post(req, ev); } -- 2.47.2