]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Slightly simplify rename_internals_fsp()
authorVolker Lendecke <vl@samba.org>
Mon, 13 Jan 2025 12:38:46 +0000 (13:38 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 23 Jan 2025 23:08:38 +0000 (23:08 +0000)
The required permissions only depend on S_ISDIR, but before this patch
they were assigned in two places far away from the call to
check_parent_access_fsp(). Consolidate that into where the permissions
are checked.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/smb2_reply.c

index 34012ebae54df34734554b9391b88f3070762ebc..693fad9bce67d9eb5b0dfdc9631d07c78cc67cfd 100644 (file)
@@ -1406,7 +1406,6 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
        struct smb_filename *smb_fname_dst = NULL;
        NTSTATUS status = NT_STATUS_OK;
        struct share_mode_lock *lck = NULL;
-       uint32_t access_mask = SEC_DIR_ADD_FILE;
        bool dst_exists, old_is_stream, new_is_stream;
        int ret;
        bool case_sensitive = fsp->fsp_flags.posix_open ?
@@ -1619,12 +1618,6 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
                goto out;
        }
 
-       /* Do we have rights to move into the destination ? */
-       if (S_ISDIR(fsp->fsp_name->st.st_ex_mode)) {
-               /* We're moving a directory. */
-               access_mask = SEC_DIR_ADD_SUBDIR;
-       }
-
        /*
         * Get a pathref on the destination parent directory, so
         * we can call check_parent_access_fsp().
@@ -1639,7 +1632,9 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
        }
 
        status = check_parent_access_fsp(parent_dir_fname_dst->fsp,
-                               access_mask);
+                                        S_ISDIR(fsp->fsp_name->st.st_ex_mode)
+                                                ? SEC_DIR_ADD_SUBDIR
+                                                : SEC_DIR_ADD_FILE);
        if (!NT_STATUS_IS_OK(status)) {
                DBG_INFO("check_parent_access_fsp on "
                        "dst %s returned %s\n",