mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
Add a test for unsetting Delete-on-Close before the close by DoC opener.
Windows semantics says that any unset of Delete-on-Close before the client that opened for Delete-on-Close closes the file is silently ignored and the file is still deleted on the last close. This test tests that in a single open case. Signed-off-by: Richard Sharpe <realrichardsharpe@gmail.com> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Fri Jul 28 11:47:06 CEST 2017 on sn-devel-144
This commit is contained in:
parent
886c26238a
commit
2186d4d317
@ -2201,6 +2201,61 @@ static bool deltest23(struct torture_context *tctx,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Test 24 ... */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test whether unsetting delete-on-close before the close has any effect.
|
||||||
|
* It should be ignored.
|
||||||
|
*/
|
||||||
|
static bool deltest24(struct torture_context *tctx)
|
||||||
|
{
|
||||||
|
int fnum1 = -1;
|
||||||
|
struct smbcli_state *cli1;
|
||||||
|
bool correct = true;
|
||||||
|
|
||||||
|
if (!torture_open_connection(&cli1, tctx, 0))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
smbcli_deltree(cli1->tree, fname);
|
||||||
|
|
||||||
|
fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0,
|
||||||
|
SEC_FILE_READ_DATA|
|
||||||
|
SEC_FILE_WRITE_DATA|
|
||||||
|
SEC_STD_DELETE,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
NTCREATEX_SHARE_ACCESS_READ|
|
||||||
|
NTCREATEX_SHARE_ACCESS_WRITE|
|
||||||
|
NTCREATEX_SHARE_ACCESS_DELETE,
|
||||||
|
NTCREATEX_DISP_CREATE,
|
||||||
|
NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
|
||||||
|
|
||||||
|
torture_assert(tctx, fnum1 != -1,
|
||||||
|
talloc_asprintf(tctx, "open of %s failed: %s!",
|
||||||
|
fname, smbcli_errstr(cli1->tree)));
|
||||||
|
|
||||||
|
/* Now, unset Delete-On-Close, but it should have no effect */
|
||||||
|
torture_assert_ntstatus_ok(
|
||||||
|
tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, false),
|
||||||
|
talloc_asprintf(tctx, "unsetting delete_on_close failed (%s)",
|
||||||
|
smbcli_errstr(cli1->tree)));
|
||||||
|
|
||||||
|
smbcli_close(cli1->tree, fnum1);
|
||||||
|
|
||||||
|
/* File should not be there. */
|
||||||
|
fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0,
|
||||||
|
SEC_RIGHTS_FILE_READ,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
NTCREATEX_SHARE_ACCESS_READ|
|
||||||
|
NTCREATEX_SHARE_ACCESS_WRITE|
|
||||||
|
NTCREATEX_SHARE_ACCESS_DELETE,
|
||||||
|
NTCREATEX_DISP_OPEN,
|
||||||
|
0, 0);
|
||||||
|
|
||||||
|
CHECK_STATUS(cli1, NT_STATUS_OBJECT_NAME_NOT_FOUND);
|
||||||
|
|
||||||
|
return correct;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Test delete on close semantics.
|
Test delete on close semantics.
|
||||||
*/
|
*/
|
||||||
@ -2241,6 +2296,7 @@ struct torture_suite *torture_test_delete(TALLOC_CTX *ctx)
|
|||||||
torture_suite_add_simple_test(suite, "deltest21", deltest21);
|
torture_suite_add_simple_test(suite, "deltest21", deltest21);
|
||||||
torture_suite_add_simple_test(suite, "deltest22", deltest22);
|
torture_suite_add_simple_test(suite, "deltest22", deltest22);
|
||||||
torture_suite_add_2smb_test(suite, "deltest23", deltest23);
|
torture_suite_add_2smb_test(suite, "deltest23", deltest23);
|
||||||
|
torture_suite_add_simple_test(suite, "deltest24", deltest24);
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user