summaryrefslogtreecommitdiff
path: root/source4/torture/raw
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-01-08 14:14:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:37:13 -0500
commit36f78c139ab4389163c6e9b26fd4659a16ede3c8 (patch)
tree29c5d69a300b672202d0d4c50b8708fab49bd6bc /source4/torture/raw
parent3e608a173e65403686628387a09f66096978783f (diff)
downloadsamba-36f78c139ab4389163c6e9b26fd4659a16ede3c8.tar.gz
samba-36f78c139ab4389163c6e9b26fd4659a16ede3c8.tar.bz2
samba-36f78c139ab4389163c6e9b26fd4659a16ede3c8.zip
r20609: Additional torture test for our bad_path handling. Most of it is disabled for
now, there are calls (for example trans2ffirst) which are quite dubious. Volker (This used to be commit 79846f09b98965af0817b362f45d11e69e23c3e4)
Diffstat (limited to 'source4/torture/raw')
-rw-r--r--source4/torture/raw/samba3misc.c212
1 files changed, 210 insertions, 2 deletions
diff --git a/source4/torture/raw/samba3misc.c b/source4/torture/raw/samba3misc.c
index eea6fe2bc6..66462ca5b1 100644
--- a/source4/torture/raw/samba3misc.c
+++ b/source4/torture/raw/samba3misc.c
@@ -25,6 +25,7 @@
#include "system/filesys.h"
#include "libcli/libcli.h"
#include "torture/util.h"
+#include "torture/raw/proto.h"
#define CHECK_STATUS(status, correct) do { \
if (!NT_STATUS_EQUAL(status, correct)) { \
@@ -219,10 +220,12 @@ static NTSTATUS raw_smbcli_open(struct smbcli_tree *tree, const char *fname, int
BOOL torture_samba3_badpath(struct torture_context *torture)
{
- struct smbcli_state *cli_nt;
- struct smbcli_state *cli_dos;
+ struct smbcli_state *cli_nt = NULL;
+ struct smbcli_state *cli_dos = NULL;
const char *fname = "test.txt";
const char *dirname = "testdir";
+ const char *invname = "testdir\\notthere.txt";
+ const char *invpath = "test.txt\\test.txt";
char *fpath;
int fnum;
NTSTATUS status;
@@ -263,6 +266,7 @@ BOOL torture_samba3_badpath(struct torture_context *torture)
goto fail;
}
+ smbcli_unlink(cli_nt->tree, fname);
smbcli_deltree(cli_nt->tree, dirname);
status = smbcli_mkdir(cli_nt->tree, dirname);
@@ -303,6 +307,14 @@ BOOL torture_samba3_badpath(struct torture_context *torture)
}
smbcli_close(cli_nt->tree, fnum);
+ fnum = smbcli_open(cli_nt->tree, fname, O_RDWR | O_CREAT, DENY_NONE);
+ if (fnum == -1) {
+ d_printf("Could not create file %s: %s\n", fname,
+ smbcli_errstr(cli_nt->tree));
+ goto fail;
+ }
+ smbcli_close(cli_nt->tree, fnum);
+
/*
* Do a whole bunch of error code checks on chkpath
*/
@@ -452,6 +464,201 @@ BOOL torture_samba3_badpath(struct torture_context *torture)
status = raw_smbcli_open(cli_dos->tree, "<\\bla", O_RDONLY, DENY_NONE, NULL);
CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidname));
+ /*
+ * Walk the Samba3 unix_convert bad_path handling. Some interesting
+ * error paths around...
+ */
+
+ status = smbcli_chkpath(cli_nt->tree, invpath);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+ status = smbcli_chkpath(cli_dos->tree, invpath);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ status = smbcli_getatr(cli_nt->tree, invpath, NULL, NULL, NULL);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+ status = smbcli_getatr(cli_dos->tree, invpath, NULL, NULL, NULL);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ status = smbcli_setatr(cli_nt->tree, invpath, 0, 0);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+ status = smbcli_setatr(cli_dos->tree, invpath, 0, 0);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ status = smbcli_setatr(cli_nt->tree, invpath, FILE_ATTRIBUTE_NORMAL,
+ 0);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+ status = smbcli_setatr(cli_dos->tree, invpath, FILE_ATTRIBUTE_NORMAL,
+ 0);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ status = smbcli_setatr(cli_nt->tree, invname, 0, 0);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
+ status = smbcli_setatr(cli_dos->tree, invname, 0, 0);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadfile));
+
+ /*
+ * reply_search returns STATUS_NO_MORE_FILES on invalid path
+ */
+
+ goto done; /* We're not yet fully there, but keep it
+ * in */
+
+ status = torture_single_search(cli_nt, mem_ctx, invpath,
+ RAW_SEARCH_SEARCH,
+ RAW_SEARCH_DATA_SEARCH, 0, NULL);
+ CHECK_STATUS(status, STATUS_NO_MORE_FILES);
+ status = torture_single_search(cli_dos, mem_ctx, invpath,
+ RAW_SEARCH_SEARCH,
+ RAW_SEARCH_DATA_SEARCH, 0, NULL);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRnofiles));
+
+ /*
+ * ... whereas t2search gets you NT_STATUS_INVALID_PARAMETER
+ */
+
+ status = torture_single_search(cli_nt, mem_ctx, dirname,
+ RAW_SEARCH_TRANS2,
+ RAW_SEARCH_DATA_STANDARD, 0xf, NULL);
+ CHECK_STATUS(status, STATUS_NO_MORE_FILES);
+ status = torture_single_search(cli_dos, mem_ctx, dirname,
+ RAW_SEARCH_TRANS2,
+ RAW_SEARCH_DATA_STANDARD, 0xf, NULL);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRnofiles));
+
+ status = torture_single_search(cli_nt, mem_ctx, invpath,
+ RAW_SEARCH_TRANS2,
+ RAW_SEARCH_DATA_STANDARD, 0xf, NULL);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+ status = torture_single_search(cli_dos, mem_ctx, invpath,
+ RAW_SEARCH_TRANS2,
+ RAW_SEARCH_DATA_STANDARD, 0xf, NULL);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidparam));
+
+ {
+ union smb_open o;
+ o.openold.level = RAW_OPEN_OPEN;
+ o.openold.in.open_mode = 0;
+ o.openold.in.search_attrs = 0;
+ o.openold.in.fname = invpath;
+
+ status = smb_raw_open(cli_nt->tree, mem_ctx, &o);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+ status = smb_raw_open(cli_dos->tree, mem_ctx, &o);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ ZERO_STRUCT(o);
+ o.openx.level = RAW_OPEN_OPENX;
+ o.openx.in.fname = invpath;
+ o.openx.in.open_func = OPENX_OPEN_FUNC_OPEN;
+
+ status = smb_raw_open(cli_nt->tree, mem_ctx, &o);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+ status = smb_raw_open(cli_dos->tree, mem_ctx, &o);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ ZERO_STRUCT(o);
+ o.mknew.level = RAW_OPEN_MKNEW;
+ o.mknew.in.fname = invpath;
+
+ status = smb_raw_open(cli_nt->tree, mem_ctx, &o);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+ status = smb_raw_open(cli_dos->tree, mem_ctx, &o);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ ZERO_STRUCT(o);
+ o.ntcreatex.level = RAW_OPEN_NTCREATEX;
+ o.ntcreatex.in.fname = invpath;
+
+ status = smb_raw_open(cli_nt->tree, mem_ctx, &o);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+ status = smb_raw_open(cli_dos->tree, mem_ctx, &o);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ ZERO_STRUCT(o);
+ o.nttrans.level = RAW_OPEN_NTTRANS_CREATE;
+ o.nttrans.in.fname = invpath;
+
+ status = smb_raw_open(cli_nt->tree, mem_ctx, &o);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+ status = smb_raw_open(cli_dos->tree, mem_ctx, &o);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ /*
+ * TODO: Check t2open
+ */
+
+#if 0
+ /*
+ * This call seems completely broken on W2k3. It gives back a
+ * fid, and when you later want to close it the server returns
+ * INVALID_HANDLE....
+ */
+
+ /*
+ * W2k3 puts the ctemp files into the root of the share, it
+ * seems to ignore the directory given. And, the file name
+ * given back seems to be bogus. The real file name is
+ * prepended with a "t"...
+ */
+
+ ZERO_STRUCT(o);
+ o.ctemp.level = RAW_OPEN_CTEMP;
+ o.ctemp.in.directory = invpath;
+
+ status = smb_raw_open(cli_nt->tree, mem_ctx, &o);
+ if (NT_STATUS_IS_OK(status)) {
+ smbcli_nt_delete_on_close(
+ cli_nt->tree, o.ctemp.out.file.fnum, True);
+ smbcli_close(cli_nt->tree, o.ctemp.out.file.fnum);
+ }
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = smb_raw_open(cli_dos->tree, mem_ctx, &o);
+ if (NT_STATUS_IS_OK(status)) {
+ smbcli_nt_delete_on_close(
+ cli_nt->tree, o.ctemp.out.file.fnum, True);
+ smbcli_close(cli_nt->tree, o.ctemp.out.file.fnum);
+ }
+ CHECK_STATUS(status, NT_STATUS_OK);
+#endif
+ }
+
+ status = smbcli_unlink(cli_nt->tree, invpath);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+ status = smbcli_unlink(cli_dos->tree, invpath);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ status = smbcli_mkdir(cli_nt->tree, invpath);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+ status = smbcli_mkdir(cli_dos->tree, invpath);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ status = smbcli_rmdir(cli_nt->tree, invpath);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+ status = smbcli_rmdir(cli_dos->tree, invpath);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ status = smbcli_rename(cli_nt->tree, invpath, "");
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD);
+ status = smbcli_rename(cli_dos->tree, invpath, "");
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidpath));
+
+ status = smbcli_rename(cli_nt->tree, "", invpath);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD);
+ status = smbcli_rename(cli_dos->tree, "", invpath);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidpath));
+
+ status = smbcli_rename(cli_nt->tree, invpath, invpath);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+ status = smbcli_rename(cli_dos->tree, invpath, invpath);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ status = smbcli_qpathinfo(cli_nt->tree, invpath, NULL, NULL, NULL,
+ NULL, NULL);
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+ status = smbcli_qpathinfo(cli_dos->tree, invpath, NULL, NULL, NULL,
+ NULL, NULL);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
goto done;
fail:
@@ -460,6 +667,7 @@ BOOL torture_samba3_badpath(struct torture_context *torture)
done:
if (cli_nt != NULL) {
smbcli_deltree(cli_nt->tree, dirname);
+ smbcli_unlink(cli_nt->tree, fname);
torture_close_connection(cli_nt);
}
if (cli_dos != NULL) {