#include "dynconfig/dynconfig.h"
#include "libcli/security/security.h"
#include "libcli/raw/raw_proto.h"
+#include "../libcli/smb/smbXcli_base.h"
#define NSERVERS 2
#define NINSTANCES 2
int analyze;
int analyze_always;
int analyze_continuous;
- uint_t max_open_handles;
- uint_t seed;
- uint_t numops;
+ unsigned int max_open_handles;
+ unsigned int seed;
+ unsigned int numops;
int use_oplocks;
char **ignore_patterns;
const char *seeds_file;
/* mapping between open handles on the server and local handles */
static struct {
bool active;
- uint_t instance;
+ unsigned int instance;
struct smb2_handle smb2_handle[NSERVERS]; /* SMB2 */
uint16_t smb_handle[NSERVERS]; /* SMB */
const char *name;
} *open_handles;
-static uint_t num_open_handles;
+static unsigned int num_open_handles;
/* state information for the servers. We open NINSTANCES connections to
each server */
/* the seeds and flags for each operation */
static struct {
- uint_t seed;
+ unsigned int seed;
bool disabled;
} *op_parms;
/* info relevant to the current operation */
static struct {
const char *name;
- uint_t seed;
+ unsigned int seed;
NTSTATUS status;
- uint_t opnum;
+ unsigned int opnum;
TALLOC_CTX *mem_ctx;
const char *mismatch;
} current_op;
static bool oplock_handler_smb2(struct smb2_transport *transport, const struct smb2_handle *handle,
uint8_t level, void *private_data);
-static void idle_func_smb2(struct smb2_transport *transport, void *private);
-static bool oplock_handler_smb(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private);
-static void idle_func_smb(struct smbcli_transport *transport, void *private);
+static void idle_func_smb2(struct smb2_transport *transport, void *private_data);
+static bool oplock_handler_smb(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private_data);
+static void idle_func_smb(struct smbcli_transport *transport, void *private_data);
/*
check if a string should be ignored. This is used as the basis
/*****************************************************
connect to the servers
*******************************************************/
-static bool connect_servers(struct event_context *ev,
+static bool connect_servers(struct tevent_context *ev,
struct loadparm_context *lp_ctx)
{
int i, j;
for (j=0;j<NINSTANCES;j++) {
NTSTATUS status;
struct smbcli_options smb_options;
- lp_smbcli_options(lp_ctx, &smb_options);
+ struct smbcli_session_options smb_session_options;
+ lpcfg_smbcli_options(lp_ctx, &smb_options);
+ lpcfg_smbcli_session_options(lp_ctx, &smb_session_options);
printf("Connecting to \\\\%s\\%s as %s - instance %d\n",
servers[i].server_name, servers[i].share_name,
if (options.smb2) {
status = smb2_connect(NULL, servers[i].server_name,
+ lpcfg_smb_ports(lp_ctx),
servers[i].share_name,
- lp_resolve_context(lp_ctx),
+ lpcfg_resolve_context(lp_ctx),
servers[i].credentials,
&servers[i].smb2_tree[j],
- ev, &smb_options);
+ ev, &smb_options,
+ lpcfg_socket_options(lp_ctx),
+ lpcfg_gensec_settings(lp_ctx, lp_ctx)
+ );
} else {
status = smbcli_tree_full_connection(NULL,
&servers[i].smb_tree[j],
servers[i].server_name,
- lp_smb_ports(lp_ctx),
+ lpcfg_smb_ports(lp_ctx),
servers[i].share_name, "A:",
+ lpcfg_socket_options(lp_ctx),
servers[i].credentials,
- lp_resolve_context(lp_ctx), ev,
- &smb_options);
+ lpcfg_resolve_context(lp_ctx), ev,
+ &smb_options,
+ &smb_session_options,
+ lpcfg_gensec_settings(lp_ctx, lp_ctx));
}
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to \\\\%s\\%s - %s\n",
/*
work out the time skew between the servers - be conservative
*/
-static uint_t time_skew(void)
+static unsigned int time_skew(void)
{
- uint_t ret;
+ unsigned int ret;
+ NTTIME nt0, nt1;
+
if (options.smb2) {
- ret = labs(servers[0].smb2_tree[0]->session->transport->negotiate.system_time -
- servers[1].smb2_tree[0]->session->transport->negotiate.system_time);
+ struct smbXcli_conn *c0, *c1;
+
+ c0 = servers[0].smb2_tree[0]->session->transport->conn;
+ c1 = servers[1].smb2_tree[0]->session->transport->conn;
+
+ nt0 = smbXcli_conn_server_system_time(c0);
+ nt1 = smbXcli_conn_server_system_time(c1);
} else {
- ret = labs(servers[0].smb_tree[0]->session->transport->negotiate.server_time -
- servers[1].smb_tree[0]->session->transport->negotiate.server_time);
+ nt0 = servers[0].smb_tree[0]->session->transport->negotiate.server_time;
+ nt1 = servers[1].smb_tree[0]->session->transport->negotiate.server_time;
}
+ ret = labs(nt0 - nt1);
return ret + 300;
}
/*
turn a server handle into a local handle
*/
-static uint_t fnum_to_handle_smb2(int server, int instance, struct smb2_handle server_handle)
+static unsigned int fnum_to_handle_smb2(int server, int instance, struct smb2_handle server_handle)
{
- uint_t i;
+ unsigned int i;
for (i=0;i<options.max_open_handles;i++) {
if (!open_handles[i].active ||
instance != open_handles[i].instance) continue;
/*
turn a server handle into a local handle
*/
-static uint_t fnum_to_handle_smb(int server, int instance, uint16_t server_handle)
+static unsigned int fnum_to_handle_smb(int server, int instance, uint16_t server_handle)
{
- uint_t i;
+ unsigned int i;
for (i=0;i<options.max_open_handles;i++) {
if (!open_handles[i].active ||
instance != open_handles[i].instance) continue;
/*
return true with 'chance' probability as a percentage
*/
-static bool gen_chance(uint_t chance)
+static bool gen_chance(unsigned int chance)
{
return ((random() % 100) <= chance);
}
*/
static int gen_int_range(uint64_t min, uint64_t max)
{
- uint_t r = random();
+ unsigned int r = random();
return min + (r % (1+max-min));
}
/*
generate a bitmask
*/
-static uint32_t gen_bits_mask(uint_t mask)
+static uint32_t gen_bits_mask(unsigned int mask)
{
- uint_t ret = random();
+ unsigned int ret = random();
return ret & mask;
}
/*
generate a file allocation size
*/
-static uint_t gen_alloc_size(void)
+static unsigned int gen_alloc_size(void)
{
- uint_t ret;
+ unsigned int ret;
if (gen_chance(30)) return 0;
/*
the oplock handler will either ack the break or close the file
*/
-static bool oplock_handler_smb(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private)
+static bool oplock_handler_smb(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private_data)
{
union smb_close io;
int i, j;
}
req->async.fn = oplock_handler_close_recv_smb;
- req->async.private = NULL;
+ req->async.private_data = NULL;
return true;
}
an operation on another connection blocking until that break is acked
we check for operations on all transports in the idle function
*/
-static void idle_func_smb(struct smbcli_transport *transport, void *private)
+static void idle_func_smb(struct smbcli_transport *transport, void *private_data)
{
int i, j;
for (i=0;i<NSERVERS;i++) {
an operation on another connection blocking until that break is acked
we check for operations on all transports in the idle function
*/
-static void idle_func_smb2(struct smb2_transport *transport, void *private)
+static void idle_func_smb2(struct smb2_transport *transport, void *private_data)
{
int i, j;
for (i=0;i<NSERVERS;i++) {
s = talloc_asprintf(current_op.mem_ctx, "%s:%s",
nt_errstr(status1),
nt_errstr(status2));
- printf("pattern: %s\n", s);
if (ignore_pattern(s)) {
return true;
}
{
int i, j;
- msleep(20);
+ smb_msleep(20);
for (j=0;j<NINSTANCES;j++) {
for (i=0;i<NSERVERS;i++) {
parm[0].ntcreatex.level = RAW_OPEN_NTCREATEX;
parm[0].ntcreatex.in.flags = gen_ntcreatex_flags();
- parm[0].ntcreatex.in.root_fid = gen_root_fid(instance);
+ parm[0].ntcreatex.in.root_fid.fnum = gen_root_fid(instance);
parm[0].ntcreatex.in.access_mask = gen_access_mask();
parm[0].ntcreatex.in.alloc_size = gen_alloc_size();
parm[0].ntcreatex.in.file_attr = gen_attrib();
}
GEN_COPY_PARM;
- if (parm[0].ntcreatex.in.root_fid != 0) {
- GEN_SET_FNUM_SMB(ntcreatex.in.root_fid);
+ if (parm[0].ntcreatex.in.root_fid.fnum != 0) {
+ GEN_SET_FNUM_SMB(ntcreatex.in.root_fid.fnum);
}
GEN_CALL_SMB(smb_raw_open(tree, current_op.mem_ctx, &parm[i]));
case RAW_SFILEINFO_UNIX_INFO2:
case RAW_SFILEINFO_UNIX_LINK:
case RAW_SFILEINFO_UNIX_HLINK:
+ case RAW_SFILEINFO_LINK_INFORMATION:
+ case RAW_SFILEINFO_PIPE_INFORMATION:
+ case RAW_SFILEINFO_VALID_DATA_INFORMATION:
+ case RAW_SFILEINFO_SHORT_NAME_INFORMATION:
+ case RAW_SFILEINFO_1027:
+ case RAW_SFILEINFO_1030:
+ case RAW_SFILEINFO_1031:
+ case RAW_SFILEINFO_1036:
+ case RAW_SFILEINFO_1041:
+ case RAW_SFILEINFO_1042:
+ case RAW_SFILEINFO_1043:
+ case RAW_SFILEINFO_1044:
/* Untested */
break;
}
union smb_setfileinfo parm[NSERVERS];
NTSTATUS status[NSERVERS];
- parm[0].generic.in.file.path = gen_fname_open(instance);
-
gen_setfileinfo(instance, &parm[0]);
+ parm[0].generic.in.file.path = gen_fname_open(instance);
GEN_COPY_PARM;
union smb_notify notify;
NTSTATUS status;
int i, j;
- uint16_t tid;
+ uint16_t tid = 0;
struct smbcli_transport *transport = req->transport;
- tid = SVAL(req->in.hdr, HDR_TID);
+ if (req->tree) {
+ tid = req->tree->tid;
+ }
notify.nttrans.level = RAW_NOTIFY_NTTRANS;
status = smb_raw_changenotify_recv(req, current_op.mem_ctx, ¬ify);
parm[0].level = RAW_LOCK_LOCKX;
parm[0].in.file.handle.data[0] = gen_fnum(instance);
parm[0].in.lock_count = gen_lock_count();
- parm[0].in.reserved = gen_reserved32();
+ parm[0].in.lock_sequence = gen_reserved32();
parm[0].in.locks = talloc_array(current_op.mem_ctx,
struct smb2_lock_element,
union smb_setfileinfo parm[NSERVERS];
NTSTATUS status[NSERVERS];
- parm[0].generic.in.file.fnum = gen_fnum(instance);
-
gen_setfileinfo(instance, &parm[0]);
+ parm[0].generic.in.file.fnum = gen_fnum(instance);
GEN_COPY_PARM;
GEN_SET_FNUM_SMB2(generic.in.file.handle);
run the test with the current set of op_parms parameters
return the number of operations that completed successfully
*/
-static int run_test(struct event_context *ev, struct loadparm_context *lp_ctx)
+static int run_test(struct tevent_context *ev, struct loadparm_context *lp_ctx)
{
int op, i;
perform a backtracking analysis of the minimal set of operations
to generate an error
*/
-static void backtrack_analyze(struct event_context *ev,
+static void backtrack_analyze(struct tevent_context *ev,
struct loadparm_context *lp_ctx)
{
int chunk, ret;
/*
start the main gentest process
*/
-static bool start_gentest(struct event_context *ev,
+static bool start_gentest(struct tevent_context *ev,
struct loadparm_context *lp_ctx)
{
int op;
/* generate the seeds - after this everything is deterministic */
if (options.use_preset_seeds) {
int numops;
- char **preset = file_lines_load(options.seeds_file, &numops, NULL);
+ char **preset = file_lines_load(options.seeds_file, &numops, 0, NULL);
if (!preset) {
printf("Failed to load %s - %s\n", options.seeds_file, strerror(errno));
exit(1);
int i, username_count=0;
bool ret;
char *ignore_file=NULL;
- struct event_context *ev;
+ struct tevent_context *ev;
struct loadparm_context *lp_ctx;
poptContext pc;
int argc_new;
while((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_UNCLIST:
- lp_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc));
+ lpcfg_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc));
break;
case 'U':
if (username_count == 2) {
}
if (ignore_file) {
- options.ignore_patterns = file_lines_load(ignore_file, NULL, NULL);
+ options.ignore_patterns = file_lines_load(ignore_file, NULL, 0, NULL);
}
argv_new = discard_const_p(char *, poptGetArgs(pc));
ev = s4_event_context_init(talloc_autofree_context());
- gensec_init(lp_ctx);
+ gensec_init();
ret = start_gentest(ev, lp_ctx);