From 0be5f29179440e3c9035c0b898af2f0856b2541f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 30 Mar 2001 06:22:14 +0000 Subject: Expanded delete on close test to 6 cases. I now understand the semantics of this and the FILE_SHARE_DELETE flag exactly. The bad news is it means our share mode handling is broken (again :-). Jeremy. (This used to be commit a55ed1a91d91beafb2f199d1da530169715dbe0e) --- source3/utils/torture.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/utils/torture.c b/source3/utils/torture.c index 76d431c64f..0869e5e019 100644 --- a/source3/utils/torture.c +++ b/source3/utils/torture.c @@ -2132,14 +2132,14 @@ static void run_deletetest(int dummy) cli_unlink(&cli1, fname); fnum1 = cli_nt_create_full(&cli1, fname, GENERIC_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL, - FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, FILE_OVERWRITE_IF, 0); + FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OVERWRITE_IF, 0); if (fnum1 == -1) { printf("[3] open - 1 of %s failed (%s)\n", fname, cli_errstr(&cli1)); return; } - /* This should fail with a sharing violation - SHARE_DELETE is only compatible + /* This should fail with a sharing violation - open for delete is only compatible with SHARE_DELETE. */ fnum2 = cli_nt_create_full(&cli1, fname, GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL, @@ -2231,6 +2231,57 @@ static void run_deletetest(int dummy) return; } + /* Test 5 ... */ + cli_setatr(&cli1, fname, 0, 0); + cli_unlink(&cli1, fname); + + fnum1 = cli_open(&cli1, fname, O_RDWR|O_CREAT, DENY_NONE); + if (fnum1 == -1) { + printf("[5] open of %s failed (%s)\n", fname, cli_errstr(&cli1)); + return; + } + + /* This should fail - only allowed on NT opens with DELETE access. */ + + if (cli_nt_delete_on_close(&cli1, fnum1, True)) { + printf("[5] setting delete_on_close on OpenX file succeeded - should fail !\n"); + return; + } + + if (!cli_close(&cli1, fnum1)) { + printf("[5] close - 2 failed (%s)\n", cli_errstr(&cli1)); + return; + } + + printf("fifth delete on close test succeeded.\n"); + + /* Test 6 ... */ + cli_setatr(&cli1, fname, 0, 0); + cli_unlink(&cli1, fname); + + fnum1 = cli_nt_create_full(&cli1, fname, FILE_READ_DATA|FILE_WRITE_DATA, + FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, + FILE_OVERWRITE_IF, 0); + + if (fnum1 == -1) { + printf("[6] open of %s failed (%s)\n", fname, cli_errstr(&cli1)); + return; + } + + /* This should fail - only allowed on NT opens with DELETE access. */ + + if (cli_nt_delete_on_close(&cli1, fnum1, True)) { + printf("[6] setting delete_on_close on file with no delete access succeeded - should fail !\n"); + return; + } + + if (!cli_close(&cli1, fnum1)) { + printf("[6] close - 2 failed (%s)\n", cli_errstr(&cli1)); + return; + } + + printf("sixth delete on close test succeeded.\n"); + cli_setatr(&cli1, fname, 0, 0); cli_unlink(&cli1, fname); -- cgit