*/
#include "includes.h"
-#include "nsswitch/libwbclient/wbc_async.h"
+#include "wbc_async.h"
#include "torture/proto.h"
#include "libcli/security/security.h"
#include "tldap.h"
static bool use_multishare_conn = False;
static bool do_encrypt;
static const char *local_path = NULL;
+static int signing_state = Undefined;
bool torture_showall = False;
zero_sockaddr(&ss);
- if (!(c = cli_initialise())) {
+ if (!(c = cli_initialise_ex(signing_state))) {
printf("Failed initialize cli_struct to connect with %s\n", host);
return NULL;
}
zero_sockaddr(&ss);
- if (!(c = cli_initialise())) {
+ if (!(c = cli_initialise_ex(signing_state))) {
printf("Failed initialize cli_struct to connect with %s\n", host);
return NULL;
}
const char *hostname,
const char *sharename)
{
- bool retry;
int flags = 0;
NTSTATUS status;
hostname, NULL, port_to_use,
sharename, "?????",
username, workgroup,
- password, flags, Undefined, &retry);
+ password, flags, signing_state);
if (!NT_STATUS_IS_OK(status)) {
printf("failed to open share connection: //%s/%s port:%d - %s\n",
hostname, sharename, port_to_use, nt_errstr(status));
unsigned countprev = 0;
ssize_t sent = 0;
bool correct = True;
- NTSTATUS status;
+ NTSTATUS status = NT_STATUS_OK;
srandom(1);
for (i = 0; i < sizeof(buf); i += sizeof(uint32))
if (procnum == 0)
{
+ if (!NT_STATUS_IS_OK(cli_unlink(c, lockfname, aSYSTEM | aHIDDEN))) {
+ printf("unlink failed (%s) (normal, this file should not exist)\n", cli_errstr(c));
+ }
+
if (!NT_STATUS_IS_OK(cli_open(c, lockfname, O_RDWR | O_CREAT | O_EXCL,
DENY_NONE, &fnum))) {
printf("first open read/write of %s failed (%s)\n",
return test;
}
-static bool run_readwritelarge(int dummy)
+static bool run_readwritelarge_internal(int max_xmit_k)
{
static struct cli_state *cli1;
uint16_t fnum1;
cli_sockopt(cli1, sockops);
memset(buf,'\0',sizeof(buf));
- cli1->max_xmit = 128*1024;
+ cli1->max_xmit = max_xmit_k*1024;
+
+ if (signing_state == Required) {
+ /* Horrible cheat to force
+ multiple signed outstanding
+ packets against a Samba server.
+ */
+ cli1->is_samba = false;
+ }
- printf("starting readwritelarge\n");
+ printf("starting readwritelarge_internal\n");
cli_unlink(cli1, lockfname, aSYSTEM | aHIDDEN);
}
if (fsize == sizeof(buf))
- printf("readwritelarge test 1 succeeded (size = %lx)\n",
+ printf("readwritelarge_internal test 1 succeeded (size = %lx)\n",
(unsigned long)fsize);
else {
- printf("readwritelarge test 1 failed (size = %lx)\n",
+ printf("readwritelarge_internal test 1 failed (size = %lx)\n",
(unsigned long)fsize);
correct = False;
}
}
if (fsize == sizeof(buf))
- printf("readwritelarge test 2 succeeded (size = %lx)\n",
+ printf("readwritelarge_internal test 2 succeeded (size = %lx)\n",
(unsigned long)fsize);
else {
- printf("readwritelarge test 2 failed (size = %lx)\n",
+ printf("readwritelarge_internal test 2 failed (size = %lx)\n",
(unsigned long)fsize);
correct = False;
}
return correct;
}
+static bool run_readwritelarge(int dummy)
+{
+ return run_readwritelarge_internal(128);
+}
+
+static bool run_readwritelarge_signtest(int dummy)
+{
+ bool ret;
+ signing_state = Required;
+ ret = run_readwritelarge_internal(2);
+ signing_state = Undefined;
+ return ret;
+}
+
int line_count = 0;
int nbio_id;
static bool run_tcon_devtype_test(int dummy)
{
static struct cli_state *cli1 = NULL;
- bool retry;
int flags = 0;
NTSTATUS status;
bool ret = True;
host, NULL, port_to_use,
NULL, NULL,
username, workgroup,
- password, flags, Undefined, &retry);
+ password, flags, signing_state);
if (!NT_STATUS_IS_OK(status)) {
printf("could not open connection\n");
/* What are we looking for here? What's sucess and what's FAILURE? */
}
+/* handler for oplock 4 tests */
+bool *oplock4_shared_correct;
+
+static NTSTATUS oplock4_handler(struct cli_state *cli, uint16_t fnum, unsigned char level)
+{
+ printf("got oplock break fnum=%d level=%d\n",
+ fnum, level);
+ *oplock4_shared_correct = true;
+ cli_oplock_ack(cli, fnum, level);
+ return NT_STATUS_UNSUCCESSFUL; /* Cause cli_receive_smb to return. */
+}
+
+static bool run_oplock4(int dummy)
+{
+ struct cli_state *cli1, *cli2;
+ const char *fname = "\\lockt4.lck";
+ const char *fname_ln = "\\lockt4_ln.lck";
+ uint16_t fnum1, fnum2;
+ int saved_use_oplocks = use_oplocks;
+ NTSTATUS status;
+ bool correct = true;
+
+ oplock4_shared_correct = (bool *)shm_setup(sizeof(bool));
+ *oplock4_shared_correct = false;
+
+ printf("starting oplock test 4\n");
+
+ if (!torture_open_connection(&cli1, 0)) {
+ use_level_II_oplocks = false;
+ use_oplocks = saved_use_oplocks;
+ return false;
+ }
+
+ if (!torture_open_connection(&cli2, 1)) {
+ use_level_II_oplocks = false;
+ use_oplocks = saved_use_oplocks;
+ return false;
+ }
+
+ cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname_ln, aSYSTEM | aHIDDEN);
+
+ cli_sockopt(cli1, sockops);
+ cli_sockopt(cli2, sockops);
+
+ /* Create the file. */
+ if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
+ printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ return false;
+ }
+
+ if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
+ printf("close1 failed (%s)\n", cli_errstr(cli1));
+ return false;
+ }
+
+ /* Now create a hardlink. */
+ if (!NT_STATUS_IS_OK(cli_nt_hardlink(cli1, fname, fname_ln))) {
+ printf("nt hardlink failed (%s)\n", cli_errstr(cli1));
+ return false;
+ }
+
+ /* Prove that opening hardlinks cause deny modes to conflict. */
+ if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR, DENY_ALL, &fnum1))) {
+ printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ return false;
+ }
+
+ status = cli_open(cli1, fname_ln, O_RDWR, DENY_NONE, &fnum2);
+ if (NT_STATUS_IS_OK(status)) {
+ printf("open of %s succeeded - should fail with sharing violation.\n",
+ fname_ln);
+ return false;
+ }
+
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
+ printf("open of %s should fail with sharing violation. Got %s\n",
+ fname_ln, nt_errstr(status));
+ return false;
+ }
+
+ if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
+ printf("close1 failed (%s)\n", cli_errstr(cli1));
+ return false;
+ }
+
+ cli1->use_oplocks = true;
+ cli1->use_level_II_oplocks = true;
+
+ cli2->use_oplocks = true;
+ cli2->use_level_II_oplocks = true;
+
+ cli_oplock_handler(cli1, oplock4_handler);
+ if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1))) {
+ printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ return false;
+ }
+
+ if (fork() == 0) {
+ /* Child code */
+ if (!NT_STATUS_IS_OK(cli_open(cli2, fname_ln, O_RDWR, DENY_NONE, &fnum2))) {
+ printf("open of %s failed (%s)\n", fname_ln, cli_errstr(cli1));
+ *oplock4_shared_correct = false;
+ exit(0);
+ }
+
+ if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
+ printf("close2 failed (%s)\n", cli_errstr(cli1));
+ *oplock4_shared_correct = false;
+ }
+
+ exit(0);
+ }
+
+ sleep(2);
+
+ /* Process the oplock break. */
+ cli_receive_smb(cli1);
+
+ if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
+ printf("close1 failed (%s)\n", cli_errstr(cli1));
+ correct = false;
+ }
+
+ if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, aSYSTEM | aHIDDEN))) {
+ printf("unlink failed (%s)\n", cli_errstr(cli1));
+ correct = false;
+ }
+ if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname_ln, aSYSTEM | aHIDDEN))) {
+ printf("unlink failed (%s)\n", cli_errstr(cli1));
+ correct = false;
+ }
+
+ if (!torture_close_connection(cli1)) {
+ correct = false;
+ }
+
+ if (!*oplock4_shared_correct) {
+ correct = false;
+ }
+
+ printf("finished oplock test 4\n");
+
+ return correct;
+}
/*
return correct;
}
+static bool run_deletetest_ln(int dummy)
+{
+ struct cli_state *cli;
+ const char *fname = "\\delete1";
+ const char *fname_ln = "\\delete1_ln";
+ uint16_t fnum;
+ uint16_t fnum1;
+ NTSTATUS status;
+ bool correct = true;
+ time_t t;
+
+ printf("starting deletetest-ln\n");
+
+ if (!torture_open_connection(&cli, 0)) {
+ return false;
+ }
+
+ cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname_ln, aSYSTEM | aHIDDEN);
+
+ cli_sockopt(cli, sockops);
+
+ /* Create the file. */
+ if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum))) {
+ printf("open of %s failed (%s)\n", fname, cli_errstr(cli));
+ return false;
+ }
+
+ if (!NT_STATUS_IS_OK(cli_close(cli, fnum))) {
+ printf("close1 failed (%s)\n", cli_errstr(cli));
+ return false;
+ }
+
+ /* Now create a hardlink. */
+ if (!NT_STATUS_IS_OK(cli_nt_hardlink(cli, fname, fname_ln))) {
+ printf("nt hardlink failed (%s)\n", cli_errstr(cli));
+ return false;
+ }
+
+ /* Open the original file. */
+ status = cli_ntcreate(cli, fname, 0, FILE_READ_DATA,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+ FILE_OPEN_IF, 0, 0, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("ntcreate of %s failed (%s)\n", fname, nt_errstr(status));
+ return false;
+ }
+
+ /* Unlink the hard link path. */
+ status = cli_ntcreate(cli, fname_ln, 0, DELETE_ACCESS,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+ FILE_OPEN_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("ntcreate of %s failed (%s)\n", fname_ln, nt_errstr(status));
+ return false;
+ }
+ status = cli_nt_delete_on_close(cli, fnum1, true);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("(%s) failed to set delete_on_close %s: %s\n",
+ __location__, fname_ln, nt_errstr(status));
+ return false;
+ }
+
+ status = cli_close(cli, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close %s failed (%s)\n",
+ fname_ln, nt_errstr(status));
+ return false;
+ }
+
+ status = cli_close(cli, fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close %s failed (%s)\n",
+ fname, nt_errstr(status));
+ return false;
+ }
+
+ /* Ensure the original file is still there. */
+ status = cli_getatr(cli, fname, NULL, NULL, &t);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("%s getatr on file %s failed (%s)\n",
+ __location__,
+ fname,
+ nt_errstr(status));
+ correct = False;
+ }
+
+ /* Ensure the link path is gone. */
+ status = cli_getatr(cli, fname_ln, NULL, NULL, &t);
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+ printf("%s, getatr for file %s returned wrong error code %s "
+ "- should have been deleted\n",
+ __location__,
+ fname_ln, nt_errstr(status));
+ correct = False;
+ }
+
+ cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname_ln, aSYSTEM | aHIDDEN);
+
+ if (!torture_close_connection(cli)) {
+ correct = false;
+ }
+
+ printf("finished deletetest-ln\n");
+
+ return correct;
+}
/*
print out server properties
slprintf(ea_name, sizeof(ea_name), "EA_%d", i);
memset(ea_val, (char)i+1, i+1);
- if (!cli_set_ea_fnum(cli, fnum, ea_name, ea_val, i+1)) {
- printf("ea_set of name %s failed - %s\n", ea_name, cli_errstr(cli));
+ status = cli_set_ea_fnum(cli, fnum, ea_name, ea_val, i+1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("ea_set of name %s failed - %s\n", ea_name,
+ nt_errstr(status));
talloc_destroy(mem_ctx);
return False;
}
slprintf(ea_name, sizeof(ea_name), "EA_%d", i+10);
memset(ea_val, (char)i+1, i+1);
- if (!cli_set_ea_path(cli, fname, ea_name, ea_val, i+1)) {
- printf("ea_set of name %s failed - %s\n", ea_name, cli_errstr(cli));
+ status = cli_set_ea_path(cli, fname, ea_name, ea_val, i+1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("ea_set of name %s failed - %s\n", ea_name,
+ nt_errstr(status));
talloc_destroy(mem_ctx);
return False;
}
for (i = 0; i < 20; i++) {
fstring ea_name;
slprintf(ea_name, sizeof(ea_name), "ea_%d", i);
- if (!cli_set_ea_path(cli, fname, ea_name, "", 0)) {
- printf("ea_set of name %s failed - %s\n", ea_name, cli_errstr(cli));
+ status = cli_set_ea_path(cli, fname, ea_name, "", 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("ea_set of name %s failed - %s\n", ea_name,
+ nt_errstr(status));
talloc_destroy(mem_ctx);
return False;
}
}
/* Try and delete a non existant EA. */
- if (!cli_set_ea_path(cli, fname, "foo", "", 0)) {
- printf("deleting non-existant EA 'foo' should succeed. %s\n", cli_errstr(cli));
+ status = cli_set_ea_path(cli, fname, "foo", "", 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("deleting non-existant EA 'foo' should succeed. %s\n",
+ nt_errstr(status));
correct = False;
}
printf("starting chain2 test\n");
status = cli_start_connection(&cli1, global_myname(), host, NULL,
- port_to_use, Undefined, 0, NULL);
+ port_to_use, Undefined, 0);
if (!NT_STATUS_IS_OK(status)) {
return False;
}
{"OPLOCK1", run_oplock1, 0},
{"OPLOCK2", run_oplock2, 0},
{"OPLOCK3", run_oplock3, 0},
+ {"OPLOCK4", run_oplock4, 0},
{"DIR", run_dirtest, 0},
{"DIR1", run_dirtest1, 0},
{"DIR-CREATETIME", run_dir_createtime, 0},
{"RW1", run_readwritetest, 0},
{"RW2", run_readwritemulti, FLAG_MULTIPROC},
{"RW3", run_readwritelarge, 0},
+ {"RW-SIGNING", run_readwritelarge_signtest, 0},
{"OPEN", run_opentest, 0},
{"POSIX", run_simple_posix_open_test, 0},
{"POSIX-APPEND", run_posix_append, 0},
{"ASYNC-ECHO", run_async_echo, 0},
{ "UID-REGRESSION-TEST", run_uid_regression_test, 0},
{ "SHORTNAME-TEST", run_shortname_test, 0},
+ { "ADDRCHANGE", run_addrchange, 0},
#if 1
{"OPENATTR", run_openattrtest, 0},
#endif
{"XCOPY", run_xcopy, 0},
{"RENAME", run_rename, 0},
{"DELETE", run_deletetest, 0},
+ {"DELETE-LN", run_deletetest_ln, 0},
{"PROPERTIES", run_properties, 0},
{"MANGLE", torture_mangle, 0},
{"MANGLE1", run_mangle1, 0},
{ "STREAMERROR", run_streamerror },
{ "NOTIFY-BENCH", run_notify_bench },
{ "BAD-NBT-SESSION", run_bad_nbt_session },
+ { "SMB-ANY-CONNECT", run_smb_any_connect },
{ "LOCAL-SUBSTITUTE", run_local_substitute, 0},
{ "LOCAL-GENCACHE", run_local_gencache, 0},
{ "LOCAL-TALLOC-DICT", run_local_talloc_dict, 0},