]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: In can_delete_file_in_directory(), remove the assertion that dirfsp ==...
authorJeremy Allison <jra@samba.org>
Tue, 8 Jun 2021 18:08:06 +0000 (11:08 -0700)
committerRalph Boehme <slow@samba.org>
Wed, 9 Jun 2021 13:14:31 +0000 (13:14 +0000)
Allow a real parent directory fsp to be passed in. We're not doing this
yet but this will allow more efficient calling from the open code
where we have the parent directory fsp available.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/file_access.c

index ac72460732a5e7d6820ce1a68b6369d17a9fc9d5..9d06bf78528700cccdfeae31a673c97882637095 100644 (file)
@@ -41,8 +41,6 @@ bool can_delete_file_in_directory(connection_struct *conn,
        bool ret;
        NTSTATUS status;
 
-       SMB_ASSERT(dirfsp == conn->cwd_fsp);
-
        if (!CAN_WRITE(conn)) {
                return False;
        }
@@ -57,14 +55,18 @@ bool can_delete_file_in_directory(connection_struct *conn,
                return true;
        }
 
-       /* Get the parent directory permission mask and owners. */
-       status = SMB_VFS_PARENT_PATHNAME(conn,
-                                        ctx,
-                                        smb_fname,
-                                        &smb_fname_parent,
-                                        NULL);
-       if (!NT_STATUS_IS_OK(status)) {
-               return false;
+       if (dirfsp != conn->cwd_fsp) {
+               smb_fname_parent = dirfsp->fsp_name;
+       } else {
+               /* Get the parent directory permission mask and owners. */
+               status = SMB_VFS_PARENT_PATHNAME(conn,
+                                                ctx,
+                                                smb_fname,
+                                                &smb_fname_parent,
+                                                NULL);
+               if (!NT_STATUS_IS_OK(status)) {
+                       return false;
+               }
        }
 
        if(SMB_VFS_STAT(conn, smb_fname_parent) != 0) {
@@ -132,7 +134,9 @@ bool can_delete_file_in_directory(connection_struct *conn,
                                false,
                                FILE_DELETE_CHILD));
  out:
-       TALLOC_FREE(smb_fname_parent);
+       if (smb_fname_parent != dirfsp->fsp_name) {
+               TALLOC_FREE(smb_fname_parent);
+       }
        return ret;
 }