Correct return code when trying to use Delete-on-Close on a RO volume/share

Richard Sharpe realrichardsharpe at gmail.com
Mon Jul 24 17:43:48 UTC 2017


Hi folks,

According to https://msdn.microsoft.com/en-us/library/ff469516.aspx

> If ((File.FileAttributes.FILE_ATTRIBUTE_READONLY || File.Volume.IsReadOnly)
>     && CreateOptions.FILE_DELETE_ON_CLOSE),
> then return STATUS_CANNOT_DELETE

However, Samba currently does:

NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32_t dosmode)
{
        /*
         * Only allow delete on close for writable files.
         */

        if ((dosmode & FILE_ATTRIBUTE_READONLY) &&
            !lp_delete_readonly(SNUM(fsp->conn))) {
                DEBUG(10,("can_set_delete_on_close: file %s delete on close "
                          "flag set but file attribute is readonly.\n",
                          fsp_str_dbg(fsp)));
                return NT_STATUS_CANNOT_DELETE;
        }

        /*
         * Only allow delete on close for writable shares.
         */

        if (!CAN_WRITE(fsp->conn)) {
                DEBUG(10,("can_set_delete_on_close: file %s delete on "
                          "close flag set but write access denied on share.\n",
                          fsp_str_dbg(fsp)));
                return NT_STATUS_ACCESS_DENIED;
        }

It might be better to return NT_STATUS_CANNOT_DELETE in the second case.

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)



More information about the samba-technical mailing list