]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Get a parent pathref in create_file_unixpath().
authorJeremy Allison <jra@samba.org>
Mon, 24 May 2021 23:09:24 +0000 (16:09 -0700)
committerRalph Boehme <slow@samba.org>
Wed, 9 Jun 2021 13:14:30 +0000 (13:14 +0000)
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 <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/open.c

index 2013ac6ced0e7df881a5935940252108fcec25cf..19f5184bb71e87a29167a6bfcdd51b2ab61ab484 100644 (file)
@@ -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;
 }