*/
#include "includes.h"
-#include "torture/torture.h"
#include "libcli/raw/libcliraw.h"
-#include "libcli/raw/raw_proto.h"
#include "system/time.h"
#include "system/filesys.h"
-#include "librpc/gen_ndr/security.h"
#include "lib/events/events.h"
#include "libcli/libcli.h"
#include "torture/util.h"
-#include "auth/credentials/credentials.h"
-#include "lib/cmdline/popt_common.h"
+#include "torture/raw/proto.h"
/* enum for whether reads/writes are possible on a file */
enum rdwr_mode {RDWR_NONE, RDWR_RDONLY, RDWR_WRONLY, RDWR_RDWR};
status = smb_raw_setpathinfo(cli->tree, &sfinfo); \
if (!NT_STATUS_IS_OK(status)) { \
torture_warning(tctx, "(%s) Failed to set attrib 0x%x on %s\n", \
- __location__, sattrib, fname); \
+ __location__, (int)sattrib, fname); \
}} while (0)
/*
test RAW_OPEN_OPEN
*/
-static bool test_open(struct smbcli_state *cli, struct torture_context *tctx)
+static bool test_open(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_open io;
union smb_fileinfo finfo;
int fnum = -1, fnum2;
bool ret = true;
- torture_comment(tctx, "Checking RAW_OPEN_OPEN\n");
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return false;
+ }
io.openold.level = RAW_OPEN_OPEN;
io.openold.in.fname = fname;
done:
smbcli_close(cli->tree, fnum);
- smbcli_unlink(cli->tree, fname);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/*
test RAW_OPEN_OPENX
*/
-static bool test_openx(struct smbcli_state *cli, struct torture_context *tctx)
+static bool test_openx(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_open io;
union smb_fileinfo finfo;
{ OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK },
};
- torture_comment(tctx, "Checking RAW_OPEN_OPENX\n");
- smbcli_unlink(cli->tree, fname);
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return false;
+ }
io.openx.level = RAW_OPEN_OPENX;
io.openx.in.fname = fname;
done:
smbcli_close(cli->tree, fnum);
- smbcli_unlink(cli->tree, fname_exe);
- smbcli_unlink(cli->tree, fname);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
many thanks to kukks for a sniff showing how this works with os2->w2k
*/
-static bool test_t2open(struct smbcli_state *cli, struct torture_context *tctx)
+static bool test_t2open(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_open io;
union smb_fileinfo finfo;
{ OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK },
};
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return false;
+ }
+
fnum = create_complex_file(cli, tctx, fname1);
if (fnum == -1) {
torture_result(tctx, TORTURE_FAIL,
}
smbcli_close(cli->tree, fnum);
- torture_comment(tctx, "Checking RAW_OPEN_T2OPEN\n");
-
io.t2open.level = RAW_OPEN_T2OPEN;
io.t2open.in.flags = OPENX_FLAGS_ADDITIONAL_INFO;
io.t2open.in.open_mode = OPENX_MODE_DENY_NONE | OPENX_MODE_ACCESS_RDWR;
done:
smbcli_close(cli->tree, fnum);
- smbcli_unlink(cli->tree, fname);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/*
test RAW_OPEN_NTCREATEX
*/
-static bool test_ntcreatex(struct smbcli_state *cli, struct torture_context *tctx)
+static bool test_ntcreatex(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_open io;
union smb_fileinfo finfo;
{ 6, false, NT_STATUS_INVALID_PARAMETER },
};
- torture_comment(tctx, "Checking RAW_OPEN_NTCREATEX\n");
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return false;
+ }
/* reasonable default parameters */
io.generic.level = RAW_OPEN_NTCREATEX;
done:
smbcli_close(cli->tree, fnum);
- smbcli_unlink(cli->tree, fname);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/*
test RAW_OPEN_NTTRANS_CREATE
*/
-static bool test_nttrans_create(struct smbcli_state *cli, struct torture_context *tctx)
+static bool test_nttrans_create(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_open io;
union smb_fileinfo finfo;
{ 6, false, NT_STATUS_INVALID_PARAMETER },
};
- torture_comment(tctx, "Checking RAW_OPEN_NTTRANS_CREATE\n");
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return false;
+ }
/* reasonable default parameters */
io.generic.level = RAW_OPEN_NTTRANS_CREATE;
done:
smbcli_close(cli->tree, fnum);
- smbcli_unlink(cli->tree, fname);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
open_disposition==NTCREATEX_DISP_OVERWRITE_IF. Windows 2003 allows the
second open.
*/
-static bool test_ntcreatex_brlocked(struct smbcli_state *cli, struct torture_context *tctx)
+static bool test_ntcreatex_brlocked(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_open io, io1;
union smb_lock io2;
NTSTATUS status;
bool ret = true;
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return false;
+ }
+
torture_comment(tctx, "Testing ntcreatex with a byte range locked file\n");
io.generic.level = RAW_OPEN_NTCREATEX;
done:
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
smbcli_close(cli->tree, io1.ntcreatex.out.file.fnum);
- smbcli_unlink(cli->tree, fname);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/*
test RAW_OPEN_MKNEW
*/
-static bool test_mknew(struct smbcli_state *cli, struct torture_context *tctx)
+static bool test_mknew(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_open io;
const char *fname = BASEDIR "\\torture_mknew.txt";
time_t basetime = (time(NULL) + 3600*24*3) & ~1;
union smb_fileinfo finfo;
- torture_comment(tctx, "Checking RAW_OPEN_MKNEW\n");
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return false;
+ }
io.mknew.level = RAW_OPEN_MKNEW;
io.mknew.in.attrib = 0;
done:
smbcli_close(cli->tree, fnum);
- smbcli_unlink(cli->tree, fname);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/*
test RAW_OPEN_CREATE
*/
-static bool test_create(struct smbcli_state *cli, struct torture_context *tctx)
+static bool test_create(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_open io;
const char *fname = BASEDIR "\\torture_create.txt";
time_t basetime = (time(NULL) + 3600*24*3) & ~1;
union smb_fileinfo finfo;
- torture_comment(tctx, "Checking RAW_OPEN_CREATE\n");
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return false;
+ }
io.create.level = RAW_OPEN_CREATE;
io.create.in.attrib = 0;
done:
smbcli_close(cli->tree, fnum);
- smbcli_unlink(cli->tree, fname);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/*
test RAW_OPEN_CTEMP
*/
-static bool test_ctemp(struct smbcli_state *cli, TALLOC_CTX *tctx)
+static bool test_ctemp(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_open io;
NTSTATUS status;
union smb_fileinfo finfo;
const char *name, *fname = NULL;
- torture_comment(tctx, "Checking RAW_OPEN_CTEMP\n");
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return false;
+ }
io.ctemp.level = RAW_OPEN_CTEMP;
io.ctemp.in.attrib = FILE_ATTRIBUTE_HIDDEN;
done:
smbcli_close(cli->tree, fnum);
- if (fname) {
- smbcli_unlink(cli->tree, fname);
- }
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/*
test chained RAW_OPEN_OPENX_READX
*/
-static bool test_chained(struct smbcli_state *cli, TALLOC_CTX *tctx)
+static bool test_chained(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_open io;
const char *fname = BASEDIR "\\torture_chained.txt";
const char *buf = "test";
char buf2[4];
- torture_comment(tctx, "Checking RAW_OPEN_OPENX chained with READX\n");
- smbcli_unlink(cli->tree, fname);
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return false;
+ }
fnum = create_complex_file(cli, tctx, fname);
done:
smbcli_close(cli->tree, fnum);
- smbcli_unlink(cli->tree, fname);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
NetApp filers are known to fail on this.
*/
-static bool test_no_leading_slash(struct smbcli_state *cli, TALLOC_CTX *tctx)
+static bool test_no_leading_slash(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_open io;
const char *fname = BASEDIR "\\torture_no_leading_slash.txt";
bool ret = true;
const char *buf = "test";
- torture_comment(tctx, "Checking RAW_OPEN_OPENX without leading "
- "slash on path\n");
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return false;
+ }
+
smbcli_unlink(cli->tree, fname);
/* Create the file */
done:
smbcli_close(cli->tree, fnum);
- smbcli_unlink(cli->tree, fname);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
Samba 3.2.0 - 3.2.6 are known to fail this.
*/
-static bool test_openx_over_dir(struct smbcli_state *cli, TALLOC_CTX *tctx)
+static bool test_openx_over_dir(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_open io;
const char *fname = BASEDIR "\\openx_over_dir";
int fnum = -1;
bool ret = true;
- torture_comment(tctx, "Checking RAW_OPEN_OPENX over an existing directory\n");
- smbcli_unlink(cli->tree, fname);
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return false;
+ }
/* Create the Directory */
status = create_directory_handle(cli->tree, fname, &d_fnum);
done:
smbcli_close(cli->tree, fnum);
- smbcli_unlink(cli->tree, fname);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
/* A little torture test to expose a race condition in Samba 3.0.20 ... :-) */
-static bool test_raw_open_multi(struct torture_context *tctx)
+static bool test_raw_open_multi(struct torture_context *tctx, struct smbcli_state *cli_ignored)
{
struct smbcli_state *cli;
TALLOC_CTX *mem_ctx = talloc_init("torture_test_oplock_multi");
/*
test opening for delete on a read-only attribute file.
*/
-static bool test_open_for_delete(struct smbcli_state *cli, struct torture_context *tctx)
+static bool test_open_for_delete(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_open io;
union smb_fileinfo finfo;
int fnum = -1;
bool ret = true;
- torture_comment(tctx, "Checking RAW_NTCREATEX for delete on a readonly file.\n");
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return false;
+ }
/* reasonable default parameters */
io.generic.level = RAW_OPEN_NTCREATEX;
done:
smbcli_close(cli->tree, fnum);
- smbcli_unlink(cli->tree, fname);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
Send chained NTCREATEX_READX on a file that doesn't exist, then create
the file and try again.
*/
-static bool test_chained_ntcreatex_readx(struct smbcli_state *cli, struct torture_context *tctx)
+static bool test_chained_ntcreatex_readx(struct torture_context *tctx, struct smbcli_state *cli)
{
TALLOC_CTX *mem_ctx = talloc_new(tctx);
union smb_open io;
const char *buf = "test";
char buf2[4];
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return false;
+ }
+
torture_comment(tctx, "Checking RAW_NTCREATEX_READX chained on "
"non-existant file \n");
- smbcli_unlink(cli->tree, fname);
/* ntcreatex parameters */
io.generic.level = RAW_OPEN_NTCREATEX_READX;
done:
smbcli_close(cli->tree, fnum);
- smbcli_unlink(cli->tree, fname);
+ smbcli_deltree(cli->tree, BASEDIR);
talloc_free(mem_ctx);
return ret;
}
-#define FILL_NTCREATEX(_struct, _init...) \
- do { \
- (_struct)->generic.level = RAW_OPEN_NTCREATEX; \
- (_struct)->ntcreatex.in \
- = (typeof((_struct)->ntcreatex.in)) {_init};\
- } while (0)
-
-static bool test_ntcreatex_opendisp_dir(struct smbcli_state *cli,
- struct torture_context *tctx)
+static bool test_ntcreatex_opendisp_dir(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
- union smb_open io;
const char *dname = BASEDIR "\\torture_ntcreatex_opendisp_dir";
NTSTATUS status;
bool ret = true;
{ 6, true, NT_STATUS_INVALID_PARAMETER },
{ 6, false, NT_STATUS_INVALID_PARAMETER },
};
+ union smb_open io;
+
+ ZERO_STRUCT(io);
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
+ io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE;
+ io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ io.ntcreatex.in.fname = dname;
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
}
- FILL_NTCREATEX(&io,
- .flags = NTCREATEX_FLAGS_EXTENDED,
- .access_mask = SEC_FLAG_MAXIMUM_ALLOWED,
- .file_attr = FILE_ATTRIBUTE_DIRECTORY,
- .share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE,
- .create_options = NTCREATEX_OPTIONS_DIRECTORY,
- .fname = dname,
- );
-
smbcli_rmdir(cli->tree, dname);
smbcli_unlink(cli->tree, dname);
}
done:
- smbcli_rmdir(cli->tree, dname);
smbcli_deltree(cli->tree, BASEDIR);
+
return ret;
}
-
-/* basic testing of all RAW_OPEN_* calls
-*/
-bool torture_raw_open(struct torture_context *torture, struct smbcli_state *cli)
+/**
+ * Test what happens when trying to open a file with directory parameters and
+ * vice-versa. Also test that NTCREATEX_OPTIONS_DIRECTORY is treated as
+ * mandatory and FILE_ATTRIBUTE_DIRECTORY is advisory for directory
+ * creation/opening.
+ */
+static bool test_ntcreatexdir(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
- bool ret = true;
+ union smb_open io;
+ const char *fname = BASEDIR "\\torture_ntcreatex.txt";
+ const char *dname = BASEDIR "\\torture_ntcreatex_dir";
+ NTSTATUS status;
+ int i;
+
+ struct {
+ uint32_t open_disp;
+ uint32_t file_attr;
+ uint32_t create_options;
+ NTSTATUS correct_status;
+ } open_funcs[] = {
+ { NTCREATEX_DISP_SUPERSEDE, 0, NTCREATEX_OPTIONS_DIRECTORY,
+ NT_STATUS_INVALID_PARAMETER },
+ { NTCREATEX_DISP_OPEN, 0, NTCREATEX_OPTIONS_DIRECTORY,
+ NT_STATUS_OBJECT_NAME_NOT_FOUND },
+ { NTCREATEX_DISP_CREATE, 0, NTCREATEX_OPTIONS_DIRECTORY,
+ NT_STATUS_OK },
+ { NTCREATEX_DISP_OPEN_IF, 0, NTCREATEX_OPTIONS_DIRECTORY,
+ NT_STATUS_OK },
+ { NTCREATEX_DISP_OVERWRITE, 0, NTCREATEX_OPTIONS_DIRECTORY,
+ NT_STATUS_INVALID_PARAMETER },
+ { NTCREATEX_DISP_OVERWRITE_IF, 0, NTCREATEX_OPTIONS_DIRECTORY,
+ NT_STATUS_INVALID_PARAMETER },
+ { NTCREATEX_DISP_SUPERSEDE, FILE_ATTRIBUTE_DIRECTORY, 0,
+ NT_STATUS_OK },
+ { NTCREATEX_DISP_OPEN, FILE_ATTRIBUTE_DIRECTORY, 0,
+ NT_STATUS_OBJECT_NAME_NOT_FOUND },
+ { NTCREATEX_DISP_CREATE, FILE_ATTRIBUTE_DIRECTORY, 0,
+ NT_STATUS_OK },
+ { NTCREATEX_DISP_OPEN_IF, FILE_ATTRIBUTE_DIRECTORY, 0,
+ NT_STATUS_OK },
+ { NTCREATEX_DISP_OVERWRITE, FILE_ATTRIBUTE_DIRECTORY, 0,
+ NT_STATUS_OBJECT_NAME_NOT_FOUND },
+ { NTCREATEX_DISP_OVERWRITE_IF, FILE_ATTRIBUTE_DIRECTORY, 0,
+ NT_STATUS_OK },
+
+ };
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
}
- ret &= test_ntcreatex_brlocked(cli, torture);
- ret &= test_open(cli, torture);
- ret &= test_raw_open_multi(torture);
- ret &= test_openx(cli, torture);
- ret &= test_ntcreatex(cli, torture);
- ret &= test_nttrans_create(cli, torture);
- ret &= test_t2open(cli, torture);
- ret &= test_mknew(cli, torture);
- ret &= test_create(cli, torture);
- ret &= test_ctemp(cli, torture);
- ret &= test_chained(cli, torture);
- ret &= test_chained_ntcreatex_readx(cli, torture);
- ret &= test_no_leading_slash(cli, torture);
- ret &= test_openx_over_dir(cli, torture);
- ret &= test_open_for_delete(cli, torture);
- ret &= test_ntcreatex_opendisp_dir(cli, torture);
-
- smb_raw_exit(cli->session);
+ /* setup some base params. */
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
+ io.ntcreatex.in.root_fid.fnum = 0;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname;
+
+ /*
+ * Test the validity checking for create dispositions, which is done
+ * against the requested parameters rather than what's actually on
+ * disk.
+ */
+ for (i=0; i<ARRAY_SIZE(open_funcs); i++) {
+ io.ntcreatex.in.open_disposition = open_funcs[i].open_disp;
+ io.ntcreatex.in.file_attr = open_funcs[i].file_attr;
+ io.ntcreatex.in.create_options = open_funcs[i].create_options;
+ status = smb_raw_open(cli->tree, tctx, &io);
+ if (!NT_STATUS_EQUAL(status, open_funcs[i].correct_status)) {
+ torture_result(tctx, TORTURE_FAIL,
+ "(%s) incorrect status %s should be %s "
+ "(i=%d open_disp=%d)\n",
+ __location__, nt_errstr(status),
+ nt_errstr(open_funcs[i].correct_status),
+ i, (int)open_funcs[i].open_disp);
+ return false;
+ }
+ /* Close and delete the file. */
+ if (NT_STATUS_IS_OK(status)) {
+ if (open_funcs[i].create_options != 0) {
+ /* out attrib should be a directory. */
+ torture_assert_int_equal(tctx,
+ io.ntcreatex.out.attrib,
+ FILE_ATTRIBUTE_DIRECTORY, "should have "
+ "created a directory");
+
+ smbcli_close(cli->tree,
+ io.ntcreatex.out.file.fnum);
+
+ /* Make sure unlink fails. */
+ status = smbcli_unlink(cli->tree, fname);
+ torture_assert_ntstatus_equal(tctx, status,
+ NT_STATUS_FILE_IS_A_DIRECTORY,
+ "unlink should fail for a directory");
+
+ status = smbcli_rmdir(cli->tree, fname);
+ torture_assert_ntstatus_ok(tctx, status,
+ "rmdir failed");
+ } else {
+ torture_assert_int_equal(tctx,
+ io.ntcreatex.out.attrib,
+ FILE_ATTRIBUTE_ARCHIVE, "should not have "
+ "created a directory");
+
+ smbcli_close(cli->tree,
+ io.ntcreatex.out.file.fnum);
+
+ /* Make sure rmdir fails. */
+ status = smbcli_rmdir(cli->tree, fname);
+ torture_assert_ntstatus_equal(tctx, status,
+ NT_STATUS_NOT_A_DIRECTORY,
+ "rmdir should fail for a file");
+
+ status = smbcli_unlink(cli->tree, fname);
+ torture_assert_ntstatus_ok(tctx, status,
+ "unlink failed");
+ }
+ }
+ }
+
+ /* Create a file. */
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
+ status = smb_raw_open(cli->tree, tctx, &io);
+ torture_assert_ntstatus_ok(tctx, status, "Failed to create file.");
+ smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
+
+ /* Try and open the file with file_attr_dir and check the error. */
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+
+ status = smb_raw_open(cli->tree, tctx, &io);
+ torture_assert_ntstatus_ok(tctx, status, "FILE_ATTRIBUTE_DIRECTORY "
+ "doesn't produce a hard failure.");
+ smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
+
+ /* Try and open file with createx_option_dir and check the error. */
+ io.ntcreatex.in.file_attr = 0;
+ io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+
+ status = smb_raw_open(cli->tree, tctx, &io);
+ torture_assert_ntstatus_equal(tctx, status, NT_STATUS_NOT_A_DIRECTORY,
+ "NTCREATEX_OPTIONS_DIRECTORY will a file from being opened.");
+ smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
+
+ /* Delete the file and move onto directory testing. */
+ smbcli_unlink(cli->tree, fname);
+
+ /* Now try some tests on a directory. */
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
+ io.ntcreatex.in.file_attr = 0;
+ io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ io.ntcreatex.in.fname = dname;
+
+ status = smb_raw_open(cli->tree, tctx, &io);
+ torture_assert_ntstatus_ok(tctx, status, "Failed to create dir.");
+
+ /* out attrib should be a directory. */
+ torture_assert_int_equal(tctx, io.ntcreatex.out.attrib,
+ FILE_ATTRIBUTE_DIRECTORY, "should have created a directory");
+
+ smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
+
+ /* Try and open it with normal attr and check the error. */
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+
+ status = smb_raw_open(cli->tree, tctx, &io);
+ torture_assert_ntstatus_ok(tctx, status, "FILE_ATTRIBUTE_NORMAL "
+ "doesn't produce a hard failure.");
+ smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
+
+ /* Try and open it with file create_options and check the error. */
+ io.ntcreatex.in.file_attr = 0;
+ io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_NON_DIRECTORY_FILE;
+
+ status = smb_raw_open(cli->tree, tctx, &io);
+ torture_assert_ntstatus_equal(tctx, status,
+ NT_STATUS_FILE_IS_A_DIRECTORY,
+ "NTCREATEX_OPTIONS_NON_DIRECTORY_FILE should be returned ");
+ smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
+
smbcli_deltree(cli->tree, BASEDIR);
- return ret;
+ return true;
+}
+
+/* basic testing of all RAW_OPEN_* calls
+*/
+struct torture_suite *torture_raw_open(TALLOC_CTX *mem_ctx)
+{
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "open");
+
+ torture_suite_add_1smb_test(suite, "brlocked", test_ntcreatex_brlocked);
+ torture_suite_add_1smb_test(suite, "open", test_open);
+ torture_suite_add_1smb_test(suite, "open-multi", test_raw_open_multi);
+ torture_suite_add_1smb_test(suite, "openx", test_openx);
+ torture_suite_add_1smb_test(suite, "ntcreatex", test_ntcreatex);
+ torture_suite_add_1smb_test(suite, "nttrans-create", test_nttrans_create);
+ torture_suite_add_1smb_test(suite, "t2open", test_t2open);
+ torture_suite_add_1smb_test(suite, "mknew", test_mknew);
+ torture_suite_add_1smb_test(suite, "create", test_create);
+ torture_suite_add_1smb_test(suite, "ctemp", test_ctemp);
+ torture_suite_add_1smb_test(suite, "chained-openx", test_chained);
+ torture_suite_add_1smb_test(suite, "chained-ntcreatex", test_chained_ntcreatex_readx);
+ torture_suite_add_1smb_test(suite, "no-leading-slash", test_no_leading_slash);
+ torture_suite_add_1smb_test(suite, "openx-over-dir", test_openx_over_dir);
+ torture_suite_add_1smb_test(suite, "open-for-delete", test_open_for_delete);
+ torture_suite_add_1smb_test(suite, "opendisp-dir", test_ntcreatex_opendisp_dir);
+ torture_suite_add_1smb_test(suite, "ntcreatedir", test_ntcreatexdir);
+
+ return suite;
}