struct smbcli_state *cli;
const char *host = lp_parm_string(-1, "torture", "host");
- calling.name = lp_netbios_name();
- calling.type = NBT_NAME_CLIENT;
- calling.scope = NULL;
+ make_nbt_name_client(&calling, lp_netbios_name());
nbt_choose_called_name(NULL, &called, host, NBT_NAME_SERVER);
cli = smbcli_state_init(NULL);
if (!cli) {
printf("Failed initialize smbcli_struct to connect with %s\n", host);
- return NULL;
+ goto failed;
}
if (!smbcli_socket_connect(cli, host)) {
printf("Failed to connect with %s\n", host);
- return cli;
+ goto failed;
}
if (!smbcli_transport_establish(cli, &calling, &called)) {
printf("%s rejected the session\n",host);
- smbcli_shutdown(cli);
- return NULL;
+ goto failed;
}
return cli;
+
+failed:
+ talloc_free(cli);
+ return NULL;
}
BOOL torture_open_connection_share(struct smbcli_state **c,
status = smbcli_full_connection(NULL,
c, hostname,
sharename, NULL,
- cmdline_credentials);
+ cmdline_credentials, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to open connection - %s\n", nt_errstr(status));
return False;
printf("tdis failed (%s)\n", smbcli_errstr(c->tree));
ret = False;
}
- smbcli_shutdown(c);
+ talloc_free(c);
return ret;
}
status = dcerpc_pipe_connect(parent_ctx,
p, binding, pipe_uuid, pipe_version,
- cmdline_credentials);
+ cmdline_credentials, NULL);
return status;
}
b->transport = transport;
status = dcerpc_pipe_connect_b(mem_ctx, p, b, pipe_uuid, pipe_version,
- cmdline_credentials);
+ cmdline_credentials, NULL);
if (NT_STATUS_IS_OK(status)) {
*p = talloc_reference(parent_ctx, *p);
return ret;
}
-static BOOL rw_torture3(struct smbcli_state *c, const char *lockfname)
-{
- int fnum = -1;
- uint_t i = 0;
- uint8_t buf[131072];
- uint8_t buf_rd[131072];
- uint_t count;
- uint_t countprev = 0;
- ssize_t sent = 0;
- BOOL correct = True;
-
- for (i = 0; i < sizeof(buf); i += sizeof(uint32_t))
- {
- SIVAL(buf, i, random());
- }
-
- if (procnum == 0)
- {
- fnum = smbcli_open(c->tree, lockfname, O_RDWR | O_CREAT | O_EXCL,
- DENY_NONE);
- if (fnum == -1) {
- printf("first open read/write of %s failed (%s)\n",
- lockfname, smbcli_errstr(c->tree));
- return False;
- }
- }
- else
- {
- for (i = 0; i < 500 && fnum == -1; i++)
- {
- fnum = smbcli_open(c->tree, lockfname, O_RDONLY,
- DENY_NONE);
- msleep(10);
- }
- if (fnum == -1) {
- printf("second open read-only of %s failed (%s)\n",
- lockfname, smbcli_errstr(c->tree));
- return False;
- }
- }
-
- i = 0;
- for (count = 0; count < sizeof(buf); count += sent)
- {
- if (count >= countprev) {
- printf("%d %8d\r", i, count);
- fflush(stdout);
- i++;
- countprev += (sizeof(buf) / 20);
- }
-
- if (procnum == 0)
- {
- sent = ((uint_t)random()%(20))+ 1;
- if (sent > sizeof(buf) - count)
- {
- sent = sizeof(buf) - count;
- }
-
- if (smbcli_write(c->tree, fnum, 0, buf+count, count, (size_t)sent) != sent) {
- printf("write failed (%s)\n", smbcli_errstr(c->tree));
- correct = False;
- }
- }
- else
- {
- sent = smbcli_read(c->tree, fnum, buf_rd+count, count,
- sizeof(buf)-count);
- if (sent < 0)
- {
- printf("read failed offset:%d size:%d (%s)\n",
- count, sizeof(buf)-count,
- smbcli_errstr(c->tree));
- correct = False;
- sent = 0;
- }
- if (sent > 0)
- {
- if (memcmp(buf_rd+count, buf+count, sent) != 0)
- {
- printf("read/write compare failed\n");
- printf("offset: %d req %d recvd %d\n",
- count, sizeof(buf)-count, sent);
- correct = False;
- break;
- }
- }
- }
-
- }
-
- if (NT_STATUS_IS_ERR(smbcli_close(c->tree, fnum))) {
- printf("close failed (%s)\n", smbcli_errstr(c->tree));
- correct = False;
- }
-
- return correct;
-}
static BOOL rw_torture2(struct smbcli_state *c1, struct smbcli_state *c2)
{
return (test1 && test2);
}
-static BOOL run_readwritemulti(struct smbcli_state *cli, int dummy)
-{
- BOOL test;
-
- test = rw_torture3(cli, "\\multitest.txt");
-
- if (!torture_close_connection(cli)) {
- test = False;
- }
-
- return test;
-}
-
-
/*
this checks to see if a secondary tconx can use open files from an
earlier tconx
}
tree1 = cli->tree; /* save old tree connection */
- if (NT_STATUS_IS_ERR(smbcli_send_tconX(cli, share, "?????", password))) {
+ if (NT_STATUS_IS_ERR(smbcli_tconX(cli, share, "?????", password))) {
printf("%s refused 2nd tree connect (%s)\n", host,
smbcli_errstr(cli->tree));
- smbcli_shutdown(cli);
+ talloc_free(cli);
return False;
}
BOOL ret;
const char *password = lp_parm_string(-1, "torture", "password");
- status = NT_STATUS_IS_OK(smbcli_send_tconX(cli, myshare, devtype,
+ status = NT_STATUS_IS_OK(smbcli_tconX(cli, myshare, devtype,
password));
printf("Trying share %s with devtype %s\n", myshare, devtype);
status = smbcli_full_connection(NULL,
&cli1, host,
share, NULL,
- cmdline_credentials);
+ cmdline_credentials, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("could not open connection\n");
if (!tcon_devtest(cli1, share, "FOOBA", NT_STATUS_BAD_DEVICE_TYPE))
ret = False;
- smbcli_shutdown(cli1);
+ talloc_free(cli1);
if (ret)
printf("Passed tcondevtest\n");
static struct smbcli_state *cli1;
static struct smbcli_state *cli2;
const char *fname = "\\readonly.file";
+ char *control_char_fname;
int fnum1, fnum2;
uint8_t buf[20];
size_t fsize;
BOOL correct = True;
char *tmp_path;
int failures = 0;
+ int i;
printf("starting open test\n");
return False;
}
+ asprintf(&control_char_fname, "\\readonly.afile");
+ for (i = 1; i <= 0x1f; i++) {
+ control_char_fname[10] = i;
+ fnum1 = smbcli_nt_create_full(cli1->tree, control_char_fname, 0, SEC_FILE_WRITE_DATA, FILE_ATTRIBUTE_NORMAL,
+ NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
+
+ if (!check_error(__location__, cli1, ERRDOS, ERRinvalidname,
+ NT_STATUS_OBJECT_NAME_INVALID)) {
+ printf("Error code should be NT_STATUS_OBJECT_NAME_INVALID, was %s for file with %d char\n",
+ smbcli_errstr(cli1->tree), i);
+ failures++;
+ }
+
+ if (fnum1 != -1) {
+ smbcli_close(cli1->tree, fnum1);
+ }
+ smbcli_setatr(cli1->tree, control_char_fname, 0, 0);
+ smbcli_unlink(cli1->tree, control_char_fname);
+ }
+ free(control_char_fname);
+
+ if (!failures)
+ printf("Create file with control char names passed.\n");
+
smbcli_setatr(cli1->tree, fname, 0, 0);
smbcli_unlink(cli1->tree, fname);
{"BASE-TCONDEV", run_tcon_devtype_test, 0},
{"BASE-VUID", run_vuidtest, 0},
{"BASE-RW1", run_readwritetest, 0},
- {"BASE-RW2", NULL, run_readwritemulti},
{"BASE-OPEN", run_opentest, 0},
{"BASE-DEFER_OPEN", NULL, run_deferopen},
{"BASE-XCOPY", run_xcopy, 0},
{"BENCH-TORTURE", NULL, run_torture},
{"BENCH-NBT", torture_bench_nbt, 0},
{"BENCH-WINS", torture_bench_wins, 0},
+ {"BENCH-RPC", torture_bench_rpc, 0},
+ {"BENCH-CLDAP", torture_bench_cldap, 0},
/* RAW smb tests */
{"RAW-QFSINFO", torture_raw_qfsinfo, 0},
{"RAW-RENAME", torture_raw_rename, 0},
{"RAW-SEEK", torture_raw_seek, 0},
{"RAW-EAS", torture_raw_eas, 0},
+ {"RAW-EAMAX", torture_max_eas, 0},
{"RAW-STREAMS", torture_raw_streams, 0},
{"RAW-ACLS", torture_raw_acls, 0},
{"RAW-RAP", torture_raw_rap, 0},
/* rpc testers */
{"RPC-LSA", torture_rpc_lsa, 0},
+ {"RPC-SECRETS", torture_rpc_lsa_secrets, 0},
{"RPC-ECHO", torture_rpc_echo, 0},
{"RPC-DFS", torture_rpc_dfs, 0},
{"RPC-SPOOLSS", torture_rpc_spoolss, 0},
{"RPC-SAMR", torture_rpc_samr, 0},
+ {"RPC-UNIXINFO", torture_rpc_unixinfo, 0},
{"RPC-NETLOGON", torture_rpc_netlogon, 0},
{"RPC-SAMLOGON", torture_rpc_samlogon, 0},
{"RPC-SAMSYNC", torture_rpc_samsync, 0},
{"LOCAL-ICONV", torture_local_iconv, 0},
{"LOCAL-TALLOC", torture_local_talloc, 0},
{"LOCAL-MESSAGING", torture_local_messaging, 0},
+ {"LOCAL-IRPC", torture_local_irpc, 0},
{"LOCAL-BINDING", torture_local_binding_string, 0},
{"LOCAL-IDTREE", torture_local_idtree, 0},
{"LOCAL-SOCKET", torture_local_socket, 0},
/* ldap testers */
{"LDAP-BASIC", torture_ldap_basic, 0},
+ {"LDAP-CLDAP", torture_cldap, 0},
/* nbt tests */
{"NBT-REGISTER", torture_nbt_register, 0},
/* libnet tests */
{"NET-USERINFO", torture_userinfo, 0},
{"NET-USERADD", torture_useradd, 0},
+ {"NET-USERDEL", torture_userdel, 0},
+ {"NET-DOMOPEN", torture_domainopen, 0},
+ {"NET-API-LOOKUP", torture_lookup, 0},
+ {"NET-API-LOOKUPHOST", torture_lookup_host, 0},
+ {"NET-API-LOOKUPPDC", torture_lookup_pdc, 0},
+ {"NET-API-CREATEUSER", torture_createuser, 0},
{NULL, NULL, 0}};
return NT_STATUS_IS_OK(status);
}
+static void max_runtime_handler(int sig)
+{
+ DEBUG(0,("maximum runtime exceeded for smbtorture - terminating\n"));
+ exit(1);
+}
+
/****************************************************************************
main program
****************************************************************************/
int opt, i;
char *p;
BOOL correct = True;
+ int max_runtime=0;
int argc_new;
char **argv_new;
poptContext pc;
{"failures", 'f', POPT_ARG_INT, &torture_failures, 0, "failures", NULL},
{"parse-dns", 'D', POPT_ARG_STRING, NULL, OPT_DNS, "parse-dns", NULL},
{"dangerous", 'X', POPT_ARG_NONE, NULL, OPT_DANGEROUS, "dangerous", NULL},
+ {"maximum-runtime", 0, POPT_ARG_INT, &max_runtime, 0,
+ "set maximum time for smbtorture to live", "seconds"},
POPT_COMMON_SAMBA
POPT_COMMON_CONNECTION
POPT_COMMON_CREDENTIALS
POPT_TABLEEND
};
- setup_logging("smbtorture", DEBUG_STDOUT);
-
#ifdef HAVE_SETBUFFER
setbuffer(stdout, NULL, 0);
#endif
}
}
- lp_load(dyn_CONFIGFILE,True,False,False);
- load_interfaces();
+ if (max_runtime) {
+ /* this will only work if nobody else uses alarm(),
+ which means it won't work for some tests, but we
+ can't use the event context method we use for smbd
+ as so many tests create their own event
+ context. This will at least catch most cases. */
+ signal(SIGALRM, max_runtime_handler);
+ alarm(max_runtime);
+ }
smbtorture_init_subsystems;