summaryrefslogtreecommitdiff
path: root/source4/torture/raw
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-08-13 02:04:44 +0000
committerAndrew Tridgell <tridge@samba.org>2003-08-13 02:04:44 +0000
commitd2b5b80c951faf9cf0abc66dab14b73b1096734d (patch)
tree8747186353a780b4ef08dc7002e54bf3d50e1ae8 /source4/torture/raw
parent9665caf83276aa8a3115db69342e898fb7b39172 (diff)
downloadsamba-d2b5b80c951faf9cf0abc66dab14b73b1096734d.tar.gz
samba-d2b5b80c951faf9cf0abc66dab14b73b1096734d.tar.bz2
samba-d2b5b80c951faf9cf0abc66dab14b73b1096734d.zip
- cope with servers that don't properly implement SMBexit
- add the pidhigh test to the locking test - expand the rename and unlink testing - test a wider range of offsets in RAW-READ (This used to be commit ef819249ec9849b4609f82a5c882e40c96a51fa2)
Diffstat (limited to 'source4/torture/raw')
-rw-r--r--source4/torture/raw/lock.c89
-rw-r--r--source4/torture/raw/read.c1
-rw-r--r--source4/torture/raw/setfileinfo.c44
-rw-r--r--source4/torture/raw/unlink.c10
-rw-r--r--source4/torture/raw/write.c42
5 files changed, 166 insertions, 20 deletions
diff --git a/source4/torture/raw/lock.c b/source4/torture/raw/lock.c
index b0b0b56451..56dc1ec163 100644
--- a/source4/torture/raw/lock.c
+++ b/source4/torture/raw/lock.c
@@ -133,6 +133,7 @@ static BOOL test_lock(struct cli_state *cli, TALLOC_CTX *mem_ctx)
CHECK_STATUS(status, NT_STATUS_OK);
done:
+ cli_close(cli, fnum);
smb_raw_exit(cli->session);
cli_deltree(cli, BASEDIR);
return ret;
@@ -181,6 +182,90 @@ static BOOL test_lockx(struct cli_state *cli, TALLOC_CTX *mem_ctx)
CHECK_STATUS(status, NT_STATUS_OK);
done:
+ cli_close(cli, fnum);
+ smb_raw_exit(cli->session);
+ cli_deltree(cli, BASEDIR);
+ return ret;
+}
+
+
+/*
+ test high pid
+*/
+static BOOL test_pidhigh(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+{
+ union smb_lock io;
+ struct smb_lock_entry lock[1];
+ NTSTATUS status;
+ BOOL ret = True;
+ int fnum;
+ const char *fname = BASEDIR "\\test.txt";
+ char c = 1;
+
+ if (cli_deltree(cli, BASEDIR) == -1 ||
+ !cli_mkdir(cli, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ return False;
+ }
+
+ printf("Testing high pid\n");
+ io.generic.level = RAW_LOCK_LOCKX;
+
+ cli->session->pid = 1;
+
+ fnum = cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE);
+ if (fnum == -1) {
+ printf("Failed to create %s - %s\n", fname, cli_errstr(cli));
+ ret = False;
+ goto done;
+ }
+
+ if (cli_write(cli, fnum, 0, &c, 0, 1) != 1) {
+ printf("Failed to write 1 byte - %s\n", cli_errstr(cli));
+ ret = False;
+ goto done;
+ }
+
+ io.lockx.level = RAW_LOCK_LOCKX;
+ io.lockx.in.fnum = fnum;
+ io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
+ io.lockx.in.timeout = 0;
+ io.lockx.in.ulock_cnt = 0;
+ io.lockx.in.lock_cnt = 1;
+ lock[0].pid = cli->session->pid;
+ lock[0].offset = 0;
+ lock[0].count = 0xFFFFFFFF;
+ io.lockx.in.locks = &lock[0];
+ status = smb_raw_lock(cli->tree, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ if (cli_read(cli, fnum, &c, 0, 1) != 1) {
+ printf("Failed to read 1 byte - %s\n", cli_errstr(cli));
+ ret = False;
+ goto done;
+ }
+
+ cli->session->pid |= 0x10000;
+
+ cli->session->pid = 2;
+
+ if (cli_read(cli, fnum, &c, 0, 1) == 1) {
+ printf("pid is incorrect handled for read with lock!\n");
+ ret = False;
+ goto done;
+ }
+
+ cli->session->pid = 0x10001;
+
+ if (cli_read(cli, fnum, &c, 0, 1) != 1) {
+ printf("High pid is used on this server!\n");
+ ret = False;
+ } else {
+ printf("High pid is not used on this server (correct)\n");
+ }
+
+done:
+ cli_close(cli, fnum);
smb_raw_exit(cli->session);
cli_deltree(cli, BASEDIR);
return ret;
@@ -210,6 +295,10 @@ BOOL torture_raw_lock(int dummy)
ret = False;
}
+ if (!test_pidhigh(cli, mem_ctx)) {
+ ret = False;
+ }
+
torture_close_connection(cli);
talloc_destroy(mem_ctx);
return ret;
diff --git a/source4/torture/raw/read.c b/source4/torture/raw/read.c
index c231f52c9d..50b3e0f2fb 100644
--- a/source4/torture/raw/read.c
+++ b/source4/torture/raw/read.c
@@ -192,6 +192,7 @@ static BOOL test_read(struct cli_state *cli, TALLOC_CTX *mem_ctx)
done:
+ cli_close(cli, fnum);
smb_raw_exit(cli->session);
cli_deltree(cli, BASEDIR);
return ret;
diff --git a/source4/torture/raw/setfileinfo.c b/source4/torture/raw/setfileinfo.c
index c169895020..0048f2e1b0 100644
--- a/source4/torture/raw/setfileinfo.c
+++ b/source4/torture/raw/setfileinfo.c
@@ -31,7 +31,7 @@ BOOL torture_raw_sfileinfo(int dummy)
struct cli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
- int fnum = -1;
+ int fnum_saved, fnum2, fnum = -1;
char *fnum_fname;
char *fnum_fname_new;
char *path_fname;
@@ -406,7 +406,7 @@ BOOL torture_raw_sfileinfo(int dummy)
CHECK_CALL_PATH(MODE_INFORMATION, NT_STATUS_OK);
CHECK_VALUE(MODE_INFORMATION, mode_information, mode, 0);
-
+#if 1
printf("finally the rename_information level\n");
cli_close(cli, create_complex_file(cli, mem_ctx, fnum_fname_new));
cli_close(cli, create_complex_file(cli, mem_ctx, path_fname_new));
@@ -424,7 +424,46 @@ BOOL torture_raw_sfileinfo(int dummy)
CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK);
CHECK_STR(NAME_INFO, name_info, fname.s, fnum_fname_new);
+ printf("Trying rename with dest file open\n");
+ fnum2 = create_complex_file(cli, mem_ctx, fnum_fname);
+ sfinfo.rename_information.in.new_name = fnum_fname+strlen(BASEDIR)+1;
+ sfinfo.rename_information.in.overwrite = 1;
+ CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_ACCESS_DENIED);
+ CHECK_STR(NAME_INFO, name_info, fname.s, fnum_fname_new);
+
+ fnum_saved = fnum;
+ fnum = fnum2;
+ sfinfo.disposition_info.in.delete_on_close = 1;
+ CHECK_CALL_FNUM(DISPOSITION_INFO, NT_STATUS_OK);
+ fnum = fnum_saved;
+
+ printf("Trying rename with dest file open and delete_on_close\n");
+ CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_ACCESS_DENIED);
+
+ cli_close(cli, fnum2);
+ CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK);
+ CHECK_STR(NAME_INFO, name_info, fname.s, fnum_fname);
+
+ printf("Trying rename with source file open twice\n");
+ sfinfo.rename_information.in.new_name = fnum_fname+strlen(BASEDIR)+1;
+ sfinfo.rename_information.in.overwrite = 1;
+ CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK);
+ CHECK_STR(NAME_INFO, name_info, fname.s, fnum_fname);
+
+ fnum2 = create_complex_file(cli, mem_ctx, fnum_fname);
+ sfinfo.rename_information.in.new_name = fnum_fname_new+strlen(BASEDIR)+1;
+ sfinfo.rename_information.in.overwrite = 0;
+ CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK);
+ CHECK_STR(NAME_INFO, name_info, fname.s, fnum_fname_new);
+ cli_close(cli, fnum2);
+
+ sfinfo.rename_information.in.new_name = fnum_fname+strlen(BASEDIR)+1;
+ sfinfo.rename_information.in.overwrite = 0;
+ CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK);
+ CHECK_STR(NAME_INFO, name_info, fname.s, fnum_fname);
+
sfinfo.rename_information.in.new_name = path_fname_new+strlen(BASEDIR)+1;
+ sfinfo.rename_information.in.overwrite = 1;
CHECK_CALL_PATH(RENAME_INFORMATION, NT_STATUS_OK);
CHECK_STR(NAME_INFO, name_info, fname.s, path_fname_new);
@@ -435,6 +474,7 @@ BOOL torture_raw_sfileinfo(int dummy)
sfinfo.rename_information.in.new_name = path_fname+strlen(BASEDIR)+1;
CHECK_CALL_PATH(RENAME_INFORMATION, NT_STATUS_OK);
CHECK_STR(NAME_INFO, name_info, fname.s, path_fname);
+#endif
#if 0
printf("test unix_basic level\n");
diff --git a/source4/torture/raw/unlink.c b/source4/torture/raw/unlink.c
index 9cae91fe41..889e25777c 100644
--- a/source4/torture/raw/unlink.c
+++ b/source4/torture/raw/unlink.c
@@ -90,6 +90,16 @@ static BOOL test_unlink(struct cli_state *cli, TALLOC_CTX *mem_ctx)
status = smb_raw_unlink(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD);
+ io.in.pattern = "\\..";
+ io.in.attrib = 0;
+ status = smb_raw_unlink(cli->tree, &io);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD);
+
+ io.in.pattern = BASEDIR "\\..";
+ io.in.attrib = 0;
+ status = smb_raw_unlink(cli->tree, &io);
+ CHECK_STATUS(status, NT_STATUS_FILE_IS_A_DIRECTORY);
+
printf("Trying wildcards\n");
cli_close(cli, cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE));
io.in.pattern = BASEDIR "\\t*.t";
diff --git a/source4/torture/raw/write.c b/source4/torture/raw/write.c
index 117b322530..644a5579c8 100644
--- a/source4/torture/raw/write.c
+++ b/source4/torture/raw/write.c
@@ -198,6 +198,7 @@ static BOOL test_write(struct cli_state *cli, TALLOC_CTX *mem_ctx)
CHECK_BUFFER(buf, seed, 4000);
done:
+ cli_close(cli, fnum);
smb_raw_exit(cli->session);
cli_deltree(cli, BASEDIR);
return ret;
@@ -212,7 +213,7 @@ static BOOL test_writex(struct cli_state *cli, TALLOC_CTX *mem_ctx)
union smb_write io;
NTSTATUS status;
BOOL ret = True;
- int fnum;
+ int fnum, i;
char *buf;
const int maxsize = 90000;
const char *fname = BASEDIR "\\test.txt";
@@ -346,29 +347,32 @@ static BOOL test_writex(struct cli_state *cli, TALLOC_CTX *mem_ctx)
}
CHECK_BUFFER(buf, seed, 4000);
- printf("Trying 2^43 offset\n");
- setup_buffer(buf, seed+1, maxsize);
- io.writex.in.fnum = fnum;
- io.writex.in.count = 4000;
- io.writex.in.offset = ((SMB_BIG_UINT)1) << 43;
- io.writex.in.data = buf;
- status = smb_raw_write(cli->tree, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VALUE(io.writex.out.nwritten, 4000);
- CHECK_ALL_INFO(io.writex.in.count + (SMB_BIG_UINT)io.writex.in.offset, size);
-
- memset(buf, 0, maxsize);
- if (cli_read(cli, fnum, buf, io.writex.in.offset, 4000) != 4000) {
- printf("read failed at %d\n", __LINE__);
- ret = False;
- goto done;
+ for (i=33;i<64;i++) {
+ printf("Trying 2^%d offset\n", i);
+ setup_buffer(buf, seed+1, maxsize);
+ io.writex.in.fnum = fnum;
+ io.writex.in.count = 4000;
+ io.writex.in.offset = ((SMB_BIG_UINT)1) << i;
+ io.writex.in.data = buf;
+ status = smb_raw_write(cli->tree, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VALUE(io.writex.out.nwritten, 4000);
+ CHECK_ALL_INFO(io.writex.in.count + (SMB_BIG_UINT)io.writex.in.offset, size);
+
+ memset(buf, 0, maxsize);
+ if (cli_read(cli, fnum, buf, io.writex.in.offset, 4000) != 4000) {
+ printf("read failed at %d\n", __LINE__);
+ ret = False;
+ goto done;
+ }
+ CHECK_BUFFER(buf, seed+1, 4000);
}
- CHECK_BUFFER(buf, seed+1, 4000);
setup_buffer(buf, seed, maxsize);
done:
+ cli_close(cli, fnum);
smb_raw_exit(cli->session);
cli_deltree(cli, BASEDIR);
return ret;
@@ -507,6 +511,7 @@ static BOOL test_writeunlock(struct cli_state *cli, TALLOC_CTX *mem_ctx)
CHECK_BUFFER(buf, seed, 4000);
done:
+ cli_close(cli, fnum);
smb_raw_exit(cli->session);
cli_deltree(cli, BASEDIR);
return ret;
@@ -659,6 +664,7 @@ static BOOL test_writeclose(struct cli_state *cli, TALLOC_CTX *mem_ctx)
CHECK_BUFFER(buf, seed, 4000);
done:
+ cli_close(cli, fnum);
smb_raw_exit(cli->session);
cli_deltree(cli, BASEDIR);
return ret;