s3/libsmb: Explicitly set delete_on_close token for rmdir
authorAnoop C S <anoopcs@redhat.com>
Thu, 9 Aug 2018 06:58:41 +0000 (12:28 +0530)
committerJeremy Allison <jra@samba.org>
Fri, 10 Aug 2018 16:05:09 +0000 (18:05 +0200)
commit6b68e3eca631c04d6d57c489daf60f64732fc86d
tree0a09abb0e342da9f222504ecb058fc56c5cfdf93
parent75287495f2e16e333ce1afe9d1b168b951350053
s3/libsmb: Explicitly set delete_on_close token for rmdir

The current implementation of `rmdir` hopes to get the directory deleted
on closing last open handle when FILE_DELETE_ON_CLOSE is set on it. But
for non-empty directories Windows doesn't error out during an open call.
Following that we internally refuse to set initial delete_on_close while
opening a non-empty directory. This prevents us from trying to delete
the directory when last open handle is closed.

Instead of relying on FILE_DELETE_ON_CLOSE during an open we explicitly
set delete_on_close token on directory handle once it is available. This
ensures that NT_STATUS_DIRECTORY_NOT_EMPTY is returned for `rmdir` on
non-empty directories while closing open directory handle.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13204

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/libsmb/cli_smb2_fnum.c