diff options
author | Jeremy Allison <jra@samba.org> | 2001-03-30 06:22:14 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-03-30 06:22:14 +0000 |
commit | 0be5f29179440e3c9035c0b898af2f0856b2541f (patch) | |
tree | a5fe1a0378f3f9fd99bca92afd05bc5c1e70d01f /source3/utils | |
parent | e51ffc811137825e32603f7330869e4ecdf18ba1 (diff) | |
download | samba-0be5f29179440e3c9035c0b898af2f0856b2541f.tar.gz samba-0be5f29179440e3c9035c0b898af2f0856b2541f.tar.xz samba-0be5f29179440e3c9035c0b898af2f0856b2541f.zip |
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)
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/torture.c | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/source3/utils/torture.c b/source3/utils/torture.c index 76d431c64f8..0869e5e0197 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); |