summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorAnoop C S <anoopcs@redhat.com>2018-08-09 12:28:41 +0530
committerKarolin Seeger <kseeger@samba.org>2018-08-23 10:38:26 +0200
commit8bf5c11c892e1f8c1d77fe2efa2acf49c60b1241 (patch)
treefbaf478ebfc29fe4c4bb03e0bff74ef7393dc156 /source3/libsmb
parent04c66d8080452f11e8fe142956ea716843823b09 (diff)
downloadsamba-8bf5c11c892e1f8c1d77fe2efa2acf49c60b1241.tar.gz
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> (cherry picked from commit 6b68e3eca631c04d6d57c489daf60f64732fc86d)
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/cli_smb2_fnum.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 462fa8e8599..26079a02eca 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -683,7 +683,7 @@ NTSTATUS cli_smb2_rmdir(struct cli_state *cli, const char *dname)
FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
FILE_OPEN, /* create_disposition */
- FILE_DIRECTORY_FILE|FILE_DELETE_ON_CLOSE, /* create_options */
+ FILE_DIRECTORY_FILE, /* create_options */
&fnum,
NULL);
@@ -711,6 +711,13 @@ NTSTATUS cli_smb2_rmdir(struct cli_state *cli, const char *dname)
if (!NT_STATUS_IS_OK(status)) {
return status;
}
+
+ status = cli_smb2_delete_on_close(cli, fnum, true);
+ if (!NT_STATUS_IS_OK(status)) {
+ cli_smb2_close_fnum(cli, fnum);
+ return status;
+ }
+
return cli_smb2_close_fnum(cli, fnum);
}