`rmdir` implementation within smbclient

Jeremy Allison jra at samba.org
Mon Aug 6 18:32:10 UTC 2018


On Thu, Aug 02, 2018 at 04:06:16PM +0530, Anoop C S via samba-technical wrote:
> Hi all,
> 
> We have the following bug report which I looked at recently:
> 
> https://bugzilla.samba.org/show_bug.cgi?id=13204 - rmdir on non-empty
> directory fails silently
> 
> If fsp->initial_delete_on_close is set during a create/open of a
> directory we attempt to delete it while closing the fnum based on
> whether it is empty or not. But as of now it is not set as we have
> this check(directory emptiness) early while opening the directory with
> FILE_DELETE_ON_CLOSE set as create option. As a result we never attempt
> to delete the directory while closing the fnum and rmdir
> return success as we could close the directory.
> 
> Does the protocol say that we don't set FILE_DELETE_ON_CLOSE if the
> directory is non-empty? If not why are we doing so?
> 
> If the current logic is as per protocol how do we move about fixing the
> bug? Is it OK if we modify `rmdir` implementation to add explicit check
> for directory emptiness?

Here's the problem. Windows clients assume if you can set
FILE_DELETE_ON_CLOSE on a handle it will go away on close,
and don't look at (or show the user) the error returned
on close. POSIX won't give an error until you try the
delete and get an error.

So we try and decide in advance if we can delete something
(that's what the code in can_set_delete_on_close() is
doing so we return the correct error on handle open).

Jeremy.



More information about the samba-technical mailing list