From 7aa5acb895f9401ab43bac4880e266f49620ce1c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 24 May 2021 16:09:24 -0700 Subject: [PATCH] s3: smbd: Get a parent pathref in create_file_unixpath(). Not yet used. We will be passing this down to open_directory() and open_file_ntcreate() and using it within create_file_unixpath() as all of these functions need a parent pathref to check parent ACLs etc. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- source3/smbd/open.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 2013ac6ced0..19f5184bb71 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -5722,6 +5722,8 @@ static NTSTATUS create_file_unixpath(connection_struct *conn, files_struct *fsp = NULL; NTSTATUS status; int ret; + struct smb_filename *parent_dir_fname = NULL; + struct smb_filename *smb_fname_atname = NULL; DBG_DEBUG("create_file_unixpath: access_mask = 0x%x " "file_attributes = 0x%x, share_access = 0x%x, " @@ -6025,6 +6027,20 @@ static NTSTATUS create_file_unixpath(connection_struct *conn, fsp_set_base_fsp(fsp, base_fsp); } + /* + * Get a pathref on the parent. We can re-use this + * for multiple calls to check parent ACLs etc. to + * avoid pathname calls. + */ + status = parent_pathref(talloc_tos(), + conn->cwd_fsp, + smb_fname, + &parent_dir_fname, + &smb_fname_atname); + if (!NT_STATUS_IS_OK(status)) { + goto fail; + } + /* * If it's a request for a directory open, deal with it separately. */ @@ -6219,6 +6235,8 @@ static NTSTATUS create_file_unixpath(connection_struct *conn, smb_fname->st = fsp->fsp_name->st; + TALLOC_FREE(parent_dir_fname); + return NT_STATUS_OK; fail: @@ -6237,6 +6255,9 @@ static NTSTATUS create_file_unixpath(connection_struct *conn, close_file(req, base_fsp, ERROR_CLOSE); base_fsp = NULL; } + + TALLOC_FREE(parent_dir_fname); + return status; } -- 2.47.3