summaryrefslogtreecommitdiff
path: root/source4/torture/basic
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-11-06 09:12:53 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:05:33 -0500
commita9158e0d47636e25ce374391cd9b02df3d27b390 (patch)
tree3724958af5445d10da788f83459b8a3f18b51a81 /source4/torture/basic
parent439c1524fba3b58abe9e353f9ff2bd7f103f3d12 (diff)
downloadsamba-a9158e0d47636e25ce374391cd9b02df3d27b390.tar.gz
samba-a9158e0d47636e25ce374391cd9b02df3d27b390.tar.bz2
samba-a9158e0d47636e25ce374391cd9b02df3d27b390.zip
r3574: the RAW-OPEN test changes broke a couple of the other tests. This
fixes most of them, although RAW-SEARCH still fails (due to an interaction with the new xattr code) (This used to be commit 09b4652b40c4cfca027765178bd5a0adbaa666c2)
Diffstat (limited to 'source4/torture/basic')
-rw-r--r--source4/torture/basic/locking.c6
-rw-r--r--source4/torture/basic/unlink.c107
2 files changed, 111 insertions, 2 deletions
diff --git a/source4/torture/basic/locking.c b/source4/torture/basic/locking.c
index aea94bd5a1..c1dd598018 100644
--- a/source4/torture/basic/locking.c
+++ b/source4/torture/basic/locking.c
@@ -55,7 +55,8 @@ BOOL torture_locktest1(void)
}
fnum2 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
- printf("open2 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
+ printf("(%s) open2 of %s failed (%s)\n",
+ __location__, fname, smbcli_errstr(cli1->tree));
return False;
}
fnum3 = smbcli_open(cli2->tree, fname, O_RDWR, DENY_NONE);
@@ -213,7 +214,8 @@ BOOL torture_locktest2(void)
fnum2 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
- printf("open2 of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
+ printf("(%s) open2 of %s failed (%s)\n",
+ __location__, fname, smbcli_errstr(cli->tree));
return False;
}
diff --git a/source4/torture/basic/unlink.c b/source4/torture/basic/unlink.c
new file mode 100644
index 0000000000..dd2ff5a5c5
--- /dev/null
+++ b/source4/torture/basic/unlink.c
@@ -0,0 +1,107 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ unlink tester
+
+ 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"
+#include "libcli/raw/libcliraw.h"
+
+/*
+ This test checks that
+
+ 1) the server does not allow an unlink on a file that is open
+*/
+BOOL torture_unlinktest(void)
+{
+ struct smbcli_state *cli;
+ const char *fname = "\\unlink.tst";
+ int fnum;
+ BOOL correct = True;
+ union smb_open io;
+ NTSTATUS status;
+
+ if (!torture_open_connection(&cli)) {
+ return False;
+ }
+
+ printf("starting unlink test\n");
+
+ smbcli_unlink(cli->tree, fname);
+
+ cli->session->pid = 1;
+
+ printf("Opening a file\n");
+
+ fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ if (fnum == -1) {
+ printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
+ return False;
+ }
+
+ printf("Unlinking a open file\n");
+
+ if (NT_STATUS_IS_OK(smbcli_unlink(cli->tree, fname))) {
+ printf("(%s) error: server allowed unlink on an open file\n", __location__);
+ correct = False;
+ } else {
+ correct = check_error(__location__, cli, ERRDOS, ERRbadshare,
+ NT_STATUS_SHARING_VIOLATION);
+ }
+
+ smbcli_close(cli->tree, fnum);
+ smbcli_unlink(cli->tree, fname);
+
+ printf("testing unlink after ntcreatex with DELETE access\n");
+
+ io.ntcreatex.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
+ io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_NON_DIRECTORY_FILE;
+ io.ntcreatex.in.file_attr = 0;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_IMPERSONATION;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE;
+ io.ntcreatex.in.access_mask = GENERIC_RIGHTS_FILE_ALL_ACCESS;
+
+ status = smb_raw_open(cli->tree, cli, &io);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("(%s) failed to open %s\n", __location__, fname);
+ }
+ if (NT_STATUS_IS_OK(smbcli_unlink(cli->tree, fname))) {
+ printf("(%s) error: server allowed unlink on an open file\n", __location__);
+ correct = False;
+ } else {
+ correct = check_error(__location__, cli, ERRDOS, ERRbadshare,
+ NT_STATUS_SHARING_VIOLATION);
+ }
+
+ if (!torture_close_connection(cli)) {
+ correct = False;
+ }
+
+ printf("unlink test finished\n");
+
+ return correct;
+}
+
+