]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: remove broken initial-delete-on-close logic from rename_internals_fsp()
authorRalph Boehme <slow@samba.org>
Fri, 28 Mar 2025 14:04:52 +0000 (15:04 +0100)
committerVolker Lendecke <vl@samba.org>
Wed, 9 Apr 2025 13:40:36 +0000 (13:40 +0000)
fh_get_private_options() return private_flags, not create_options and thus can
never contain FILE_DELETE_ON_CLOSE.

Afaict fsp_flags.initial_delete_on_close is already correctly filled in
open_file_ntcreate():

        /* Handle strange delete on close create semantics. */
        if (create_options & FILE_DELETE_ON_CLOSE) {
                if (!new_file_created) {
                        status = can_set_delete_on_close(fsp,
                                         existing_dos_attributes);

                        if (!NT_STATUS_IS_OK(status)) {
                                /* Remember to delete the mode we just added. */
                                lck_state.cleanup_fn =
                                        open_ntcreate_lock_cleanup_entry;
                                goto unlock;
                        }
                }
                /* Note that here we set the *initial* delete on close flag,
                   not the regular one. The magic gets handled in close. */
                fsp->fsp_flags.initial_delete_on_close = true;
        }

so we can just remove the broken handling here.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/smbd/smb2_reply.c

index d3220978db323461f6eac93c180d5b58d46cc079..00c9f2aa6e68bbdea9f9f775bf01f886599f9f2e 100644 (file)
@@ -1751,7 +1751,6 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
                        parent_dir_fname_dst_atname,
                        &rhow);
        if (ret == 0) {
-               uint32_t create_options = fh_get_private_options(fsp->fh);
                struct smb_filename *old_fname = NULL;
 
                DBG_NOTICE("succeeded doing rename on "
@@ -1793,25 +1792,6 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
                        }
                }
 
-               /*
-                * A rename acts as a new file create w.r.t. allowing an initial delete
-                * on close, probably because in Windows there is a new handle to the
-                * new file. If initial delete on close was requested but not
-                * originally set, we need to set it here. This is probably not 100% correct,
-                * but will work for the CIFSFS client which in non-posix mode
-                * depends on these semantics. JRA.
-                */
-
-               if (create_options & FILE_DELETE_ON_CLOSE) {
-                       status = can_set_delete_on_close(fsp, 0);
-
-                       if (NT_STATUS_IS_OK(status)) {
-                               /* Note that here we set the *initial* delete on close flag,
-                                * not the regular one. The magic gets handled in close. */
-                               fsp->fsp_flags.initial_delete_on_close = true;
-                       }
-               }
-
                TALLOC_FREE(lck);
 
                notify_rename(conn,