[PATCHES][BUG 13673] smbd: Fix DELETE_ON_CLOSE behaviour on files with READ_ONLY attribute

Jeremy Allison jra at samba.org
Sat Nov 3 00:15:46 UTC 2018

On Fri, Nov 02, 2018 at 05:03:45PM -0700, Christof Schmitt wrote:
> > 
> > patch. It handles the delete-on-close of a new file *before*
> > we create the new file. Let me know if you're OK with it.
> I was also getting there. The two if statements for existing files can be
> combined to reduce the indentation. Also, for new files, shouldn't we
> set fsp->initial_delete_on_close = True as well? I need that to get the
> test to pass. (see attached version).

My code already does that.

Note that the second hunk *always* sets fsp->initial_delete_on_close
if (create_options & FILE_DELETE_ON_CLOSE) whether it's a new file or
not, only the can_set_delete_on_close() is gated on !new_file_created.

After my patch the second delete on close hunk looks like:

        /* 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,

                        if (!NT_STATUS_IS_OK(status)) {
                                /* Remember to delete the mode we just added. */
                                del_share_mode(lck, fsp);
                                return status;
                /* Note that here we set the *inital* delete on close flag,
                   not the regular one. The magic gets handled in close. */
                fsp->initial_delete_on_close = True;

You can also add it to the 'new file' case, but I thought that
was redundent.


More information about the samba-technical mailing list