From 86457e659cbb3fe59b946bb1c0adcadd5d747a78 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 24 Oct 2004 09:08:52 +0000 Subject: r3149: separate the delete on close test into torture/basic/delete.c (This used to be commit 50379a0a58d9eade3e1390713ef89473c66e65fc) --- source4/torture/basic/delete.c | 524 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 524 insertions(+) create mode 100644 source4/torture/basic/delete.c (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c new file mode 100644 index 0000000000..a4489023a6 --- /dev/null +++ b/source4/torture/basic/delete.c @@ -0,0 +1,524 @@ +/* + Unix SMB/CIFS implementation. + + delete on close testing + + Copyright (C) Andrew Tridgell 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + + +/* + Test delete on close semantics. + */ +BOOL torture_test_delete(int dummy) +{ + struct smbcli_state *cli1; + struct smbcli_state *cli2 = NULL; + const char *fname = "\\delete.file"; + int fnum1 = -1; + int fnum2 = -1; + BOOL correct = True; + NTSTATUS status; + + printf("starting delete test\n"); + + if (!torture_open_connection(&cli1)) { + return False; + } + + /* Test 1 - this should delete the file on close. */ + + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, + NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); + + if (fnum1 == -1) { + printf("[1] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { + printf("[1] close failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); + if (fnum1 != -1) { + printf("[1] open of %s succeeded (should fail)\n", fname); + correct = False; + goto fail; + } + + printf("first delete on close test succeeded.\n"); + + /* Test 2 - this should delete the file on close. */ + + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, + FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, + NTCREATEX_DISP_OVERWRITE_IF, 0, 0); + + if (fnum1 == -1) { + printf("[2] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { + printf("[2] setting delete_on_close failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { + printf("[2] close failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); + if (fnum1 != -1) { + printf("[2] open of %s succeeded should have been deleted on close !\n", fname); + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { + printf("[2] close failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + smbcli_unlink(cli1->tree, fname); + } else + printf("second delete on close test succeeded.\n"); + + /* Test 3 - ... */ + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); + + if (fnum1 == -1) { + printf("[3] open - 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* This should fail with a sharing violation - open for delete is only compatible + with SHARE_DELETE. */ + + fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, + NTCREATEX_DISP_OPEN, 0, 0); + + if (fnum2 != -1) { + printf("[3] open - 2 of %s succeeded - should have failed.\n", fname); + correct = False; + goto fail; + } + + /* This should succeed. */ + + fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); + + if (fnum2 == -1) { + printf("[3] open - 2 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { + printf("[3] setting delete_on_close failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { + printf("[3] close 1 failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) { + printf("[3] close 2 failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* This should fail - file should no longer be there. */ + + fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); + if (fnum1 != -1) { + printf("[3] open of %s succeeded should have been deleted on close !\n", fname); + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { + printf("[3] close failed (%s)\n", smbcli_errstr(cli1->tree)); + } + smbcli_unlink(cli1->tree, fname); + correct = False; + goto fail; + } else + printf("third delete on close test succeeded.\n"); + + /* Test 4 ... */ + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SA_RIGHT_FILE_READ_DATA | + SA_RIGHT_FILE_WRITE_DATA | + STD_RIGHT_DELETE_ACCESS, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, + NTCREATEX_DISP_OVERWRITE_IF, 0, 0); + + if (fnum1 == -1) { + printf("[4] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* This should succeed. */ + fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ | + NTCREATEX_SHARE_ACCESS_WRITE | + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, 0, 0); + if (fnum2 == -1) { + printf("[4] open - 2 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) { + printf("[4] close - 1 failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { + printf("[4] setting delete_on_close failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* This should fail - no more opens once delete on close set. */ + fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, + FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, 0, 0); + if (fnum2 != -1) { + printf("[4] open - 3 of %s succeeded ! Should have failed.\n", fname ); + correct = False; + goto fail; + } else + printf("fourth delete on close test succeeded.\n"); + + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { + printf("[4] close - 2 failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* Test 5 ... */ + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + + fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT, DENY_NONE); + if (fnum1 == -1) { + printf("[5] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* This should fail - only allowed on NT opens with DELETE access. */ + + if (NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { + printf("[5] setting delete_on_close on OpenX file succeeded - should fail !\n"); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { + printf("[5] close - 2 failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + printf("fifth delete on close test succeeded.\n"); + + /* Test 6 ... */ + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SA_RIGHT_FILE_READ_DATA | SA_RIGHT_FILE_WRITE_DATA, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ | + NTCREATEX_SHARE_ACCESS_WRITE | + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OVERWRITE_IF, 0, 0); + + if (fnum1 == -1) { + printf("[6] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* This should fail - only allowed on NT opens with DELETE access. */ + + if (NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { + printf("[6] setting delete_on_close on file with no delete access succeeded - should fail !\n"); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { + printf("[6] close - 2 failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + printf("sixth delete on close test succeeded.\n"); + + /* Test 7 ... */ + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SA_RIGHT_FILE_READ_DATA | + SA_RIGHT_FILE_WRITE_DATA | + STD_RIGHT_DELETE_ACCESS, + FILE_ATTRIBUTE_NORMAL, 0, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); + + if (fnum1 == -1) { + printf("[7] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { + printf("[7] setting delete_on_close on file failed !\n"); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, False))) { + printf("[7] unsetting delete_on_close on file failed !\n"); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { + printf("[7] close - 2 failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* This next open should succeed - we reset the flag. */ + + fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); + if (fnum1 == -1) { + printf("[5] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { + printf("[7] close - 2 failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + printf("seventh delete on close test succeeded.\n"); + + /* Test 7 ... */ + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + + if (!torture_open_connection(&cli2)) { + printf("[8] failed to open second connection.\n"); + correct = False; + goto fail; + } + + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS, + FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OVERWRITE_IF, 0, 0); + + if (fnum1 == -1) { + printf("[8] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS, + FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, 0, 0); + + if (fnum2 == -1) { + printf("[8] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { + printf("[8] setting delete_on_close on file failed !\n"); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { + printf("[8] close - 1 failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { + printf("[8] close - 2 failed (%s)\n", smbcli_errstr(cli2->tree)); + correct = False; + goto fail; + } + + /* This should fail.. */ + fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); + if (fnum1 != -1) { + printf("[8] open of %s succeeded should have been deleted on close !\n", fname); + goto fail; + correct = False; + } else + printf("eighth delete on close test succeeded.\n"); + + /* This should fail - we need to set DELETE_ACCESS. */ + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0,SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA, + FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); + + if (fnum1 != -1) { + printf("[9] open of %s succeeded should have failed!\n", fname); + correct = False; + goto fail; + } + + printf("ninth delete on close test succeeded.\n"); + + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS, + FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); + if (fnum1 == -1) { + printf("[10] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* This should delete the file. */ + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { + printf("[10] close failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* This should fail.. */ + fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); + if (fnum1 != -1) { + printf("[10] open of %s succeeded should have been deleted on close !\n", fname); + goto fail; + correct = False; + } else + printf("tenth delete on close test succeeded.\n"); + + /* test 11 - does having read only attribute still allow delete on close. */ + + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, + FILE_ATTRIBUTE_READONLY, NTCREATEX_SHARE_ACCESS_NONE, + NTCREATEX_DISP_OVERWRITE_IF, 0, 0); + + if (fnum1 == -1) { + printf("[11] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + status = smbcli_nt_delete_on_close(cli1->tree, fnum1, True); + + if (NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_CANNOT_DELETE)) { + printf("[11] setting delete_on_close should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { + printf("[11] close failed (%s)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + + printf("eleventh delete on close test succeeded.\n"); + + /* test 12 - does having read only attribute still allow delete on close at time of open. */ + + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_READONLY, + NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, + NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); + + if (fnum1 != -1) { + printf("[12] open of %s succeeded. Should fail with NT_STATUS_CANNOT_DELETE.\n", fname); + smbcli_close(cli1->tree, fnum1); + correct = False; + goto fail; + } else { + status = smbcli_nt_error(cli1->tree); + if (NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_CANNOT_DELETE)) { + printf("[12] setting delete_on_close on open should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)\n", smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + } + + printf("twelvth delete on close test succeeded.\n"); + + printf("finished delete test\n"); + + fail: + /* FIXME: This will crash if we aborted before cli2 got + * intialized, because these functions don't handle + * uninitialized connections. */ + + smbcli_close(cli1->tree, fnum1); + smbcli_close(cli1->tree, fnum2); + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + + if (!torture_close_connection(cli1)) { + correct = False; + } + if (!torture_close_connection(cli2)) { + correct = False; + } + return correct; +} + -- cgit From 5a698367e1582876590cb553bf47e07aaa8f200a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 24 Oct 2004 10:27:38 +0000 Subject: r3150: printing __location__ is more useful than a operation number (This used to be commit 022b21460a572803b86ef5c11f6fe0b6fa1dcae1) --- source4/torture/basic/delete.c | 174 +++++++++++++++++++++++++++-------------- 1 file changed, 117 insertions(+), 57 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index a4489023a6..1a469add8d 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -41,7 +41,7 @@ BOOL torture_test_delete(int dummy) if (!torture_open_connection(&cli1)) { return False; } - + /* Test 1 - this should delete the file on close. */ smbcli_setatr(cli1->tree, fname, 0, 0); @@ -52,20 +52,23 @@ BOOL torture_test_delete(int dummy) NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); if (fnum1 == -1) { - printf("[1] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + printf("(%s) open of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("[1] close failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) close failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); if (fnum1 != -1) { - printf("[1] open of %s succeeded (should fail)\n", fname); + printf("(%s) open of %s succeeded (should fail)\n", + __location__, fname); correct = False; goto fail; } @@ -82,28 +85,33 @@ BOOL torture_test_delete(int dummy) NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { - printf("[2] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + printf("(%s) open of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("[2] setting delete_on_close failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) setting delete_on_close failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("[2] close failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) close failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); if (fnum1 != -1) { - printf("[2] open of %s succeeded should have been deleted on close !\n", fname); + printf("(%s) open of %s succeeded should have been deleted on close !\n", + __location__, fname); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("[2] close failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) close failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -115,11 +123,15 @@ BOOL torture_test_delete(int dummy) smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); - fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL, - NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + GENERIC_RIGHTS_FILE_ALL_ACCESS, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, + NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { - printf("[3] open - 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -127,12 +139,15 @@ BOOL torture_test_delete(int dummy) /* This should fail with a sharing violation - open for delete is only compatible with SHARE_DELETE. */ - fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL, - NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, - NTCREATEX_DISP_OPEN, 0, 0); + fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, + GENERIC_RIGHTS_FILE_READ, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, + NTCREATEX_DISP_OPEN, 0, 0); if (fnum2 != -1) { - printf("[3] open - 2 of %s succeeded - should have failed.\n", fname); + printf("(%s) open - 2 of %s succeeded - should have failed.\n", + __location__, fname); correct = False; goto fail; } @@ -143,25 +158,29 @@ BOOL torture_test_delete(int dummy) NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); if (fnum2 == -1) { - printf("[3] open - 2 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + printf("(%s) open - 2 of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("[3] setting delete_on_close failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) setting delete_on_close failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("[3] close 1 failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) close 1 failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) { - printf("[3] close 2 failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) close 2 failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -170,9 +189,11 @@ BOOL torture_test_delete(int dummy) fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); if (fnum1 != -1) { - printf("[3] open of %s succeeded should have been deleted on close !\n", fname); + printf("(%s) open of %s succeeded should have been deleted on close !\n", + __location__, fname); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("[3] close failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) close failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); } smbcli_unlink(cli1->tree, fname); correct = False; @@ -182,7 +203,12 @@ BOOL torture_test_delete(int dummy) /* Test 4 ... */ smbcli_setatr(cli1->tree, fname, 0, 0); - smbcli_unlink(cli1->tree, fname); + status = smbcli_unlink(cli1->tree, fname); + if (NT_STATUS_IS_OK(status)) { + printf("(%s) succeeded unlink of %s\n", __location__, fname); + correct = False; + goto fail; + } fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA | @@ -193,7 +219,8 @@ BOOL torture_test_delete(int dummy) NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { - printf("[4] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + printf("(%s) open of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -206,19 +233,22 @@ BOOL torture_test_delete(int dummy) NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); if (fnum2 == -1) { - printf("[4] open - 2 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + printf("(%s) open - 2 of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) { - printf("[4] close - 1 failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) close - 1 failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("[4] setting delete_on_close failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) setting delete_on_close failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -228,14 +258,16 @@ BOOL torture_test_delete(int dummy) FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); if (fnum2 != -1) { - printf("[4] open - 3 of %s succeeded ! Should have failed.\n", fname ); + printf("(%s) open - 3 of %s succeeded ! Should have failed.\n", + __location__, fname ); correct = False; goto fail; } else printf("fourth delete on close test succeeded.\n"); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("[4] close - 2 failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) close - 2 failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -246,7 +278,8 @@ BOOL torture_test_delete(int dummy) fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum1 == -1) { - printf("[5] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + printf("(%s) open of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -254,13 +287,15 @@ BOOL torture_test_delete(int dummy) /* This should fail - only allowed on NT opens with DELETE access. */ if (NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("[5] setting delete_on_close on OpenX file succeeded - should fail !\n"); + printf("(%s) setting delete_on_close on OpenX file succeeded - should fail !\n", + __location__); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("[5] close - 2 failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) close - 2 failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -280,7 +315,8 @@ BOOL torture_test_delete(int dummy) NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { - printf("[6] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + printf("(%s) open of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -288,13 +324,15 @@ BOOL torture_test_delete(int dummy) /* This should fail - only allowed on NT opens with DELETE access. */ if (NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("[6] setting delete_on_close on file with no delete access succeeded - should fail !\n"); + printf("(%s) setting delete_on_close on file with no delete access succeeded - should fail !\n", + __location__); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("[6] close - 2 failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) close - 2 failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -312,25 +350,29 @@ BOOL torture_test_delete(int dummy) FILE_ATTRIBUTE_NORMAL, 0, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { - printf("[7] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + printf("(%s) open of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("[7] setting delete_on_close on file failed !\n"); + printf("(%s) setting delete_on_close on file failed !\n", + __location__); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, False))) { - printf("[7] unsetting delete_on_close on file failed !\n"); + printf("(%s) unsetting delete_on_close on file failed !\n", + __location__); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("[7] close - 2 failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) close - 2 failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -339,13 +381,15 @@ BOOL torture_test_delete(int dummy) fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); if (fnum1 == -1) { - printf("[5] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + printf("(%s) open of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("[7] close - 2 failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) close - 2 failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -357,7 +401,8 @@ BOOL torture_test_delete(int dummy) smbcli_unlink(cli1->tree, fname); if (!torture_open_connection(&cli2)) { - printf("[8] failed to open second connection.\n"); + printf("(%s) failed to open second connection.\n", + __location__); correct = False; goto fail; } @@ -367,7 +412,8 @@ BOOL torture_test_delete(int dummy) NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { - printf("[8] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + printf("(%s) open of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -377,25 +423,29 @@ BOOL torture_test_delete(int dummy) NTCREATEX_DISP_OPEN, 0, 0); if (fnum2 == -1) { - printf("[8] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + printf("(%s) open of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("[8] setting delete_on_close on file failed !\n"); + printf("(%s) setting delete_on_close on file failed !\n", + __location__); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("[8] close - 1 failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) close - 1 failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { - printf("[8] close - 2 failed (%s)\n", smbcli_errstr(cli2->tree)); + printf("(%s) close - 2 failed (%s)\n", + __location__, smbcli_errstr(cli2->tree)); correct = False; goto fail; } @@ -403,7 +453,8 @@ BOOL torture_test_delete(int dummy) /* This should fail.. */ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); if (fnum1 != -1) { - printf("[8] open of %s succeeded should have been deleted on close !\n", fname); + printf("(%s) open of %s succeeded should have been deleted on close !\n", + __location__, fname); goto fail; correct = False; } else @@ -414,7 +465,8 @@ BOOL torture_test_delete(int dummy) FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); if (fnum1 != -1) { - printf("[9] open of %s succeeded should have failed!\n", fname); + printf("(%s) open of %s succeeded should have failed!\n", + __location__, fname); correct = False; goto fail; } @@ -424,14 +476,16 @@ BOOL torture_test_delete(int dummy) fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); if (fnum1 == -1) { - printf("[10] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + printf("(%s) open of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } /* This should delete the file. */ if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("[10] close failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) close failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -439,7 +493,8 @@ BOOL torture_test_delete(int dummy) /* This should fail.. */ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); if (fnum1 != -1) { - printf("[10] open of %s succeeded should have been deleted on close !\n", fname); + printf("(%s) open of %s succeeded should have been deleted on close !\n", + __location__, fname); goto fail; correct = False; } else @@ -455,7 +510,8 @@ BOOL torture_test_delete(int dummy) NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { - printf("[11] open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + printf("(%s) open of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -463,13 +519,15 @@ BOOL torture_test_delete(int dummy) status = smbcli_nt_delete_on_close(cli1->tree, fnum1, True); if (NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_CANNOT_DELETE)) { - printf("[11] setting delete_on_close should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)\n", smbcli_errstr(cli1->tree)); + printf("(%s) setting delete_on_close should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("[11] close failed (%s)\n", smbcli_errstr(cli1->tree)); + printf("(%s) close failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -486,14 +544,16 @@ BOOL torture_test_delete(int dummy) NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); if (fnum1 != -1) { - printf("[12] open of %s succeeded. Should fail with NT_STATUS_CANNOT_DELETE.\n", fname); + printf("(%s) open of %s succeeded. Should fail with NT_STATUS_CANNOT_DELETE.\n", + __location__, fname); smbcli_close(cli1->tree, fnum1); correct = False; goto fail; } else { status = smbcli_nt_error(cli1->tree); if (NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_CANNOT_DELETE)) { - printf("[12] setting delete_on_close on open should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)\n", smbcli_errstr(cli1->tree)); + printf("(%s) setting delete_on_close on open should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)\n", + __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; } -- cgit From e9381dfd707a7b7ff9faca6e12262a2b2f9f193a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 24 Oct 2004 12:38:32 +0000 Subject: r3152: reformatted some of the delete test code (This used to be commit d7b0dece6fbc2b5f8216b6a6a41e3db76b8627aa) --- source4/torture/basic/delete.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 1a469add8d..552da56420 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -227,11 +227,11 @@ BOOL torture_test_delete(int dummy) /* This should succeed. */ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, - FILE_ATTRIBUTE_NORMAL, - NTCREATEX_SHARE_ACCESS_READ | - NTCREATEX_SHARE_ACCESS_WRITE | - NTCREATEX_SHARE_ACCESS_DELETE, - NTCREATEX_DISP_OPEN, 0, 0); + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ | + NTCREATEX_SHARE_ACCESS_WRITE | + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, 0, 0); if (fnum2 == -1) { printf("(%s) open - 2 of %s failed (%s)\n", __location__, fname, smbcli_errstr(cli1->tree)); @@ -254,9 +254,11 @@ BOOL torture_test_delete(int dummy) } /* This should fail - no more opens once delete on close set. */ - fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, - FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, - NTCREATEX_DISP_OPEN, 0, 0); + fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, + GENERIC_RIGHTS_FILE_READ, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, 0, 0); if (fnum2 != -1) { printf("(%s) open - 3 of %s succeeded ! Should have failed.\n", __location__, fname ); @@ -461,8 +463,12 @@ BOOL torture_test_delete(int dummy) printf("eighth delete on close test succeeded.\n"); /* This should fail - we need to set DELETE_ACCESS. */ - fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0,SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA, - FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_NONE, + NTCREATEX_DISP_OVERWRITE_IF, + NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); if (fnum1 != -1) { printf("(%s) open of %s succeeded should have failed!\n", @@ -473,8 +479,12 @@ BOOL torture_test_delete(int dummy) printf("ninth delete on close test succeeded.\n"); - fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS, - FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_NONE, + NTCREATEX_DISP_OVERWRITE_IF, + NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); if (fnum1 == -1) { printf("(%s) open of %s failed (%s)\n", __location__, fname, smbcli_errstr(cli1->tree)); -- cgit From 2641612a49ceae26b5caf5389bdf03e11623bd8e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 24 Oct 2004 12:55:12 +0000 Subject: r3155: reformat a delete test (This used to be commit 739c9e401cfbe04f2596e5b4b178243263218c04) --- source4/torture/basic/delete.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 552da56420..225a73736e 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -515,9 +515,11 @@ BOOL torture_test_delete(int dummy) smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); - fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, - FILE_ATTRIBUTE_READONLY, NTCREATEX_SHARE_ACCESS_NONE, - NTCREATEX_DISP_OVERWRITE_IF, 0, 0); + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + GENERIC_RIGHTS_FILE_ALL_ACCESS, + FILE_ATTRIBUTE_READONLY, + NTCREATEX_SHARE_ACCESS_NONE, + NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { printf("(%s) open of %s failed (%s)\n", -- cgit From ba6d5fcb97b9831dddf7dfe09fb02fbb23d864b4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 28 Oct 2004 13:40:50 +0000 Subject: r3324: made the smbtorture code completely warning free (This used to be commit 7067bb9b52223cafa28470f264f0b60646a07a01) --- source4/torture/basic/delete.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 225a73736e..742a51bcaa 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -26,7 +26,7 @@ /* Test delete on close semantics. */ -BOOL torture_test_delete(int dummy) +BOOL torture_test_delete(void) { struct smbcli_state *cli1; struct smbcli_state *cli2 = NULL; -- cgit From fdc9f417d89fdf9dd6afbc22843d70585e195c9d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 30 Nov 2004 04:33:27 +0000 Subject: r4011: get rid of rpc_secdes.h and replace it with a single sane set of definitions for security access masks, in security.idl The previous definitions were inconsistently named, and contained many duplicate and misleading entries. I kept finding myself tripping up while using them. (This used to be commit 01c0fa722f80ceeb3f81f01987de95f365a2ed3d) --- source4/torture/basic/delete.c | 93 ++++++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 36 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 742a51bcaa..99be602de9 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "librpc/gen_ndr/ndr_security.h" /* @@ -47,9 +48,11 @@ BOOL torture_test_delete(void) smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); - fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL, - NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, - NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SEC_RIGHTS_FULL_CONTROL, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, + NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); if (fnum1 == -1) { printf("(%s) open of %s failed (%s)\n", @@ -80,9 +83,10 @@ BOOL torture_test_delete(void) smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); - fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, - FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, - NTCREATEX_DISP_OVERWRITE_IF, 0, 0); + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SEC_RIGHTS_FULL_CONTROL, + FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, + NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { printf("(%s) open of %s failed (%s)\n", @@ -124,7 +128,7 @@ BOOL torture_test_delete(void) smbcli_unlink(cli1->tree, fname); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, - GENERIC_RIGHTS_FILE_ALL_ACCESS, + SEC_RIGHTS_FULL_CONTROL, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); @@ -140,7 +144,7 @@ BOOL torture_test_delete(void) with SHARE_DELETE. */ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, - GENERIC_RIGHTS_FILE_READ, + SEC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OPEN, 0, 0); @@ -154,8 +158,11 @@ BOOL torture_test_delete(void) /* This should succeed. */ - fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL, - NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); + fnum2 = 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); if (fnum2 == -1) { printf("(%s) open - 2 of %s failed (%s)\n", @@ -211,12 +218,12 @@ BOOL torture_test_delete(void) } fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, - SA_RIGHT_FILE_READ_DATA | - SA_RIGHT_FILE_WRITE_DATA | - STD_RIGHT_DELETE_ACCESS, - FILE_ATTRIBUTE_NORMAL, - NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, - NTCREATEX_DISP_OVERWRITE_IF, 0, 0); + SEC_FILE_READ_DATA | + SEC_FILE_WRITE_DATA | + SEC_STD_DELETE, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, + NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { printf("(%s) open of %s failed (%s)\n", @@ -226,7 +233,8 @@ BOOL torture_test_delete(void) } /* This should succeed. */ - fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, + fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, + SEC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE | @@ -255,7 +263,7 @@ BOOL torture_test_delete(void) /* This should fail - no more opens once delete on close set. */ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, - GENERIC_RIGHTS_FILE_READ, + SEC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); @@ -309,7 +317,7 @@ BOOL torture_test_delete(void) smbcli_unlink(cli1->tree, fname); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, - SA_RIGHT_FILE_READ_DATA | SA_RIGHT_FILE_WRITE_DATA, + SEC_FILE_READ_DATA | SEC_FILE_WRITE_DATA, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE | @@ -346,10 +354,11 @@ BOOL torture_test_delete(void) smbcli_unlink(cli1->tree, fname); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, - SA_RIGHT_FILE_READ_DATA | - SA_RIGHT_FILE_WRITE_DATA | - STD_RIGHT_DELETE_ACCESS, - FILE_ATTRIBUTE_NORMAL, 0, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); + SEC_FILE_READ_DATA | + SEC_FILE_WRITE_DATA | + SEC_STD_DELETE, + FILE_ATTRIBUTE_NORMAL, 0, + NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { printf("(%s) open of %s failed (%s)\n", @@ -409,9 +418,13 @@ BOOL torture_test_delete(void) goto fail; } - fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS, - FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, - NTCREATEX_DISP_OVERWRITE_IF, 0, 0); + 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_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { printf("(%s) open of %s failed (%s)\n", @@ -420,9 +433,13 @@ BOOL torture_test_delete(void) goto fail; } - fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS, - FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, - NTCREATEX_DISP_OPEN, 0, 0); + fnum2 = smbcli_nt_create_full(cli2->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_OPEN, 0, 0); if (fnum2 == -1) { printf("(%s) open of %s failed (%s)\n", @@ -464,7 +481,7 @@ BOOL torture_test_delete(void) /* This should fail - we need to set DELETE_ACCESS. */ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, - SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA, + SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, @@ -480,7 +497,9 @@ BOOL torture_test_delete(void) printf("ninth delete on close test succeeded.\n"); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, - SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS, + SEC_FILE_READ_DATA| + SEC_FILE_WRITE_DATA| + SEC_STD_DELETE, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, @@ -514,9 +533,9 @@ BOOL torture_test_delete(void) smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); - + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, - GENERIC_RIGHTS_FILE_ALL_ACCESS, + SEC_RIGHTS_FULL_CONTROL, FILE_ATTRIBUTE_READONLY, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); @@ -551,9 +570,11 @@ BOOL torture_test_delete(void) /* test 12 - does having read only attribute still allow delete on close at time of open. */ - fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_READONLY, - NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, - NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SEC_RIGHTS_FULL_CONTROL, + FILE_ATTRIBUTE_READONLY, + NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, + NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); if (fnum1 != -1) { printf("(%s) open of %s succeeded. Should fail with NT_STATUS_CANNOT_DELETE.\n", -- cgit From cc8f4358cca2404895015e2351394f2f4a16e025 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 2 Dec 2004 04:37:36 +0000 Subject: r4035: more effort on consistent naming of the access mask bits. This removes the duplicate named SEC_RIGHTS_MAXIMUM_ALLOWED and SEC_RIGHTS_FULL_CONTROL, which are just other names for SEC_FLAG_MAXIMUM_ALLOWED and SEC_RIGHTS_FILE_ALL. The latter names match the new naming conventions in security.idl Also added names for the generic->specific mappings for files are directories (This used to be commit 17a4e0b3aca227b40957ed1e0c57e498debc6ddf) --- source4/torture/basic/delete.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 99be602de9..3247a7cd28 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -49,7 +49,7 @@ BOOL torture_test_delete(void) smbcli_unlink(cli1->tree, fname); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, - SEC_RIGHTS_FULL_CONTROL, + SEC_RIGHTS_FILE_ALL, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); @@ -84,7 +84,7 @@ BOOL torture_test_delete(void) smbcli_unlink(cli1->tree, fname); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, - SEC_RIGHTS_FULL_CONTROL, + SEC_RIGHTS_FILE_ALL, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); @@ -128,7 +128,7 @@ BOOL torture_test_delete(void) smbcli_unlink(cli1->tree, fname); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, - SEC_RIGHTS_FULL_CONTROL, + SEC_RIGHTS_FILE_ALL, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); @@ -535,7 +535,7 @@ BOOL torture_test_delete(void) smbcli_unlink(cli1->tree, fname); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, - SEC_RIGHTS_FULL_CONTROL, + SEC_RIGHTS_FILE_ALL, FILE_ATTRIBUTE_READONLY, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); @@ -571,7 +571,7 @@ BOOL torture_test_delete(void) /* test 12 - does having read only attribute still allow delete on close at time of open. */ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, - SEC_RIGHTS_FULL_CONTROL, + SEC_RIGHTS_FILE_ALL, FILE_ATTRIBUTE_READONLY, NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); -- cgit From e82aad1ce39a6b7a2e51b9e2cb494d74ec70e158 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 10 Feb 2005 05:09:35 +0000 Subject: r5298: - got rid of pstring.h from includes.h. This at least makes it a bit less likely that anyone will use pstring for new code - got rid of winbind_client.h from includes.h. This one triggered a huge change, as winbind_client.h was including system/filesys.h and defining the old uint32 and uint16 types, as well as its own pstring and fstring. (This used to be commit 9db6c79e902ec538108d6b7d3324039aabe1704f) --- source4/torture/basic/delete.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 3247a7cd28..f3aef08ce1 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "system/filesys.h" #include "librpc/gen_ndr/ndr_security.h" -- cgit From fee56ea90040a020cfe1938a3678effa00b772d4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Jul 2005 05:05:28 +0000 Subject: r8117: fixed a bunch more dos error code handing. The biggest change was fixing the RAW-CONTEXT test. It was forcing capabilities to zero in an attempt to not negotiated extended security, but as a side effect it was forcing negotiation of dos error codes. This confused the hell out of the test code! Also fixed a bunch of places incorrectly using NT_STATUS_V() instead of NT_STATUS_EQUAL() and several places that had the wrong dos status codes (This used to be commit 0b22744f40804a0d6dc94bfc40ec09306f584f7e) --- source4/torture/basic/delete.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index f3aef08ce1..7ddd39c1cb 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -550,7 +550,7 @@ BOOL torture_test_delete(void) status = smbcli_nt_delete_on_close(cli1->tree, fnum1, True); - if (NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_CANNOT_DELETE)) { + if (!NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) { printf("(%s) setting delete_on_close should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)\n", __location__, smbcli_errstr(cli1->tree)); correct = False; @@ -585,7 +585,7 @@ BOOL torture_test_delete(void) goto fail; } else { status = smbcli_nt_error(cli1->tree); - if (NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_CANNOT_DELETE)) { + if (!NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) { printf("(%s) setting delete_on_close on open should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)\n", __location__, smbcli_errstr(cli1->tree)); correct = False; -- cgit From 44b66a73d3e55cb30eec5d80f51edf5188401ac0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 6 Jul 2005 07:45:22 +0000 Subject: r8176: Exploring the share mode database... A delete-on-close deleted file is still around while open on another fd. But only for findfirst, not for qpathinfo :-) Volker (This used to be commit dbc7a1a978d782c73f593f4b46f2a81d35169713) --- source4/torture/basic/delete.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 7ddd39c1cb..19af9fc76d 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -463,6 +463,45 @@ BOOL torture_test_delete(void) goto fail; } + { + TALLOC_CTX *mem_ctx = talloc_init("single_search"); + union smb_search_data data; + status = torture_single_search(cli1, mem_ctx, + fname, RAW_SEARCH_FULL_DIRECTORY_INFO, + &data); + if (!NT_STATUS_IS_OK(status)) { + printf("(%s) single_search failed (%s)\n", + __location__, nt_errstr(status)); + correct = False; + } + talloc_free(mem_ctx); + } + + { + time_t c_time, a_time, m_time, w_time; + size_t size; + uint16_t mode; + ino_t ino; + status = smbcli_qpathinfo(cli1->tree, fname, + &c_time, &a_time, &m_time, + &size, &mode); + if (!NT_STATUS_EQUAL(status, NT_STATUS_DELETE_PENDING)) { + printf("(%s) qpathinfo did not give correct error " + "code (%s) -- NT_STATUS_DELETE_PENDING " + "expected\n", __location__, + nt_errstr(status)); + correct = False; + } + status = smbcli_qfileinfo(cli2->tree, fnum2, &mode, &size, + &c_time, &a_time, &m_time, + &w_time, &ino); + if (!NT_STATUS_IS_OK(status)) { + printf("(%s) qfileinfo failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); + correct = False; + } + } + if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { printf("(%s) close - 2 failed (%s)\n", __location__, smbcli_errstr(cli2->tree)); -- cgit From 441934bc93c49ad4c8cae299a7c16e462e74861b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 6 Jul 2005 08:13:11 +0000 Subject: r8177: More explorations. The share mode db is actually checked on qpathinfo even before the delete-on-close is executed. Volker (This used to be commit 124f3b74ca2ece9ba73737c3ccb75e1730973f19) --- source4/torture/basic/delete.c | 47 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 19af9fc76d..cdd7d3260a 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -456,6 +456,41 @@ BOOL torture_test_delete(void) goto fail; } + { + time_t c_time, a_time, m_time, w_time; + size_t size; + uint16_t mode; + ino_t ino; + status = smbcli_qpathinfo(cli1->tree, fname, + &c_time, &a_time, &m_time, + &size, &mode); + if (!NT_STATUS_EQUAL(status, NT_STATUS_DELETE_PENDING)) { + printf("(%s) qpathinfo 1 did not give correct error " + "code (%s) -- NT_STATUS_DELETE_PENDING " + "expected\n", __location__, + nt_errstr(status)); + correct = False; + } + status = smbcli_qpathinfo(cli2->tree, fname, + &c_time, &a_time, &m_time, + &size, &mode); + if (!NT_STATUS_EQUAL(status, NT_STATUS_DELETE_PENDING)) { + printf("(%s) qpathinfo 2 did not give correct error " + "code (%s) -- NT_STATUS_DELETE_PENDING " + "expected\n", __location__, + nt_errstr(status)); + correct = False; + } + status = smbcli_qfileinfo(cli2->tree, fnum2, &mode, &size, + &c_time, &a_time, &m_time, + &w_time, &ino); + if (!NT_STATUS_IS_OK(status)) { + printf("(%s) qfileinfo failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); + correct = False; + } + } + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close - 1 failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); @@ -486,7 +521,17 @@ BOOL torture_test_delete(void) &c_time, &a_time, &m_time, &size, &mode); if (!NT_STATUS_EQUAL(status, NT_STATUS_DELETE_PENDING)) { - printf("(%s) qpathinfo did not give correct error " + printf("(%s) qpathinfo 1 did not give correct error " + "code (%s) -- NT_STATUS_DELETE_PENDING " + "expected\n", __location__, + nt_errstr(status)); + correct = False; + } + status = smbcli_qpathinfo(cli2->tree, fname, + &c_time, &a_time, &m_time, + &size, &mode); + if (!NT_STATUS_EQUAL(status, NT_STATUS_DELETE_PENDING)) { + printf("(%s) qpathinfo 2 did not give correct error " "code (%s) -- NT_STATUS_DELETE_PENDING " "expected\n", __location__, nt_errstr(status)); -- cgit From 755741f93d3e5a67a6bd9c98f0d46ff0dce80009 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 6 Jul 2005 09:50:31 +0000 Subject: r8179: Delete-on-close is really a shared DB. Setting it on one connection(!) and resetting it on another resets it for both. Volker (This used to be commit 30bd7e36669dbb2fd7d85a1cd72927370267d616) --- source4/torture/basic/delete.c | 222 +++++++++++++++++++++++++---------------- 1 file changed, 138 insertions(+), 84 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index cdd7d3260a..65d6b36731 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -24,6 +24,48 @@ #include "system/filesys.h" #include "librpc/gen_ndr/ndr_security.h" +static BOOL check_delete_on_close(struct smbcli_state *cli, const char *fname, + BOOL expect_it) +{ + TALLOC_CTX *mem_ctx = talloc_init("single_search"); + union smb_search_data data; + NTSTATUS status; + + time_t c_time, a_time, m_time; + size_t size; + uint16_t mode; + + status = torture_single_search(cli, mem_ctx, + fname, RAW_SEARCH_FULL_DIRECTORY_INFO, + &data); + if (!NT_STATUS_IS_OK(status)) { + printf("(%s) single_search failed (%s)\n", + __location__, nt_errstr(status)); + return False; + } + + status = smbcli_qpathinfo(cli->tree, fname, + &c_time, &a_time, &m_time, + &size, &mode); + + if (expect_it) { + if (!NT_STATUS_EQUAL(status, NT_STATUS_DELETE_PENDING)) { + printf("(%s) qpathinfo did not give correct error " + "code (%s) -- NT_STATUS_DELETE_PENDING " + "expected\n", __location__, + nt_errstr(status)); + return False; + } + } else { + if (!NT_STATUS_IS_OK(status)) { + printf("(%s) qpathinfo failed (%s)\n", __location__, + nt_errstr(status)); + return False; + } + } + + return True; +} /* Test delete on close semantics. @@ -374,6 +416,8 @@ BOOL torture_test_delete(void) correct = False; goto fail; } + + correct &= check_delete_on_close(cli1, fname, True); if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, False))) { printf("(%s) unsetting delete_on_close on file failed !\n", @@ -382,6 +426,8 @@ BOOL torture_test_delete(void) goto fail; } + correct &= check_delete_on_close(cli1, fname, False); + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close - 2 failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); @@ -455,41 +501,9 @@ BOOL torture_test_delete(void) correct = False; goto fail; } - - { - time_t c_time, a_time, m_time, w_time; - size_t size; - uint16_t mode; - ino_t ino; - status = smbcli_qpathinfo(cli1->tree, fname, - &c_time, &a_time, &m_time, - &size, &mode); - if (!NT_STATUS_EQUAL(status, NT_STATUS_DELETE_PENDING)) { - printf("(%s) qpathinfo 1 did not give correct error " - "code (%s) -- NT_STATUS_DELETE_PENDING " - "expected\n", __location__, - nt_errstr(status)); - correct = False; - } - status = smbcli_qpathinfo(cli2->tree, fname, - &c_time, &a_time, &m_time, - &size, &mode); - if (!NT_STATUS_EQUAL(status, NT_STATUS_DELETE_PENDING)) { - printf("(%s) qpathinfo 2 did not give correct error " - "code (%s) -- NT_STATUS_DELETE_PENDING " - "expected\n", __location__, - nt_errstr(status)); - correct = False; - } - status = smbcli_qfileinfo(cli2->tree, fnum2, &mode, &size, - &c_time, &a_time, &m_time, - &w_time, &ino); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) qfileinfo failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - } - } + + correct &= check_delete_on_close(cli1, fname, True); + correct &= check_delete_on_close(cli2, fname, True); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close - 1 failed (%s)\n", @@ -498,55 +512,9 @@ BOOL torture_test_delete(void) goto fail; } - { - TALLOC_CTX *mem_ctx = talloc_init("single_search"); - union smb_search_data data; - status = torture_single_search(cli1, mem_ctx, - fname, RAW_SEARCH_FULL_DIRECTORY_INFO, - &data); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) single_search failed (%s)\n", - __location__, nt_errstr(status)); - correct = False; - } - talloc_free(mem_ctx); - } - - { - time_t c_time, a_time, m_time, w_time; - size_t size; - uint16_t mode; - ino_t ino; - status = smbcli_qpathinfo(cli1->tree, fname, - &c_time, &a_time, &m_time, - &size, &mode); - if (!NT_STATUS_EQUAL(status, NT_STATUS_DELETE_PENDING)) { - printf("(%s) qpathinfo 1 did not give correct error " - "code (%s) -- NT_STATUS_DELETE_PENDING " - "expected\n", __location__, - nt_errstr(status)); - correct = False; - } - status = smbcli_qpathinfo(cli2->tree, fname, - &c_time, &a_time, &m_time, - &size, &mode); - if (!NT_STATUS_EQUAL(status, NT_STATUS_DELETE_PENDING)) { - printf("(%s) qpathinfo 2 did not give correct error " - "code (%s) -- NT_STATUS_DELETE_PENDING " - "expected\n", __location__, - nt_errstr(status)); - correct = False; - } - status = smbcli_qfileinfo(cli2->tree, fnum2, &mode, &size, - &c_time, &a_time, &m_time, - &w_time, &ino); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) qfileinfo failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - } - } - + correct &= check_delete_on_close(cli1, fname, True); + correct &= check_delete_on_close(cli2, fname, True); + if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { printf("(%s) close - 2 failed (%s)\n", __location__, smbcli_errstr(cli2->tree)); @@ -679,6 +647,92 @@ BOOL torture_test_delete(void) printf("twelvth delete on close test succeeded.\n"); + /* Test 13: Does resetting the delete on close flag affect a second + * fd? */ + + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(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_OVERWRITE_IF, + 0, 0); + + if (fnum1 == -1) { + printf("(%s) open of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + fnum2 = smbcli_nt_create_full(cli2->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_OPEN, 0, 0); + + if (fnum2 == -1) { + printf("(%s) open of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli2->tree)); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, + True))) { + printf("(%s) setting delete_on_close on file failed !\n", + __location__); + correct = False; + goto fail; + } + + correct &= check_delete_on_close(cli1, fname, True); + correct &= check_delete_on_close(cli2, fname, True); + + if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli2->tree, fnum2, + False))) { + printf("(%s) setting delete_on_close on file failed !\n", + __location__); + correct = False; + goto fail; + } + + correct &= check_delete_on_close(cli1, fname, False); + correct &= check_delete_on_close(cli2, fname, False); + + if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { + printf("(%s) close - 1 failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { + printf("(%s) close - 2 failed (%s)\n", + __location__, smbcli_errstr(cli2->tree)); + correct = False; + goto fail; + } + + fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); + + if (fnum1 == -1) { + printf("(%s) open of %s failed!\n", + __location__, fname); + correct = False; + goto fail; + } + + smbcli_close(cli1->tree, fnum1); + + printf("thirteenth delete on close test succeeded.\n"); + printf("finished delete test\n"); fail: -- cgit From 520427119c684483697b0d6672700c08aff4c1da Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 6 Jul 2005 13:24:38 +0000 Subject: r8182: Little more testing delete-on-close: Check flag with qfileinfo. Volker (This used to be commit 47a9df946d5ff967289fba0ff4209711ead11e31) --- source4/torture/basic/delete.c | 95 +++++++++++++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 16 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 65d6b36731..d4d196968a 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -24,8 +24,8 @@ #include "system/filesys.h" #include "librpc/gen_ndr/ndr_security.h" -static BOOL check_delete_on_close(struct smbcli_state *cli, const char *fname, - BOOL expect_it) +static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, + const char *fname, BOOL expect_it) { TALLOC_CTX *mem_ctx = talloc_init("single_search"); union smb_search_data data; @@ -35,13 +35,72 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, const char *fname, size_t size; uint16_t mode; + BOOL res = True; + status = torture_single_search(cli, mem_ctx, fname, RAW_SEARCH_FULL_DIRECTORY_INFO, &data); if (!NT_STATUS_IS_OK(status)) { printf("(%s) single_search failed (%s)\n", __location__, nt_errstr(status)); - return False; + res = False; + goto done; + } + + if (fnum != -1) { + union smb_fileinfo io; + int nlink = expect_it ? 0 : 1; + + io.all_info.level = RAW_FILEINFO_ALL_INFO; + io.all_info.in.fnum = fnum; + + status = smb_raw_fileinfo(cli->tree, mem_ctx, &io); + if (!NT_STATUS_IS_OK(status)) { + printf("(%s) qpathinfo failed (%s)\n", __location__, + nt_errstr(status)); + res = False; + goto done; + } + + if (expect_it != io.all_info.out.delete_pending) { + printf("Expected del_on_close flag %d, qfileinfo gave %d\n", + expect_it, io.all_info.out.delete_pending); + res = False; + goto done; + } + + if (nlink != io.all_info.out.nlink) { + printf("Expected nlink %d, qfileinfo gave %d\n", + nlink, io.all_info.out.nlink); + res = False; + goto done; + } + + io.standard_info.level = RAW_FILEINFO_STANDARD_INFO; + io.standard_info.in.fnum = fnum; + + status = smb_raw_fileinfo(cli->tree, mem_ctx, &io); + if (!NT_STATUS_IS_OK(status)) { + printf("(%s) qpathinfo failed (%s)\n", __location__, + nt_errstr(status)); + res = False; + goto done; + } + + if (expect_it != io.standard_info.out.delete_pending) { + printf("Expected del_on_close flag %d, qfileinfo gave %d\n", + expect_it, io.standard_info.out.delete_pending); + res = False; + goto done; + } + + if (nlink != io.standard_info.out.nlink) { + printf("Expected nlink %d, qfileinfo gave %d\n", + nlink, io.all_info.out.nlink); + res = False; + goto done; + } + } status = smbcli_qpathinfo(cli->tree, fname, @@ -54,17 +113,21 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, const char *fname, "code (%s) -- NT_STATUS_DELETE_PENDING " "expected\n", __location__, nt_errstr(status)); - return False; + res = False; + goto done; } } else { if (!NT_STATUS_IS_OK(status)) { printf("(%s) qpathinfo failed (%s)\n", __location__, nt_errstr(status)); - return False; + res = False; + goto done; } } - return True; + done: + talloc_free(mem_ctx); + return res; } /* @@ -417,7 +480,7 @@ BOOL torture_test_delete(void) goto fail; } - correct &= check_delete_on_close(cli1, fname, True); + correct &= check_delete_on_close(cli1, fnum1, fname, True); if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, False))) { printf("(%s) unsetting delete_on_close on file failed !\n", @@ -426,7 +489,7 @@ BOOL torture_test_delete(void) goto fail; } - correct &= check_delete_on_close(cli1, fname, False); + correct &= check_delete_on_close(cli1, fnum1, fname, False); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close - 2 failed (%s)\n", @@ -502,8 +565,8 @@ BOOL torture_test_delete(void) goto fail; } - correct &= check_delete_on_close(cli1, fname, True); - correct &= check_delete_on_close(cli2, fname, True); + correct &= check_delete_on_close(cli1, fnum1, fname, True); + correct &= check_delete_on_close(cli2, fnum2, fname, True); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close - 1 failed (%s)\n", @@ -512,8 +575,8 @@ BOOL torture_test_delete(void) goto fail; } - correct &= check_delete_on_close(cli1, fname, True); - correct &= check_delete_on_close(cli2, fname, True); + correct &= check_delete_on_close(cli1, -1, fname, True); + correct &= check_delete_on_close(cli2, fnum2, fname, True); if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { printf("(%s) close - 2 failed (%s)\n", @@ -692,8 +755,8 @@ BOOL torture_test_delete(void) goto fail; } - correct &= check_delete_on_close(cli1, fname, True); - correct &= check_delete_on_close(cli2, fname, True); + correct &= check_delete_on_close(cli1, fnum1, fname, True); + correct &= check_delete_on_close(cli2, fnum2, fname, True); if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli2->tree, fnum2, False))) { @@ -703,8 +766,8 @@ BOOL torture_test_delete(void) goto fail; } - correct &= check_delete_on_close(cli1, fname, False); - correct &= check_delete_on_close(cli2, fname, False); + correct &= check_delete_on_close(cli1, fnum1, fname, False); + correct &= check_delete_on_close(cli2, fnum2, fname, False); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close - 1 failed (%s)\n", -- cgit From 824f5b47818fd4cc7fe0084bf454bb31930c4f38 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 6 Jul 2005 14:56:45 +0000 Subject: r8185: Delete on close on directories: Creating a file in a directory with delete-on-close set returns DELETE_PENDING, and trying to set the flag on a non-empty directory returns DIRECTORY_NOT_EMPTY. Volker (This used to be commit 5680f34778b2f5291936f4d4fb937a7713696c52) --- source4/torture/basic/delete.c | 137 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index d4d196968a..e28561db37 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -39,6 +39,7 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, status = torture_single_search(cli, mem_ctx, fname, RAW_SEARCH_FULL_DIRECTORY_INFO, + FILE_ATTRIBUTE_DIRECTORY, &data); if (!NT_STATUS_IS_OK(status)) { printf("(%s) single_search failed (%s)\n", @@ -138,8 +139,10 @@ BOOL torture_test_delete(void) struct smbcli_state *cli1; struct smbcli_state *cli2 = NULL; const char *fname = "\\delete.file"; + const char *dirname = "\\delete.dir"; int fnum1 = -1; int fnum2 = -1; + int dnum1 = -1; BOOL correct = True; NTSTATUS status; @@ -149,6 +152,8 @@ BOOL torture_test_delete(void) return False; } + smbcli_deltree(cli1->tree, dirname); + /* Test 1 - this should delete the file on close. */ smbcli_setatr(cli1->tree, fname, 0, 0); @@ -793,9 +798,141 @@ BOOL torture_test_delete(void) } smbcli_close(cli1->tree, fnum1); + smbcli_unlink(cli1->tree, fname); printf("thirteenth delete on close test succeeded.\n"); + /* Test 14 -- directory */ + + dnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + SEC_FILE_READ_DATA| + SEC_FILE_WRITE_DATA| + SEC_STD_DELETE, + FILE_ATTRIBUTE_DIRECTORY, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_CREATE, 0, 0); + if (dnum1 == -1) { + printf("(%s) open of %s failed: %s!\n", + __location__, dirname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + check_delete_on_close(cli1, dnum1, dirname, False); + if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, dnum1, True))) { + printf("(%s) setting delete_on_close on file failed !\n", + __location__); + correct = False; + goto fail; + } + check_delete_on_close(cli1, dnum1, dirname, True); + smbcli_close(cli1->tree, dnum1); + + /* Now it should be gone... */ + + dnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + SEC_FILE_READ_DATA| + SEC_FILE_WRITE_DATA| + SEC_STD_DELETE, + FILE_ATTRIBUTE_DIRECTORY, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, 0, 0); + if (dnum1 != -1) { + printf("(%s) setting delete_on_close on file succeeded !\n", + __location__); + correct = False; + goto fail; + } + + printf("fourteenth delete on close test succeeded.\n"); + + /* Test 15 -- non-empty directory */ + + dnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + SEC_FILE_READ_DATA| + SEC_FILE_WRITE_DATA| + SEC_STD_DELETE, + FILE_ATTRIBUTE_DIRECTORY, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_CREATE, + NTCREATEX_OPTIONS_DIRECTORY, 0); + if (dnum1 == -1) { + printf("(%s) open of %s failed: %s!\n", + __location__, dirname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + check_delete_on_close(cli1, dnum1, dirname, False); + status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True); + + { + char *fullname; + asprintf(&fullname, "\\%s%s", dirname, fname); + fnum1 = smbcli_open(cli1->tree, fullname, O_CREAT|O_RDWR, + DENY_NONE); + if (fnum1 != -1) { + printf("(%s) smbcli_open succeeded, should have " + "failed: %s\n", + __location__, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree), + NT_STATUS_DELETE_PENDING)) { + printf("(%s) smbcli_open returned %s, expected " + "NT_STATUS_DELETE_PENDING\n", + __location__, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + } + + status = smbcli_nt_delete_on_close(cli1->tree, dnum1, False); + if (!NT_STATUS_IS_OK(status)) { + printf("(%s) setting delete_on_close on file failed !\n", + __location__); + correct = False; + goto fail; + } + + { + char *fullname; + asprintf(&fullname, "\\%s%s", dirname, fname); + fnum1 = smbcli_open(cli1->tree, fullname, O_CREAT|O_RDWR, + DENY_NONE); + if (fnum1 == -1) { + printf("(%s) smbcli_open failed: %s\n", + __location__, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + smbcli_close(cli1->tree, fnum1); + } + + status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True); + + if (!NT_STATUS_EQUAL(status, NT_STATUS_DIRECTORY_NOT_EMPTY)) { + printf("(%s) setting delete_on_close returned %s, expected " + "NT_STATUS_DIRECTORY_NOT_EMPTY\n", __location__, + smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + smbcli_close(cli1->tree, dnum1); + + /* Now it should be gone... */ + + printf("fifteenth delete on close test succeeded.\n"); + printf("finished delete test\n"); fail: -- cgit From 520139439ede489f94f32e4424526d9bb66fa597 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 20 Aug 2005 21:28:30 +0000 Subject: r9431: Check an error code in BASE-DELETE. Volker (This used to be commit 71571fffc0493a5658c5980e6ebe4d8f9ada4699) --- source4/torture/basic/delete.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index e28561db37..081058af42 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -23,6 +23,7 @@ #include "includes.h" #include "system/filesys.h" #include "librpc/gen_ndr/ndr_security.h" +#include "libcli/raw/libcliraw.h" static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, const char *fname, BOOL expect_it) @@ -131,6 +132,14 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, return res; } +#define CHECK_STATUS(_cli, _expected) do { \ + if (!NT_STATUS_EQUAL(_cli->tree->session->transport->error.e.nt_status, _expected)) { \ + printf("(%d) Incorrect status %s - should be %s\n", \ + __LINE__, nt_errstr(_cli->tree->session->transport->error.e.nt_status), nt_errstr(_expected)); \ + correct = False; \ + goto fail; \ + }} while (0) + /* Test delete on close semantics. */ @@ -383,8 +392,10 @@ BOOL torture_test_delete(void) __location__, fname ); correct = False; goto fail; - } else - printf("fourth delete on close test succeeded.\n"); + } + CHECK_STATUS(cli1, NT_STATUS_DELETE_PENDING); + + printf("fourth delete on close test succeeded.\n"); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close - 2 failed (%s)\n", -- cgit From cdfdb732805da3dad447583e0a1f9abea11ba1a2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 9 Dec 2005 19:36:40 +0000 Subject: r12150: Reformatting (This used to be commit aaa21b7132ec81008ad2ec7b2aafc4604d13093d) --- source4/torture/basic/delete.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 081058af42..60db6a78ed 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -697,27 +697,30 @@ BOOL torture_test_delete(void) smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); - printf("eleventh delete on close test succeeded.\n"); - /* test 12 - does having read only attribute still allow delete on close at time of open. */ + /* test 12 - does having read only attribute still allow delete on + * close at time of open. */ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_RIGHTS_FILE_ALL, FILE_ATTRIBUTE_READONLY, - NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); if (fnum1 != -1) { - printf("(%s) open of %s succeeded. Should fail with NT_STATUS_CANNOT_DELETE.\n", - __location__, fname); + printf("(%s) open of %s succeeded. Should fail with " + "NT_STATUS_CANNOT_DELETE.\n", __location__, fname); smbcli_close(cli1->tree, fnum1); correct = False; goto fail; } else { status = smbcli_nt_error(cli1->tree); if (!NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) { - printf("(%s) setting delete_on_close on open should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)\n", + printf("(%s) setting delete_on_close on open should " + "fail with NT_STATUS_CANNOT_DELETE. Got %s " + "instead)\n", __location__, smbcli_errstr(cli1->tree)); correct = False; goto fail; @@ -737,7 +740,9 @@ BOOL torture_test_delete(void) SEC_FILE_WRITE_DATA| SEC_STD_DELETE, FILE_ATTRIBUTE_NORMAL, - NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); @@ -753,7 +758,9 @@ BOOL torture_test_delete(void) SEC_FILE_WRITE_DATA| SEC_STD_DELETE, FILE_ATTRIBUTE_NORMAL, - NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); if (fnum2 == -1) { -- cgit From 10275774499a6ff25efa066ce82d802641285772 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 9 Dec 2005 21:49:11 +0000 Subject: r12154: Torture test for bug # 3303. Jeremy, to run this against Samba3 at all you need to insert a "goto line 957" in line 548. Without this we fail some tests before # 16 and bail out. While looking at it, you wanted to fix the directory-based ones a while ago.... :-)) Volker (This used to be commit 45cd224102f21364c4f6ca056417f956f21eb02e) --- source4/torture/basic/delete.c | 125 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 60db6a78ed..d1ee98941c 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -148,6 +148,7 @@ BOOL torture_test_delete(void) struct smbcli_state *cli1; struct smbcli_state *cli2 = NULL; const char *fname = "\\delete.file"; + const char *fname_new = "\\delete.new"; const char *dirname = "\\delete.dir"; int fnum1 = -1; int fnum2 = -1; @@ -951,6 +952,130 @@ BOOL torture_test_delete(void) printf("fifteenth delete on close test succeeded.\n"); + /* Test 16: delete on close under rename */ + + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + smbcli_unlink(cli1->tree, fname_new); + + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SEC_FILE_READ_DATA, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OVERWRITE_IF, + 0, 0); + + if (fnum1 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + status = smbcli_rename(cli2->tree, fname, fname_new); + + if (!NT_STATUS_IS_OK(status)) { + printf("(%s) renaming failed: %s !\n", + __location__, nt_errstr(status)); + correct = False; + goto fail; + } + + fnum2 = smbcli_nt_create_full(cli2->tree, fname_new, 0, + SEC_GENERIC_ALL, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OVERWRITE_IF, + 0, 0); + + if (fnum2 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, fname_new, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + status = smbcli_nt_delete_on_close(cli2->tree, fnum2, True); + + if (!NT_STATUS_IS_OK(status)) { + printf("(%s) setting delete_on_close on file failed !\n", + __location__); + correct = False; + goto fail; + } + + smbcli_close(cli2->tree, fnum2); + + /* The file should be around under the new name, there's a second + * handle open */ + + if (!check_delete_on_close(cli1, fnum1, fname_new, True)) { + printf("(%s) checking delete on close on file %s failed!\n", + __location__, fname_new); + correct = False; + goto fail; + } + + fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, + SEC_GENERIC_ALL, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OVERWRITE_IF, + 0, 0); + + if (fnum2 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + smbcli_close(cli2->tree, fnum2); + smbcli_close(cli1->tree, fnum1); + + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SEC_FILE_READ_EA, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, + 0, 0); + + if (fnum1 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + smbcli_close(cli1->tree, fnum1); + + fnum1 = smbcli_nt_create_full(cli1->tree, fname_new, 0, + SEC_FILE_READ_EA, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, + 0, 0); + + if (fnum1 != -1) { + printf("(%s) smbcli_open succeeded, should have " + "failed\n", __location__); + smbcli_close(cli1->tree, fnum1); + correct = False; + goto fail; + } + + printf("sixteenth delete on close test succeeded.\n"); + printf("finished delete test\n"); fail: -- cgit From d4de4c2d210d2e8c9b5aedf70695594809ad6a0b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 13:16:54 +0000 Subject: r12608: Remove some unused #include lines. (This used to be commit 70e7449318aa0e9d2639c76730a7d1683b2f4981) --- source4/torture/basic/delete.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index d1ee98941c..81c3f3f1d1 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -22,7 +22,6 @@ #include "includes.h" #include "system/filesys.h" -#include "librpc/gen_ndr/ndr_security.h" #include "libcli/raw/libcliraw.h" static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, -- cgit From 25bb00fbcd409572e1c19c05fdc42c883936780b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 3 Jan 2006 13:41:17 +0000 Subject: r12693: Move core data structures out of smb.h into core.h torture prototypes in seperate header (This used to be commit 73610639b23ca3743077193fa0b1de7c7f65944d) --- source4/torture/basic/delete.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 81c3f3f1d1..3138f48d0f 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "torture/torture.h" #include "system/filesys.h" #include "libcli/raw/libcliraw.h" -- cgit From 78c50015bb8bd5a1d831a6e7ec796b3367c73145 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 3 Jan 2006 15:40:05 +0000 Subject: r12694: Move some headers to the directory of the subsystem they belong to. (This used to be commit c722f665c90103f3ed57621c460e32ad33e7a8a3) --- source4/torture/basic/delete.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 3138f48d0f..c6ddd4bd70 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "libcli/libcli.h" #include "torture/torture.h" #include "system/filesys.h" #include "libcli/raw/libcliraw.h" -- cgit From 4a9d08319b45a8a721f39c00067c64487b6b5be9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 1 Feb 2006 02:30:57 +0000 Subject: r13270: Add tests for even more insane delete-on-close semantics. Jeremy. (This used to be commit ae0851ce667c0559e786c3a83389ccfddce1a813) --- source4/torture/basic/delete.c | 142 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index c6ddd4bd70..50db9a09eb 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -1077,6 +1077,148 @@ BOOL torture_test_delete(void) printf("sixteenth delete on close test succeeded.\n"); + /* Test 17. */ + + /* Ensure the file doesn't already exist. */ + smbcli_close(cli1->tree, fnum1); + smbcli_close(cli1->tree, fnum2); + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + + /* Firstly create with all access, but delete on close. */ + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SEC_RIGHTS_FILE_ALL, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_CREATE, + NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); + + if (fnum1 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* The delete on close bit is *not* reported as being set. */ + check_delete_on_close(cli1, fnum1, fname, False); + + /* Now try opening again for read-only. */ + fnum2 = 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); + + + /* Should work. */ + if (fnum2 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* Now close both.... */ + smbcli_close(cli1->tree, fnum1); + smbcli_close(cli1->tree, fnum2); + + /* And the file should be deleted ! */ + fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); + if (fnum1 != -1) { + printf("(%s) open of %s succeeded (should fail)\n", + __location__, fname); + correct = False; + goto fail; + } + + printf("seventeenth delete on close test succeeded.\n"); + + /* Test 18. */ + + /* Ensure the file doesn't already exist. */ + smbcli_close(cli1->tree, fnum1); + smbcli_close(cli1->tree, fnum2); + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + + /* Firstly open and create with all access */ + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SEC_RIGHTS_FILE_ALL, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_CREATE, + 0, 0); + if (fnum1 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* And close - just to create the file. */ + smbcli_close(cli1->tree, fnum1); + + /* Next open with all access, but add delete on close. */ + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SEC_RIGHTS_FILE_ALL, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, + NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); + + if (fnum1 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* The delete on close bit is *not* reported as being set. */ + check_delete_on_close(cli1, fnum1, fname, False); + + /* Now try opening again for read-only. */ + fnum2 = 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); + + /* Should work. */ + if (fnum2 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* Now close both.... */ + smbcli_close(cli1->tree, fnum1); + smbcli_close(cli1->tree, fnum2); + + /* See if the file is deleted - shouldn't be.... */ + fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); + if (fnum1 == -1) { + printf("(%s) open of %s failed (should succeed)\n", + __location__, fname); + correct = False; + goto fail; + } + + printf("eighteenth delete on close test succeeded.\n"); + printf("finished delete test\n"); fail: -- cgit From 1b33f040d376fe05a2a0bd79602cc5273d8aca5b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 1 Feb 2006 03:36:04 +0000 Subject: r13271: Do the same tests with directories. Jeremy. (This used to be commit 7986af2ece2e707ee3d98dadb37af9fc5126d138) --- source4/torture/basic/delete.c | 163 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 161 insertions(+), 2 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 50db9a09eb..e76f387f80 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -949,8 +949,6 @@ BOOL torture_test_delete(void) smbcli_close(cli1->tree, dnum1); - /* Now it should be gone... */ - printf("fifteenth delete on close test succeeded.\n"); /* Test 16: delete on close under rename */ @@ -1219,6 +1217,165 @@ BOOL torture_test_delete(void) printf("eighteenth delete on close test succeeded.\n"); + /* Test 19. With directories. */ + + /* Ensure the file doesn't already exist. */ + smbcli_close(cli1->tree, fnum1); + smbcli_close(cli1->tree, fnum2); + + smbcli_deltree(cli1->tree, dirname); + + /* Firstly create with all access, but delete on close. */ + fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + SEC_FILE_READ_DATA| + SEC_FILE_WRITE_DATA| + SEC_STD_DELETE, + FILE_ATTRIBUTE_DIRECTORY, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_CREATE, + NTCREATEX_OPTIONS_DIRECTORY|NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); + + if (fnum1 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, dirname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* The delete on close bit is *not* reported as being set. */ + check_delete_on_close(cli1, fnum1, dirname, False); + + /* Now try opening again for read-only. */ + fnum2 = smbcli_nt_create_full(cli1->tree, dirname, 0, + SEC_RIGHTS_FILE_READ, + FILE_ATTRIBUTE_DIRECTORY, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, + NTCREATEX_OPTIONS_DIRECTORY, 0); + + + /* Should work. */ + if (fnum2 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, dirname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* Now close both.... */ + smbcli_close(cli1->tree, fnum1); + smbcli_close(cli1->tree, fnum2); + + /* And the directory should be deleted ! */ + fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + SEC_RIGHTS_FILE_READ, + FILE_ATTRIBUTE_DIRECTORY, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, + NTCREATEX_OPTIONS_DIRECTORY, 0); + if (fnum1 != -1) { + printf("(%s) open of %s succeeded (should fail)\n", + __location__, dirname); + correct = False; + goto fail; + } + + printf("nineteenth delete on close test succeeded.\n"); + + /* Test 20. */ + + smbcli_deltree(cli1->tree, dirname); + + /* Firstly open and create with all access */ + fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + SEC_FILE_READ_DATA| + SEC_FILE_WRITE_DATA| + SEC_STD_DELETE, + FILE_ATTRIBUTE_DIRECTORY, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_CREATE, + NTCREATEX_OPTIONS_DIRECTORY, 0); + + if (fnum1 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, dirname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* And close - just to create the directory. */ + smbcli_close(cli1->tree, fnum1); + + /* Next open with all access, but add delete on close. */ + fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + SEC_FILE_READ_DATA| + SEC_FILE_WRITE_DATA| + SEC_STD_DELETE, + FILE_ATTRIBUTE_DIRECTORY, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, + NTCREATEX_OPTIONS_DIRECTORY|NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); + + if (fnum1 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* The delete on close bit is *not* reported as being set. */ + check_delete_on_close(cli1, fnum1, dirname, False); + + /* Now try opening again for read-only. */ + fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + SEC_RIGHTS_FILE_READ, + FILE_ATTRIBUTE_DIRECTORY, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, + NTCREATEX_OPTIONS_DIRECTORY, 0); + + /* Should work. */ + if (fnum2 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, dirname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + /* Now close both.... */ + smbcli_close(cli1->tree, fnum1); + smbcli_close(cli1->tree, fnum2); + + /* See if the file is deleted - shouldn't be.... */ + fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + SEC_RIGHTS_FILE_READ, + FILE_ATTRIBUTE_DIRECTORY, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, + NTCREATEX_OPTIONS_DIRECTORY, 0); + if (fnum1 == -1) { + printf("(%s) open of %s failed (should succeed)\n", + __location__, dirname); + correct = False; + goto fail; + } + + printf("twentieth delete on close test succeeded.\n"); + printf("finished delete test\n"); fail: @@ -1231,6 +1388,8 @@ BOOL torture_test_delete(void) smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); + smbcli_deltree(cli1->tree, dirname); + if (!torture_close_connection(cli1)) { correct = False; } -- cgit From 4e612e7d202928adbf5c4b3d90aa44b46bfb180e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 1 Feb 2006 04:09:02 +0000 Subject: r13272: Re-arrange so all the normal tests we can pass come first. Jeremy. (This used to be commit 0b61a8df3c1b5b1a73bf6afd0404871286d3a2fc) --- source4/torture/basic/delete.c | 182 +++++++++++++++++++++-------------------- 1 file changed, 92 insertions(+), 90 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index e76f387f80..00807f0420 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -870,88 +870,7 @@ BOOL torture_test_delete(void) printf("fourteenth delete on close test succeeded.\n"); - /* Test 15 -- non-empty directory */ - - dnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, - SEC_FILE_READ_DATA| - SEC_FILE_WRITE_DATA| - SEC_STD_DELETE, - FILE_ATTRIBUTE_DIRECTORY, - NTCREATEX_SHARE_ACCESS_READ| - NTCREATEX_SHARE_ACCESS_WRITE| - NTCREATEX_SHARE_ACCESS_DELETE, - NTCREATEX_DISP_CREATE, - NTCREATEX_OPTIONS_DIRECTORY, 0); - if (dnum1 == -1) { - printf("(%s) open of %s failed: %s!\n", - __location__, dirname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } - - check_delete_on_close(cli1, dnum1, dirname, False); - status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True); - - { - char *fullname; - asprintf(&fullname, "\\%s%s", dirname, fname); - fnum1 = smbcli_open(cli1->tree, fullname, O_CREAT|O_RDWR, - DENY_NONE); - if (fnum1 != -1) { - printf("(%s) smbcli_open succeeded, should have " - "failed: %s\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } - - if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree), - NT_STATUS_DELETE_PENDING)) { - printf("(%s) smbcli_open returned %s, expected " - "NT_STATUS_DELETE_PENDING\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } - } - - status = smbcli_nt_delete_on_close(cli1->tree, dnum1, False); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) setting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } - - { - char *fullname; - asprintf(&fullname, "\\%s%s", dirname, fname); - fnum1 = smbcli_open(cli1->tree, fullname, O_CREAT|O_RDWR, - DENY_NONE); - if (fnum1 == -1) { - printf("(%s) smbcli_open failed: %s\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } - smbcli_close(cli1->tree, fnum1); - } - - status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True); - - if (!NT_STATUS_EQUAL(status, NT_STATUS_DIRECTORY_NOT_EMPTY)) { - printf("(%s) setting delete_on_close returned %s, expected " - "NT_STATUS_DIRECTORY_NOT_EMPTY\n", __location__, - smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } - - smbcli_close(cli1->tree, dnum1); - - printf("fifteenth delete on close test succeeded.\n"); - - /* Test 16: delete on close under rename */ + /* Test 15: delete on close under rename */ smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); @@ -1073,9 +992,9 @@ BOOL torture_test_delete(void) goto fail; } - printf("sixteenth delete on close test succeeded.\n"); + printf("fifteenth delete on close test succeeded.\n"); - /* Test 17. */ + /* Test 16. */ /* Ensure the file doesn't already exist. */ smbcli_close(cli1->tree, fnum1); @@ -1135,9 +1054,9 @@ BOOL torture_test_delete(void) goto fail; } - printf("seventeenth delete on close test succeeded.\n"); + printf("sixteenth delete on close test succeeded.\n"); - /* Test 18. */ + /* Test 17. */ /* Ensure the file doesn't already exist. */ smbcli_close(cli1->tree, fnum1); @@ -1215,9 +1134,9 @@ BOOL torture_test_delete(void) goto fail; } - printf("eighteenth delete on close test succeeded.\n"); + printf("seventeenth delete on close test succeeded.\n"); - /* Test 19. With directories. */ + /* Test 18. With directories. */ /* Ensure the file doesn't already exist. */ smbcli_close(cli1->tree, fnum1); @@ -1286,9 +1205,9 @@ BOOL torture_test_delete(void) goto fail; } - printf("nineteenth delete on close test succeeded.\n"); + printf("eighteenth delete on close test succeeded.\n"); - /* Test 20. */ + /* Test 19. */ smbcli_deltree(cli1->tree, dirname); @@ -1374,6 +1293,89 @@ BOOL torture_test_delete(void) goto fail; } + printf("nineteenth delete on close test succeeded.\n"); + + /* Test 20 -- non-empty directory hardest to get right... */ + + smbcli_deltree(cli1->tree, dirname); + + dnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + SEC_FILE_READ_DATA| + SEC_FILE_WRITE_DATA| + SEC_STD_DELETE, + FILE_ATTRIBUTE_DIRECTORY, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_CREATE, + NTCREATEX_OPTIONS_DIRECTORY, 0); + if (dnum1 == -1) { + printf("(%s) open of %s failed: %s!\n", + __location__, dirname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + check_delete_on_close(cli1, dnum1, dirname, False); + status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True); + + { + char *fullname; + asprintf(&fullname, "\\%s%s", dirname, fname); + fnum1 = smbcli_open(cli1->tree, fullname, O_CREAT|O_RDWR, + DENY_NONE); + if (fnum1 != -1) { + printf("(%s) smbcli_open succeeded, should have " + "failed: %s\n", + __location__, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree), + NT_STATUS_DELETE_PENDING)) { + printf("(%s) smbcli_open returned %s, expected " + "NT_STATUS_DELETE_PENDING\n", + __location__, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + } + + status = smbcli_nt_delete_on_close(cli1->tree, dnum1, False); + if (!NT_STATUS_IS_OK(status)) { + printf("(%s) setting delete_on_close on file failed !\n", + __location__); + correct = False; + goto fail; + } + + { + char *fullname; + asprintf(&fullname, "\\%s%s", dirname, fname); + fnum1 = smbcli_open(cli1->tree, fullname, O_CREAT|O_RDWR, + DENY_NONE); + if (fnum1 == -1) { + printf("(%s) smbcli_open failed: %s\n", + __location__, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + smbcli_close(cli1->tree, fnum1); + } + + status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True); + + if (!NT_STATUS_EQUAL(status, NT_STATUS_DIRECTORY_NOT_EMPTY)) { + printf("(%s) setting delete_on_close returned %s, expected " + "NT_STATUS_DIRECTORY_NOT_EMPTY\n", __location__, + smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + smbcli_close(cli1->tree, dnum1); + printf("twentieth delete on close test succeeded.\n"); printf("finished delete test\n"); -- cgit From c084da47cf1eafd0d70842ab9ab1195abbd0b11e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 1 Feb 2006 04:41:54 +0000 Subject: r13275: With a liberal sprinkling of smb_raw_exit this now passes for me for W2K and W2K3... booting the XP box to test it... Jeremy. (This used to be commit 0133ba78c15b10e925f4e26e163656aa7cd11476) --- source4/torture/basic/delete.c | 79 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 70 insertions(+), 9 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 00807f0420..0c01561d2e 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -163,6 +163,13 @@ BOOL torture_test_delete(void) return False; } + if (!torture_open_connection(&cli2)) { + printf("(%s) failed to open second connection.\n", + __location__); + correct = False; + goto fail; + } + smbcli_deltree(cli1->tree, dirname); /* Test 1 - this should delete the file on close. */ @@ -198,6 +205,9 @@ BOOL torture_test_delete(void) goto fail; } + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + printf("first delete on close test succeeded.\n"); /* Test 2 - this should delete the file on close. */ @@ -245,6 +255,9 @@ BOOL torture_test_delete(void) } else printf("second delete on close test succeeded.\n"); + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + /* Test 3 - ... */ smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); @@ -330,6 +343,9 @@ BOOL torture_test_delete(void) } else printf("third delete on close test succeeded.\n"); + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + /* Test 4 ... */ smbcli_setatr(cli1->tree, fname, 0, 0); status = smbcli_unlink(cli1->tree, fname); @@ -397,8 +413,6 @@ BOOL torture_test_delete(void) } CHECK_STATUS(cli1, NT_STATUS_DELETE_PENDING); - printf("fourth delete on close test succeeded.\n"); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close - 2 failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); @@ -406,6 +420,11 @@ BOOL torture_test_delete(void) goto fail; } + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + + printf("fourth delete on close test succeeded.\n"); + /* Test 5 ... */ smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); @@ -434,6 +453,9 @@ BOOL torture_test_delete(void) goto fail; } + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + printf("fifth delete on close test succeeded.\n"); /* Test 6 ... */ @@ -471,6 +493,9 @@ BOOL torture_test_delete(void) goto fail; } + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + printf("sixth delete on close test succeeded.\n"); /* Test 7 ... */ @@ -533,19 +558,15 @@ BOOL torture_test_delete(void) goto fail; } + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + printf("seventh delete on close test succeeded.\n"); /* Test 7 ... */ smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); - if (!torture_open_connection(&cli2)) { - printf("(%s) failed to open second connection.\n", - __location__); - correct = False; - goto fail; - } - fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_FILE_READ_DATA| SEC_FILE_WRITE_DATA| @@ -613,6 +634,9 @@ BOOL torture_test_delete(void) } else printf("eighth delete on close test succeeded.\n"); + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + /* This should fail - we need to set DELETE_ACCESS. */ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA, @@ -628,6 +652,9 @@ BOOL torture_test_delete(void) goto fail; } + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + printf("ninth delete on close test succeeded.\n"); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, @@ -663,6 +690,9 @@ BOOL torture_test_delete(void) } else printf("tenth delete on close test succeeded.\n"); + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + /* test 11 - does having read only attribute still allow delete on close. */ smbcli_setatr(cli1->tree, fname, 0, 0); @@ -699,6 +729,10 @@ BOOL torture_test_delete(void) smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); + + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + printf("eleventh delete on close test succeeded.\n"); /* test 12 - does having read only attribute still allow delete on @@ -729,6 +763,9 @@ BOOL torture_test_delete(void) } } + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + printf("twelvth delete on close test succeeded.\n"); /* Test 13: Does resetting the delete on close flag affect a second @@ -820,6 +857,9 @@ BOOL torture_test_delete(void) smbcli_close(cli1->tree, fnum1); smbcli_unlink(cli1->tree, fname); + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + printf("thirteenth delete on close test succeeded.\n"); /* Test 14 -- directory */ @@ -868,6 +908,9 @@ BOOL torture_test_delete(void) goto fail; } + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + printf("fourteenth delete on close test succeeded.\n"); /* Test 15: delete on close under rename */ @@ -992,6 +1035,9 @@ BOOL torture_test_delete(void) goto fail; } + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + printf("fifteenth delete on close test succeeded.\n"); /* Test 16. */ @@ -1054,6 +1100,9 @@ BOOL torture_test_delete(void) goto fail; } + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + printf("sixteenth delete on close test succeeded.\n"); /* Test 17. */ @@ -1134,6 +1183,9 @@ BOOL torture_test_delete(void) goto fail; } + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + printf("seventeenth delete on close test succeeded.\n"); /* Test 18. With directories. */ @@ -1205,6 +1257,9 @@ BOOL torture_test_delete(void) goto fail; } + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + printf("eighteenth delete on close test succeeded.\n"); /* Test 19. */ @@ -1293,6 +1348,9 @@ BOOL torture_test_delete(void) goto fail; } + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + printf("nineteenth delete on close test succeeded.\n"); /* Test 20 -- non-empty directory hardest to get right... */ @@ -1376,6 +1434,9 @@ BOOL torture_test_delete(void) smbcli_close(cli1->tree, dnum1); + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + printf("twentieth delete on close test succeeded.\n"); printf("finished delete test\n"); -- cgit From 52f023d4de6934cd0a4b91c10983aa8729331e22 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 1 Feb 2006 05:22:44 +0000 Subject: r13277: print a useful error message when test 17 fails (This used to be commit 70ad98b05136da0cdbd91b8374ac9709abfcadeb) --- source4/torture/basic/delete.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 0c01561d2e..0980ae1d0d 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -1177,8 +1177,8 @@ BOOL torture_test_delete(void) /* See if the file is deleted - shouldn't be.... */ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); if (fnum1 == -1) { - printf("(%s) open of %s failed (should succeed)\n", - __location__, fname); + printf("(%s) open of %s failed (should succeed) - %s\n", + __location__, fname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } -- cgit From 71a43967deb4c9bad9c1d4aa5b538ebf0fd434be Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 3 Feb 2006 02:07:22 +0000 Subject: r13297: It's a good thing the shipment of function headers tridge sent me arrived on time... :-). Refactor this code to make it comprehensible. Tested against W2K3 SP 1 and W2K SP 4. Test 19 is different from what I thought. Turns out delete on close on "open" of a directory (not create) does have an effect - even if not reported in the flag bit. trige please test against Vista (my XP box is refusing to serve at the moment - have to reinstall). Jeremy. (This used to be commit 2b708e26185bfc0a909a33e74e67dd2101c3bbbe) --- source4/torture/basic/delete.c | 625 ++++++++++++++++++++++++++--------------- 1 file changed, 404 insertions(+), 221 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 0980ae1d0d..ac168b3ed4 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -141,42 +141,30 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, goto fail; \ }} while (0) -/* - Test delete on close semantics. - */ -BOOL torture_test_delete(void) -{ - struct smbcli_state *cli1; - struct smbcli_state *cli2 = NULL; - const char *fname = "\\delete.file"; - const char *fname_new = "\\delete.new"; - const char *dirname = "\\delete.dir"; - int fnum1 = -1; - int fnum2 = -1; - int dnum1 = -1; - BOOL correct = True; - NTSTATUS status; - - printf("starting delete test\n"); - - if (!torture_open_connection(&cli1)) { - return False; - } - - if (!torture_open_connection(&cli2)) { - printf("(%s) failed to open second connection.\n", - __location__); - correct = False; - goto fail; - } +const char *fname = "\\delete.file"; +const char *fname_new = "\\delete.new"; +const char *dirname = "\\delete.dir"; +static void del_clean_area(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ smbcli_deltree(cli1->tree, dirname); - - /* Test 1 - this should delete the file on close. */ - smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); - + smbcli_setatr(cli1->tree, fname_new, 0, 0); + smbcli_unlink(cli1->tree, fname_new); + + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); +} + +/* Test 1 - this should delete the file on close. */ + +static BOOL deltest1(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + + del_clean_area(cli1, cli2); + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_RIGHTS_FILE_ALL, FILE_ATTRIBUTE_NORMAL, @@ -186,35 +174,33 @@ BOOL torture_test_delete(void) if (fnum1 == -1) { printf("(%s) open of %s failed (%s)\n", __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); if (fnum1 != -1) { printf("(%s) open of %s succeeded (should fail)\n", __location__, fname); - correct = False; - goto fail; + return False; } - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); - printf("first delete on close test succeeded.\n"); - - /* Test 2 - this should delete the file on close. */ - - smbcli_setatr(cli1->tree, fname, 0, 0); - smbcli_unlink(cli1->tree, fname); - + return True; +} + +/* Test 2 - this should delete the file on close. */ +static BOOL deltest2(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + + del_clean_area(cli1, cli2); + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_RIGHTS_FILE_ALL, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, @@ -223,22 +209,19 @@ BOOL torture_test_delete(void) if (fnum1 == -1) { printf("(%s) open of %s failed (%s)\n", __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { printf("(%s) setting delete_on_close failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); @@ -248,19 +231,22 @@ BOOL torture_test_delete(void) if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } smbcli_unlink(cli1->tree, fname); - } else + } else { printf("second delete on close test succeeded.\n"); - - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); + } + return True; +} - /* Test 3 - ... */ - smbcli_setatr(cli1->tree, fname, 0, 0); - smbcli_unlink(cli1->tree, fname); +/* Test 3 - ... */ +static BOOL deltest3(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + int fnum2 = -1; + + del_clean_area(cli1, cli2); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_RIGHTS_FILE_ALL, @@ -271,8 +257,7 @@ BOOL torture_test_delete(void) if (fnum1 == -1) { printf("(%s) open - 1 of %s failed (%s)\n", __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } /* This should fail with a sharing violation - open for delete is only compatible @@ -287,8 +272,7 @@ BOOL torture_test_delete(void) if (fnum2 != -1) { printf("(%s) open - 2 of %s succeeded - should have failed.\n", __location__, fname); - correct = False; - goto fail; + return False; } /* This should succeed. */ @@ -302,29 +286,25 @@ BOOL torture_test_delete(void) if (fnum2 == -1) { printf("(%s) open - 2 of %s failed (%s)\n", __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { printf("(%s) setting delete_on_close failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close 1 failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) { printf("(%s) close 2 failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } /* This should fail - file should no longer be there. */ @@ -338,22 +318,21 @@ BOOL torture_test_delete(void) __location__, smbcli_errstr(cli1->tree)); } smbcli_unlink(cli1->tree, fname); - correct = False; - goto fail; - } else + return False; + } else { printf("third delete on close test succeeded.\n"); + } + return True; +} - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); +/* Test 4 ... */ +static BOOL deltest4(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + int fnum2 = -1; + BOOL correct = True; - /* Test 4 ... */ - smbcli_setatr(cli1->tree, fname, 0, 0); - status = smbcli_unlink(cli1->tree, fname); - if (NT_STATUS_IS_OK(status)) { - printf("(%s) succeeded unlink of %s\n", __location__, fname); - correct = False; - goto fail; - } + del_clean_area(cli1, cli2); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_FILE_READ_DATA | @@ -366,8 +345,7 @@ BOOL torture_test_delete(void) if (fnum1 == -1) { printf("(%s) open of %s failed (%s)\n", __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } /* This should succeed. */ @@ -381,22 +359,19 @@ BOOL torture_test_delete(void) if (fnum2 == -1) { printf("(%s) open - 2 of %s failed (%s)\n", __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) { printf("(%s) close - 1 failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { printf("(%s) setting delete_on_close failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } /* This should fail - no more opens once delete on close set. */ @@ -408,33 +383,35 @@ BOOL torture_test_delete(void) if (fnum2 != -1) { printf("(%s) open - 3 of %s succeeded ! Should have failed.\n", __location__, fname ); - correct = False; - goto fail; + return False; } CHECK_STATUS(cli1, NT_STATUS_DELETE_PENDING); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close - 2 failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); - printf("fourth delete on close test succeeded.\n"); - - /* Test 5 ... */ - smbcli_setatr(cli1->tree, fname, 0, 0); - smbcli_unlink(cli1->tree, fname); - + + fail: + + return correct; +} + +/* Test 5 ... */ +static BOOL deltest5(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + + del_clean_area(cli1, cli2); + fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum1 == -1) { printf("(%s) open of %s failed (%s)\n", __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } /* This should fail - only allowed on NT opens with DELETE access. */ @@ -442,26 +419,26 @@ BOOL torture_test_delete(void) if (NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { printf("(%s) setting delete_on_close on OpenX file succeeded - should fail !\n", __location__); - correct = False; - goto fail; + return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close - 2 failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } - - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); printf("fifth delete on close test succeeded.\n"); - - /* Test 6 ... */ - smbcli_setatr(cli1->tree, fname, 0, 0); - smbcli_unlink(cli1->tree, fname); - + return True; +} + +/* Test 6 ... */ +static BOOL deltest6(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + + del_clean_area(cli1, cli2); + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_FILE_READ_DATA | SEC_FILE_WRITE_DATA, FILE_ATTRIBUTE_NORMAL, @@ -473,8 +450,7 @@ BOOL torture_test_delete(void) if (fnum1 == -1) { printf("(%s) open of %s failed (%s)\n", __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } /* This should fail - only allowed on NT opens with DELETE access. */ @@ -482,26 +458,27 @@ BOOL torture_test_delete(void) if (NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { printf("(%s) setting delete_on_close on file with no delete access succeeded - should fail !\n", __location__); - correct = False; - goto fail; + return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close - 2 failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); - printf("sixth delete on close test succeeded.\n"); - - /* Test 7 ... */ - smbcli_setatr(cli1->tree, fname, 0, 0); - smbcli_unlink(cli1->tree, fname); - + return True; +} + +/* Test 7 ... */ +static BOOL deltest7(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + BOOL correct = True; + + del_clean_area(cli1, cli2); + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_FILE_READ_DATA | SEC_FILE_WRITE_DATA | @@ -558,15 +535,22 @@ BOOL torture_test_delete(void) goto fail; } - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); - printf("seventh delete on close test succeeded.\n"); - - /* Test 7 ... */ - smbcli_setatr(cli1->tree, fname, 0, 0); - smbcli_unlink(cli1->tree, fname); - + + fail: + + return correct; +} + +/* Test 8 ... */ +static BOOL deltest8(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + int fnum2 = -1; + BOOL correct = True; + + del_clean_area(cli1, cli2); + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_FILE_READ_DATA| SEC_FILE_WRITE_DATA| @@ -629,13 +613,22 @@ BOOL torture_test_delete(void) if (fnum1 != -1) { printf("(%s) open of %s succeeded should have been deleted on close !\n", __location__, fname); - goto fail; correct = False; - } else + } else { printf("eighth delete on close test succeeded.\n"); + } - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); + fail: + + return correct; +} + +/* Test 9 ... */ +static BOOL deltest9(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + + del_clean_area(cli1, cli2); /* This should fail - we need to set DELETE_ACCESS. */ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, @@ -648,14 +641,20 @@ BOOL torture_test_delete(void) if (fnum1 != -1) { printf("(%s) open of %s succeeded should have failed!\n", __location__, fname); - correct = False; - goto fail; + return False; } - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); - printf("ninth delete on close test succeeded.\n"); + return True; +} + +/* Test 10 ... */ +static BOOL deltest10(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + BOOL correct = True; + + del_clean_area(cli1, cli2); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_FILE_READ_DATA| @@ -685,18 +684,26 @@ BOOL torture_test_delete(void) if (fnum1 != -1) { printf("(%s) open of %s succeeded should have been deleted on close !\n", __location__, fname); - goto fail; correct = False; - } else + goto fail; + } else { printf("tenth delete on close test succeeded.\n"); + } - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); + fail: - /* test 11 - does having read only attribute still allow delete on close. */ + return correct; +} - smbcli_setatr(cli1->tree, fname, 0, 0); - smbcli_unlink(cli1->tree, fname); +/* Test 11 ... */ +static BOOL deltest11(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + NTSTATUS status; + + del_clean_area(cli1, cli2); + + /* test 11 - does having read only attribute still allow delete on close. */ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_RIGHTS_FILE_ALL, @@ -707,8 +714,7 @@ BOOL torture_test_delete(void) if (fnum1 == -1) { printf("(%s) open of %s failed (%s)\n", __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } status = smbcli_nt_delete_on_close(cli1->tree, fnum1, True); @@ -716,24 +722,26 @@ BOOL torture_test_delete(void) if (!NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) { printf("(%s) setting delete_on_close should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)\n", __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } - smbcli_setatr(cli1->tree, fname, 0, 0); - smbcli_unlink(cli1->tree, fname); + printf("eleventh delete on close test succeeded.\n"); + return True; +} - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); +/* Test 12 ... */ +static BOOL deltest12(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + NTSTATUS status; - printf("eleventh delete on close test succeeded.\n"); + del_clean_area(cli1, cli2); /* test 12 - does having read only attribute still allow delete on * close at time of open. */ @@ -749,8 +757,7 @@ BOOL torture_test_delete(void) printf("(%s) open of %s succeeded. Should fail with " "NT_STATUS_CANNOT_DELETE.\n", __location__, fname); smbcli_close(cli1->tree, fnum1); - correct = False; - goto fail; + return False; } else { status = smbcli_nt_error(cli1->tree); if (!NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) { @@ -758,22 +765,26 @@ BOOL torture_test_delete(void) "fail with NT_STATUS_CANNOT_DELETE. Got %s " "instead)\n", __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; + return False; } } - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); - printf("twelvth delete on close test succeeded.\n"); + return True; +} + +/* Test 13 ... */ +static BOOL deltest13(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + int fnum2 = -1; + BOOL correct = True; + + del_clean_area(cli1, cli2); /* Test 13: Does resetting the delete on close flag affect a second * fd? */ - smbcli_setatr(cli1->tree, fname, 0, 0); - smbcli_unlink(cli1->tree, fname); - fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_FILE_READ_DATA| SEC_FILE_WRITE_DATA| @@ -854,13 +865,20 @@ BOOL torture_test_delete(void) goto fail; } - smbcli_close(cli1->tree, fnum1); - smbcli_unlink(cli1->tree, fname); + printf("thirteenth delete on close test succeeded.\n"); - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); + fail: - printf("thirteenth delete on close test succeeded.\n"); + return correct; +} + +/* Test 14 ... */ +static BOOL deltest14(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int dnum1 = -1; + BOOL correct = True; + + del_clean_area(cli1, cli2); /* Test 14 -- directory */ @@ -908,11 +926,23 @@ BOOL torture_test_delete(void) goto fail; } - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); - printf("fourteenth delete on close test succeeded.\n"); + fail: + + return correct; +} + +/* Test 15 ... */ +static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + int fnum2 = -1; + BOOL correct = True; + NTSTATUS status; + + del_clean_area(cli1, cli2); + /* Test 15: delete on close under rename */ smbcli_setatr(cli1->tree, fname, 0, 0); @@ -1035,11 +1065,22 @@ BOOL torture_test_delete(void) goto fail; } - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); - printf("fifteenth delete on close test succeeded.\n"); + fail: + + return correct; +} + +/* Test 16 ... */ +static BOOL deltest16(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + int fnum2 = -1; + BOOL correct = True; + + del_clean_area(cli1, cli2); + /* Test 16. */ /* Ensure the file doesn't already exist. */ @@ -1100,11 +1141,22 @@ BOOL torture_test_delete(void) goto fail; } - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); - printf("sixteenth delete on close test succeeded.\n"); + fail: + + return correct; +} + +/* Test 17 ... */ +static BOOL deltest17(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + int fnum2 = -1; + BOOL correct = True; + + del_clean_area(cli1, cli2); + /* Test 17. */ /* Ensure the file doesn't already exist. */ @@ -1183,11 +1235,22 @@ BOOL torture_test_delete(void) goto fail; } - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); - printf("seventeenth delete on close test succeeded.\n"); + fail: + + return correct; +} + +/* Test 18 ... */ +static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + int fnum2 = -1; + BOOL correct = True; + + del_clean_area(cli1, cli2); + /* Test 18. With directories. */ /* Ensure the file doesn't already exist. */ @@ -1257,11 +1320,22 @@ BOOL torture_test_delete(void) goto fail; } - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); - printf("eighteenth delete on close test succeeded.\n"); + fail: + + return correct; +} + +/* Test 19 ... */ +static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + int fnum2 = -1; + BOOL correct = True; + + del_clean_area(cli1, cli2); + /* Test 19. */ smbcli_deltree(cli1->tree, dirname); @@ -1311,7 +1385,7 @@ BOOL torture_test_delete(void) check_delete_on_close(cli1, fnum1, dirname, False); /* Now try opening again for read-only. */ - fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + fnum2 = smbcli_nt_create_full(cli1->tree, dirname, 0, SEC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_DIRECTORY, NTCREATEX_SHARE_ACCESS_READ| @@ -1332,7 +1406,7 @@ BOOL torture_test_delete(void) smbcli_close(cli1->tree, fnum1); smbcli_close(cli1->tree, fnum2); - /* See if the file is deleted - shouldn't be.... */ + /* See if the file is deleted - for a directory this seems to be true ! */ fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, SEC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_DIRECTORY, @@ -1341,18 +1415,33 @@ BOOL torture_test_delete(void) NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, NTCREATEX_OPTIONS_DIRECTORY, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (should succeed)\n", + + CHECK_STATUS(cli1, NT_STATUS_OBJECT_NAME_NOT_FOUND); + + if (fnum1 != -1) { + printf("(%s) open of %s succeeded (should fail)\n", __location__, dirname); correct = False; goto fail; } - - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); printf("nineteenth delete on close test succeeded.\n"); + fail: + + return correct; +} + +/* Test 20 ... */ +static BOOL deltest20(struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + int dnum1 = -1; + BOOL correct = True; + NTSTATUS status; + + del_clean_area(cli1, cli2); + /* Test 20 -- non-empty directory hardest to get right... */ smbcli_deltree(cli1->tree, dirname); @@ -1434,24 +1523,119 @@ BOOL torture_test_delete(void) smbcli_close(cli1->tree, dnum1); - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); - printf("twentieth delete on close test succeeded.\n"); + fail: + + return correct; +} + +/* + Test delete on close semantics. + */ +BOOL torture_test_delete(void) +{ + struct smbcli_state *cli1 = NULL; + struct smbcli_state *cli2 = NULL; + BOOL correct = True; + + printf("starting delete test\n"); + + if (!torture_open_connection(&cli1)) { + return False; + } + + if (!torture_open_connection(&cli2)) { + printf("(%s) failed to open second connection.\n", + __location__); + correct = False; + goto fail; + } + + if (!deltest1(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest2(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest3(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest4(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest5(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest6(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest7(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest8(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest9(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest10(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest11(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest12(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest13(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest14(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest15(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest16(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest17(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest18(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest19(cli1, cli2)) { + correct = False; + goto fail; + } + if (!deltest20(cli1, cli2)) { + correct = False; + goto fail; + } printf("finished delete test\n"); fail: - /* FIXME: This will crash if we aborted before cli2 got - * intialized, because these functions don't handle - * uninitialized connections. */ - - smbcli_close(cli1->tree, fnum1); - smbcli_close(cli1->tree, fnum2); - smbcli_setatr(cli1->tree, fname, 0, 0); - smbcli_unlink(cli1->tree, fname); - - smbcli_deltree(cli1->tree, dirname); + del_clean_area(cli1, cli2); if (!torture_close_connection(cli1)) { correct = False; @@ -1461,4 +1645,3 @@ BOOL torture_test_delete(void) } return correct; } - -- cgit From 1a53c1dc927efbc6a594ed513feb9ab9247078e8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 4 Feb 2006 14:08:24 +0000 Subject: r13346: use private proto header files for the torture tests metze (This used to be commit 67837dbd2bcff8ec1917ba02884ee2eaa0776b46) --- source4/torture/basic/delete.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index ac168b3ed4..983f67ad1a 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -26,6 +26,8 @@ #include "system/filesys.h" #include "libcli/raw/libcliraw.h" +#include "torture/raw/proto.h" + static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, const char *fname, BOOL expect_it) { -- cgit From 2b163e64f58d3e5f27b0ff11f70c77a6c764658b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 6 Feb 2006 19:43:24 +0000 Subject: r13370: Added deltest21 - pull the rug out from a connection by socket close after setting delete on close flag. Jeremy. (This used to be commit fbea18e78f8a3c6dbb36aa935b7044c0fcf61da4) --- source4/torture/basic/delete.c | 171 ++++++++++++++++++++++------------------- 1 file changed, 90 insertions(+), 81 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 983f67ad1a..226e5a5aa4 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -1208,7 +1208,8 @@ static BOOL deltest17(struct smbcli_state *cli1, struct smbcli_state *cli2) /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, - SEC_RIGHTS_FILE_READ, + SEC_RIGHTS_FILE_READ| + SEC_STD_DELETE, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ| NTCREATEX_SHARE_ACCESS_WRITE| @@ -1532,6 +1533,68 @@ static BOOL deltest20(struct smbcli_state *cli1, struct smbcli_state *cli2) return correct; } +/* Test 21 ... */ +static BOOL deltest21(struct smbcli_state **ppcli1, struct smbcli_state **ppcli2) +{ + int fnum1 = -1; + struct smbcli_state *cli1 = *ppcli1; + struct smbcli_state *cli2 = *ppcli2; + BOOL correct = True; + + del_clean_area(cli1, cli2); + + /* Test 21 -- Test removal of file after socket close. */ + + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SEC_RIGHTS_FILE_ALL, + FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, + NTCREATEX_DISP_OVERWRITE_IF, 0, 0); + + if (fnum1 == -1) { + printf("(%s) open of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); + return False; + } + + if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { + printf("(%s) setting delete_on_close failed (%s)\n", + __location__, smbcli_errstr(cli1->tree)); + return False; + } + + /* Ensure delete on close is set. */ + check_delete_on_close(cli1, fnum1, fname, True); + + /* Now yank the rug from under cli1. */ + smbcli_transport_dead(cli1->transport); + + fnum1 = -1; + + if (!torture_open_connection(ppcli1)) { + return False; + } + + cli1 = *ppcli1; + + /* 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); + + printf("twenty-first delete on close test succeeded.\n"); + + fail: + + return correct; +} + /* Test delete on close semantics. */ @@ -1554,87 +1617,33 @@ BOOL torture_test_delete(void) goto fail; } - if (!deltest1(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest2(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest3(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest4(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest5(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest6(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest7(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest8(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest9(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest10(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest11(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest12(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest13(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest14(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest15(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest16(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest17(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest18(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest19(cli1, cli2)) { - correct = False; - goto fail; - } - if (!deltest20(cli1, cli2)) { - correct = False; - goto fail; + correct &= deltest1(cli1, cli2); + correct &= deltest2(cli1, cli2); + correct &= deltest3(cli1, cli2); + correct &= deltest4(cli1, cli2); + correct &= deltest5(cli1, cli2); + correct &= deltest6(cli1, cli2); + correct &= deltest7(cli1, cli2); + correct &= deltest8(cli1, cli2); + correct &= deltest9(cli1, cli2); + correct &= deltest10(cli1, cli2); + correct &= deltest11(cli1, cli2); + correct &= deltest12(cli1, cli2); + correct &= deltest13(cli1, cli2); + correct &= deltest14(cli1, cli2); + correct &= deltest15(cli1, cli2); + correct &= deltest16(cli1, cli2); + correct &= deltest17(cli1, cli2); + correct &= deltest18(cli1, cli2); + correct &= deltest19(cli1, cli2); + correct &= deltest20(cli1, cli2); + correct &= deltest21(&cli1, &cli2); + + if (!correct) { + printf("Failed delete test\n"); + } else { + printf("delete test ok !\n"); } - printf("finished delete test\n"); fail: del_clean_area(cli1, cli2); -- cgit From 57ba33c0a403833267d084aa19067c3883f65115 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Feb 2006 03:23:28 +0000 Subject: r13707: expanded the delete on close test some more, and make it easier to track down where a error is happening. The semantics sure are strange! (This used to be commit f722aed66d19edc6b49ecde927853aaa7895ab91) --- source4/torture/basic/delete.c | 117 ++++++++++++++++++++++++----------------- 1 file changed, 70 insertions(+), 47 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 226e5a5aa4..606e85a304 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -29,7 +29,8 @@ #include "torture/raw/proto.h" static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, - const char *fname, BOOL expect_it) + const char *fname, BOOL expect_it, + const char *where) { TALLOC_CTX *mem_ctx = talloc_init("single_search"); union smb_search_data data; @@ -47,7 +48,7 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, &data); if (!NT_STATUS_IS_OK(status)) { printf("(%s) single_search failed (%s)\n", - __location__, nt_errstr(status)); + where, nt_errstr(status)); res = False; goto done; } @@ -61,22 +62,22 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, status = smb_raw_fileinfo(cli->tree, mem_ctx, &io); if (!NT_STATUS_IS_OK(status)) { - printf("(%s) qpathinfo failed (%s)\n", __location__, + printf("(%s) qfileinfo failed (%s)\n", where, nt_errstr(status)); res = False; goto done; } if (expect_it != io.all_info.out.delete_pending) { - printf("Expected del_on_close flag %d, qfileinfo gave %d\n", - expect_it, io.all_info.out.delete_pending); + printf("%s - Expected del_on_close flag %d, qfileinfo/all_info gave %d\n", + where, expect_it, io.all_info.out.delete_pending); res = False; goto done; } if (nlink != io.all_info.out.nlink) { - printf("Expected nlink %d, qfileinfo gave %d\n", - nlink, io.all_info.out.nlink); + printf("%s - Expected nlink %d, qfileinfo/all_info gave %d\n", + where, nlink, io.all_info.out.nlink); res = False; goto done; } @@ -86,22 +87,22 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, status = smb_raw_fileinfo(cli->tree, mem_ctx, &io); if (!NT_STATUS_IS_OK(status)) { - printf("(%s) qpathinfo failed (%s)\n", __location__, + printf("(%s) qpathinfo failed (%s)\n", where, nt_errstr(status)); res = False; goto done; } if (expect_it != io.standard_info.out.delete_pending) { - printf("Expected del_on_close flag %d, qfileinfo gave %d\n", - expect_it, io.standard_info.out.delete_pending); + printf("%s - Expected del_on_close flag %d, qfileinfo/standard_info gave %d\n", + where, expect_it, io.standard_info.out.delete_pending); res = False; goto done; } if (nlink != io.standard_info.out.nlink) { - printf("Expected nlink %d, qfileinfo gave %d\n", - nlink, io.all_info.out.nlink); + printf("%s - Expected nlink %d, qfileinfo/standard_info gave %d\n", + where, nlink, io.all_info.out.nlink); res = False; goto done; } @@ -116,14 +117,14 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, if (!NT_STATUS_EQUAL(status, NT_STATUS_DELETE_PENDING)) { printf("(%s) qpathinfo did not give correct error " "code (%s) -- NT_STATUS_DELETE_PENDING " - "expected\n", __location__, + "expected\n", where, nt_errstr(status)); res = False; goto done; } } else { if (!NT_STATUS_IS_OK(status)) { - printf("(%s) qpathinfo failed (%s)\n", __location__, + printf("(%s) qpathinfo failed (%s)\n", where, nt_errstr(status)); res = False; goto done; @@ -191,7 +192,7 @@ static BOOL deltest1(struct smbcli_state *cli1, struct smbcli_state *cli2) __location__, fname); return False; } - + printf("first delete on close test succeeded.\n"); return True; } @@ -502,7 +503,7 @@ static BOOL deltest7(struct smbcli_state *cli1, struct smbcli_state *cli2) goto fail; } - correct &= check_delete_on_close(cli1, fnum1, fname, True); + correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__); if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, False))) { printf("(%s) unsetting delete_on_close on file failed !\n", @@ -511,7 +512,7 @@ static BOOL deltest7(struct smbcli_state *cli1, struct smbcli_state *cli2) goto fail; } - correct &= check_delete_on_close(cli1, fnum1, fname, False); + correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close - 2 failed (%s)\n", @@ -590,8 +591,8 @@ static BOOL deltest8(struct smbcli_state *cli1, struct smbcli_state *cli2) goto fail; } - correct &= check_delete_on_close(cli1, fnum1, fname, True); - correct &= check_delete_on_close(cli2, fnum2, fname, True); + correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__); + correct &= check_delete_on_close(cli2, fnum2, fname, True, __location__); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close - 1 failed (%s)\n", @@ -600,8 +601,8 @@ static BOOL deltest8(struct smbcli_state *cli1, struct smbcli_state *cli2) goto fail; } - correct &= check_delete_on_close(cli1, -1, fname, True); - correct &= check_delete_on_close(cli2, fnum2, fname, True); + correct &= check_delete_on_close(cli1, -1, fname, True, __location__); + correct &= check_delete_on_close(cli2, fnum2, fname, True, __location__); if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { printf("(%s) close - 2 failed (%s)\n", @@ -830,8 +831,8 @@ static BOOL deltest13(struct smbcli_state *cli1, struct smbcli_state *cli2) goto fail; } - correct &= check_delete_on_close(cli1, fnum1, fname, True); - correct &= check_delete_on_close(cli2, fnum2, fname, True); + correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__); + correct &= check_delete_on_close(cli2, fnum2, fname, True, __location__); if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli2->tree, fnum2, False))) { @@ -841,8 +842,8 @@ static BOOL deltest13(struct smbcli_state *cli1, struct smbcli_state *cli2) goto fail; } - correct &= check_delete_on_close(cli1, fnum1, fname, False); - correct &= check_delete_on_close(cli2, fnum2, fname, False); + correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(cli2, fnum2, fname, False, __location__); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close - 1 failed (%s)\n", @@ -900,14 +901,14 @@ static BOOL deltest14(struct smbcli_state *cli1, struct smbcli_state *cli2) goto fail; } - check_delete_on_close(cli1, dnum1, dirname, False); + correct &= check_delete_on_close(cli1, dnum1, dirname, False, __location__); if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, dnum1, True))) { printf("(%s) setting delete_on_close on file failed !\n", __location__); correct = False; goto fail; } - check_delete_on_close(cli1, dnum1, dirname, True); + correct &= check_delete_on_close(cli1, dnum1, dirname, True, __location__); smbcli_close(cli1->tree, dnum1); /* Now it should be gone... */ @@ -1006,12 +1007,7 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2) /* The file should be around under the new name, there's a second * handle open */ - if (!check_delete_on_close(cli1, fnum1, fname_new, True)) { - printf("(%s) checking delete on close on file %s failed!\n", - __location__, fname_new); - correct = False; - goto fail; - } + correct &= check_delete_on_close(cli1, fnum1, fname_new, True, __location__); fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_GENERIC_ALL, @@ -1029,6 +1025,8 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2) goto fail; } + correct &= check_delete_on_close(cli2, fnum2, fname, False, __location__); + smbcli_close(cli2->tree, fnum2); smbcli_close(cli1->tree, fnum1); @@ -1109,10 +1107,14 @@ static BOOL deltest16(struct smbcli_state *cli1, struct smbcli_state *cli2) } /* The delete on close bit is *not* reported as being set. */ - check_delete_on_close(cli1, fnum1, fname, False); + correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); + + /* The delete on close bit is *not* reported as being set. */ + correct &= check_delete_on_close(cli1, -1, fname, False, __location__); + correct &= check_delete_on_close(cli2, -1, fname, False, __location__); /* Now try opening again for read-only. */ - fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, + fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ| @@ -1130,9 +1132,17 @@ static BOOL deltest16(struct smbcli_state *cli1, struct smbcli_state *cli2) goto fail; } - /* Now close both.... */ + correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(cli1, -1, fname, False, __location__); + correct &= check_delete_on_close(cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(cli2, -1, fname, False, __location__); + smbcli_close(cli1->tree, fnum1); - smbcli_close(cli1->tree, fnum2); + + correct &= check_delete_on_close(cli2, fnum2, fname, True, __location__); + correct &= check_delete_on_close(cli2, -1, fname, True, __location__); + + smbcli_close(cli2->tree, fnum2); /* And the file should be deleted ! */ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); @@ -1204,7 +1214,7 @@ static BOOL deltest17(struct smbcli_state *cli1, struct smbcli_state *cli2) } /* The delete on close bit is *not* reported as being set. */ - check_delete_on_close(cli1, fnum1, fname, False); + correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, @@ -1225,8 +1235,14 @@ static BOOL deltest17(struct smbcli_state *cli1, struct smbcli_state *cli2) goto fail; } - /* Now close both.... */ + /* still not reported as being set on either */ + correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(cli1, fnum2, fname, False, __location__); + smbcli_close(cli1->tree, fnum1); + + correct &= check_delete_on_close(cli1, fnum2, fname, False, __location__); + smbcli_close(cli1->tree, fnum2); /* See if the file is deleted - shouldn't be.... */ @@ -1282,7 +1298,7 @@ static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2) } /* The delete on close bit is *not* reported as being set. */ - check_delete_on_close(cli1, fnum1, dirname, False); + correct &= check_delete_on_close(cli1, fnum1, dirname, False, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli1->tree, dirname, 0, @@ -1303,8 +1319,13 @@ static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2) goto fail; } - /* Now close both.... */ + correct &= check_delete_on_close(cli1, fnum1, dirname, False, __location__); + correct &= check_delete_on_close(cli1, fnum2, dirname, False, __location__); + smbcli_close(cli1->tree, fnum1); + + correct &= check_delete_on_close(cli1, fnum2, dirname, True, __location__); + smbcli_close(cli1->tree, fnum2); /* And the directory should be deleted ! */ @@ -1385,7 +1406,7 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) } /* The delete on close bit is *not* reported as being set. */ - check_delete_on_close(cli1, fnum1, dirname, False); + correct &= check_delete_on_close(cli1, fnum1, dirname, False, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli1->tree, dirname, 0, @@ -1405,8 +1426,10 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) goto fail; } - /* Now close both.... */ smbcli_close(cli1->tree, fnum1); + + correct &= check_delete_on_close(cli1, fnum2, dirname, True, __location__); + smbcli_close(cli1->tree, fnum2); /* See if the file is deleted - for a directory this seems to be true ! */ @@ -1466,7 +1489,7 @@ static BOOL deltest20(struct smbcli_state *cli1, struct smbcli_state *cli2) goto fail; } - check_delete_on_close(cli1, dnum1, dirname, False); + correct &= check_delete_on_close(cli1, dnum1, dirname, False, __location__); status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True); { @@ -1476,8 +1499,8 @@ static BOOL deltest20(struct smbcli_state *cli1, struct smbcli_state *cli2) DENY_NONE); if (fnum1 != -1) { printf("(%s) smbcli_open succeeded, should have " - "failed: %s\n", - __location__, smbcli_errstr(cli1->tree)); + "failed with NT_STATUS_DELETE_PENDING\n", + __location__); correct = False; goto fail; } @@ -1563,7 +1586,7 @@ static BOOL deltest21(struct smbcli_state **ppcli1, struct smbcli_state **ppcli2 } /* Ensure delete on close is set. */ - check_delete_on_close(cli1, fnum1, fname, True); + correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__); /* Now yank the rug from under cli1. */ smbcli_transport_dead(cli1->transport); -- cgit From 307e43bb5628e8b53a930c2928279af994281ba5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 10 Mar 2006 20:49:20 +0000 Subject: r14173: change smb interface structures to always use a union smb_file, to abtract - const char *path fot qpathinfo and setpathinfo - uint16_t fnum for SMB - smb2_handle handle for SMB2 the idea is to later add a struct ntvfs_handle *ntvfs so that the ntvfs subsystem don't need to know the difference between SMB and SMB2 metze (This used to be commit 2ef3f5970901b5accdb50f0d0115b5d46b0c788f) --- source4/torture/basic/delete.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 606e85a304..6aae6d073b 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -58,7 +58,7 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, int nlink = expect_it ? 0 : 1; io.all_info.level = RAW_FILEINFO_ALL_INFO; - io.all_info.in.fnum = fnum; + io.all_info.file.fnum = fnum; status = smb_raw_fileinfo(cli->tree, mem_ctx, &io); if (!NT_STATUS_IS_OK(status)) { @@ -83,7 +83,7 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, } io.standard_info.level = RAW_FILEINFO_STANDARD_INFO; - io.standard_info.in.fnum = fnum; + io.standard_info.file.fnum = fnum; status = smb_raw_fileinfo(cli->tree, mem_ctx, &io); if (!NT_STATUS_IS_OK(status)) { -- cgit From a1b295ed4823ce8d06f830b8db9a5d965c934b54 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 12 Mar 2006 22:48:25 +0000 Subject: r14256: - rename smb_file -> smb_handle - move it into the in/out substructs again - allow file.path only on smb_fileinfo/smb_setfileinfo metze (This used to be commit be6d5298a2cdb7e7c61d70471bad445645af5963) --- source4/torture/basic/delete.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 6aae6d073b..98bd00010f 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -58,7 +58,7 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, int nlink = expect_it ? 0 : 1; io.all_info.level = RAW_FILEINFO_ALL_INFO; - io.all_info.file.fnum = fnum; + io.all_info.in.file.fnum = fnum; status = smb_raw_fileinfo(cli->tree, mem_ctx, &io); if (!NT_STATUS_IS_OK(status)) { @@ -83,7 +83,7 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, } io.standard_info.level = RAW_FILEINFO_STANDARD_INFO; - io.standard_info.file.fnum = fnum; + io.standard_info.in.file.fnum = fnum; status = smb_raw_fileinfo(cli->tree, mem_ctx, &io); if (!NT_STATUS_IS_OK(status)) { -- cgit From d09b70c98b8222eb293bc9d8713ec071188ed01d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 17 Mar 2006 17:59:58 +0000 Subject: r14527: Fix build problems. (This used to be commit 863ca4014d9b821706ee90f58ab5d5cf3899a4c7) --- source4/torture/basic/delete.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 98bd00010f..97ae518ea8 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -23,6 +23,7 @@ #include "includes.h" #include "libcli/libcli.h" #include "torture/torture.h" +#include "torture/util.h" #include "system/filesys.h" #include "libcli/raw/libcliraw.h" -- cgit From 909b111f587705a45f63540b39968f1af58a9b5d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 25 Mar 2006 16:01:28 +0000 Subject: r14720: Add torture_context argument to all torture tests (This used to be commit 3c7a5ce29108dd82210dc3e1f00414f545949e1d) --- source4/torture/basic/delete.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 97ae518ea8..6e1c34612f 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -1622,7 +1622,7 @@ static BOOL deltest21(struct smbcli_state **ppcli1, struct smbcli_state **ppcli2 /* Test delete on close semantics. */ -BOOL torture_test_delete(void) +BOOL torture_test_delete(struct torture_context *torture) { struct smbcli_state *cli1 = NULL; struct smbcli_state *cli2 = NULL; -- cgit From 3d448a1851bf2502e020cb101138ba229ae4b83a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 24 May 2006 14:45:07 +0000 Subject: r15865: using dirname for a variable isn't that good, but making it a global symbol is really bad... fix linking on sun1 in the build-farm metze (This used to be commit d073320f642ceeb49b11060aa958608248f3aff5) --- source4/torture/basic/delete.c | 72 +++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 6e1c34612f..faefd48b74 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -145,13 +145,13 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, goto fail; \ }} while (0) -const char *fname = "\\delete.file"; -const char *fname_new = "\\delete.new"; -const char *dirname = "\\delete.dir"; +static const char *fname = "\\delete.file"; +static const char *fname_new = "\\delete.new"; +static const char *dname = "\\delete.dir"; static void del_clean_area(struct smbcli_state *cli1, struct smbcli_state *cli2) { - smbcli_deltree(cli1->tree, dirname); + smbcli_deltree(cli1->tree, dname); smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); smbcli_setatr(cli1->tree, fname_new, 0, 0); @@ -886,7 +886,7 @@ static BOOL deltest14(struct smbcli_state *cli1, struct smbcli_state *cli2) /* Test 14 -- directory */ - dnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + dnum1 = smbcli_nt_create_full(cli1->tree, dname, 0, SEC_FILE_READ_DATA| SEC_FILE_WRITE_DATA| SEC_STD_DELETE, @@ -897,24 +897,24 @@ static BOOL deltest14(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_CREATE, 0, 0); if (dnum1 == -1) { printf("(%s) open of %s failed: %s!\n", - __location__, dirname, smbcli_errstr(cli1->tree)); + __location__, dname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } - correct &= check_delete_on_close(cli1, dnum1, dirname, False, __location__); + correct &= check_delete_on_close(cli1, dnum1, dname, False, __location__); if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, dnum1, True))) { printf("(%s) setting delete_on_close on file failed !\n", __location__); correct = False; goto fail; } - correct &= check_delete_on_close(cli1, dnum1, dirname, True, __location__); + correct &= check_delete_on_close(cli1, dnum1, dname, True, __location__); smbcli_close(cli1->tree, dnum1); /* Now it should be gone... */ - dnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + dnum1 = smbcli_nt_create_full(cli1->tree, dname, 0, SEC_FILE_READ_DATA| SEC_FILE_WRITE_DATA| SEC_STD_DELETE, @@ -1277,10 +1277,10 @@ static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2) smbcli_close(cli1->tree, fnum1); smbcli_close(cli1->tree, fnum2); - smbcli_deltree(cli1->tree, dirname); + smbcli_deltree(cli1->tree, dname); /* Firstly create with all access, but delete on close. */ - fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + fnum1 = smbcli_nt_create_full(cli1->tree, dname, 0, SEC_FILE_READ_DATA| SEC_FILE_WRITE_DATA| SEC_STD_DELETE, @@ -1293,16 +1293,16 @@ static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2) if (fnum1 == -1) { printf("(%s) open - 1 of %s failed (%s)\n", - __location__, dirname, smbcli_errstr(cli1->tree)); + __location__, dname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(cli1, fnum1, dirname, False, __location__); + correct &= check_delete_on_close(cli1, fnum1, dname, False, __location__); /* Now try opening again for read-only. */ - fnum2 = smbcli_nt_create_full(cli1->tree, dirname, 0, + fnum2 = smbcli_nt_create_full(cli1->tree, dname, 0, SEC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_DIRECTORY, NTCREATEX_SHARE_ACCESS_READ| @@ -1315,22 +1315,22 @@ static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2) /* Should work. */ if (fnum2 == -1) { printf("(%s) open - 1 of %s failed (%s)\n", - __location__, dirname, smbcli_errstr(cli1->tree)); + __location__, dname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } - correct &= check_delete_on_close(cli1, fnum1, dirname, False, __location__); - correct &= check_delete_on_close(cli1, fnum2, dirname, False, __location__); + correct &= check_delete_on_close(cli1, fnum1, dname, False, __location__); + correct &= check_delete_on_close(cli1, fnum2, dname, False, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(cli1, fnum2, dirname, True, __location__); + correct &= check_delete_on_close(cli1, fnum2, dname, True, __location__); smbcli_close(cli1->tree, fnum2); /* And the directory should be deleted ! */ - fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + fnum1 = smbcli_nt_create_full(cli1->tree, dname, 0, SEC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_DIRECTORY, NTCREATEX_SHARE_ACCESS_READ| @@ -1340,7 +1340,7 @@ static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_OPTIONS_DIRECTORY, 0); if (fnum1 != -1) { printf("(%s) open of %s succeeded (should fail)\n", - __location__, dirname); + __location__, dname); correct = False; goto fail; } @@ -1363,10 +1363,10 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) /* Test 19. */ - smbcli_deltree(cli1->tree, dirname); + smbcli_deltree(cli1->tree, dname); /* Firstly open and create with all access */ - fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + fnum1 = smbcli_nt_create_full(cli1->tree, dname, 0, SEC_FILE_READ_DATA| SEC_FILE_WRITE_DATA| SEC_STD_DELETE, @@ -1379,7 +1379,7 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) if (fnum1 == -1) { printf("(%s) open - 1 of %s failed (%s)\n", - __location__, dirname, smbcli_errstr(cli1->tree)); + __location__, dname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } @@ -1388,7 +1388,7 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) smbcli_close(cli1->tree, fnum1); /* Next open with all access, but add delete on close. */ - fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + fnum1 = smbcli_nt_create_full(cli1->tree, dname, 0, SEC_FILE_READ_DATA| SEC_FILE_WRITE_DATA| SEC_STD_DELETE, @@ -1407,10 +1407,10 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) } /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(cli1, fnum1, dirname, False, __location__); + correct &= check_delete_on_close(cli1, fnum1, dname, False, __location__); /* Now try opening again for read-only. */ - fnum2 = smbcli_nt_create_full(cli1->tree, dirname, 0, + fnum2 = smbcli_nt_create_full(cli1->tree, dname, 0, SEC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_DIRECTORY, NTCREATEX_SHARE_ACCESS_READ| @@ -1422,19 +1422,19 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) /* Should work. */ if (fnum2 == -1) { printf("(%s) open - 1 of %s failed (%s)\n", - __location__, dirname, smbcli_errstr(cli1->tree)); + __location__, dname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(cli1, fnum2, dirname, True, __location__); + correct &= check_delete_on_close(cli1, fnum2, dname, True, __location__); smbcli_close(cli1->tree, fnum2); /* See if the file is deleted - for a directory this seems to be true ! */ - fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + fnum1 = smbcli_nt_create_full(cli1->tree, dname, 0, SEC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_DIRECTORY, NTCREATEX_SHARE_ACCESS_READ| @@ -1447,7 +1447,7 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) if (fnum1 != -1) { printf("(%s) open of %s succeeded (should fail)\n", - __location__, dirname); + __location__, dname); correct = False; goto fail; } @@ -1471,9 +1471,9 @@ static BOOL deltest20(struct smbcli_state *cli1, struct smbcli_state *cli2) /* Test 20 -- non-empty directory hardest to get right... */ - smbcli_deltree(cli1->tree, dirname); + smbcli_deltree(cli1->tree, dname); - dnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, + dnum1 = smbcli_nt_create_full(cli1->tree, dname, 0, SEC_FILE_READ_DATA| SEC_FILE_WRITE_DATA| SEC_STD_DELETE, @@ -1485,17 +1485,17 @@ static BOOL deltest20(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_OPTIONS_DIRECTORY, 0); if (dnum1 == -1) { printf("(%s) open of %s failed: %s!\n", - __location__, dirname, smbcli_errstr(cli1->tree)); + __location__, dname, smbcli_errstr(cli1->tree)); correct = False; goto fail; } - correct &= check_delete_on_close(cli1, dnum1, dirname, False, __location__); + correct &= check_delete_on_close(cli1, dnum1, dname, False, __location__); status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True); { char *fullname; - asprintf(&fullname, "\\%s%s", dirname, fname); + asprintf(&fullname, "\\%s%s", dname, fname); fnum1 = smbcli_open(cli1->tree, fullname, O_CREAT|O_RDWR, DENY_NONE); if (fnum1 != -1) { @@ -1526,7 +1526,7 @@ static BOOL deltest20(struct smbcli_state *cli1, struct smbcli_state *cli2) { char *fullname; - asprintf(&fullname, "\\%s%s", dirname, fname); + asprintf(&fullname, "\\%s%s", dname, fname); fnum1 = smbcli_open(cli1->tree, fullname, O_CREAT|O_RDWR, DENY_NONE); if (fnum1 == -1) { -- cgit From 4d333d26b3ff8cd01b0252722f0f8d3dfbba72e8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 13 Jun 2006 09:11:29 +0000 Subject: r16182: Better test the 15 out of 20 tests we right now survive than not test at all... Volker (This used to be commit 1d4a129bb56ef7b944dbd386313ea8345a675e6f) --- source4/torture/basic/delete.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index faefd48b74..c7b7fffa18 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -1656,11 +1656,13 @@ BOOL torture_test_delete(struct torture_context *torture) correct &= deltest13(cli1, cli2); correct &= deltest14(cli1, cli2); correct &= deltest15(cli1, cli2); - correct &= deltest16(cli1, cli2); - correct &= deltest17(cli1, cli2); - correct &= deltest18(cli1, cli2); - correct &= deltest19(cli1, cli2); - correct &= deltest20(cli1, cli2); + if (!lp_parm_bool(-1, "target", "samba3", False)) { + correct &= deltest16(cli1, cli2); + correct &= deltest17(cli1, cli2); + correct &= deltest18(cli1, cli2); + correct &= deltest19(cli1, cli2); + correct &= deltest20(cli1, cli2); + } correct &= deltest21(&cli1, &cli2); if (!correct) { -- cgit From 81d590104493d0ff73c8c08d2573dd02dee78981 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 2 Jul 2006 08:53:49 +0000 Subject: r16756: Some machines on the build farms sporadically fail the test /* Test 21 -- Test removal of file after socket close. */ I think it might be because they are too slow to delete the file. Jeremy, can you check this test does not change semantics in a way you don't want it? Volker (This used to be commit 92aa95f8206364a832bd6ad8cebc030bc001d940) --- source4/torture/basic/delete.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index c7b7fffa18..a220e52438 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -1600,6 +1600,10 @@ static BOOL deltest21(struct smbcli_state **ppcli1, struct smbcli_state **ppcli2 cli1 = *ppcli1; + /* On slow build farm machines it might happen that they are not fast + * enogh to delete the file for this test */ + msleep(200); + /* File should not be there. */ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_RIGHTS_FILE_READ, -- cgit From af0a9eb52955cfae570bfdc01821f56385c860cf Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 6 Jul 2006 08:00:24 +0000 Subject: r16834: split the level's of smb_search_first/smb_search_next and the levels of smb_search_data metze (This used to be commit 78c201db8a47a71908698c4dda2add4cf85694d9) --- source4/torture/basic/delete.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index a220e52438..a71fed32b7 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -44,7 +44,9 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, BOOL res = True; status = torture_single_search(cli, mem_ctx, - fname, RAW_SEARCH_FULL_DIRECTORY_INFO, + fname, + RAW_SEARCH_TRANS2, + RAW_SEARCH_DATA_FULL_DIRECTORY_INFO, FILE_ATTRIBUTE_DIRECTORY, &data); if (!NT_STATUS_IS_OK(status)) { -- cgit From b7c5bc522b286e8e478b6f74a68bc68829e64c3c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 10 Jul 2006 08:00:06 +0000 Subject: r16907: Add an index parameter to torture_open_connection. Next step is to enable the unclist parameter for all tests that do two connections, to enable cluster testing. Volker (This used to be commit a5d6db09244d444986f8fded3fc6e72c74c8ca1f) --- source4/torture/basic/delete.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index a71fed32b7..d3f7de201f 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -1596,7 +1596,7 @@ static BOOL deltest21(struct smbcli_state **ppcli1, struct smbcli_state **ppcli2 fnum1 = -1; - if (!torture_open_connection(ppcli1)) { + if (!torture_open_connection(ppcli1, 0)) { return False; } @@ -1636,11 +1636,11 @@ BOOL torture_test_delete(struct torture_context *torture) printf("starting delete test\n"); - if (!torture_open_connection(&cli1)) { + if (!torture_open_connection(&cli1, 0)) { return False; } - if (!torture_open_connection(&cli2)) { + if (!torture_open_connection(&cli2, 1)) { printf("(%s) failed to open second connection.\n", __location__); correct = False; -- cgit From 440d0487a6ad9a39630d7364eb54e46367207d05 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 13 Jul 2006 17:37:45 +0000 Subject: r17020: pass the real error to the failing requests metze (This used to be commit 49b96ac44a883c020c69df7a12df154dc4faa4d5) --- source4/torture/basic/delete.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index d3f7de201f..445333ca6f 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -1592,7 +1592,7 @@ static BOOL deltest21(struct smbcli_state **ppcli1, struct smbcli_state **ppcli2 correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__); /* Now yank the rug from under cli1. */ - smbcli_transport_dead(cli1->transport); + smbcli_transport_dead(cli1->transport, NT_STATUS_LOCAL_DISCONNECT); fnum1 = -1; -- cgit From 8773e743c518578584d07d35ffdafdd598af88b0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 16 Oct 2006 13:06:41 +0000 Subject: r19339: Merge my 4.0-unittest branch. This adds an API for more fine-grained output in the testsuite rather than just True or False for a set of tests. The aim is to use this for: * known failure lists (run all tests and detect tests that started working or started failing). This would allow us to get rid of the RPC-SAMBA3-* tests * nicer torture output * simplification of the testsuite system * compatibility with other unit testing systems * easier usage of smbtorture (being able to run one test and automatically set up the environment for that) This is still a work-in-progress; expect more updates over the next couple of days. (This used to be commit 0eb6097305776325c75081356309115f445a7218) --- source4/torture/basic/delete.c | 1118 +++++++++++++--------------------------- 1 file changed, 360 insertions(+), 758 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 445333ca6f..4f787ebb65 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -29,11 +29,11 @@ #include "torture/raw/proto.h" -static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, - const char *fname, BOOL expect_it, - const char *where) +static bool check_delete_on_close(struct torture_context *tctx, + struct smbcli_state *cli, int fnum, + const char *fname, bool expect_it, + const char *where) { - TALLOC_CTX *mem_ctx = talloc_init("single_search"); union smb_search_data data; NTSTATUS status; @@ -41,20 +41,14 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, size_t size; uint16_t mode; - BOOL res = True; - - status = torture_single_search(cli, mem_ctx, + status = torture_single_search(cli, tctx, fname, RAW_SEARCH_TRANS2, RAW_SEARCH_DATA_FULL_DIRECTORY_INFO, FILE_ATTRIBUTE_DIRECTORY, &data); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) single_search failed (%s)\n", - where, nt_errstr(status)); - res = False; - goto done; - } + torture_assert_ntstatus_ok(tctx, status, + talloc_asprintf(tctx, "single_search failed (%s)", where)); if (fnum != -1) { union smb_fileinfo io; @@ -63,53 +57,33 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, io.all_info.level = RAW_FILEINFO_ALL_INFO; io.all_info.in.file.fnum = fnum; - status = smb_raw_fileinfo(cli->tree, mem_ctx, &io); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) qfileinfo failed (%s)\n", where, - nt_errstr(status)); - res = False; - goto done; - } + status = smb_raw_fileinfo(cli->tree, tctx, &io); + torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, + "qfileinfo failed (%s)", where)); - if (expect_it != io.all_info.out.delete_pending) { - printf("%s - Expected del_on_close flag %d, qfileinfo/all_info gave %d\n", - where, expect_it, io.all_info.out.delete_pending); - res = False; - goto done; - } + torture_assert(tctx, expect_it == io.all_info.out.delete_pending, + talloc_asprintf(tctx, + "%s - Expected del_on_close flag %d, qfileinfo/all_info gave %d", + where, expect_it, io.all_info.out.delete_pending)); - if (nlink != io.all_info.out.nlink) { - printf("%s - Expected nlink %d, qfileinfo/all_info gave %d\n", - where, nlink, io.all_info.out.nlink); - res = False; - goto done; - } + torture_assert(tctx, nlink == io.all_info.out.nlink, + talloc_asprintf(tctx, + "%s - Expected nlink %d, qfileinfo/all_info gave %d", + where, nlink, io.all_info.out.nlink)); io.standard_info.level = RAW_FILEINFO_STANDARD_INFO; io.standard_info.in.file.fnum = fnum; - status = smb_raw_fileinfo(cli->tree, mem_ctx, &io); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) qpathinfo failed (%s)\n", where, - nt_errstr(status)); - res = False; - goto done; - } - - if (expect_it != io.standard_info.out.delete_pending) { - printf("%s - Expected del_on_close flag %d, qfileinfo/standard_info gave %d\n", - where, expect_it, io.standard_info.out.delete_pending); - res = False; - goto done; - } + status = smb_raw_fileinfo(cli->tree, tctx, &io); + torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "qpathinfo failed (%s)", where)); - if (nlink != io.standard_info.out.nlink) { - printf("%s - Expected nlink %d, qfileinfo/standard_info gave %d\n", - where, nlink, io.all_info.out.nlink); - res = False; - goto done; - } + torture_assert(tctx, expect_it == io.standard_info.out.delete_pending, + talloc_asprintf(tctx, "%s - Expected del_on_close flag %d, qfileinfo/standard_info gave %d\n", + where, expect_it, io.standard_info.out.delete_pending)); + torture_assert(tctx, nlink == io.standard_info.out.nlink, + talloc_asprintf(tctx, "%s - Expected nlink %d, qfileinfo/standard_info gave %d", + where, nlink, io.all_info.out.nlink)); } status = smbcli_qpathinfo(cli->tree, fname, @@ -117,35 +91,19 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, &size, &mode); if (expect_it) { - if (!NT_STATUS_EQUAL(status, NT_STATUS_DELETE_PENDING)) { - printf("(%s) qpathinfo did not give correct error " - "code (%s) -- NT_STATUS_DELETE_PENDING " - "expected\n", where, - nt_errstr(status)); - res = False; - goto done; - } + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_DELETE_PENDING, + "qpathinfo did not give correct error code"); } else { - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) qpathinfo failed (%s)\n", where, - nt_errstr(status)); - res = False; - goto done; - } + torture_assert_ntstatus_ok(tctx, status, + talloc_asprintf(tctx, "qpathinfo failed (%s)", where)); } - done: - talloc_free(mem_ctx); - return res; + return true; } -#define CHECK_STATUS(_cli, _expected) do { \ - if (!NT_STATUS_EQUAL(_cli->tree->session->transport->error.e.nt_status, _expected)) { \ - printf("(%d) Incorrect status %s - should be %s\n", \ - __LINE__, nt_errstr(_cli->tree->session->transport->error.e.nt_status), nt_errstr(_expected)); \ - correct = False; \ - goto fail; \ - }} while (0) +#define CHECK_STATUS(_cli, _expected) \ + torture_assert_ntstatus_equal(tctx, _cli->tree->session->transport->error.e.nt_status, _expected, \ + "Incorrect status") static const char *fname = "\\delete.file"; static const char *fname_new = "\\delete.new"; @@ -153,19 +111,19 @@ static const char *dname = "\\delete.dir"; static void del_clean_area(struct smbcli_state *cli1, struct smbcli_state *cli2) { + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + smbcli_deltree(cli1->tree, dname); smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); smbcli_setatr(cli1->tree, fname_new, 0, 0); smbcli_unlink(cli1->tree, fname_new); - - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); } /* Test 1 - this should delete the file on close. */ -static BOOL deltest1(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest1(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; @@ -177,31 +135,21 @@ static BOOL deltest1(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close failed (%s)", smbcli_errstr(cli1->tree))); fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); - if (fnum1 != -1) { - printf("(%s) open of %s succeeded (should fail)\n", - __location__, fname); - return False; - } + torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail)", + fname)); - printf("first delete on close test succeeded.\n"); return True; } /* Test 2 - this should delete the file on close. */ -static BOOL deltest2(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest2(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; @@ -212,23 +160,17 @@ static BOOL deltest2(struct smbcli_state *cli1, struct smbcli_state *cli2) FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("(%s) setting delete_on_close failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + talloc_asprintf(tctx, "setting delete_on_close failed (%s)", + smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close failed (%s)", + smbcli_errstr(cli1->tree))); fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); if (fnum1 != -1) { @@ -240,14 +182,12 @@ static BOOL deltest2(struct smbcli_state *cli1, struct smbcli_state *cli2) return False; } smbcli_unlink(cli1->tree, fname); - } else { - printf("second delete on close test succeeded.\n"); } - return True; + return true; } /* Test 3 - ... */ -static BOOL deltest3(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest3(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int fnum2 = -1; @@ -260,11 +200,8 @@ static BOOL deltest3(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); /* This should fail with a sharing violation - open for delete is only compatible with SHARE_DELETE. */ @@ -275,11 +212,9 @@ static BOOL deltest3(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OPEN, 0, 0); - if (fnum2 != -1) { - printf("(%s) open - 2 of %s succeeded - should have failed.\n", - __location__, fname); - return False; - } + torture_assert(tctx, fnum2 == -1, + talloc_asprintf(tctx, "open - 2 of %s succeeded - should have failed.", + fname)); /* This should succeed. */ @@ -289,29 +224,21 @@ static BOOL deltest3(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); - if (fnum2 == -1) { - printf("(%s) open - 2 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 2 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("(%s) setting delete_on_close failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + talloc_asprintf(tctx, "setting delete_on_close failed (%s)", + smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close 1 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close 1 failed (%s)", + smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) { - printf("(%s) close 2 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum2), + talloc_asprintf(tctx, "close 2 failed (%s)", + smbcli_errstr(cli1->tree))); /* This should fail - file should no longer be there. */ @@ -325,18 +252,16 @@ static BOOL deltest3(struct smbcli_state *cli1, struct smbcli_state *cli2) } smbcli_unlink(cli1->tree, fname); return False; - } else { - printf("third delete on close test succeeded.\n"); } return True; } /* Test 4 ... */ -static BOOL deltest4(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest4(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int fnum2 = -1; - BOOL correct = True; + bool correct = True; del_clean_area(cli1, cli2); @@ -348,11 +273,8 @@ static BOOL deltest4(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); /* This should succeed. */ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, @@ -362,23 +284,18 @@ static BOOL deltest4(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); - if (fnum2 == -1) { - printf("(%s) open - 2 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 2 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) { - printf("(%s) close - 1 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_close(cli1->tree, fnum2), + talloc_asprintf(tctx, "close - 1 failed (%s)", + smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("(%s) setting delete_on_close failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + talloc_asprintf(tctx, "setting delete_on_close failed (%s)", + smbcli_errstr(cli1->tree))); /* This should fail - no more opens once delete on close set. */ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, @@ -386,60 +303,43 @@ static BOOL deltest4(struct smbcli_state *cli1, struct smbcli_state *cli2) FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); - if (fnum2 != -1) { - printf("(%s) open - 3 of %s succeeded ! Should have failed.\n", - __location__, fname ); - return False; - } + torture_assert(tctx, fnum2 == -1, + talloc_asprintf(tctx, "open - 3 of %s succeeded ! Should have failed.", + fname )); + CHECK_STATUS(cli1, NT_STATUS_DELETE_PENDING); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 2 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 2 failed (%s)", + smbcli_errstr(cli1->tree))); - printf("fourth delete on close test succeeded.\n"); - - fail: - return correct; } /* Test 5 ... */ -static BOOL deltest5(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest5(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; del_clean_area(cli1, cli2); fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT, DENY_NONE); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } - + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); + /* This should fail - only allowed on NT opens with DELETE access. */ - if (NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("(%s) setting delete_on_close on OpenX file succeeded - should fail !\n", - __location__); - return False; - } + torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True)), + "setting delete_on_close on OpenX file succeeded - should fail !"); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 2 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli1->tree))); - printf("fifth delete on close test succeeded.\n"); return True; } /* Test 6 ... */ -static BOOL deltest6(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest6(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; @@ -453,35 +353,28 @@ static BOOL deltest6(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); /* This should fail - only allowed on NT opens with DELETE access. */ - if (NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("(%s) setting delete_on_close on file with no delete access succeeded - should fail !\n", - __location__); - return False; - } + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True)), + "setting delete_on_close on file with no delete access succeeded - should fail !"); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 2 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 2 failed (%s)", + smbcli_errstr(cli1->tree))); - printf("sixth delete on close test succeeded.\n"); return True; } /* Test 7 ... */ -static BOOL deltest7(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest7(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; - BOOL correct = True; + bool correct = True; del_clean_area(cli1, cli2); @@ -492,68 +385,42 @@ static BOOL deltest7(struct smbcli_state *cli1, struct smbcli_state *cli2) FILE_ATTRIBUTE_NORMAL, 0, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("(%s) setting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, False))) { - printf("(%s) unsetting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, + smbcli_nt_delete_on_close(cli1->tree, fnum1, False), + "unsetting delete_on_close on file failed !"); - correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 2 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli1->tree))); /* This next open should succeed - we reset the flag. */ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 2 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } - - printf("seventh delete on close test succeeded.\n"); - - fail: + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 2 failed (%s)", + smbcli_errstr(cli1->tree))); return correct; } /* Test 8 ... */ -static BOOL deltest8(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest8(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int fnum2 = -1; - BOOL correct = True; + bool correct = True; del_clean_area(cli1, cli2); @@ -565,12 +432,9 @@ static BOOL deltest8(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_FILE_READ_DATA| @@ -580,57 +444,36 @@ static BOOL deltest8(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); - if (fnum2 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("(%s) setting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, + smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__); - correct &= check_delete_on_close(cli2, fnum2, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 1 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 1 failed (%s)", + smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(cli1, -1, fname, True, __location__); - correct &= check_delete_on_close(cli2, fnum2, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, -1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__); - if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { - printf("(%s) close - 2 failed (%s)\n", - __location__, smbcli_errstr(cli2->tree)); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli2->tree, fnum2), + talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli2->tree))); /* This should fail.. */ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); - if (fnum1 != -1) { - printf("(%s) open of %s succeeded should have been deleted on close !\n", - __location__, fname); - correct = False; - } else { - printf("eighth delete on close test succeeded.\n"); - } - - fail: + torture_assert(tctx, fnum1 == -1, + talloc_asprintf(tctx, "open of %s succeeded should have been deleted on close !\n", fname)); return correct; } /* Test 9 ... */ -static BOOL deltest9(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest9(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; @@ -644,21 +487,17 @@ static BOOL deltest9(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); - if (fnum1 != -1) { - printf("(%s) open of %s succeeded should have failed!\n", - __location__, fname); - return False; - } + torture_assert(tctx, fnum1 == -1, + talloc_asprintf(tctx, "open of %s succeeded should have failed!", + fname)); - printf("ninth delete on close test succeeded.\n"); return True; } /* Test 10 ... */ -static BOOL deltest10(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest10(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; - BOOL correct = True; del_clean_area(cli1, cli2); @@ -670,39 +509,25 @@ static BOOL deltest10(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); /* This should delete the file. */ - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close failed (%s)", + smbcli_errstr(cli1->tree))); /* This should fail.. */ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); - if (fnum1 != -1) { - printf("(%s) open of %s succeeded should have been deleted on close !\n", - __location__, fname); - correct = False; - goto fail; - } else { - printf("tenth delete on close test succeeded.\n"); - } - - fail: - - return correct; + torture_assert(tctx, fnum1 == -1, + talloc_asprintf(tctx, "open of %s succeeded should have been deleted on close !", + fname)); + return true; } /* Test 11 ... */ -static BOOL deltest11(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest11(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; NTSTATUS status; @@ -717,32 +542,23 @@ static BOOL deltest11(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); status = smbcli_nt_delete_on_close(cli1->tree, fnum1, True); - if (!NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) { - printf("(%s) setting delete_on_close should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_CANNOT_DELETE, + talloc_asprintf(tctx, "setting delete_on_close should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)", smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close failed (%s)", + smbcli_errstr(cli1->tree))); - printf("eleventh delete on close test succeeded.\n"); return True; } /* Test 12 ... */ -static BOOL deltest12(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest12(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; NTSTATUS status; @@ -759,32 +575,26 @@ static BOOL deltest12(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); - if (fnum1 != -1) { - printf("(%s) open of %s succeeded. Should fail with " - "NT_STATUS_CANNOT_DELETE.\n", __location__, fname); - smbcli_close(cli1->tree, fnum1); - return False; - } else { - status = smbcli_nt_error(cli1->tree); - if (!NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) { - printf("(%s) setting delete_on_close on open should " + torture_assert(tctx, fnum1 == -1, + talloc_asprintf(tctx, "open of %s succeeded. Should fail with " + "NT_STATUS_CANNOT_DELETE.\n", fname)); + + status = smbcli_nt_error(cli1->tree); + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_CANNOT_DELETE, + talloc_asprintf(tctx, "setting delete_on_close on open should " "fail with NT_STATUS_CANNOT_DELETE. Got %s " - "instead)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } - } + "instead)", + smbcli_errstr(cli1->tree))); - printf("twelvth delete on close test succeeded.\n"); - return True; + return true; } /* Test 13 ... */ -static BOOL deltest13(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest13(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int fnum2 = -1; - BOOL correct = True; + bool correct = True; del_clean_area(cli1, cli2); @@ -802,12 +612,9 @@ static BOOL deltest13(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_FILE_READ_DATA| @@ -819,70 +626,48 @@ static BOOL deltest13(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); - if (fnum2 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli2->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, + "open of %s failed (%s)", + fname, smbcli_errstr(cli2->tree))); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, - True))) { - printf("(%s) setting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, + smbcli_nt_delete_on_close(cli1->tree, fnum1, + True), + "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__); - correct &= check_delete_on_close(cli2, fnum2, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli2->tree, fnum2, - False))) { - printf("(%s) setting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli2->tree, fnum2, + False), + "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); - correct &= check_delete_on_close(cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 1 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 1 failed (%s)", + smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { - printf("(%s) close - 2 failed (%s)\n", - __location__, smbcli_errstr(cli2->tree)); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli2->tree, fnum2), + talloc_asprintf(tctx, "close - 2 failed (%s)", + smbcli_errstr(cli2->tree))); fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); - if (fnum1 == -1) { - printf("(%s) open of %s failed!\n", - __location__, fname); - correct = False; - goto fail; - } - - printf("thirteenth delete on close test succeeded.\n"); + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed!", + fname)); - fail: + smbcli_close(cli1->tree, fnum1); return correct; } /* Test 14 ... */ -static BOOL deltest14(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest14(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int dnum1 = -1; - BOOL correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -897,21 +682,13 @@ static BOOL deltest14(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_WRITE| NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_CREATE, 0, 0); - if (dnum1 == -1) { - printf("(%s) open of %s failed: %s!\n", - __location__, dname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, dnum1 != -1, talloc_asprintf(tctx, "open of %s failed: %s!", + dname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(cli1, dnum1, dname, False, __location__); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, dnum1, True))) { - printf("(%s) setting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } - correct &= check_delete_on_close(cli1, dnum1, dname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, dnum1, dname, False, __location__); + torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, True), + "setting delete_on_close on file failed !"); + correct &= check_delete_on_close(tctx, cli1, dnum1, dname, True, __location__); smbcli_close(cli1->tree, dnum1); /* Now it should be gone... */ @@ -925,26 +702,17 @@ static BOOL deltest14(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_WRITE| NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); - if (dnum1 != -1) { - printf("(%s) setting delete_on_close on file succeeded !\n", - __location__); - correct = False; - goto fail; - } - - printf("fourteenth delete on close test succeeded.\n"); - - fail: + torture_assert(tctx, dnum1 == -1, "setting delete_on_close on file succeeded !"); return correct; } /* Test 15 ... */ -static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest15(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; + bool correct = true; int fnum2 = -1; - BOOL correct = True; NTSTATUS status; del_clean_area(cli1, cli2); @@ -964,21 +732,12 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); status = smbcli_rename(cli2->tree, fname, fname_new); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) renaming failed: %s !\n", - __location__, nt_errstr(status)); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, status, "renaming failed!"); fnum2 = smbcli_nt_create_full(cli2->tree, fname_new, 0, SEC_GENERIC_ALL, @@ -989,28 +748,21 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum2 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname_new, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum2 != -1, + talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname_new, smbcli_errstr(cli1->tree))); status = smbcli_nt_delete_on_close(cli2->tree, fnum2, True); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) setting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, status, + "setting delete_on_close on file failed !"); smbcli_close(cli2->tree, fnum2); /* The file should be around under the new name, there's a second * handle open */ - correct &= check_delete_on_close(cli1, fnum1, fname_new, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname_new, True, __location__); fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_GENERIC_ALL, @@ -1021,14 +773,10 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum2 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); smbcli_close(cli2->tree, fnum2); smbcli_close(cli1->tree, fnum1); @@ -1042,12 +790,8 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OPEN, 0, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); smbcli_close(cli1->tree, fnum1); @@ -1060,27 +804,19 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OPEN, 0, 0); - if (fnum1 != -1) { - printf("(%s) smbcli_open succeeded, should have " - "failed\n", __location__); - smbcli_close(cli1->tree, fnum1); - correct = False; - goto fail; - } - - printf("fifteenth delete on close test succeeded.\n"); - - fail: + torture_assert(tctx, fnum1 == -1, + "smbcli_open succeeded, should have " + "failed"); return correct; } /* Test 16 ... */ -static BOOL deltest16(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest16(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int fnum2 = -1; - BOOL correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -1102,19 +838,14 @@ static BOOL deltest16(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_CREATE, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert (tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(cli1, -1, fname, False, __location__); - correct &= check_delete_on_close(cli2, -1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, -1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, -1, fname, False, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, @@ -1126,49 +857,36 @@ static BOOL deltest16(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OPEN, 0, 0); - /* Should work. */ - if (fnum2 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); - correct &= check_delete_on_close(cli1, -1, fname, False, __location__); - correct &= check_delete_on_close(cli2, fnum2, fname, False, __location__); - correct &= check_delete_on_close(cli2, -1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, -1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, -1, fname, False, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(cli2, fnum2, fname, True, __location__); - correct &= check_delete_on_close(cli2, -1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli2, -1, fname, True, __location__); smbcli_close(cli2->tree, fnum2); /* And the file should be deleted ! */ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); - if (fnum1 != -1) { - printf("(%s) open of %s succeeded (should fail)\n", - __location__, fname); - correct = False; - goto fail; - } - - printf("sixteenth delete on close test succeeded.\n"); - - fail: + torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail)", + fname)); return correct; } /* Test 17 ... */ -static BOOL deltest17(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest17(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int fnum2 = -1; - BOOL correct = True; + bool correct = True; del_clean_area(cli1, cli2); @@ -1189,12 +907,8 @@ static BOOL deltest17(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_CREATE, 0, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); /* And close - just to create the file. */ smbcli_close(cli1->tree, fnum1); @@ -1209,15 +923,11 @@ static BOOL deltest17(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OPEN, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, @@ -1231,45 +941,33 @@ static BOOL deltest17(struct smbcli_state *cli1, struct smbcli_state *cli2) 0, 0); /* Should work. */ - if (fnum2 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); /* still not reported as being set on either */ - correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); - correct &= check_delete_on_close(cli1, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, fname, False, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(cli1, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, fname, False, __location__); smbcli_close(cli1->tree, fnum2); /* See if the file is deleted - shouldn't be.... */ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); - if (fnum1 == -1) { - printf("(%s) open of %s failed (should succeed) - %s\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } - - printf("seventeenth delete on close test succeeded.\n"); - - fail: + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (should succeed) - %s", + fname, smbcli_errstr(cli1->tree))); return correct; } /* Test 18 ... */ -static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest18(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int fnum2 = -1; - BOOL correct = True; + bool correct = True; del_clean_area(cli1, cli2); @@ -1293,15 +991,11 @@ static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_CREATE, NTCREATEX_OPTIONS_DIRECTORY|NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, dname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + dname, smbcli_errstr(cli1->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(cli1, fnum1, dname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, dname, False, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli1->tree, dname, 0, @@ -1315,19 +1009,15 @@ static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2) /* Should work. */ - if (fnum2 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, dname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + dname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(cli1, fnum1, dname, False, __location__); - correct &= check_delete_on_close(cli1, fnum2, dname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, dname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, dname, False, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(cli1, fnum2, dname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, dname, True, __location__); smbcli_close(cli1->tree, fnum2); @@ -1340,26 +1030,18 @@ static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, NTCREATEX_OPTIONS_DIRECTORY, 0); - if (fnum1 != -1) { - printf("(%s) open of %s succeeded (should fail)\n", - __location__, dname); - correct = False; - goto fail; - } - - printf("eighteenth delete on close test succeeded.\n"); - - fail: + torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail)", + dname)); return correct; } /* Test 19 ... */ -static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest19(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int fnum2 = -1; - BOOL correct = True; + bool correct = True; del_clean_area(cli1, cli2); @@ -1379,12 +1061,8 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_CREATE, NTCREATEX_OPTIONS_DIRECTORY, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, dname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + dname, smbcli_errstr(cli1->tree))); /* And close - just to create the directory. */ smbcli_close(cli1->tree, fnum1); @@ -1401,15 +1079,11 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OPEN, NTCREATEX_OPTIONS_DIRECTORY|NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(cli1, fnum1, dname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, dname, False, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli1->tree, dname, 0, @@ -1422,16 +1096,12 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_OPTIONS_DIRECTORY, 0); /* Should work. */ - if (fnum2 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, dname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + dname, smbcli_errstr(cli1->tree))); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(cli1, fnum2, dname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, dname, True, __location__); smbcli_close(cli1->tree, fnum2); @@ -1447,26 +1117,18 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) CHECK_STATUS(cli1, NT_STATUS_OBJECT_NAME_NOT_FOUND); - if (fnum1 != -1) { - printf("(%s) open of %s succeeded (should fail)\n", - __location__, dname); - correct = False; - goto fail; - } - - printf("nineteenth delete on close test succeeded.\n"); - - fail: + torture_assert(tctx, fnum1 == -1, + talloc_asprintf(tctx, "open of %s succeeded (should fail)", dname)); return correct; } /* Test 20 ... */ -static BOOL deltest20(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int dnum1 = -1; - BOOL correct = True; + bool correct = True; NTSTATUS status; del_clean_area(cli1, cli2); @@ -1485,14 +1147,10 @@ static BOOL deltest20(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_CREATE, NTCREATEX_OPTIONS_DIRECTORY, 0); - if (dnum1 == -1) { - printf("(%s) open of %s failed: %s!\n", - __location__, dname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, dnum1 != -1, talloc_asprintf(tctx, "open of %s failed: %s!", + dname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(cli1, dnum1, dname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, dnum1, dname, False, __location__); status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True); { @@ -1500,72 +1158,54 @@ static BOOL deltest20(struct smbcli_state *cli1, struct smbcli_state *cli2) asprintf(&fullname, "\\%s%s", dname, fname); fnum1 = smbcli_open(cli1->tree, fullname, O_CREAT|O_RDWR, DENY_NONE); - if (fnum1 != -1) { - printf("(%s) smbcli_open succeeded, should have " - "failed with NT_STATUS_DELETE_PENDING\n", - __location__); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 == -1, + "smbcli_open succeeded, should have " + "failed with NT_STATUS_DELETE_PENDING" + ); - if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree), - NT_STATUS_DELETE_PENDING)) { - printf("(%s) smbcli_open returned %s, expected " - "NT_STATUS_DELETE_PENDING\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert_ntstatus_equal(tctx, + smbcli_nt_error(cli1->tree), + NT_STATUS_DELETE_PENDING, + "smbcli_open failed"); } status = smbcli_nt_delete_on_close(cli1->tree, dnum1, False); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) setting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, status, + "setting delete_on_close on file failed !"); { char *fullname; asprintf(&fullname, "\\%s%s", dname, fname); fnum1 = smbcli_open(cli1->tree, fullname, O_CREAT|O_RDWR, DENY_NONE); - if (fnum1 == -1) { - printf("(%s) smbcli_open failed: %s\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, "smbcli_open failed: %s\n", + smbcli_errstr(cli1->tree))); smbcli_close(cli1->tree, fnum1); } status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True); - if (!NT_STATUS_EQUAL(status, NT_STATUS_DIRECTORY_NOT_EMPTY)) { - printf("(%s) setting delete_on_close returned %s, expected " - "NT_STATUS_DIRECTORY_NOT_EMPTY\n", __location__, - smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } - + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_DIRECTORY_NOT_EMPTY, + "setting delete_on_close failed"); smbcli_close(cli1->tree, dnum1); - printf("twentieth delete on close test succeeded.\n"); - - fail: - return correct; } /* Test 21 ... */ -static BOOL deltest21(struct smbcli_state **ppcli1, struct smbcli_state **ppcli2) +static bool deltest21(struct torture_context *tctx) { int fnum1 = -1; - struct smbcli_state *cli1 = *ppcli1; - struct smbcli_state *cli2 = *ppcli2; - BOOL correct = True; + struct smbcli_state *cli1; + struct smbcli_state *cli2; + bool correct = True; + + if (!torture_open_connection(&cli1, 0)) + return False; + + if (!torture_open_connection(&cli2, 1)) + return False; del_clean_area(cli1, cli2); @@ -1576,32 +1216,26 @@ static BOOL deltest21(struct smbcli_state **ppcli1, struct smbcli_state **ppcli2 FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("(%s) setting delete_on_close failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + talloc_asprintf(tctx, "setting delete_on_close failed (%s)", + smbcli_errstr(cli1->tree))); /* Ensure delete on close is set. */ - correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__); /* Now yank the rug from under cli1. */ smbcli_transport_dead(cli1->transport, NT_STATUS_LOCAL_DISCONNECT); fnum1 = -1; - if (!torture_open_connection(ppcli1, 0)) { + if (!torture_open_connection(&cli1, 0)) { return False; } - cli1 = *ppcli1; - /* On slow build farm machines it might happen that they are not fast * enogh to delete the file for this test */ msleep(200); @@ -1618,73 +1252,41 @@ static BOOL deltest21(struct smbcli_state **ppcli1, struct smbcli_state **ppcli2 CHECK_STATUS(cli1, NT_STATUS_OBJECT_NAME_NOT_FOUND); - printf("twenty-first delete on close test succeeded.\n"); - - fail: - return correct; } /* Test delete on close semantics. */ -BOOL torture_test_delete(struct torture_context *torture) +struct torture_suite *torture_test_delete(void) { - struct smbcli_state *cli1 = NULL; - struct smbcli_state *cli2 = NULL; - BOOL correct = True; - - printf("starting delete test\n"); - - if (!torture_open_connection(&cli1, 0)) { - return False; - } - - if (!torture_open_connection(&cli2, 1)) { - printf("(%s) failed to open second connection.\n", - __location__); - correct = False; - goto fail; - } - - correct &= deltest1(cli1, cli2); - correct &= deltest2(cli1, cli2); - correct &= deltest3(cli1, cli2); - correct &= deltest4(cli1, cli2); - correct &= deltest5(cli1, cli2); - correct &= deltest6(cli1, cli2); - correct &= deltest7(cli1, cli2); - correct &= deltest8(cli1, cli2); - correct &= deltest9(cli1, cli2); - correct &= deltest10(cli1, cli2); - correct &= deltest11(cli1, cli2); - correct &= deltest12(cli1, cli2); - correct &= deltest13(cli1, cli2); - correct &= deltest14(cli1, cli2); - correct &= deltest15(cli1, cli2); + struct torture_suite *suite = torture_suite_create( + talloc_autofree_context(), + "DELETE"); + + torture_suite_add_2smb_test(suite, "deltest1", deltest1); + torture_suite_add_2smb_test(suite, "deltest2", deltest2); + torture_suite_add_2smb_test(suite, "deltest3", deltest3); + torture_suite_add_2smb_test(suite, "deltest4", deltest4); + torture_suite_add_2smb_test(suite, "deltest5", deltest5); + torture_suite_add_2smb_test(suite, "deltest6", deltest6); + torture_suite_add_2smb_test(suite, "deltest7", deltest7); + torture_suite_add_2smb_test(suite, "deltest8", deltest8); + torture_suite_add_2smb_test(suite, "deltest9", deltest9); + torture_suite_add_2smb_test(suite, "deltest10", deltest10); + torture_suite_add_2smb_test(suite, "deltest11", deltest11); + torture_suite_add_2smb_test(suite, "deltest12", deltest12); + torture_suite_add_2smb_test(suite, "deltest13", deltest13); + torture_suite_add_2smb_test(suite, "deltest14", deltest14); + torture_suite_add_2smb_test(suite, "deltest15", deltest15); if (!lp_parm_bool(-1, "target", "samba3", False)) { - correct &= deltest16(cli1, cli2); - correct &= deltest17(cli1, cli2); - correct &= deltest18(cli1, cli2); - correct &= deltest19(cli1, cli2); - correct &= deltest20(cli1, cli2); + torture_suite_add_2smb_test(suite, "deltest16", deltest16); + torture_suite_add_2smb_test(suite, "deltest17", deltest17); + torture_suite_add_2smb_test(suite, "deltest18", deltest18); + torture_suite_add_2smb_test(suite, "deltest19", deltest19); + torture_suite_add_2smb_test(suite, "deltest20", deltest20); } - correct &= deltest21(&cli1, &cli2); + torture_suite_add_simple_test(suite, "deltest21", deltest21); - if (!correct) { - printf("Failed delete test\n"); - } else { - printf("delete test ok !\n"); - } - - fail: - del_clean_area(cli1, cli2); - - if (!torture_close_connection(cli1)) { - correct = False; - } - if (!torture_close_connection(cli2)) { - correct = False; - } - return correct; + return suite; } -- cgit From 19af876bbb7038f5a40cd87eced81661a2fc2ee6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 18 Oct 2006 12:23:35 +0000 Subject: r19389: Remove samba3-specific checks: instead, always simply mark these tests as known failing. (This used to be commit 3855ec9dcaa694fffa1f2a24205d490708d12750) --- source4/torture/basic/delete.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 4f787ebb65..de78329fe4 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -1279,13 +1279,11 @@ struct torture_suite *torture_test_delete(void) torture_suite_add_2smb_test(suite, "deltest13", deltest13); torture_suite_add_2smb_test(suite, "deltest14", deltest14); torture_suite_add_2smb_test(suite, "deltest15", deltest15); - if (!lp_parm_bool(-1, "target", "samba3", False)) { - torture_suite_add_2smb_test(suite, "deltest16", deltest16); - torture_suite_add_2smb_test(suite, "deltest17", deltest17); - torture_suite_add_2smb_test(suite, "deltest18", deltest18); - torture_suite_add_2smb_test(suite, "deltest19", deltest19); - torture_suite_add_2smb_test(suite, "deltest20", deltest20); - } + torture_suite_add_2smb_test(suite, "deltest16", deltest16); + torture_suite_add_2smb_test(suite, "deltest17", deltest17); + torture_suite_add_2smb_test(suite, "deltest18", deltest18); + torture_suite_add_2smb_test(suite, "deltest19", deltest19); + torture_suite_add_2smb_test(suite, "deltest20", deltest20); torture_suite_add_simple_test(suite, "deltest21", deltest21); return suite; -- cgit From 7a734d3b30540d12b5f58aa4b5e51edd39e2be53 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 4 Jan 2007 16:26:15 +0000 Subject: r20525: Closing a dir with del-on-close set requires the same as files: Don't actually unlink/rmdir if another process still has it open. Jeremy, this is a potential merger to 3.0.24. Volker (This used to be commit d0550a01af219344ec2e4c16d5253814afc89974) --- source4/torture/basic/delete.c | 80 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index de78329fe4..dd1f564947 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -1254,6 +1254,85 @@ static bool deltest21(struct torture_context *tctx) return correct; } + +/* Test 22 ... */ + +/* + * Test whether a second *directory* handle inhibits delete if the first has + * del-on-close set and is closed + */ +static bool deltest22(struct torture_context *tctx) +{ + int dnum1 = -1; + int dnum2 = -1; + struct smbcli_state *cli1; + bool correct = True; + + if (!torture_open_connection(&cli1, 0)) + return False; + + smbcli_deltree(cli1->tree, dname); + + torture_assert_ntstatus_ok( + tctx, smbcli_mkdir(cli1->tree, dname), + talloc_asprintf(tctx, "smbcli_mdir failed: (%s)\n", + smbcli_errstr(cli1->tree))); + + dnum1 = smbcli_nt_create_full(cli1->tree, dname, 0, + SEC_FILE_READ_DATA| + SEC_FILE_WRITE_DATA| + SEC_STD_DELETE, + FILE_ATTRIBUTE_DIRECTORY, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, + NTCREATEX_OPTIONS_DIRECTORY, 0); + + torture_assert(tctx, dnum1 != -1, + talloc_asprintf(tctx, "open of %s failed: %s!", + dname, smbcli_errstr(cli1->tree))); + + dnum2 = smbcli_nt_create_full(cli1->tree, dname, 0, + SEC_FILE_READ_DATA| + SEC_FILE_WRITE_DATA, + FILE_ATTRIBUTE_DIRECTORY, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, + NTCREATEX_OPTIONS_DIRECTORY, 0); + + torture_assert(tctx, dnum2 != -1, + talloc_asprintf(tctx, "open of %s failed: %s!", + dname, smbcli_errstr(cli1->tree))); + + torture_assert_ntstatus_ok( + tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, True), + talloc_asprintf(tctx, "setting delete_on_close failed (%s)", + smbcli_errstr(cli1->tree))); + + smbcli_close(cli1->tree, dnum1); + + dnum1 = smbcli_nt_create_full(cli1->tree, dname, 0, + SEC_FILE_READ_DATA| + SEC_FILE_WRITE_DATA| + SEC_STD_DELETE, + FILE_ATTRIBUTE_DIRECTORY, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, + NTCREATEX_OPTIONS_DIRECTORY, 0); + + torture_assert(tctx, dnum1 == -1, + talloc_asprintf(tctx, "open of %s succeeded!\n", + dname)); + + CHECK_STATUS(cli1, NT_STATUS_DELETE_PENDING); + + return correct; +} /* Test delete on close semantics. @@ -1285,6 +1364,7 @@ struct torture_suite *torture_test_delete(void) torture_suite_add_2smb_test(suite, "deltest19", deltest19); torture_suite_add_2smb_test(suite, "deltest20", deltest20); torture_suite_add_simple_test(suite, "deltest21", deltest21); + torture_suite_add_simple_test(suite, "deltest22", deltest22); return suite; } -- cgit From 627595b7a3c91d02fe8a29737beb77b2a4c4ae0f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 3 Feb 2007 17:46:32 +0000 Subject: r21134: Attempt to quieten the build farm for Samba3 (This used to be commit 966c30ca591c410a4a229396c7919fe8f98bd066) --- source4/torture/basic/delete.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index dd1f564947..8ef4d0208d 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -1135,6 +1135,10 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s /* Test 20 -- non-empty directory hardest to get right... */ + if (torture_setting_bool(tctx, "samba3", False)) { + return True; + } + smbcli_deltree(cli1->tree, dname); dnum1 = smbcli_nt_create_full(cli1->tree, dname, 0, -- cgit From 042ddf28ec036141b2457eb4bf6d2b0cec5cc790 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 21 May 2007 05:40:04 +0000 Subject: r23029: fixed formatting (This used to be commit 72ee4707725e9bbc9ab564315c7d78bdc564256f) --- source4/torture/basic/delete.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 8ef4d0208d..0c9016ca88 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -296,7 +296,7 @@ static bool deltest4(struct torture_context *tctx, struct smbcli_state *cli1, st smbcli_nt_delete_on_close(cli1->tree, fnum1, True), talloc_asprintf(tctx, "setting delete_on_close failed (%s)", smbcli_errstr(cli1->tree))); - + /* This should fail - no more opens once delete on close set. */ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_RIGHTS_FILE_READ, @@ -1344,8 +1344,8 @@ static bool deltest22(struct torture_context *tctx) struct torture_suite *torture_test_delete(void) { struct torture_suite *suite = torture_suite_create( - talloc_autofree_context(), - "DELETE"); + talloc_autofree_context(), + "DELETE"); torture_suite_add_2smb_test(suite, "deltest1", deltest1); torture_suite_add_2smb_test(suite, "deltest2", deltest2); -- cgit From 2087e1ce6a5efd6639daaf79f0eef0b11ac7857a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 23 May 2007 21:14:05 +0000 Subject: r23099: New interesting delete on close tests :-). This will break all delete tests on the build farm until I check in my server patch. Jeremy. (This used to be commit c31f775f1c8f6f7e50d038d093898a1f4280be23) --- source4/torture/basic/delete.c | 63 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 0c9016ca88..fbeec05d27 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -1197,6 +1197,66 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s return correct; } +/* Test 20a ... */ +static bool deltest20a(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + int fnum2 = -1; + bool correct = True; + + del_clean_area(cli1, cli2); + + /* Test 20a. */ + + /* Ensure the file doesn't already exist. */ + smbcli_close(cli1->tree, fnum1); + smbcli_close(cli1->tree, fnum2); + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + + /* Firstly open and create with all access */ + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SEC_RIGHTS_FILE_ALL, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_CREATE, + 0, 0); + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); + + /* Next open with all access, but add delete on close. */ + fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, + SEC_RIGHTS_FILE_ALL, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, + NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); + + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 2 of %s failed (%s)", + fname, smbcli_errstr(cli2->tree))); + + /* The delete on close bit is *not* reported as being set. */ + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + + smbcli_close(cli1->tree, fnum1); + + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + + smbcli_close(cli2->tree, fnum2); + + /* See if the file is deleted - should be.... */ + fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); + torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail) - %s", + fname, smbcli_errstr(cli1->tree))); + + return correct; +} + /* Test 21 ... */ static bool deltest21(struct torture_context *tctx) { @@ -1337,7 +1397,7 @@ static bool deltest22(struct torture_context *tctx) return correct; } - + /* Test delete on close semantics. */ @@ -1367,6 +1427,7 @@ struct torture_suite *torture_test_delete(void) torture_suite_add_2smb_test(suite, "deltest18", deltest18); torture_suite_add_2smb_test(suite, "deltest19", deltest19); torture_suite_add_2smb_test(suite, "deltest20", deltest20); + torture_suite_add_2smb_test(suite, "deltest20a", deltest20a); torture_suite_add_simple_test(suite, "deltest21", deltest21); torture_suite_add_simple_test(suite, "deltest22", deltest22); -- cgit From 6223ae4015075d92549a271ee90a8092d4eab3a2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 23 May 2007 23:11:16 +0000 Subject: r23103: Add a torture test for the insane semantics Steve's cifsfs client uses so we don't regress :-). Jeremy. (This used to be commit 5ce41ae40c5413bb9f15d1c47a095f63d7f167e0) --- source4/torture/basic/delete.c | 104 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index fbeec05d27..888a22a4c6 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -1257,6 +1257,109 @@ static bool deltest20a(struct torture_context *tctx, struct smbcli_state *cli1, return correct; } +/* Test 20b ... */ +static bool deltest20b(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + int fnum1 = -1; + int fnum2 = -1; + bool correct = True; + + del_clean_area(cli1, cli2); + + /* Test 20a. */ + + /* Ensure the file doesn't already exist. */ + smbcli_close(cli1->tree, fnum1); + smbcli_close(cli1->tree, fnum2); + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + smbcli_setatr(cli1->tree, fname_new, 0, 0); + smbcli_unlink(cli1->tree, fname_new); + + /* Firstly open and create with all access */ + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SEC_RIGHTS_FILE_ALL, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_CREATE, + 0, 0); + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); + + /* And close - just to create the file. */ + smbcli_close(cli1->tree, fnum1); + + /* Firstly open and create with all access */ + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SEC_RIGHTS_FILE_ALL, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, + 0, 0); + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); + + /* Next open with all access, but add delete on close. */ + fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, + SEC_RIGHTS_FILE_ALL, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, + NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); + + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 2 of %s failed (%s)", + fname, smbcli_errstr(cli2->tree))); + + /* The delete on close bit is *not* reported as being set. */ + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + + smbcli_close(cli1->tree, fnum1); + + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + + /* Rename the file by handle. */ + + { + union smb_setfileinfo sfinfo; + NTSTATUS status; + + memset(&sfinfo, '\0', sizeof(sfinfo)); + sfinfo.generic.level = RAW_SFILEINFO_RENAME_INFORMATION; + sfinfo.generic.in.file.fnum = fnum2; + sfinfo.rename_information.in.root_fid = 0; + /* Don't start the filename with '\\', we get NT_STATUS_NOT_SUPPORTED if so. */ + sfinfo.rename_information.in.new_name = fname_new + 1; + sfinfo.rename_information.in.overwrite = 1; + + status = smb_raw_setfileinfo(cli2->tree, &sfinfo); + + torture_assert_ntstatus_equal(tctx,status,NT_STATUS_OK,talloc_asprintf(tctx, "rename of %s to %s failed (%s)", + fname, fname_new, smbcli_errstr(cli2->tree))); + } + + correct &= check_delete_on_close(tctx, cli2, fnum2, fname_new, False, __location__); + + smbcli_close(cli2->tree, fnum2); + + /* See if the file is deleted - should be.... */ + fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); + torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail) - %s", + fname, smbcli_errstr(cli1->tree))); + fnum1 = smbcli_open(cli1->tree, fname_new, O_RDWR, DENY_NONE); + torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail) - %s", + fname_new, smbcli_errstr(cli1->tree))); + + return correct; +} + + /* Test 21 ... */ static bool deltest21(struct torture_context *tctx) { @@ -1428,6 +1531,7 @@ struct torture_suite *torture_test_delete(void) torture_suite_add_2smb_test(suite, "deltest19", deltest19); torture_suite_add_2smb_test(suite, "deltest20", deltest20); torture_suite_add_2smb_test(suite, "deltest20a", deltest20a); + torture_suite_add_2smb_test(suite, "deltest20b", deltest20b); torture_suite_add_simple_test(suite, "deltest21", deltest21); torture_suite_add_simple_test(suite, "deltest22", deltest22); -- cgit From 45afb4fdb03a6c9fb22582f67b427a0431a08194 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 23 May 2007 23:14:48 +0000 Subject: r23104: Add comment explaining the new test. Jeremy. (This used to be commit 7b9b5c59a4ac2afca151ba12eba7c808057a677e) --- source4/torture/basic/delete.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 888a22a4c6..eb23a894ee 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -1258,6 +1258,12 @@ static bool deltest20a(struct torture_context *tctx, struct smbcli_state *cli1, } /* Test 20b ... */ +/* This is the delete semantics that the cifsfs client depends on when + * trying to delete an open file on a Windows server. It + * opens a file with initial delete on close set, renames it then closes + * all open handles. The file goes away on Windows. + */ + static bool deltest20b(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; @@ -1266,7 +1272,7 @@ static bool deltest20b(struct torture_context *tctx, struct smbcli_state *cli1, del_clean_area(cli1, cli2); - /* Test 20a. */ + /* Test 20b. */ /* Ensure the file doesn't already exist. */ smbcli_close(cli1->tree, fnum1); -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/torture/basic/delete.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index eb23a894ee..93b282272f 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 2151cde58014ea2e822c13d2f8a369b45dc19ca8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:28:14 +0000 Subject: r25554: Convert last instances of BOOL, True and False to the standard types. (This used to be commit 566aa14139510788548a874e9213d91317f83ca9) --- source4/torture/basic/delete.c | 172 ++++++++++++++++++++--------------------- 1 file changed, 86 insertions(+), 86 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 93b282272f..38528cd845 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -144,7 +144,7 @@ static bool deltest1(struct torture_context *tctx, struct smbcli_state *cli1, st torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail)", fname)); - return True; + return true; } /* Test 2 - this should delete the file on close. */ @@ -163,7 +163,7 @@ static bool deltest2(struct torture_context *tctx, struct smbcli_state *cli1, st talloc_asprintf(tctx, "open of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); - torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, true), talloc_asprintf(tctx, "setting delete_on_close failed (%s)", smbcli_errstr(cli1->tree))); @@ -178,7 +178,7 @@ static bool deltest2(struct torture_context *tctx, struct smbcli_state *cli1, st if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - return False; + return false; } smbcli_unlink(cli1->tree, fname); } @@ -227,7 +227,7 @@ static bool deltest3(struct torture_context *tctx, struct smbcli_state *cli1, st fname, smbcli_errstr(cli1->tree))); torture_assert_ntstatus_ok(tctx, - smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + smbcli_nt_delete_on_close(cli1->tree, fnum1, true), talloc_asprintf(tctx, "setting delete_on_close failed (%s)", smbcli_errstr(cli1->tree))); @@ -250,9 +250,9 @@ static bool deltest3(struct torture_context *tctx, struct smbcli_state *cli1, st __location__, smbcli_errstr(cli1->tree)); } smbcli_unlink(cli1->tree, fname); - return False; + return false; } - return True; + return true; } /* Test 4 ... */ @@ -260,7 +260,7 @@ static bool deltest4(struct torture_context *tctx, struct smbcli_state *cli1, st { int fnum1 = -1; int fnum2 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -292,7 +292,7 @@ static bool deltest4(struct torture_context *tctx, struct smbcli_state *cli1, st smbcli_errstr(cli1->tree))); torture_assert_ntstatus_ok(tctx, - smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + smbcli_nt_delete_on_close(cli1->tree, fnum1, true), talloc_asprintf(tctx, "setting delete_on_close failed (%s)", smbcli_errstr(cli1->tree))); @@ -328,13 +328,13 @@ static bool deltest5(struct torture_context *tctx, struct smbcli_state *cli1, st /* This should fail - only allowed on NT opens with DELETE access. */ - torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True)), + torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, true)), "setting delete_on_close on OpenX file succeeded - should fail !"); torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli1->tree))); - return True; + return true; } /* Test 6 ... */ @@ -358,7 +358,7 @@ static bool deltest6(struct torture_context *tctx, struct smbcli_state *cli1, st /* This should fail - only allowed on NT opens with DELETE access. */ torture_assert(tctx, - !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True)), + !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, true)), "setting delete_on_close on file with no delete access succeeded - should fail !"); torture_assert_ntstatus_ok(tctx, @@ -366,14 +366,14 @@ static bool deltest6(struct torture_context *tctx, struct smbcli_state *cli1, st talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli1->tree))); - return True; + return true; } /* Test 7 ... */ static bool deltest7(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -387,16 +387,16 @@ static bool deltest7(struct torture_context *tctx, struct smbcli_state *cli1, st torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); - torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, true), "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, true, __location__); torture_assert_ntstatus_ok(tctx, - smbcli_nt_delete_on_close(cli1->tree, fnum1, False), + smbcli_nt_delete_on_close(cli1->tree, fnum1, false), "unsetting delete_on_close on file failed !"); - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__); torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli1->tree))); @@ -419,7 +419,7 @@ static bool deltest8(struct torture_context *tctx, struct smbcli_state *cli1, st { int fnum1 = -1; int fnum2 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -447,18 +447,18 @@ static bool deltest8(struct torture_context *tctx, struct smbcli_state *cli1, st fname, smbcli_errstr(cli1->tree))); torture_assert_ntstatus_ok(tctx, - smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + smbcli_nt_delete_on_close(cli1->tree, fnum1, true), "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, true, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, true, __location__); torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), talloc_asprintf(tctx, "close - 1 failed (%s)", smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(tctx, cli1, -1, fname, True, __location__); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, -1, fname, true, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, true, __location__); torture_assert_ntstatus_ok(tctx, smbcli_close(cli2->tree, fnum2), talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli2->tree))); @@ -490,7 +490,7 @@ static bool deltest9(struct torture_context *tctx, struct smbcli_state *cli1, st talloc_asprintf(tctx, "open of %s succeeded should have failed!", fname)); - return True; + return true; } /* Test 10 ... */ @@ -544,7 +544,7 @@ static bool deltest11(struct torture_context *tctx, struct smbcli_state *cli1, s torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); - status = smbcli_nt_delete_on_close(cli1->tree, fnum1, True); + status = smbcli_nt_delete_on_close(cli1->tree, fnum1, true); torture_assert_ntstatus_equal(tctx, status, NT_STATUS_CANNOT_DELETE, talloc_asprintf(tctx, "setting delete_on_close should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)", smbcli_errstr(cli1->tree))); @@ -553,7 +553,7 @@ static bool deltest11(struct torture_context *tctx, struct smbcli_state *cli1, s talloc_asprintf(tctx, "close failed (%s)", smbcli_errstr(cli1->tree))); - return True; + return true; } /* Test 12 ... */ @@ -593,7 +593,7 @@ static bool deltest13(struct torture_context *tctx, struct smbcli_state *cli1, s { int fnum1 = -1; int fnum2 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -631,18 +631,18 @@ static bool deltest13(struct torture_context *tctx, struct smbcli_state *cli1, s torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, - True), + true), "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, true, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, true, __location__); torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli2->tree, fnum2, - False), + false), "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__); torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), talloc_asprintf(tctx, "close - 1 failed (%s)", @@ -684,10 +684,10 @@ static bool deltest14(struct torture_context *tctx, struct smbcli_state *cli1, s torture_assert(tctx, dnum1 != -1, talloc_asprintf(tctx, "open of %s failed: %s!", dname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(tctx, cli1, dnum1, dname, False, __location__); - torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, True), + correct &= check_delete_on_close(tctx, cli1, dnum1, dname, false, __location__); + torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, true), "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(tctx, cli1, dnum1, dname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, dnum1, dname, true, __location__); smbcli_close(cli1->tree, dnum1); /* Now it should be gone... */ @@ -751,7 +751,7 @@ static bool deltest15(struct torture_context *tctx, struct smbcli_state *cli1, s talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname_new, smbcli_errstr(cli1->tree))); - status = smbcli_nt_delete_on_close(cli2->tree, fnum2, True); + status = smbcli_nt_delete_on_close(cli2->tree, fnum2, true); torture_assert_ntstatus_ok(tctx, status, "setting delete_on_close on file failed !"); @@ -761,7 +761,7 @@ static bool deltest15(struct torture_context *tctx, struct smbcli_state *cli1, s /* The file should be around under the new name, there's a second * handle open */ - correct &= check_delete_on_close(tctx, cli1, fnum1, fname_new, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname_new, true, __location__); fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_GENERIC_ALL, @@ -775,7 +775,7 @@ static bool deltest15(struct torture_context *tctx, struct smbcli_state *cli1, s torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__); smbcli_close(cli2->tree, fnum2); smbcli_close(cli1->tree, fnum1); @@ -840,11 +840,11 @@ static bool deltest16(struct torture_context *tctx, struct smbcli_state *cli1, s torture_assert (tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(tctx, cli1, -1, fname, False, __location__); - correct &= check_delete_on_close(tctx, cli2, -1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, -1, fname, false, __location__); + correct &= check_delete_on_close(tctx, cli2, -1, fname, false, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, @@ -860,15 +860,15 @@ static bool deltest16(struct torture_context *tctx, struct smbcli_state *cli1, s torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); - correct &= check_delete_on_close(tctx, cli1, -1, fname, False, __location__); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); - correct &= check_delete_on_close(tctx, cli2, -1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__); + correct &= check_delete_on_close(tctx, cli1, -1, fname, false, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__); + correct &= check_delete_on_close(tctx, cli2, -1, fname, false, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__); - correct &= check_delete_on_close(tctx, cli2, -1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, true, __location__); + correct &= check_delete_on_close(tctx, cli2, -1, fname, true, __location__); smbcli_close(cli2->tree, fnum2); @@ -885,7 +885,7 @@ static bool deltest17(struct torture_context *tctx, struct smbcli_state *cli1, s { int fnum1 = -1; int fnum2 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -926,7 +926,7 @@ static bool deltest17(struct torture_context *tctx, struct smbcli_state *cli1, s fname, smbcli_errstr(cli1->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, @@ -944,12 +944,12 @@ static bool deltest17(struct torture_context *tctx, struct smbcli_state *cli1, s fname, smbcli_errstr(cli1->tree))); /* still not reported as being set on either */ - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); - correct &= check_delete_on_close(tctx, cli1, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, fname, false, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(tctx, cli1, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, fname, false, __location__); smbcli_close(cli1->tree, fnum2); @@ -966,7 +966,7 @@ static bool deltest18(struct torture_context *tctx, struct smbcli_state *cli1, s { int fnum1 = -1; int fnum2 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -994,7 +994,7 @@ static bool deltest18(struct torture_context *tctx, struct smbcli_state *cli1, s dname, smbcli_errstr(cli1->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(tctx, cli1, fnum1, dname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, dname, false, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli1->tree, dname, 0, @@ -1011,12 +1011,12 @@ static bool deltest18(struct torture_context *tctx, struct smbcli_state *cli1, s torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", dname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(tctx, cli1, fnum1, dname, False, __location__); - correct &= check_delete_on_close(tctx, cli1, fnum2, dname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, dname, false, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, dname, false, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(tctx, cli1, fnum2, dname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, dname, true, __location__); smbcli_close(cli1->tree, fnum2); @@ -1040,7 +1040,7 @@ static bool deltest19(struct torture_context *tctx, struct smbcli_state *cli1, s { int fnum1 = -1; int fnum2 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -1082,7 +1082,7 @@ static bool deltest19(struct torture_context *tctx, struct smbcli_state *cli1, s talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(tctx, cli1, fnum1, dname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, dname, false, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli1->tree, dname, 0, @@ -1100,7 +1100,7 @@ static bool deltest19(struct torture_context *tctx, struct smbcli_state *cli1, s smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(tctx, cli1, fnum2, dname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, dname, true, __location__); smbcli_close(cli1->tree, fnum2); @@ -1127,15 +1127,15 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s { int fnum1 = -1; int dnum1 = -1; - bool correct = True; + bool correct = true; NTSTATUS status; del_clean_area(cli1, cli2); /* Test 20 -- non-empty directory hardest to get right... */ - if (torture_setting_bool(tctx, "samba3", False)) { - return True; + if (torture_setting_bool(tctx, "samba3", false)) { + return true; } smbcli_deltree(cli1->tree, dname); @@ -1153,8 +1153,8 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s torture_assert(tctx, dnum1 != -1, talloc_asprintf(tctx, "open of %s failed: %s!", dname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(tctx, cli1, dnum1, dname, False, __location__); - status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True); + correct &= check_delete_on_close(tctx, cli1, dnum1, dname, false, __location__); + status = smbcli_nt_delete_on_close(cli1->tree, dnum1, true); { char *fullname; @@ -1172,7 +1172,7 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s "smbcli_open failed"); } - status = smbcli_nt_delete_on_close(cli1->tree, dnum1, False); + status = smbcli_nt_delete_on_close(cli1->tree, dnum1, false); torture_assert_ntstatus_ok(tctx, status, "setting delete_on_close on file failed !"); @@ -1187,7 +1187,7 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s smbcli_close(cli1->tree, fnum1); } - status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True); + status = smbcli_nt_delete_on_close(cli1->tree, dnum1, true); torture_assert_ntstatus_equal(tctx, status, NT_STATUS_DIRECTORY_NOT_EMPTY, "setting delete_on_close failed"); @@ -1201,7 +1201,7 @@ static bool deltest20a(struct torture_context *tctx, struct smbcli_state *cli1, { int fnum1 = -1; int fnum2 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -1239,12 +1239,12 @@ static bool deltest20a(struct torture_context *tctx, struct smbcli_state *cli1, fname, smbcli_errstr(cli2->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__); smbcli_close(cli2->tree, fnum2); @@ -1267,7 +1267,7 @@ static bool deltest20b(struct torture_context *tctx, struct smbcli_state *cli1, { int fnum1 = -1; int fnum2 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -1322,12 +1322,12 @@ static bool deltest20b(struct torture_context *tctx, struct smbcli_state *cli1, fname, smbcli_errstr(cli2->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__); /* Rename the file by handle. */ @@ -1349,7 +1349,7 @@ static bool deltest20b(struct torture_context *tctx, struct smbcli_state *cli1, fname, fname_new, smbcli_errstr(cli2->tree))); } - correct &= check_delete_on_close(tctx, cli2, fnum2, fname_new, False, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname_new, false, __location__); smbcli_close(cli2->tree, fnum2); @@ -1371,13 +1371,13 @@ static bool deltest21(struct torture_context *tctx) int fnum1 = -1; struct smbcli_state *cli1; struct smbcli_state *cli2; - bool correct = True; + bool correct = true; if (!torture_open_connection(&cli1, 0)) - return False; + return false; if (!torture_open_connection(&cli2, 1)) - return False; + return false; del_clean_area(cli1, cli2); @@ -1392,12 +1392,12 @@ static bool deltest21(struct torture_context *tctx) fname, smbcli_errstr(cli1->tree))); torture_assert_ntstatus_ok(tctx, - smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + smbcli_nt_delete_on_close(cli1->tree, fnum1, true), talloc_asprintf(tctx, "setting delete_on_close failed (%s)", smbcli_errstr(cli1->tree))); /* Ensure delete on close is set. */ - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, true, __location__); /* Now yank the rug from under cli1. */ smbcli_transport_dead(cli1->transport, NT_STATUS_LOCAL_DISCONNECT); @@ -1405,7 +1405,7 @@ static bool deltest21(struct torture_context *tctx) fnum1 = -1; if (!torture_open_connection(&cli1, 0)) { - return False; + return false; } /* On slow build farm machines it might happen that they are not fast @@ -1438,10 +1438,10 @@ static bool deltest22(struct torture_context *tctx) int dnum1 = -1; int dnum2 = -1; struct smbcli_state *cli1; - bool correct = True; + bool correct = true; if (!torture_open_connection(&cli1, 0)) - return False; + return false; smbcli_deltree(cli1->tree, dname); @@ -1480,7 +1480,7 @@ static bool deltest22(struct torture_context *tctx) dname, smbcli_errstr(cli1->tree))); torture_assert_ntstatus_ok( - tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, True), + tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, true), talloc_asprintf(tctx, "setting delete_on_close failed (%s)", smbcli_errstr(cli1->tree))); -- cgit From 0a2f1a46a02d2c9497d05d7e534829dc6e9430dc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Dec 2007 15:53:07 +0100 Subject: r26249: Remove a couple more uses of global_loadparm. (This used to be commit 80a61200508a00d5b16a3e748ce92d54b9fefcd2) --- source4/torture/basic/delete.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 38528cd845..8b84880c06 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -1373,10 +1373,10 @@ static bool deltest21(struct torture_context *tctx) struct smbcli_state *cli2; bool correct = true; - if (!torture_open_connection(&cli1, 0)) + if (!torture_open_connection(&cli1, tctx, 0)) return false; - if (!torture_open_connection(&cli2, 1)) + if (!torture_open_connection(&cli2, tctx, 1)) return false; del_clean_area(cli1, cli2); @@ -1404,7 +1404,7 @@ static bool deltest21(struct torture_context *tctx) fnum1 = -1; - if (!torture_open_connection(&cli1, 0)) { + if (!torture_open_connection(&cli1, tctx, 0)) { return false; } @@ -1440,7 +1440,7 @@ static bool deltest22(struct torture_context *tctx) struct smbcli_state *cli1; bool correct = true; - if (!torture_open_connection(&cli1, 0)) + if (!torture_open_connection(&cli1, tctx, 0)) return false; smbcli_deltree(cli1->tree, dname); -- cgit From afe3e8172ddaa5e4aa811faceecda4f943d6e2ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 04:53:27 +0200 Subject: Install public header files again and include required prototypes. (This used to be commit 47ffbbf67435904754469544390b67d34c958343) --- source4/torture/basic/delete.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/basic/delete.c') diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 8b84880c06..b71c85aeb8 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -25,6 +25,7 @@ #include "torture/util.h" #include "system/filesys.h" #include "libcli/raw/libcliraw.h" +#include "libcli/raw/raw_proto.h" #include "torture/raw/proto.h" -- cgit