From: Ralph Boehme Date: Fri, 28 Mar 2025 14:04:52 +0000 (+0100) Subject: smbd: remove broken initial-delete-on-close logic from rename_internals_fsp() X-Git-Tag: tevent-0.17.0~354 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d3adfb1b6474d71154a0a402f4bf40078525987;p=thirdparty%2Fsamba.git smbd: remove broken initial-delete-on-close logic from rename_internals_fsp() 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 Reviewed-by: Volker Lendecke --- diff --git a/source3/smbd/smb2_reply.c b/source3/smbd/smb2_reply.c index d3220978db3..00c9f2aa6e6 100644 --- a/source3/smbd/smb2_reply.c +++ b/source3/smbd/smb2_reply.c @@ -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,