ldap_service = talloc_zero(task, struct ldapsrv_service);
if (ldap_service == NULL) goto failed;
- ldap_service->tls_params = tls_initialise(ldap_service);
+ ldap_service->tls_params = tls_initialise(ldap_service, task->lp_ctx);
if (ldap_service->tls_params == NULL) goto failed;
if (lp_interfaces(task->lp_ctx) && lp_bind_interfaces_only(task->lp_ctx)) {
/*
initialise global tls state
*/
-struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx)
+struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
{
struct tls_params *params;
int ret;
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
- const char *keyfile = private_path(tmp_ctx, global_loadparm, lp_tls_keyfile(global_loadparm));
- const char *certfile = private_path(tmp_ctx, global_loadparm, lp_tls_certfile(global_loadparm));
- const char *cafile = private_path(tmp_ctx, global_loadparm, lp_tls_cafile(global_loadparm));
- const char *crlfile = private_path(tmp_ctx, global_loadparm, lp_tls_crlfile(global_loadparm));
- const char *dhpfile = private_path(tmp_ctx, global_loadparm, lp_tls_dhpfile(global_loadparm));
+ const char *keyfile = private_path(tmp_ctx, lp_ctx, lp_tls_keyfile(lp_ctx));
+ const char *certfile = private_path(tmp_ctx, lp_ctx, lp_tls_certfile(lp_ctx));
+ const char *cafile = private_path(tmp_ctx, lp_ctx, lp_tls_cafile(lp_ctx));
+ const char *crlfile = private_path(tmp_ctx, lp_ctx, lp_tls_crlfile(lp_ctx));
+ const char *dhpfile = private_path(tmp_ctx, lp_ctx, lp_tls_dhpfile(lp_ctx));
void tls_cert_generate(TALLOC_CTX *, const char *, const char *, const char *);
params = talloc(mem_ctx, struct tls_params);
return NULL;
}
- if (!lp_tls_enabled(global_loadparm) || keyfile == NULL || *keyfile == 0) {
+ if (!lp_tls_enabled(lp_ctx) || keyfile == NULL || *keyfile == 0) {
params->tls_enabled = false;
talloc_free(tmp_ctx);
return params;
setup for a new client connection
*/
struct socket_context *tls_init_client(struct socket_context *socket,
- struct fd_event *fde)
+ struct fd_event *fde,
+ const char *ca_path)
{
struct tls_context *tls;
int ret = 0;
}
new_sock->private_data = tls;
- cafile = private_path(tls, global_loadparm, lp_tls_cafile(global_loadparm));
- if (!cafile || !*cafile) {
- goto failed;
- }
-
gnutls_global_init();
gnutls_certificate_allocate_credentials(&tls->xcred);
gnutls_certificate_set_x509_trust_file(tls->xcred, cafile, GNUTLS_X509_FMT_PEM);
- talloc_free(cafile);
TLSCHECK(gnutls_init(&tls->session, GNUTLS_CLIENT));
TLSCHECK(gnutls_set_default_priority(tls->session));
gnutls_certificate_type_set_priority(tls->session, cert_type_priority);
/* for systems without tls we just fail the operations, and the caller
* will retain the original socket */
-struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx)
+struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
{
return talloc_new(mem_ctx);
}
setup for a new client connection
*/
struct socket_context *tls_init_client(struct socket_context *socket,
- struct fd_event *fde)
+ struct fd_event *fde,
+ const char *ca_path)
{
return NULL;
}
#include "lib/socket/socket.h"
+struct loadparm_context;
+
/*
call tls_initialise() once per task to startup the tls subsystem
*/
-struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx);
+struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
/*
call tls_init_server() on each new server connection
call tls_init_client() on each new client connection
*/
struct socket_context *tls_init_client(struct socket_context *sock,
- struct fd_event *fde);
+ struct fd_event *fde,
+ const char *cafile);
/*
return True if a connection used tls
#include "lib/tls/tls.h"
#include "auth/gensec/gensec.h"
#include "system/time.h"
+#include "param/param.h"
/*
talloc_steal(conn, conn->sock);
if (conn->ldaps) {
- struct socket_context *tls_socket = tls_init_client(conn->sock, conn->event.fde);
+ struct socket_context *tls_socket;
+ char *cafile = private_path(conn->sock, global_loadparm, lp_tls_cafile(global_loadparm));
+
+ if (!cafile || !*cafile) {
+ talloc_free(conn->sock);
+ return;
+ }
+
+ tls_socket = tls_init_client(conn->sock, conn->event.fde, cafile);
+ talloc_free(cafile);
+
if (tls_socket == NULL) {
talloc_free(conn->sock);
return;
setup a listening socket on all the SMB ports for a particular address
*/
_PUBLIC_ NTSTATUS smbsrv_add_socket(struct event_context *event_context,
+ struct loadparm_context *lp_ctx,
const struct model_ops *model_ops,
const char *address)
{
- const char **ports = lp_smb_ports(global_loadparm);
+ const char **ports = lp_smb_ports(lp_ctx);
int i;
NTSTATUS status;
task_server_set_title(task, "task[smbsrv]");
- if (lp_interfaces(global_loadparm) && lp_bind_interfaces_only(global_loadparm)) {
+ if (lp_interfaces(task->lp_ctx) && lp_bind_interfaces_only(task->lp_ctx)) {
int num_interfaces = iface_count();
int i;
*/
for(i = 0; i < num_interfaces; i++) {
const char *address = iface_n_ip(i);
- status = smbsrv_add_socket(task->event_ctx, task->model_ops, address);
+ status = smbsrv_add_socket(task->event_ctx, task->lp_ctx, task->model_ops, address);
if (!NT_STATUS_IS_OK(status)) goto failed;
}
} else {
/* Just bind to lp_socket_address() (usually 0.0.0.0) */
- status = smbsrv_add_socket(task->event_ctx, task->model_ops,
- lp_socket_address(global_loadparm));
+ status = smbsrv_add_socket(task->event_ctx, task->lp_ctx, task->model_ops,
+ lp_socket_address(task->lp_ctx));
if (!NT_STATUS_IS_OK(status)) goto failed;
}
};
struct model_ops;
+struct loadparm_context;
NTSTATUS smbsrv_add_socket(struct event_context *event_context,
+ struct loadparm_context *lp_ctx,
const struct model_ops *model_ops,
const char *address);
torture_assert(tctx, 0 == smb_krb5_init_context(mem_ctx,
NULL,
- global_loadparm,
+ tctx->lp_ctx,
&smb_krb5_context),
"smb_krb5_init_context");
TALLOC_CTX *mem_ctx = tctx;
torture_assert(tctx, 0 == smb_krb5_init_context(mem_ctx, NULL,
- global_loadparm,
+ tctx->lp_ctx,
&smb_krb5_context),
"smb_krb5_init_context");
struct smbcli_state *cli;
const char *host = torture_setting_string(tctx, "host", NULL);
- make_nbt_name_client(&calling, lp_netbios_name(global_loadparm));
+ make_nbt_name_client(&calling, lp_netbios_name(tctx->lp_ctx));
nbt_choose_called_name(NULL, &called, host, NBT_NAME_SERVER);
for (i=0;i<100;i++) {
struct smbcli_request *req;
- req = smb_raw_negotiate_send(cli->transport, lp_unicode(global_loadparm), PROTOCOL_NT1);
+ req = smb_raw_negotiate_send(cli->transport, lp_unicode(tctx->lp_ctx), PROTOCOL_NT1);
event_loop_once(cli->transport->socket->event.ctx);
if (req->state == SMBCLI_REQUEST_ERROR) {
if (i > 0) {
return false;
}
- nt_status_support = lp_nt_status_support(global_loadparm);
+ nt_status_support = lp_nt_status_support(tctx->lp_ctx);
- if (!lp_set_cmdline(global_loadparm, "nt status support", "yes")) {
+ if (!lp_set_cmdline(tctx->lp_ctx, "nt status support", "yes")) {
torture_comment(tctx, "Could not set 'nt status support = yes'\n");
goto fail;
}
goto fail;
}
- if (!lp_set_cmdline(global_loadparm, "nt status support", "no")) {
+ if (!lp_set_cmdline(tctx->lp_ctx, "nt status support", "no")) {
torture_comment(tctx, "Could not set 'nt status support = yes'\n");
goto fail;
}
goto fail;
}
- if (!lp_set_cmdline(global_loadparm, "nt status support",
+ if (!lp_set_cmdline(tctx->lp_ctx, "nt status support",
nt_status_support ? "yes":"no")) {
torture_comment(tctx, "Could not reset 'nt status support = yes'");
goto fail;
lpar->writeratio = torture_setting_int(tctx, "writeratio",5);
lpar->num_parallel_requests = torture_setting_int(
tctx, "parallel_requests", 5);
- lpar->workgroup = lp_workgroup(global_loadparm);
+ lpar->workgroup = lp_workgroup(tctx->lp_ctx);
p = torture_setting_string(tctx, "unclist", NULL);
if (p) {
#include "auth/credentials/credentials.h"
#include "param/param.h"
-static bool try_failed_login(struct smbcli_state *cli)
+static bool try_failed_login(struct torture_context *tctx, struct smbcli_state *cli)
{
NTSTATUS status;
struct smb_composite_sesssetup setup;
session = smbcli_session_init(cli->transport, cli, false);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities;
- setup.in.workgroup = lp_workgroup(global_loadparm);
+ setup.in.workgroup = lp_workgroup(tctx->lp_ctx);
setup.in.credentials = cli_credentials_init(session);
- cli_credentials_set_conf(setup.in.credentials, global_loadparm);
+ cli_credentials_set_conf(setup.in.credentials, tctx->lp_ctx);
cli_credentials_set_domain(setup.in.credentials, "INVALID-DOMAIN", CRED_SPECIFIED);
cli_credentials_set_username(setup.in.credentials, "INVALID-USERNAME", CRED_SPECIFIED);
cli_credentials_set_password(setup.in.credentials, "INVALID-PASSWORD", CRED_SPECIFIED);
int timelimit = torture_setting_int(tctx, "timelimit", 20);
while (time(NULL) < t1+timelimit) {
- if (!try_failed_login(cli)) {
+ if (!try_failed_login(tctx, cli)) {
return false;
}
talloc_report(NULL, stdout);
/*
test generic cldap operations
*/
-static bool test_cldap_generic(TALLOC_CTX *mem_ctx, const char *dest)
+static bool test_cldap_generic(struct torture_context *tctx, const char *dest)
{
- struct cldap_socket *cldap = cldap_socket_init(mem_ctx, NULL);
+ struct cldap_socket *cldap = cldap_socket_init(tctx, NULL);
NTSTATUS status;
struct cldap_search search;
bool ret = true;
ZERO_STRUCT(search);
search.in.dest_address = dest;
- search.in.dest_port = lp_cldap_port(global_loadparm);
+ search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
search.in.timeout = 10;
search.in.retries = 3;
- status = cldap_search(cldap, mem_ctx, &search);
+ status = cldap_search(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
printf("fetching whole rootDSE\n");
search.in.filter = "(objectclass=*)";
search.in.attributes = NULL;
- status = cldap_search(cldap, mem_ctx, &search);
+ status = cldap_search(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
if (DEBUGLVL(3)) cldap_dump_results(&search);
search.in.filter = "(objectclass=*)";
search.in.attributes = attrs1;
- status = cldap_search(cldap, mem_ctx, &search);
+ status = cldap_search(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
if (DEBUGLVL(3)) cldap_dump_results(&search);
search.in.filter = "(objectclass=*)";
search.in.attributes = attrs2;
- status = cldap_search(cldap, mem_ctx, &search);
+ status = cldap_search(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
if (DEBUGLVL(3)) cldap_dump_results(&search);
search.in.filter = "(objectclass2=*)";
search.in.attributes = attrs3;
- status = cldap_search(cldap, mem_ctx, &search);
+ status = cldap_search(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
if (DEBUGLVL(3)) cldap_dump_results(&search);
search.in.filter = "(&(objectclass=*)(highestCommittedUSN=2))";
search.in.attributes = attrs1;
- status = cldap_search(cldap, mem_ctx, &search);
+ status = cldap_search(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
if (DEBUGLVL(3)) cldap_dump_results(&search);
bool torture_cldap(struct torture_context *torture)
{
- TALLOC_CTX *mem_ctx;
bool ret = true;
const char *host = torture_setting_string(torture, "host", NULL);
- mem_ctx = talloc_init("torture_cldap");
-
- ret &= test_cldap_netlogon(mem_ctx, host);
- ret &= test_cldap_generic(mem_ctx, host);
-
- talloc_free(mem_ctx);
+ ret &= test_cldap_netlogon(torture, host);
+ ret &= test_cldap_generic(torture, host);
return ret;
}
url = talloc_asprintf(torture, "ldap://%s/", host);
- ldb = ldb_wrap_connect(torture, global_loadparm, url,
+ ldb = ldb_wrap_connect(torture, torture->lp_ctx, url,
NULL,
cmdline_credentials,
0, NULL);
url = talloc_asprintf(torture, "ldap://%s/", host);
if (!url) goto failed;
- ldb = ldb_wrap_connect(torture, global_loadparm, url,
+ ldb = ldb_wrap_connect(torture, torture->lp_ctx, url,
NULL,
cmdline_credentials,
0, NULL);
return false;
}
- name.string = lp_workgroup(global_loadparm);
+ name.string = lp_workgroup(torture->lp_ctx);
/*
* Testing synchronous version
return false;
}
- name.string = lp_workgroup(global_loadparm);
+ name.string = lp_workgroup(torture->lp_ctx);
/*
* Testing synchronous version
return false;
}
- domain_name.string = lp_workgroup(global_loadparm);
+ domain_name.string = lp_workgroup(torture->lp_ctx);
if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) {
ret = false;
goto done;
s->schema = NULL;
DEBUG(0,("Reopen the SAM LDB with system credentials and all replicated data: %s\n", s->path.samdb_ldb));
- s->ldb = ldb_wrap_connect(s, global_loadparm, s->path.samdb_ldb,
+ s->ldb = ldb_wrap_connect(s, torture->lp_ctx, s->path.samdb_ldb,
system_session(s),
NULL, 0, NULL);
if (!s->ldb) {
goto cleanup;
}
- if (lp_parm_bool(global_loadparm, NULL, "become dc", "do not unjoin", false)) {
+ if (lp_parm_bool(torture->lp_ctx, NULL, "become dc", "do not unjoin", false)) {
talloc_free(s);
return ret;
}
/* we're accessing domain controller so the domain name should be
passed (it's going to be resolved to dc name and address) instead
of specific server name. */
- domain_name = lp_workgroup(global_loadparm);
+ domain_name = lp_workgroup(torture->lp_ctx);
ctx = libnet_context_init(NULL);
if (ctx == NULL) {
goto done;
}
- domain_name.string = lp_workgroup(global_loadparm);
+ domain_name.string = lp_workgroup(torture->lp_ctx);
if (!test_opendomain_lsa(p, torture, &h, &domain_name, &access_mask)) {
d_printf("failed to open domain on lsa service\n");
/* we're accessing domain controller so the domain name should be
passed (it's going to be resolved to dc name and address) instead
of specific server name. */
- domain_name = lp_workgroup(global_loadparm);
+ domain_name = lp_workgroup(torture->lp_ctx);
/*
* Testing synchronous version
goto done;
}
- domain_name.string = talloc_strdup(mem_ctx, lp_workgroup(global_loadparm));
+ domain_name.string = talloc_strdup(mem_ctx, lp_workgroup(torture->lp_ctx));
if (!test_opendomain_samr(p, torture, &h, &domain_name, &access_mask, &sid)) {
d_printf("failed to open domain on samr service\n");
return false;
}
- domain_name.string = lp_workgroup(global_loadparm);
+ domain_name.string = lp_workgroup(torture->lp_ctx);
if (!test_opendomain(p, prep_mem_ctx, &h, &domain_name)) {
ret = false;
goto done;
goto done;
}
- lookup->in.domain_name = lp_workgroup(global_loadparm);
+ lookup->in.domain_name = lp_workgroup(torture->lp_ctx);
lookup->in.name_type = NBT_NAME_PDC;
status = libnet_LookupDCs(ctx, mem_ctx, lookup);
if (mem_ctx == NULL) return false;
r.in.name = "Administrator";
- r.in.domain_name = lp_workgroup(global_loadparm);
+ r.in.domain_name = lp_workgroup(torture->lp_ctx);
status = libnet_LookupName(ctx, mem_ctx, &r);
/* we're accessing domain controller so the domain name should be
passed (it's going to be resolved to dc name and address) instead
of specific server name. */
- domain_name = lp_workgroup(global_loadparm);
+ domain_name = lp_workgroup(torture->lp_ctx);
return torture_rpc_connect(torture, level, NULL, domain_name);
}
/* we're accessing domain controller so the domain name should be
passed (it's going to be resolved to dc name and address) instead
of specific server name. */
- domain_name = lp_workgroup(global_loadparm);
+ domain_name = lp_workgroup(torture->lp_ctx);
return torture_rpc_connect(torture, level, NULL, domain_name);
}
/* we're accessing domain controller so the domain name should be
passed (it's going to be resolved to dc name and address) instead
of specific server name. */
- domain_name = lp_workgroup(global_loadparm);
+ domain_name = lp_workgroup(torture->lp_ctx);
return torture_rpc_connect(torture, level, NULL, domain_name);
}
ctx->cred = cmdline_credentials;
req.in.user_name = TEST_USERNAME;
- req.in.domain_name = lp_workgroup(global_loadparm);
+ req.in.domain_name = lp_workgroup(torture->lp_ctx);
req.out.error_string = NULL;
status = libnet_CreateUser(ctx, mem_ctx, &req);
ctx->cred = cmdline_credentials;
req.in.user_name = TEST_USERNAME;
- req.in.domain_name = lp_workgroup(global_loadparm);
+ req.in.domain_name = lp_workgroup(torture->lp_ctx);
status = torture_rpc_connection(torture,
&p,
goto done;
}
- domain_name.string = lp_workgroup(global_loadparm);
+ domain_name.string = lp_workgroup(torture->lp_ctx);
if (!test_opendomain(p, prep_mem_ctx, &h, &domain_name)) {
ret = false;
goto done;
name = talloc_strdup(prep_mem_ctx, TEST_USERNAME);
- domain_name.string = lp_workgroup(global_loadparm);
+ domain_name.string = lp_workgroup(torture->lp_ctx);
if (!test_opendomain(p, prep_mem_ctx, &h, &domain_name)) {
ret = false;
goto done;
for (fld = 1; fld < FIELDS_NUM - 1; fld++) {
ZERO_STRUCT(req);
- req.in.domain_name = lp_workgroup(global_loadparm);
+ req.in.domain_name = lp_workgroup(torture->lp_ctx);
req.in.user_name = name;
set_test_changes(mem_ctx, &req, 1, &name, fld);
}
ZERO_STRUCT(user_req);
- user_req.in.domain_name = lp_workgroup(global_loadparm);
+ user_req.in.domain_name = lp_workgroup(torture->lp_ctx);
user_req.in.user_name = name;
status = libnet_UserInfo(ctx, mem_ctx, &user_req);
/* restore original testing username - it's useful when test fails
because it prevents from problems with recreating account */
ZERO_STRUCT(req);
- req.in.domain_name = lp_workgroup(global_loadparm);
+ req.in.domain_name = lp_workgroup(torture->lp_ctx);
req.in.user_name = name;
req.in.account_name = TEST_USERNAME;
return false;
}
- domain_name.string = lp_workgroup(global_loadparm);
+ domain_name.string = lp_workgroup(torture->lp_ctx);
if (!test_opendomain(p, prep_mem_ctx, &h, &domain_name)) {
ret = false;
goto done;
ctx = libnet_context_init(NULL);
ctx->cred = cmdline_credentials;
- domain_name.string = lp_workgroup(global_loadparm);
+ domain_name.string = lp_workgroup(torture->lp_ctx);
mem_ctx = talloc_init("torture user list");
ZERO_STRUCT(req);
return false;
}
- name.string = lp_workgroup(global_loadparm);
+ name.string = lp_workgroup(torture->lp_ctx);
/*
* Testing synchronous version
return false;
}
- domain_name.string = lp_workgroup(global_loadparm);
+ domain_name.string = lp_workgroup(torture->lp_ctx);
if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) {
ret = false;
goto done;
return false;
}
- domain_name.string = lp_workgroup(global_loadparm);
+ domain_name.string = lp_workgroup(torture->lp_ctx);
if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) {
ret = false;
goto done;
goto done;
}
- domain_name.string = lp_workgroup(global_loadparm);
+ domain_name.string = lp_workgroup(torture->lp_ctx);
name = talloc_strdup(mem_ctx, TEST_USERNAME);
if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) {
torture_comment(torture, "Testing ldb speed for sidmap\n");
- ldb = ldb_wrap_connect(tmp_ctx, global_loadparm, "tdb://test.ldb",
+ ldb = ldb_wrap_connect(tmp_ctx, torture->lp_ctx, "tdb://test.ldb",
NULL, NULL, LDB_FLG_NOSYNC, NULL);
if (!ldb) {
unlink("./test.ldb");
const char *address;
struct nbt_name name;
- name.name = lp_workgroup(global_loadparm);
+ name.name = lp_workgroup(tctx->lp_ctx);
name.type = NBT_NAME_LOGON;
name.scope = NULL;
socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name,
- myaddress, lp_dgram_port(global_loadparm));
+ myaddress, lp_dgram_port(tctx->lp_ctx));
torture_assert(tctx, socket_address != NULL, "Error getting address");
/* try receiving replies on port 138 first, which will only
const char *address;
struct nbt_name name;
- name.name = lp_workgroup(global_loadparm);
+ name.name = lp_workgroup(tctx->lp_ctx);
name.type = NBT_NAME_LOGON;
name.scope = NULL;
myaddress = talloc_strdup(dgmsock, iface_best_ip(address));
socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name,
- myaddress, lp_dgram_port(global_loadparm));
+ myaddress, lp_dgram_port(tctx->lp_ctx));
torture_assert(tctx, socket_address != NULL, "Error getting address");
/* try receiving replies on port 138 first, which will only
const char *address;
struct nbt_name name;
- name.name = lp_workgroup(global_loadparm);
+ name.name = lp_workgroup(tctx->lp_ctx);
name.type = NBT_NAME_LOGON;
name.scope = NULL;
myaddress = talloc_strdup(dgmsock, iface_best_ip(address));
socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name,
- myaddress, lp_dgram_port(global_loadparm));
+ myaddress, lp_dgram_port(tctx->lp_ctx));
torture_assert(tctx, socket_address != NULL, "Error getting address");
/* try receiving replies on port 138 first, which will only
ACB_WSTRUST, &machine_credentials);
torture_assert(tctx, join_ctx != NULL,
talloc_asprintf(tctx, "Failed to join domain %s as %s\n",
- lp_workgroup(global_loadparm), TEST_NAME));
+ lp_workgroup(tctx->lp_ctx), TEST_NAME));
dom_sid = torture_join_sid(join_ctx);
if (!ctx->nbtsock_srv) return NULL;
/* Make a port 137 version of ctx->myaddr */
- nbt_srv_addr = socket_address_from_strings(tctx, ctx->nbtsock_srv->sock->backend_name, ctx->myaddr->addr, lp_nbt_port(global_loadparm));
+ nbt_srv_addr = socket_address_from_strings(tctx, ctx->nbtsock_srv->sock->backend_name, ctx->myaddr->addr, lp_nbt_port(tctx->lp_ctx));
if (!nbt_srv_addr) return NULL;
/* And if possible, bind to it. This won't work unless we are root or in sockewrapper */
nbt_srv_addr = socket_address_from_strings(tctx,
ctx->nbtsock_srv->sock->backend_name,
ctx->myaddr2->addr,
- lp_nbt_port(global_loadparm));
+ lp_nbt_port(tctx->lp_ctx));
if (!nbt_srv_addr) return NULL;
/* And if possible, bind to it. This won't work unless we are root or in sockewrapper */
if (!ctx->nbtsock_srv) {
torture_comment(tctx, "SKIP: Test Replica records vs. owned active records: not bound to port[%d]\n",
- lp_nbt_port(global_loadparm));
+ lp_nbt_port(tctx->lp_ctx));
return true;
}
/*
test a simple savefile/loadfile combination
*/
-static bool test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_loadfile(struct smbcli_state *cli, struct torture_context *tctx)
{
const char *fname = BASEDIR "\\test.txt";
NTSTATUS status;
size_t len = random() % 100000;
const int num_ops = 50;
int i;
- int *count = talloc_zero(mem_ctx, int);
+ int *count = talloc_zero(tctx, int);
- data = talloc_array(mem_ctx, uint8_t, len);
+ data = talloc_array(tctx, uint8_t, len);
generate_random_buffer(data, len);
printf("testing parallel loadfile with %d ops\n", num_ops);
- c = talloc_array(mem_ctx, struct composite_context *, num_ops);
+ c = talloc_array(tctx, struct composite_context *, num_ops);
for (i=0;i<num_ops;i++) {
c[i] = smb_composite_loadfile_send(cli->tree, &io2);
printf("waiting for completion\n");
while (*count != num_ops) {
event_loop_once(cli->transport->socket->event.ctx);
- if (lp_parm_bool(global_loadparm, NULL, "torture", "progress", true)) {
+ if (torture_setting_bool(tctx, "progress", true)) {
printf("(%s) count=%d\r", __location__, *count);
fflush(stdout);
}
printf("count=%d\n", *count);
for (i=0;i<num_ops;i++) {
- status = smb_composite_loadfile_recv(c[i], mem_ctx);
+ status = smb_composite_loadfile_recv(c[i], tctx);
if (!NT_STATUS_IS_OK(status)) {
printf("(%s) loadfile[%d] failed - %s\n", __location__, i, nt_errstr(status));
return false;
/*
test a simple savefile/loadfile combination
*/
-static bool test_fetchfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_fetchfile(struct smbcli_state *cli, struct torture_context *tctx)
{
const char *fname = BASEDIR "\\test.txt";
NTSTATUS status;
size_t len = random() % 10000;
extern int torture_numops;
struct event_context *event_ctx;
- int *count = talloc_zero(mem_ctx, int);
+ int *count = talloc_zero(tctx, int);
bool ret = true;
- data = talloc_array(mem_ctx, uint8_t, len);
+ data = talloc_array(tctx, uint8_t, len);
generate_random_buffer(data, len);
return false;
}
- io2.in.dest_host = lp_parm_string(global_loadparm, NULL, "torture", "host");
+ io2.in.dest_host = torture_setting_string(tctx, "host", NULL);
io2.in.port = 0;
- io2.in.called_name = lp_parm_string(global_loadparm, NULL, "torture", "host");
- io2.in.service = lp_parm_string(global_loadparm, NULL, "torture", "share");
+ io2.in.called_name = torture_setting_string(tctx, "host", NULL);
+ io2.in.service = torture_setting_string(tctx, "share", NULL);
io2.in.service_type = "A:";
io2.in.credentials = cmdline_credentials;
- io2.in.workgroup = lp_workgroup(global_loadparm);
+ io2.in.workgroup = lp_workgroup(tctx->lp_ctx);
io2.in.filename = fname;
printf("testing parallel fetchfile with %d ops\n", torture_numops);
event_ctx = cli->transport->socket->event.ctx;
- c = talloc_array(mem_ctx, struct composite_context *, torture_numops);
+ c = talloc_array(tctx, struct composite_context *, torture_numops);
for (i=0; i<torture_numops; i++) {
c[i] = smb_composite_fetchfile_send(&io2, event_ctx);
while (*count != torture_numops) {
event_loop_once(event_ctx);
- if (lp_parm_bool(global_loadparm, NULL, "torture", "progress", true)) {
+ if (torture_setting_bool(tctx, "progress", true)) {
printf("(%s) count=%d\r", __location__, *count);
fflush(stdout);
}
printf("count=%d\n", *count);
for (i=0;i<torture_numops;i++) {
- status = smb_composite_fetchfile_recv(c[i], mem_ctx);
+ status = smb_composite_fetchfile_recv(c[i], tctx);
if (!NT_STATUS_IS_OK(status)) {
printf("(%s) loadfile[%d] failed - %s\n", __location__, i,
nt_errstr(status));
/*
test setfileacl
*/
-static bool test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_appendacl(struct smbcli_state *cli, struct torture_context *tctx)
{
struct smb_composite_appendacl **io;
struct smb_composite_appendacl **io_orig;
struct dom_sid *test_sid;
const int num_ops = 50;
- int *count = talloc_zero(mem_ctx, int);
+ int *count = talloc_zero(tctx, int);
struct smb_composite_savefile io1;
NTSTATUS status;
int i;
- io_orig = talloc_array(mem_ctx, struct smb_composite_appendacl *, num_ops);
+ io_orig = talloc_array(tctx, struct smb_composite_appendacl *, num_ops);
printf ("creating %d empty files and getting their acls with appendacl\n", num_ops);
/* fill Security Descriptor with aces to be added */
- test_sd = security_descriptor_initialise(mem_ctx);
- test_sid = dom_sid_parse_talloc (mem_ctx, "S-1-5-32-1234-5432");
+ test_sd = security_descriptor_initialise(tctx);
+ test_sid = dom_sid_parse_talloc (tctx, "S-1-5-32-1234-5432");
- ace = talloc_zero(mem_ctx, struct security_ace);
+ ace = talloc_zero(tctx, struct security_ace);
ace->type = SEC_ACE_TYPE_ACCESS_ALLOWED;
ace->flags = 0;
printf("testing parallel appendacl with %d ops\n", num_ops);
- c = talloc_array(mem_ctx, struct composite_context *, num_ops);
- io = talloc_array(mem_ctx, struct smb_composite_appendacl *, num_ops);
+ c = talloc_array(tctx, struct composite_context *, num_ops);
+ io = talloc_array(tctx, struct smb_composite_appendacl *, num_ops);
for (i=0; i < num_ops; i++) {
io[i] = talloc (io, struct smb_composite_appendacl);
c[i]->async.private_data = count;
}
- event_ctx = talloc_reference(mem_ctx, cli->tree->session->transport->socket->event.ctx);
+ event_ctx = talloc_reference(tctx, cli->tree->session->transport->socket->event.ctx);
printf("waiting for completion\n");
while (*count != num_ops) {
event_loop_once(event_ctx);
- if (lp_parm_bool(global_loadparm, NULL, "torture", "progress", true)) {
+ if (torture_setting_bool(tctx, "progress", true)) {
printf("(%s) count=%d\r", __location__, *count);
fflush(stdout);
}
}
/* test a query FS info by asking for share's GUID */
-static bool test_fsinfo(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_fsinfo(struct smbcli_state *cli, struct torture_context *tctx)
{
char *guid = NULL;
NTSTATUS status;
int i;
extern int torture_numops;
struct event_context *event_ctx;
- int *count = talloc_zero(mem_ctx, int);
+ int *count = talloc_zero(tctx, int);
bool ret = true;
- io1.in.dest_host = lp_parm_string(global_loadparm, NULL, "torture", "host");
+ io1.in.dest_host = torture_setting_string(tctx, "host", NULL);
io1.in.port = 0;
- io1.in.called_name = lp_parm_string(global_loadparm, NULL, "torture", "host");
- io1.in.service = lp_parm_string(global_loadparm, NULL, "torture", "share");
+ io1.in.called_name = torture_setting_string(tctx, "host", NULL);
+ io1.in.service = torture_setting_string(tctx, "share", NULL);
io1.in.service_type = "A:";
io1.in.credentials = cmdline_credentials;
- io1.in.workgroup = lp_workgroup(global_loadparm);
+ io1.in.workgroup = lp_workgroup(tctx->lp_ctx);
io1.in.level = RAW_QFS_OBJECTID_INFORMATION;
printf("testing parallel queryfsinfo [Object ID] with %d ops\n", torture_numops);
- event_ctx = talloc_reference(mem_ctx, cli->tree->session->transport->socket->event.ctx);
- c = talloc_array(mem_ctx, struct composite_context *, torture_numops);
+ event_ctx = talloc_reference(tctx, cli->tree->session->transport->socket->event.ctx);
+ c = talloc_array(tctx, struct composite_context *, torture_numops);
for (i=0; i<torture_numops; i++) {
c[i] = smb_composite_fsinfo_send(cli->tree,&io1);
while (*count < torture_numops) {
event_loop_once(event_ctx);
- if (lp_parm_bool(global_loadparm, NULL, "torture", "progress", true)) {
+ if (torture_setting_bool(tctx, "progress", true)) {
printf("(%s) count=%d\r", __location__, *count);
fflush(stdout);
}
printf("count=%d\n", *count);
for (i=0;i<torture_numops;i++) {
- status = smb_composite_fsinfo_recv(c[i], mem_ctx);
+ status = smb_composite_fsinfo_recv(c[i], tctx);
if (!NT_STATUS_IS_OK(status)) {
printf("(%s) fsinfo[%d] failed - %s\n", __location__, i, nt_errstr(status));
ret = false;
continue;
}
- guid=GUID_string(mem_ctx, &io1.out.fsinfo->objectid_information.out.guid);
+ guid=GUID_string(tctx, &io1.out.fsinfo->objectid_information.out.guid);
printf("[%d] GUID: %s\n", i, guid);
/*
test session ops
*/
-static bool test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_session(struct smbcli_state *cli, struct torture_context *tctx)
{
NTSTATUS status;
bool ret = true;
}
printf("create a second security context on the same transport\n");
- session = smbcli_session_init(cli->transport, mem_ctx, false);
+ session = smbcli_session_init(cli->transport, tctx, false);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */
- setup.in.workgroup = lp_workgroup(global_loadparm);
+ setup.in.workgroup = lp_workgroup(tctx->lp_ctx);
setup.in.credentials = cmdline_credentials;
session->vuid = setup.out.vuid;
printf("create a third security context on the same transport, with vuid set\n");
- session2 = smbcli_session_init(cli->transport, mem_ctx, false);
+ session2 = smbcli_session_init(cli->transport, tctx, false);
session2->vuid = session->vuid;
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */
- setup.in.workgroup = lp_workgroup(global_loadparm);
+ setup.in.workgroup = lp_workgroup(tctx->lp_ctx);
setup.in.credentials = cmdline_credentials;
if (cli->transport->negotiate.capabilities & CAP_EXTENDED_SECURITY) {
printf("create a fourth security context on the same transport, without extended security\n");
- session3 = smbcli_session_init(cli->transport, mem_ctx, false);
+ session3 = smbcli_session_init(cli->transport, tctx, false);
session3->vuid = session->vuid;
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities &= ~CAP_EXTENDED_SECURITY; /* force a non extended security login (should fail) */
- setup.in.workgroup = lp_workgroup(global_loadparm);
+ setup.in.workgroup = lp_workgroup(tctx->lp_ctx);
setup.in.credentials = cmdline_credentials;
CHECK_STATUS(status, NT_STATUS_LOGON_FAILURE);
printf("create a fouth anonymous security context on the same transport, without extended security\n");
- session4 = smbcli_session_init(cli->transport, mem_ctx, false);
+ session4 = smbcli_session_init(cli->transport, tctx, false);
session4->vuid = session->vuid;
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities &= ~CAP_EXTENDED_SECURITY; /* force a non extended security login (should fail) */
- setup.in.workgroup = lp_workgroup(global_loadparm);
+ setup.in.workgroup = lp_workgroup(tctx->lp_ctx);
- anon_creds = cli_credentials_init(mem_ctx);
- cli_credentials_set_conf(anon_creds, global_loadparm);
+ anon_creds = cli_credentials_init(tctx);
+ cli_credentials_set_conf(anon_creds, tctx->lp_ctx);
cli_credentials_set_anonymous(anon_creds);
setup.in.credentials = anon_creds;
}
printf("use the same tree as the existing connection\n");
- tree = smbcli_tree_init(session, mem_ctx, false);
+ tree = smbcli_tree_init(session, tctx, false);
tree->tid = cli->tree->tid;
printf("create a file using the new vuid\n");
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = fname;
- status = smb_raw_open(tree, mem_ctx, &io);
+ status = smb_raw_open(tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
for (i=0; i <ARRAY_SIZE(sessions); i++) {
setups[i].in.sesskey = cli->transport->negotiate.sesskey;
setups[i].in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */
- setups[i].in.workgroup = lp_workgroup(global_loadparm);
+ setups[i].in.workgroup = lp_workgroup(tctx->lp_ctx);
setups[i].in.credentials = cmdline_credentials;
- sessions[i] = smbcli_session_init(cli->transport, mem_ctx, false);
+ sessions[i] = smbcli_session_init(cli->transport, tctx, false);
composite_contexts[i] = smb_composite_sesssetup_send(sessions[i], &setups[i]);
}
/*
test tree ops
*/
-static bool test_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_tree(struct smbcli_state *cli, struct torture_context *tctx)
{
NTSTATUS status;
bool ret = true;
return false;
}
- share = lp_parm_string(global_loadparm, NULL, "torture", "share");
- host = lp_parm_string(global_loadparm, NULL, "torture", "host");
+ share = torture_setting_string(tctx, "share", NULL);
+ host = torture_setting_string(tctx, "host", NULL);
printf("create a second tree context on the same session\n");
- tree = smbcli_tree_init(cli->session, mem_ctx, false);
+ tree = smbcli_tree_init(cli->session, tctx, false);
tcon.generic.level = RAW_TCON_TCONX;
tcon.tconx.in.flags = 0;
tcon.tconx.in.password = data_blob(NULL, 0);
- tcon.tconx.in.path = talloc_asprintf(mem_ctx, "\\\\%s\\%s", host, share);
+ tcon.tconx.in.path = talloc_asprintf(tctx, "\\\\%s\\%s", host, share);
tcon.tconx.in.device = "A:";
- status = smb_raw_tcon(tree, mem_ctx, &tcon);
+ status = smb_raw_tcon(tree, tctx, &tcon);
CHECK_STATUS(status, NT_STATUS_OK);
printf("try a tconx with a bad device type\n");
tcon.tconx.in.device = "FOO";
- status = smb_raw_tcon(tree, mem_ctx, &tcon);
+ status = smb_raw_tcon(tree, tctx, &tcon);
CHECK_STATUS(status, NT_STATUS_BAD_DEVICE_TYPE);
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = fname;
- status = smb_raw_open(tree, mem_ctx, &io);
+ status = smb_raw_open(tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
this demonstrates that a tcon isn't autoclosed by a ulogoff
the tcon can be reused using any other valid session later
*/
-static bool test_tree_ulogoff(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_tree_ulogoff(struct smbcli_state *cli, struct torture_context *tctx)
{
NTSTATUS status;
bool ret = true;
return false;
}
- share = lp_parm_string(global_loadparm, NULL, "torture", "share");
- host = lp_parm_string(global_loadparm, NULL, "torture", "host");
+ share = torture_setting_string(tctx, "share", NULL);
+ host = torture_setting_string(tctx, "host", NULL);
printf("create the first new sessions\n");
- session1 = smbcli_session_init(cli->transport, mem_ctx, false);
+ session1 = smbcli_session_init(cli->transport, tctx, false);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities;
- setup.in.workgroup = lp_workgroup(global_loadparm);
+ setup.in.workgroup = lp_workgroup(tctx->lp_ctx);
setup.in.credentials = cmdline_credentials;
status = smb_composite_sesssetup(session1, &setup);
CHECK_STATUS(status, NT_STATUS_OK);
printf("vuid1=%d\n", session1->vuid);
printf("create a tree context on the with vuid1\n");
- tree = smbcli_tree_init(session1, mem_ctx, false);
+ tree = smbcli_tree_init(session1, tctx, false);
tcon.generic.level = RAW_TCON_TCONX;
tcon.tconx.in.flags = 0;
tcon.tconx.in.password = data_blob(NULL, 0);
- tcon.tconx.in.path = talloc_asprintf(mem_ctx, "\\\\%s\\%s", host, share);
+ tcon.tconx.in.path = talloc_asprintf(tctx, "\\\\%s\\%s", host, share);
tcon.tconx.in.device = "A:";
- status = smb_raw_tcon(tree, mem_ctx, &tcon);
+ status = smb_raw_tcon(tree, tctx, &tcon);
CHECK_STATUS(status, NT_STATUS_OK);
tree->tid = tcon.tconx.out.tid;
printf("tid=%d\n", tree->tid);
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = fname1;
- status = smb_raw_open(tree, mem_ctx, &io);
+ status = smb_raw_open(tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum1 = io.ntcreatex.out.file.fnum;
CHECK_STATUS(status, NT_STATUS_OK);
printf("create the second new sessions\n");
- session2 = smbcli_session_init(cli->transport, mem_ctx, false);
+ session2 = smbcli_session_init(cli->transport, tctx, false);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities;
- setup.in.workgroup = lp_workgroup(global_loadparm);
+ setup.in.workgroup = lp_workgroup(tctx->lp_ctx);
setup.in.credentials = cmdline_credentials;
status = smb_composite_sesssetup(session2, &setup);
CHECK_STATUS(status, NT_STATUS_OK);
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = fname2;
- status = smb_raw_open(tree, mem_ctx, &io);
+ status = smb_raw_open(tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
/*
test pid ops with 2 sessions
*/
-static bool test_pid_2sess(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_pid_2sess(struct smbcli_state *cli, struct torture_context *tctx)
{
NTSTATUS status;
bool ret = true;
}
printf("create a second security context on the same transport\n");
- session = smbcli_session_init(cli->transport, mem_ctx, false);
+ session = smbcli_session_init(cli->transport, tctx, false);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */
- setup.in.workgroup = lp_workgroup(global_loadparm);
+ setup.in.workgroup = lp_workgroup(tctx->lp_ctx);
setup.in.credentials = cmdline_credentials;
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = fname;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
/*
test pid ops with 2 tcons
*/
-static bool test_pid_2tcon(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_pid_2tcon(struct smbcli_state *cli, struct torture_context *tctx)
{
NTSTATUS status;
bool ret = true;
return false;
}
- share = lp_parm_string(global_loadparm, NULL, "torture", "share");
- host = lp_parm_string(global_loadparm, NULL, "torture", "host");
+ share = torture_setting_string(tctx, "share", NULL);
+ host = torture_setting_string(tctx, "host", NULL);
printf("create a second tree context on the same session\n");
- tree = smbcli_tree_init(cli->session, mem_ctx, false);
+ tree = smbcli_tree_init(cli->session, tctx, false);
tcon.generic.level = RAW_TCON_TCONX;
tcon.tconx.in.flags = 0;
tcon.tconx.in.password = data_blob(NULL, 0);
- tcon.tconx.in.path = talloc_asprintf(mem_ctx, "\\\\%s\\%s", host, share);
+ tcon.tconx.in.path = talloc_asprintf(tctx, "\\\\%s\\%s", host, share);
tcon.tconx.in.device = "A:";
- status = smb_raw_tcon(tree, mem_ctx, &tcon);
+ status = smb_raw_tcon(tree, tctx, &tcon);
CHECK_STATUS(status, NT_STATUS_OK);
tree->tid = tcon.tconx.out.tid;
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = fname1;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum1 = io.ntcreatex.out.file.fnum;
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = fname2;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
struct smbcli_state *cli)
{
bool ret = true;
- if (lp_use_spnego(global_loadparm)) {
+ if (lp_use_spnego(torture->lp_ctx)) {
ret &= torture_raw_context_int(torture, cli);
- lp_set_cmdline(global_loadparm, "use spnego", "False");
+ lp_set_cmdline(torture->lp_ctx, "use spnego", "False");
}
ret &= torture_raw_context_int(torture, cli);
* --option torture:maxeasize=1024 --option torture:maxeadebug=1 ...
*
*/
-static bool test_max_eas(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_max_eas(struct smbcli_state *cli, struct torture_context *tctx)
{
NTSTATUS status;
union smb_open io;
printf("TESTING SETFILEINFO MAX. EA_SET\n");
- maxeasize = lp_parm_int(global_loadparm, NULL, "torture", "maxeasize", 65536);
- maxeanames = lp_parm_int(global_loadparm, NULL, "torture", "maxeanames", 101);
- maxeastart = lp_parm_int(global_loadparm, NULL, "torture", "maxeastart", 1);
- maxeadebug = lp_parm_int(global_loadparm, NULL, "torture", "maxeadebug", 0);
+ maxeasize = torture_setting_int(tctx, "maxeasize", 65536);
+ maxeanames = torture_setting_int(tctx, "maxeanames", 101);
+ maxeastart = torture_setting_int(tctx, "maxeastart", 1);
+ maxeadebug = torture_setting_int(tctx, "maxeadebug", 0);
/* Do some sanity check on possibly passed parms */
if (maxeasize <= 0) {
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = fname;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
- eablob = data_blob_talloc(mem_ctx, NULL, maxeasize);
+ eablob = data_blob_talloc(tctx, NULL, maxeasize);
if (eablob.data == NULL) {
goto done;
}
if (eaname != NULL) {
talloc_free(eaname);
}
- eaname = talloc_asprintf(mem_ctx, "MAX%d", i);
+ eaname = talloc_asprintf(tctx, "MAX%d", i);
if(eaname == NULL) {
goto done;
}
{
struct smbcli_state *cli;
bool ret = true;
- TALLOC_CTX *mem_ctx;
if (!torture_open_connection(&cli, 0)) {
return false;
}
- mem_ctx = talloc_init("torture_raw_eas");
-
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
}
- ret &= test_max_eas(cli, mem_ctx);
+ ret &= test_max_eas(cli, torture);
smb_raw_exit(cli->session);
if (!maxeadebug) {
}
torture_close_connection(cli);
- talloc_free(mem_ctx);
return ret;
}
session = smbcli_session_init(cli->transport, tctx, false);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities;
- setup.in.workgroup = lp_workgroup(global_loadparm);
+ setup.in.workgroup = lp_workgroup(tctx->lp_ctx);
setup.in.credentials = cmdline_credentials;
status = smb_composite_sesssetup(session, &setup);
CHECK_STATUS(status, NT_STATUS_OK);
session->vuid = setup.out.vuid;
printf("create new tree context\n");
- share = lp_parm_string(global_loadparm, NULL, "torture", "share");
- host = lp_parm_string(global_loadparm, NULL, "torture", "host");
+ share = torture_setting_string(tctx, "share", NULL);
+ host = torture_setting_string(tctx, "host", NULL);
tree = smbcli_tree_init(session, tctx, false);
tcon.generic.level = RAW_TCON_TCONX;
tcon.tconx.in.flags = 0;
progress = torture_setting_bool(torture, "progress", true);
- nprocs = lp_parm_int(global_loadparm, NULL, "torture", "nprocs", 4);
+ nprocs = torture_setting_int(torture, "nprocs", 4);
state = talloc_zero_array(mem_ctx, struct benchlock_state, nprocs);
/*
test mkdir ops
*/
-static bool test_mkdir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_mkdir(struct smbcli_state *cli, struct torture_context *tctx)
{
union smb_mkdir md;
struct smb_rmdir rd;
printf("testing mkdir collision with file\n");
/* name collision with a file */
- smbcli_close(cli->tree, create_complex_file(cli, mem_ctx, path));
+ smbcli_close(cli->tree, create_complex_file(cli, tctx, path));
status = smb_raw_mkdir(cli->tree, &md);
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION);
CHECK_STATUS(status, NT_STATUS_OK);
printf("testing t2mkdir bad path\n");
- md.t2mkdir.in.path = talloc_asprintf(mem_ctx, "%s\\bad_path\\bad_path",
+ md.t2mkdir.in.path = talloc_asprintf(tctx, "%s\\bad_path\\bad_path",
BASEDIR);
status = smb_raw_mkdir(cli->tree, &md);
CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
md.t2mkdir.level = RAW_MKDIR_T2MKDIR;
md.t2mkdir.in.path = path;
md.t2mkdir.in.num_eas = 3;
- md.t2mkdir.in.eas = talloc_array(mem_ctx, struct ea_struct, md.t2mkdir.in.num_eas);
+ md.t2mkdir.in.eas = talloc_array(tctx, struct ea_struct, md.t2mkdir.in.num_eas);
md.t2mkdir.in.eas[0].flags = 0;
md.t2mkdir.in.eas[0].name.s = "EAONE";
- md.t2mkdir.in.eas[0].value = data_blob_talloc(mem_ctx, "blah", 4);
+ md.t2mkdir.in.eas[0].value = data_blob_talloc(tctx, "blah", 4);
md.t2mkdir.in.eas[1].flags = 0;
md.t2mkdir.in.eas[1].name.s = "EA TWO";
- md.t2mkdir.in.eas[1].value = data_blob_talloc(mem_ctx, "foo bar", 7);
+ md.t2mkdir.in.eas[1].value = data_blob_talloc(tctx, "foo bar", 7);
md.t2mkdir.in.eas[2].flags = 0;
md.t2mkdir.in.eas[2].name.s = "EATHREE";
- md.t2mkdir.in.eas[2].value = data_blob_talloc(mem_ctx, "xx1", 3);
+ md.t2mkdir.in.eas[2].value = data_blob_talloc(tctx, "xx1", 3);
status = smb_raw_mkdir(cli->tree, &md);
- if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)
+ if (torture_setting_bool(tctx, "samba3", false)
&& NT_STATUS_EQUAL(status, NT_STATUS_EAS_NOT_SUPPORTED)) {
d_printf("EAS not supported -- not treating as fatal\n");
}
/*
testing of mask bits for change notify
*/
-static bool test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_notify_mask(struct smbcli_state *cli, struct torture_context *tctx)
{
bool ret = true;
NTSTATUS status;
#define NOTIFY_MASK_TEST(setup, op, cleanup, Action, expected, nchanges) \
do { for (mask=i=0;i<32;i++) { \
struct smbcli_request *req; \
- status = smb_raw_open(cli->tree, mem_ctx, &io); \
+ status = smb_raw_open(cli->tree, tctx, &io); \
CHECK_STATUS(status, NT_STATUS_OK); \
fnum = io.ntcreatex.out.file.fnum; \
setup \
req = smb_raw_changenotify_send(cli->tree, ¬ify); \
op \
msleep(200); smb_raw_ntcancel(req); \
- status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); \
+ status = smb_raw_changenotify_recv(req, tctx, ¬ify); \
cleanup \
smbcli_close(cli->tree, fnum); \
if (NT_STATUS_EQUAL(status, NT_STATUS_CANCELLED)) continue; \
printf("testing set file attribute\n");
NOTIFY_MASK_TEST(
- fnum2 = create_complex_file(cli, mem_ctx, BASEDIR "\\tname1");,
+ fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");,
smbcli_fsetatr(cli->tree, fnum2, FILE_ATTRIBUTE_HIDDEN, 0, 0, 0, 0);,
(smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));,
NOTIFY_ACTION_MODIFIED,
FILE_NOTIFY_CHANGE_ATTRIBUTES, 1);
- if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
+ if (torture_setting_bool(tctx, "samba3", false)) {
printf("Samba3 does not yet support create times "
"everywhere\n");
}
else {
printf("testing set file create time\n");
NOTIFY_MASK_TEST(
- fnum2 = create_complex_file(cli, mem_ctx,
+ fnum2 = create_complex_file(cli, tctx,
BASEDIR "\\tname1");,
smbcli_fsetatr(cli->tree, fnum2, 0, t, 0, 0, 0);,
(smbcli_close(cli->tree, fnum2),
printf("testing set file access time\n");
NOTIFY_MASK_TEST(
- fnum2 = create_complex_file(cli, mem_ctx, BASEDIR "\\tname1");,
+ fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");,
smbcli_fsetatr(cli->tree, fnum2, 0, 0, t, 0, 0);,
(smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));,
NOTIFY_ACTION_MODIFIED,
printf("testing set file write time\n");
NOTIFY_MASK_TEST(
- fnum2 = create_complex_file(cli, mem_ctx, BASEDIR "\\tname1");,
+ fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");,
smbcli_fsetatr(cli->tree, fnum2, 0, 0, 0, t, 0);,
(smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));,
NOTIFY_ACTION_MODIFIED,
printf("testing set file change time\n");
NOTIFY_MASK_TEST(
- fnum2 = create_complex_file(cli, mem_ctx, BASEDIR "\\tname1");,
+ fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");,
smbcli_fsetatr(cli->tree, fnum2, 0, 0, 0, 0, t);,
(smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));,
NOTIFY_ACTION_MODIFIED,
printf("testing write\n");
NOTIFY_MASK_TEST(
- fnum2 = create_complex_file(cli, mem_ctx, BASEDIR "\\tname1");,
+ fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");,
smbcli_write(cli->tree, fnum2, 1, &c, 10000, 1);,
(smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));,
NOTIFY_ACTION_MODIFIED,
printf("testing truncate\n");
NOTIFY_MASK_TEST(
- fnum2 = create_complex_file(cli, mem_ctx, BASEDIR "\\tname1");,
+ fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");,
smbcli_ftruncate(cli->tree, fnum2, 10000);,
(smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));,
NOTIFY_ACTION_MODIFIED,
}} while (0)
#define CREATE_FILE do { \
- fnum = create_complex_file(cli, mem_ctx, fname); \
+ fnum = create_complex_file(cli, tctx, fname); \
if (fnum == -1) { \
printf("(%s) Failed to create %s - %s\n", __location__, fname, smbcli_errstr(cli->tree)); \
ret = false; \
time_t t1, t2; \
finfo.all_info.level = RAW_FILEINFO_ALL_INFO; \
finfo.all_info.in.file.path = fname; \
- status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); \
+ status = smb_raw_pathinfo(cli->tree, tctx, &finfo); \
CHECK_STATUS(status, NT_STATUS_OK); \
t1 = t & ~1; \
t2 = nt_time_to_unix(finfo.all_info.out.field) & ~1; \
if (abs(t1-t2) > 2) { \
printf("(%s) wrong time for field %s %s - %s\n", \
__location__, #field, \
- timestring(mem_ctx, t1), \
- timestring(mem_ctx, t2)); \
- dump_all_info(mem_ctx, &finfo); \
+ timestring(tctx, t1), \
+ timestring(tctx, t2)); \
+ dump_all_info(tctx, &finfo); \
ret = false; \
}} while (0)
NTTIME t2; \
finfo.all_info.level = RAW_FILEINFO_ALL_INFO; \
finfo.all_info.in.file.path = fname; \
- status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); \
+ status = smb_raw_pathinfo(cli->tree, tctx, &finfo); \
CHECK_STATUS(status, NT_STATUS_OK); \
t2 = finfo.all_info.out.field; \
if (t != t2) { \
printf("(%s) wrong time for field %s %s - %s\n", \
__location__, #field, \
- nt_time_string(mem_ctx, t), \
- nt_time_string(mem_ctx, t2)); \
- dump_all_info(mem_ctx, &finfo); \
+ nt_time_string(tctx, t), \
+ nt_time_string(tctx, t2)); \
+ dump_all_info(tctx, &finfo); \
ret = false; \
}} while (0)
#define CHECK_ALL_INFO(v, field) do { \
finfo.all_info.level = RAW_FILEINFO_ALL_INFO; \
finfo.all_info.in.file.path = fname; \
- status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); \
+ status = smb_raw_pathinfo(cli->tree, tctx, &finfo); \
CHECK_STATUS(status, NT_STATUS_OK); \
if ((v) != (finfo.all_info.out.field)) { \
printf("(%s) wrong value for field %s 0x%x - 0x%x\n", \
__location__, #field, (int)v, (int)(finfo.all_info.out.field)); \
- dump_all_info(mem_ctx, &finfo); \
+ dump_all_info(tctx, &finfo); \
ret = false; \
}} while (0)
/*
test RAW_OPEN_OPEN
*/
-static bool test_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_open(struct smbcli_state *cli, struct torture_context *tctx)
{
union smb_open io;
union smb_fileinfo finfo;
io.openold.in.fname = fname;
io.openold.in.open_mode = OPEN_FLAGS_FCB;
io.openold.in.search_attrs = 0;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
fnum = io.openold.out.file.fnum;
CREATE_FILE;
smbcli_close(cli->tree, fnum);
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.openold.out.file.fnum;
CHECK_RDWR(fnum, RDWR_RDWR);
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum2 = io.openold.out.file.fnum;
CHECK_RDWR(fnum2, RDWR_RDWR);
io.openold.in.search_attrs = 0;
io.openold.in.open_mode = OPEN_FLAGS_OPEN_READ;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.openold.out.file.fnum;
CHECK_RDWR(fnum, RDWR_RDONLY);
smbcli_close(cli->tree, fnum);
io.openold.in.open_mode = OPEN_FLAGS_OPEN_WRITE;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.openold.out.file.fnum;
CHECK_RDWR(fnum, RDWR_WRONLY);
smbcli_close(cli->tree, fnum);
io.openold.in.open_mode = OPEN_FLAGS_OPEN_RDWR;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.openold.out.file.fnum;
CHECK_RDWR(fnum, RDWR_RDWR);
/* check the share modes roughly - not a complete matrix */
io.openold.in.open_mode = OPEN_FLAGS_OPEN_RDWR | OPEN_FLAGS_DENY_WRITE;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.openold.out.file.fnum;
CHECK_RDWR(fnum, RDWR_RDWR);
}
io.openold.in.open_mode = OPEN_FLAGS_OPEN_RDWR | OPEN_FLAGS_DENY_NONE;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
io.openold.in.open_mode = OPEN_FLAGS_OPEN_READ | OPEN_FLAGS_DENY_NONE;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum2 = io.openold.out.file.fnum;
CHECK_RDWR(fnum2, RDWR_RDONLY);
io.openold.in.fname = fname;
io.openold.in.search_attrs = 0;
io.openold.in.open_mode = OPEN_FLAGS_OPEN_READ;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.openold.out.file.fnum;
/*
test RAW_OPEN_OPENX
*/
-static bool test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_openx(struct smbcli_state *cli, struct torture_context *tctx)
{
union smb_open io;
union smb_fileinfo finfo;
/* check all combinations of open_func */
for (i=0; i<ARRAY_SIZE(open_funcs); i++) {
if (open_funcs[i].with_file) {
- fnum = create_complex_file(cli, mem_ctx, fname);
+ fnum = create_complex_file(cli, tctx, fname);
if (fnum == -1) {
d_printf("Failed to create file %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = false;
smbcli_close(cli->tree, fnum);
}
io.openx.in.open_func = open_funcs[i].open_func;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
if (!NT_STATUS_EQUAL(status, open_funcs[i].correct_status)) {
printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_func=0x%x)\n",
__location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status),
/* check the basic return fields */
io.openx.in.open_func = OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.openx.out.file.fnum;
smbcli_unlink(cli->tree, fname);
/* check the fields when the file already existed */
- fnum2 = create_complex_file(cli, mem_ctx, fname);
+ fnum2 = create_complex_file(cli, tctx, fname);
if (fnum2 == -1) {
ret = false;
goto done;
smbcli_close(cli->tree, fnum2);
io.openx.in.open_func = OPENX_OPEN_FUNC_OPEN;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.openx.out.file.fnum;
CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN, attrib);
io.openx.in.search_attrs = FILE_ATTRIBUTE_HIDDEN;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
smbcli_close(cli->tree, io.openx.out.file.fnum);
io.openx.in.search_attrs = 0;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
smbcli_close(cli->tree, io.openx.out.file.fnum);
io.openx.in.open_func = OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE;
io.openx.in.search_attrs = 0;
io.openx.in.file_attrs = FILE_ATTRIBUTE_SYSTEM;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
+ if (torture_setting_bool(tctx, "samba3", false)) {
CHECK_ALL_INFO(FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE,
attrib & ~(FILE_ATTRIBUTE_NONINDEXED|
FILE_ATTRIBUTE_SPARSE));
io.openx.in.open_func = OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE;
io.openx.in.file_attrs = 0;
io.openx.in.open_mode = OPENX_MODE_ACCESS_RDWR | OPENX_MODE_DENY_ALL;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.openx.out.file.fnum;
io.openx.in.timeout = 20000;
tv = timeval_current();
io.openx.in.open_mode = OPENX_MODE_ACCESS_RDWR | OPENX_MODE_DENY_NONE;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
if (timeval_elapsed(&tv) > 3.0) {
printf("(%s) Incorrect timing in openx with timeout - waited %.2f seconds\n",
io.openx.in.write_time = 0;
io.openx.in.size = 0;
io.openx.in.timeout = 0;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
smbcli_close(cli->tree, io.openx.out.file.fnum);
/* check the extended return flag */
io.openx.in.flags = OPENX_FLAGS_ADDITIONAL_INFO | OPENX_FLAGS_EXTENDED_RETURN;
io.openx.in.open_func = OPENX_OPEN_FUNC_OPEN;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VAL(io.openx.out.access_mask, SEC_STD_ALL);
smbcli_close(cli->tree, io.openx.out.file.fnum);
io.openx.in.fname = "\\A.+,;=[].B";
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
/* Check the mapping for open exec. */
/* First create an .exe file. */
smbcli_unlink(cli->tree, fname_exe);
- fnum = create_complex_file(cli, mem_ctx, fname_exe);
+ fnum = create_complex_file(cli, tctx, fname_exe);
smbcli_close(cli->tree, fnum);
io.openx.level = RAW_OPEN_OPENX;
io.openx.in.write_time = 0;
io.openx.in.size = 0;
io.openx.in.timeout = 0;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
/* Can we read and write ? */
many thanks to kukks for a sniff showing how this works with os2->w2k
*/
-static bool test_t2open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_t2open(struct smbcli_state *cli, struct torture_context *tctx)
{
union smb_open io;
union smb_fileinfo finfo;
{ OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK },
};
- fnum = create_complex_file(cli, mem_ctx, fname1);
+ fnum = create_complex_file(cli, tctx, fname1);
if (fnum == -1) {
d_printf("Failed to create file %s - %s\n", fname1, smbcli_errstr(cli->tree));
ret = false;
io.t2open.in.timeout = 0;
io.t2open.in.num_eas = 3;
- io.t2open.in.eas = talloc_array(mem_ctx, struct ea_struct, io.t2open.in.num_eas);
+ io.t2open.in.eas = talloc_array(tctx, struct ea_struct, io.t2open.in.num_eas);
io.t2open.in.eas[0].flags = 0;
io.t2open.in.eas[0].name.s = ".CLASSINFO";
- io.t2open.in.eas[0].value = data_blob_talloc(mem_ctx, "first value", 11);
+ io.t2open.in.eas[0].value = data_blob_talloc(tctx, "first value", 11);
io.t2open.in.eas[1].flags = 0;
io.t2open.in.eas[1].name.s = "EA TWO";
- io.t2open.in.eas[1].value = data_blob_talloc(mem_ctx, "foo", 3);
+ io.t2open.in.eas[1].value = data_blob_talloc(tctx, "foo", 3);
io.t2open.in.eas[2].flags = 0;
io.t2open.in.eas[2].name.s = "X THIRD";
- io.t2open.in.eas[2].value = data_blob_talloc(mem_ctx, "xy", 2);
+ io.t2open.in.eas[2].value = data_blob_talloc(tctx, "xy", 2);
/* check all combinations of open_func */
for (i=0; i<ARRAY_SIZE(open_funcs); i++) {
io.t2open.in.fname = fname2;
}
io.t2open.in.open_func = open_funcs[i].open_func;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
if ((io.t2open.in.num_eas != 0)
&& NT_STATUS_EQUAL(status, NT_STATUS_EAS_NOT_SUPPORTED)
- && lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
+ && torture_setting_bool(tctx, "samba3", false)) {
printf("(%s) EAs not supported, not treating as fatal "
"in Samba3 test\n", __location__);
io.t2open.in.num_eas = 0;
io.t2open.in.open_func = OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE;
io.t2open.in.write_time = 0;
io.t2open.in.fname = fname;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.t2open.out.file.fnum;
SET_ATTRIB(FILE_ATTRIBUTE_HIDDEN);
CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN, attrib);
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
smbcli_close(cli->tree, io.t2open.out.file.fnum);
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
smbcli_close(cli->tree, io.t2open.out.file.fnum);
/* and check attrib on create */
io.t2open.in.open_func = OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE;
io.t2open.in.file_attrs = FILE_ATTRIBUTE_SYSTEM;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
/* check timeout on create - win2003 ignores the timeout! */
io.t2open.in.file_attrs = 0;
io.t2open.in.timeout = 20000;
io.t2open.in.open_mode = OPENX_MODE_ACCESS_RDWR | OPENX_MODE_DENY_ALL;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
done:
/*
test RAW_OPEN_NTCREATEX
*/
-static bool test_ntcreatex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_ntcreatex(struct smbcli_state *cli, struct torture_context *tctx)
{
union smb_open io;
union smb_fileinfo finfo;
smbcli_close(cli->tree, fnum);
}
io.ntcreatex.in.open_disposition = open_funcs[i].open_disp;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
if (!NT_STATUS_EQUAL(status, open_funcs[i].correct_status)) {
printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_disp=%d)\n",
__location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status),
/* basic field testing */
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
/* check fields when the file already existed */
smbcli_close(cli->tree, fnum);
smbcli_unlink(cli->tree, fname);
- fnum = create_complex_file(cli, mem_ctx, fname);
+ fnum = create_complex_file(cli, tctx, fname);
if (fnum == -1) {
ret = false;
goto done;
smbcli_close(cli->tree, fnum);
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
/*
test RAW_OPEN_NTTRANS_CREATE
*/
-static bool test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_nttrans_create(struct smbcli_state *cli, struct torture_context *tctx)
{
union smb_open io;
union smb_fileinfo finfo;
smbcli_close(cli->tree, fnum);
}
io.ntcreatex.in.open_disposition = open_funcs[i].open_disp;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
if (!NT_STATUS_EQUAL(status, open_funcs[i].correct_status)) {
printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_disp=%d)\n",
__location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status),
/* basic field testing */
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
/* check fields when the file already existed */
smbcli_close(cli->tree, fnum);
smbcli_unlink(cli->tree, fname);
- fnum = create_complex_file(cli, mem_ctx, fname);
+ fnum = create_complex_file(cli, tctx, fname);
if (fnum == -1) {
ret = false;
goto done;
smbcli_close(cli->tree, fnum);
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
open_disposition==NTCREATEX_DISP_OVERWRITE_IF. Windows 2003 allows the
second open.
*/
-static bool test_ntcreatex_brlocked(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_ntcreatex_brlocked(struct smbcli_state *cli, struct torture_context *tctx)
{
union smb_open io, io1;
union smb_lock io2;
NTCREATEX_SECURITY_ALL;
io.ntcreatex.in.fname = fname;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
io2.lockx.level = RAW_LOCK_LOCKX;
NTCREATEX_SECURITY_ALL;
io1.ntcreatex.in.fname = fname;
- status = smb_raw_open(cli->tree, mem_ctx, &io1);
+ status = smb_raw_open(cli->tree, tctx, &io1);
CHECK_STATUS(status, NT_STATUS_OK);
done:
/*
test RAW_OPEN_MKNEW
*/
-static bool test_mknew(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_mknew(struct smbcli_state *cli, struct torture_context *tctx)
{
union smb_open io;
const char *fname = BASEDIR "\\torture_mknew.txt";
io.mknew.in.attrib = 0;
io.mknew.in.write_time = 0;
io.mknew.in.fname = fname;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.mknew.out.file.fnum;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION);
smbcli_close(cli->tree, fnum);
/* make sure write_time works */
io.mknew.in.write_time = basetime;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.mknew.out.file.fnum;
CHECK_TIME(basetime, write_time);
/* make sure file_attrs works */
io.mknew.in.attrib = FILE_ATTRIBUTE_HIDDEN;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.mknew.out.file.fnum;
CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE,
/*
test RAW_OPEN_CREATE
*/
-static bool test_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_create(struct smbcli_state *cli, struct torture_context *tctx)
{
union smb_open io;
const char *fname = BASEDIR "\\torture_create.txt";
io.create.in.attrib = 0;
io.create.in.write_time = 0;
io.create.in.fname = fname;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.create.out.file.fnum;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
smbcli_close(cli->tree, io.create.out.file.fnum);
/* make sure write_time works */
io.create.in.write_time = basetime;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.create.out.file.fnum;
CHECK_TIME(basetime, write_time);
/* make sure file_attrs works */
io.create.in.attrib = FILE_ATTRIBUTE_HIDDEN;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.create.out.file.fnum;
CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE,
/*
test RAW_OPEN_CTEMP
*/
-static bool test_ctemp(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_ctemp(struct smbcli_state *cli, TALLOC_CTX *tctx)
{
union smb_open io;
NTSTATUS status;
io.ctemp.in.attrib = FILE_ATTRIBUTE_HIDDEN;
io.ctemp.in.write_time = basetime;
io.ctemp.in.directory = BASEDIR;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ctemp.out.file.fnum;
finfo.generic.level = RAW_FILEINFO_NAME_INFO;
finfo.generic.in.file.fnum = fnum;
- status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo);
+ status = smb_raw_fileinfo(cli->tree, tctx, &finfo);
CHECK_STATUS(status, NT_STATUS_OK);
fname = finfo.name_info.out.fname.s;
/*
test chained RAW_OPEN_OPENX_READX
*/
-static bool test_chained(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_chained(struct smbcli_state *cli, TALLOC_CTX *tctx)
{
union smb_open io;
const char *fname = BASEDIR "\\torture_chained.txt";
printf("Checking RAW_OPEN_OPENX chained with READX\n");
smbcli_unlink(cli->tree, fname);
- fnum = create_complex_file(cli, mem_ctx, fname);
+ fnum = create_complex_file(cli, tctx, fname);
smbcli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf));
io.openxreadx.in.remaining = 0;
io.openxreadx.out.data = (uint8_t *)buf2;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.openxreadx.out.file.fnum;
NetApp filers are known to fail on this.
*/
-static bool test_no_leading_slash(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_no_leading_slash(struct smbcli_state *cli, TALLOC_CTX *tctx)
{
union smb_open io;
const char *fname = BASEDIR "\\torture_no_leading_slash.txt";
smbcli_unlink(cli->tree, fname);
/* Create the file */
- fnum = create_complex_file(cli, mem_ctx, fname);
+ fnum = create_complex_file(cli, tctx, fname);
smbcli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf));
smbcli_close(cli->tree, fnum);
io.openx.in.size = 1024*1024;
io.openx.in.timeout = 0;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
+ status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.openx.out.file.fnum;
/* A little torture test to expose a race condition in Samba 3.0.20 ... :-) */
-static bool test_raw_open_multi(void)
+static bool test_raw_open_multi(struct torture_context *tctx)
{
struct smbcli_state *cli;
TALLOC_CTX *mem_ctx = talloc_init("torture_test_oplock_multi");
struct smbcli_state **clients;
struct smbcli_request **requests;
union smb_open *ios;
- const char *host = lp_parm_string(global_loadparm, NULL, "torture", "host");
- const char *share = lp_parm_string(global_loadparm, NULL, "torture", "share");
+ const char *host = torture_setting_string(tctx, "host", NULL);
+ const char *share = torture_setting_string(tctx, "share", NULL);
int i, num_files = 3;
struct event_context *ev;
int num_ok = 0;
ret &= test_ntcreatex_brlocked(cli, torture);
ret &= test_open(cli, torture);
- ret &= test_raw_open_multi();
+ ret &= test_raw_open_multi(torture);
ret &= test_openx(cli, torture);
ret &= test_ntcreatex(cli, torture);
ret &= test_nttrans_create(cli, torture);
uint8_t *val;
int count, loops;
- fn = lp_parm_string(global_loadparm, NULL, "torture", "filename");
+ fn = torture_setting_string(torture, "filename", NULL);
if (fn == NULL) {
DEBUG(0,("You must specify the filename using --option=torture:filename=...\n"));
return false;
}
- num_locks = lp_parm_int(global_loadparm, NULL, "torture", "num_locks", -1);
+ num_locks = torture_setting_int(torture, "num_locks", -1);
if (num_locks == -1) {
DEBUG(0,("You must specify num_locks using --option=torture:num_locks=...\n"));
return false;
}
- do_reads = lp_parm_bool(global_loadparm, NULL, "torture", "read", false);
- do_writes = lp_parm_bool(global_loadparm, NULL, "torture", "write", false);
- lock_timeout = lp_parm_int(global_loadparm, NULL, "torture", "lock_timeout", 100000);
+ do_reads = torture_setting_bool(torture, "read", false);
+ do_writes = torture_setting_bool(torture, "write", false);
+ lock_timeout = torture_setting_int(torture, "lock_timeout", 100000);
if (!torture_open_connection(&cli, 0)) {
DEBUG(0,("Could not open connection\n"));
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.readx.out.remaining, 0xFFFF);
CHECK_VALUE(io.readx.out.compaction_mode, 0);
- if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
+ if (torture_setting_bool(tctx, "samba3", false)) {
printf("SAMBA3: large read extension\n");
CHECK_VALUE(io.readx.out.nread, 80000);
} else {
io.readx.in.maxcnt = 0x10000;
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
+ if (torture_setting_bool(tctx, "samba3", false)) {
printf("SAMBA3: large read extension\n");
CHECK_VALUE(io.readx.out.nread, 0x10000);
} else {
io.readx.in.maxcnt = 0x10001;
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
+ if (torture_setting_bool(tctx, "samba3", false)) {
printf("SAMBA3: large read extension\n");
CHECK_VALUE(io.readx.out.nread, 0x10001);
} else {
return false;
}
- nt_status_support = lp_nt_status_support(global_loadparm);
+ nt_status_support = lp_nt_status_support(torture->lp_ctx);
- if (!lp_set_cmdline(global_loadparm, "nt status support", "yes")) {
+ if (!lp_set_cmdline(torture->lp_ctx, "nt status support", "yes")) {
printf("Could not set 'nt status support = yes'\n");
goto fail;
}
goto fail;
}
- if (!lp_set_cmdline(global_loadparm, "nt status support", "no")) {
+ if (!lp_set_cmdline(torture->lp_ctx, "nt status support", "no")) {
printf("Could not set 'nt status support = yes'\n");
goto fail;
}
goto fail;
}
- if (!lp_set_cmdline(global_loadparm, "nt status support",
+ if (!lp_set_cmdline(torture->lp_ctx, "nt status support",
nt_status_support ? "yes":"no")) {
printf("Could not reset 'nt status support = yes'");
goto fail;
io.unlink.in.attrib = FILE_ATTRIBUTE_DIRECTORY;
status = smb_raw_unlink(cli->tree, &io);
- if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
+ if (torture_setting_bool(tctx, "samba3", false)) {
/*
* In Samba3 we gave up upon getting the error codes in
* wildcard unlink correct. Trying gentest showed that this is
io.unlink.in.pattern = BASEDIR "\\t*";
io.unlink.in.attrib = FILE_ATTRIBUTE_DIRECTORY;
status = smb_raw_unlink(cli->tree, &io);
- if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
+ if (torture_setting_bool(tctx, "samba3", false)) {
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID);
}
else {
io.unlink.in.pattern = BASEDIR "\\*.dat";
io.unlink.in.attrib = FILE_ATTRIBUTE_DIRECTORY;
status = smb_raw_unlink(cli->tree, &io);
- if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
+ if (torture_setting_bool(tctx, "samba3", false)) {
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID);
}
else {
io.unlink.in.pattern = BASEDIR "\\*.tx?";
io.unlink.in.attrib = 0;
status = smb_raw_unlink(cli->tree, &io);
- if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
+ if (torture_setting_bool(tctx, "samba3", false)) {
CHECK_STATUS(status, NT_STATUS_NO_SUCH_FILE);
}
else {
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
- if (!lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
+ if (!torture_setting_bool(tctx, "samba3", false)) {
/*
* Known deficiency, also skipped in base-delete.
/*
benchmark srvsvc netshareenumall queries
*/
-static bool bench_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool bench_NetShareEnumAll(struct torture_context *tctx, struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
{
struct timeval tv = timeval_current();
bool ret = true;
- int timelimit = lp_parm_int(global_loadparm, NULL, "torture", "timelimit", 10);
+ int timelimit = torture_setting_int(tctx, "timelimit", 10);
int count=0;
printf("Running for %d seconds\n", timelimit);
talloc_free(tmp_ctx);
count++;
if (count % 50 == 0) {
- if (lp_parm_bool(global_loadparm, NULL, "torture", "progress", true)) {
+ if (torture_setting_bool(tctx, "progress", true)) {
printf("%.1f queries per second \r",
count / timeval_elapsed(&tv));
}
return false;
}
- if (!bench_NetShareEnumAll(p, mem_ctx)) {
+ if (!bench_NetShareEnumAll(torture, p, mem_ctx)) {
ret = false;
}
if (!mem_ctx) {
return false;
}
- iface_name = lp_parm_string(global_loadparm, NULL, "countcalls", "interface");
+ iface_name = lp_parm_string(torture->lp_ctx, NULL, "countcalls", "interface");
if (iface_name != NULL) {
iface = ndr_table_by_name(iface_name);
if (!iface) {
return ret;
}
-static bool test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DsReplicaGetInfo(struct dcerpc_pipe *p, struct torture_context *tctx,
struct DsPrivate *priv)
{
NTSTATUS status;
}
};
- if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
+ if (torture_setting_bool(tctx, "samba4", false)) {
printf("skipping DsReplicaGetInfo test against Samba4\n");
return true;
}
break;
}
- status = dcerpc_drsuapi_DsReplicaGetInfo(p, mem_ctx, &r);
+ status = dcerpc_drsuapi_DsReplicaGetInfo(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
const char *errstr = nt_errstr(status);
if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
- errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
+ errstr = dcerpc_errstr(tctx, p->last_fault_code);
}
if (p->last_fault_code != DCERPC_FAULT_INVALID_TAG) {
printf("dcerpc_drsuapi_DsReplicaGetInfo failed - %s\n", errstr);
return ret;
}
-static bool test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DsReplicaSync(struct dcerpc_pipe *p, struct torture_context *tctx,
struct DsPrivate *priv)
{
NTSTATUS status;
}
};
- if (!lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", false)) {
+ if (!torture_setting_bool(tctx, "dangerous", false)) {
printf("DsReplicaSync disabled - enable dangerous tests to use\n");
return true;
}
- if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
+ if (torture_setting_bool(tctx, "samba4", false)) {
printf("skipping DsReplicaSync test against Samba4\n");
return true;
}
break;
}
- status = dcerpc_drsuapi_DsReplicaSync(p, mem_ctx, &r);
+ status = dcerpc_drsuapi_DsReplicaSync(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
const char *errstr = nt_errstr(status);
if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
- errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
+ errstr = dcerpc_errstr(tctx, p->last_fault_code);
}
printf("dcerpc_drsuapi_DsReplicaSync failed - %s\n", errstr);
ret = false;
return ret;
}
-static bool test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, struct torture_context *tctx,
struct DsPrivate *priv)
{
NTSTATUS status;
}
};
- if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
+ if (torture_setting_bool(tctx, "samba4", false)) {
printf("skipping DsReplicaUpdateRefs test against Samba4\n");
return true;
}
nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:"";
r.in.req.req1.naming_context = &nc;
- r.in.req.req1.dest_dsa_dns_name = talloc_asprintf(mem_ctx, "__some_dest_dsa_guid_string._msdn.%s",
+ r.in.req.req1.dest_dsa_dns_name = talloc_asprintf(tctx, "__some_dest_dsa_guid_string._msdn.%s",
priv->domain_dns_name);
r.in.req.req1.dest_dsa_guid = null_guid;
r.in.req.req1.options = 0;
break;
}
- status = dcerpc_drsuapi_DsReplicaUpdateRefs(p, mem_ctx, &r);
+ status = dcerpc_drsuapi_DsReplicaUpdateRefs(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
const char *errstr = nt_errstr(status);
if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
- errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
+ errstr = dcerpc_errstr(tctx, p->last_fault_code);
}
printf("dcerpc_drsuapi_DsReplicaUpdateRefs failed - %s\n", errstr);
ret = false;
return ret;
}
-static bool test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DsGetNCChanges(struct dcerpc_pipe *p, struct torture_context *tctx,
struct DsPrivate *priv)
{
NTSTATUS status;
}
};
- if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
+ if (torture_setting_bool(tctx, "samba4", false)) {
printf("skipping DsGetNCChanges test against Samba4\n");
return true;
}
break;
}
- status = dcerpc_drsuapi_DsGetNCChanges(p, mem_ctx, &r);
+ status = dcerpc_drsuapi_DsGetNCChanges(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
const char *errstr = nt_errstr(status);
if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
- errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
+ errstr = dcerpc_errstr(tctx, p->last_fault_code);
}
printf("dcerpc_drsuapi_DsGetNCChanges failed - %s\n", errstr);
ret = false;
static uint32_t object_id;
const char *save_values_dir;
- if (!lp_parm_bool(global_loadparm, NULL,"dssync","print_pwd_blobs", false)) {
+ if (!lp_parm_bool(global_loadparm, NULL, "dssync", "print_pwd_blobs", false)) {
return;
}
r.in.guid1 = NULL;
r.in.guid2 = NULL;
r.in.replica_set = talloc_asprintf(tctx, "%s",
- lp_realm(global_loadparm));
+ lp_realm(tctx->lp_ctx));
r.in.partner_name = dcerpc_server_name(p);
torture_assert_ntstatus_ok(tctx,
continue;
}
- lp_set_cmdline(global_loadparm, "torture:binding", dcerpc_binding_string(loop_ctx, b));
+ lp_set_cmdline(torture->lp_ctx, "torture:binding", dcerpc_binding_string(loop_ctx, b));
status = torture_rpc_connection(torture, &p, &ndr_table_mgmt);
if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
DATA_BLOB names_blob, chal, lm_resp, nt_resp;
int i;
int flags = CLI_CRED_NTLM_AUTH;
- if (lp_client_lanman_auth(global_loadparm)) {
+ if (lp_client_lanman_auth(tctx->lp_ctx)) {
flags |= CLI_CRED_LANMAN_AUTH;
}
- if (lp_client_ntlmv2_auth(global_loadparm)) {
+ if (lp_client_ntlmv2_auth(tctx->lp_ctx)) {
flags |= CLI_CRED_NTLMv2_AUTH;
}
struct netr_GetDcName r;
r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
- r.in.domainname = lp_workgroup(global_loadparm);
+ r.in.domainname = lp_workgroup(tctx->lp_ctx);
status = dcerpc_netr_GetDcName(p, tctx, &r);
torture_assert_ntstatus_ok(tctx, status, "GetDcName");
struct netr_GetAnyDCName r;
r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
- r.in.domainname = lp_workgroup(global_loadparm);
+ r.in.domainname = lp_workgroup(tctx->lp_ctx);
status = dcerpc_netr_GetAnyDCName(p, tctx, &r);
torture_assert_ntstatus_ok(tctx, status, "GetAnyDCName");
r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.function_code = NETLOGON_CONTROL_REDISCOVER;
- r.in.data.domain = lp_workgroup(global_loadparm);
+ r.in.data.domain = lp_workgroup(tctx->lp_ctx);
for (i=1;i<4;i++) {
r.in.level = i;
}
r.in.function_code = NETLOGON_CONTROL_TC_QUERY;
- r.in.data.domain = lp_workgroup(global_loadparm);
+ r.in.data.domain = lp_workgroup(tctx->lp_ctx);
for (i=1;i<4;i++) {
r.in.level = i;
}
r.in.function_code = NETLOGON_CONTROL_TRANSPORT_NOTIFY;
- r.in.data.domain = lp_workgroup(global_loadparm);
+ r.in.data.domain = lp_workgroup(tctx->lp_ctx);
for (i=1;i<4;i++) {
r.in.level = i;
r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.function_code = NETLOGON_CONTROL_REDISCOVER;
- r.in.data.domain = lp_workgroup(global_loadparm);
+ r.in.data.domain = lp_workgroup(tctx->lp_ctx);
for (i=1;i<4;i++) {
r.in.level = i;
}
r.in.function_code = NETLOGON_CONTROL_TC_QUERY;
- r.in.data.domain = lp_workgroup(global_loadparm);
+ r.in.data.domain = lp_workgroup(tctx->lp_ctx);
for (i=1;i<4;i++) {
r.in.level = i;
}
r.in.function_code = NETLOGON_CONTROL_TRANSPORT_NOTIFY;
- r.in.data.domain = lp_workgroup(global_loadparm);
+ r.in.data.domain = lp_workgroup(tctx->lp_ctx);
for (i=1;i<4;i++) {
r.in.level = i;
struct netr_DsRGetDCName r;
r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
- r.in.domain_name = talloc_asprintf(tctx, "%s", lp_realm(global_loadparm));
+ r.in.domain_name = talloc_asprintf(tctx, "%s", lp_realm(tctx->lp_ctx));
r.in.domain_guid = NULL;
r.in.site_guid = NULL;
r.in.flags = DS_RETURN_DNS_NAME;
struct netr_DsRGetDCNameEx r;
r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
- r.in.domain_name = talloc_asprintf(tctx, "%s", lp_realm(global_loadparm));
+ r.in.domain_name = talloc_asprintf(tctx, "%s", lp_realm(tctx->lp_ctx));
r.in.domain_guid = NULL;
r.in.site_name = NULL;
r.in.flags = DS_RETURN_DNS_NAME;
r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.client_account = NULL;
r.in.mask = 0x00000000;
- r.in.domain_name = talloc_asprintf(tctx, "%s", lp_realm(global_loadparm));
+ r.in.domain_name = talloc_asprintf(tctx, "%s", lp_realm(tctx->lp_ctx));
r.in.domain_guid = NULL;
r.in.site_name = NULL;
r.in.flags = DS_RETURN_DNS_NAME;
goto done;
}
- cli_credentials_set_conf(wks_creds, global_loadparm);
+ cli_credentials_set_conf(wks_creds, torture->lp_ctx);
cli_credentials_set_secure_channel_type(wks_creds, SEC_CHAN_WKSTA);
cli_credentials_set_username(wks_creds, wks_name, CRED_SPECIFIED);
cli_credentials_set_workstation(wks_creds, wks_name, CRED_SPECIFIED);
goto done;
}
- cli_credentials_set_conf(user_creds, global_loadparm);
+ cli_credentials_set_conf(user_creds, torture->lp_ctx);
cli_credentials_set_username(user_creds, "torture_username",
CRED_SPECIFIED);
cli_credentials_set_password(user_creds,
ZERO_STRUCT(userlevel1);
userlevel1.client = talloc_asprintf(
- mem_ctx, "\\\\%s", lp_netbios_name(global_loadparm));
+ mem_ctx, "\\\\%s", lp_netbios_name(torture->lp_ctx));
userlevel1.user = cli_credentials_get_username(cmdline_credentials);
userlevel1.build = 2600;
userlevel1.major = 3;
return false;
}
- userdomain = torture_setting_string(torture, "userdomain", lp_workgroup(global_loadparm));
+ userdomain = torture_setting_string(torture, "userdomain", lp_workgroup(torture->lp_ctx));
user_ctx = torture_create_testuser(torture,
TEST_USER_NAME,
.username = talloc_asprintf(mem_ctx,
"%s@%s",
TEST_USER_NAME,
- lp_realm(global_loadparm)),
+ lp_realm(torture->lp_ctx)),
.password = user_password,
.network_login = true,
.expected_interactive_error = NT_STATUS_OK,
ld.in.connect_handle = &ch;
ld.in.domain_name = &dn;
- dn.string = lp_workgroup(global_loadparm);
+ dn.string = lp_workgroup(tctx->lp_ctx);
status = dcerpc_samr_LookupDomain(p, tctx, &ld);
if (!NT_STATUS_IS_OK(status)) {
ld.in.connect_handle = &ch;
ld.in.domain_name = &dn;
- dn.string = lp_workgroup(global_loadparm);
+ dn.string = lp_workgroup(tctx->lp_ctx);
status = dcerpc_samr_LookupDomain(p, tctx, &ld);
if(!NT_STATUS_EQUAL(NT_STATUS_ACCESS_DENIED, status)) {
ld.in.connect_handle = &ch;
ld.in.domain_name = &dn;
- dn.string = lp_workgroup(global_loadparm);
+ dn.string = lp_workgroup(tctx->lp_ctx);
status = dcerpc_samr_LookupDomain(p, tctx, &ld);
if (!NT_STATUS_IS_OK(status)) {
printf("LookupDomain failed - %s\n", nt_errstr(status));
const struct dom_sid *test_sid;
/* create a test user */
- testuser = torture_create_testuser(tctx, TEST_USER_NAME, lp_workgroup(global_loadparm),
+ testuser = torture_create_testuser(tctx, TEST_USER_NAME, lp_workgroup(tctx->lp_ctx),
ACB_NORMAL, &testuser_passwd);
if (!testuser) {
printf("Failed to create test user\n");
}
test_credentials = cli_credentials_init(tctx);
cli_credentials_set_workstation(test_credentials, "localhost", CRED_SPECIFIED);
- cli_credentials_set_domain(test_credentials, lp_workgroup(global_loadparm),
+ cli_credentials_set_domain(test_credentials, lp_workgroup(tctx->lp_ctx),
CRED_SPECIFIED);
cli_credentials_set_username(test_credentials, TEST_USER_NAME, CRED_SPECIFIED);
cli_credentials_set_password(test_credentials, testuser_passwd, CRED_SPECIFIED);
test_machine_account = talloc_asprintf(mem_ctx, "%s$", TEST_MACHINE_NAME);
join_ctx = torture_create_testuser(torture, test_machine_account,
- lp_workgroup(global_loadparm), ACB_SVRTRUST,
+ lp_workgroup(torture->lp_ctx), ACB_SVRTRUST,
&machine_password);
if (!join_ctx) {
talloc_free(mem_ctx);
}
test_wksta_machine_account = talloc_asprintf(mem_ctx, "%s$", TEST_WKSTA_MACHINE_NAME);
- join_ctx2 = torture_create_testuser(torture, test_wksta_machine_account, lp_workgroup(global_loadparm), ACB_WSTRUST, &wksta_machine_password);
+ join_ctx2 = torture_create_testuser(torture, test_wksta_machine_account, lp_workgroup(torture->lp_ctx), ACB_WSTRUST, &wksta_machine_password);
if (!join_ctx2) {
talloc_free(mem_ctx);
printf("Failed to join as member\n");
}
user_ctx = torture_create_testuser(torture, TEST_USER_NAME,
- lp_workgroup(global_loadparm),
+ lp_workgroup(torture->lp_ctx),
ACB_NORMAL, NULL);
if (!user_ctx) {
talloc_free(mem_ctx);
goto failed;
}
- domain_policy = samsync_open_domain(mem_ctx, samsync_state, lp_workgroup(global_loadparm), NULL);
+ domain_policy = samsync_open_domain(mem_ctx, samsync_state, lp_workgroup(torture->lp_ctx), NULL);
if (!domain_policy) {
printf("samrsync_open_domain failed\n");
ret = false;
credentials = cli_credentials_init(mem_ctx);
cli_credentials_set_workstation(credentials, TEST_MACHINE_NAME, CRED_SPECIFIED);
- cli_credentials_set_domain(credentials, lp_workgroup(global_loadparm), CRED_SPECIFIED);
+ cli_credentials_set_domain(credentials, lp_workgroup(torture->lp_ctx), CRED_SPECIFIED);
cli_credentials_set_username(credentials, test_machine_account, CRED_SPECIFIED);
cli_credentials_set_password(credentials, machine_password, CRED_SPECIFIED);
cli_credentials_set_secure_channel_type(credentials,
credentials_wksta = cli_credentials_init(mem_ctx);
cli_credentials_set_workstation(credentials_wksta, TEST_WKSTA_MACHINE_NAME, CRED_SPECIFIED);
- cli_credentials_set_domain(credentials_wksta, lp_workgroup(global_loadparm), CRED_SPECIFIED);
+ cli_credentials_set_domain(credentials_wksta, lp_workgroup(torture->lp_ctx), CRED_SPECIFIED);
cli_credentials_set_username(credentials_wksta, test_wksta_machine_account, CRED_SPECIFIED);
cli_credentials_set_password(credentials_wksta, wksta_machine_password, CRED_SPECIFIED);
cli_credentials_set_secure_channel_type(credentials_wksta,
b->endpoint = talloc_strdup(b, l->table->name);
}
- lp_set_cmdline(global_loadparm, "torture:binding", dcerpc_binding_string(torture, b));
+ lp_set_cmdline(torture->lp_ctx, "torture:binding", dcerpc_binding_string(torture, b));
status = torture_rpc_connection(torture, &p, &ndr_table_mgmt);
if (!NT_STATUS_IS_OK(status)) {
DATA_BLOB names_blob, chal, lm_resp, nt_resp;
int i;
int flags = CLI_CRED_NTLM_AUTH;
- if (lp_client_lanman_auth(global_loadparm)) {
+ if (lp_client_lanman_auth(tctx->lp_ctx)) {
flags |= CLI_CRED_LANMAN_AUTH;
}
- if (lp_client_ntlmv2_auth(global_loadparm)) {
+ if (lp_client_ntlmv2_auth(tctx->lp_ctx)) {
flags |= CLI_CRED_NTLMv2_AUTH;
}
struct policy_handle handle;
struct policy_handle domain_handle;
- name.string = lp_workgroup(global_loadparm);
+ name.string = lp_workgroup(tctx->lp_ctx);
r.in.domain_name = &name;
connect.in.system_name = 0;
{
struct test_join *join_ctx;
NTSTATUS status;
- const char *binding = lp_parm_string(global_loadparm, NULL, "torture", "binding");
+ const char *binding = torture_setting_string(tctx, "binding", NULL);
struct dcerpc_binding *b;
struct dcerpc_pipe *p = NULL;
struct dcerpc_pipe *p_netlogon = NULL;
const struct secret_settings *settings =
(const struct secret_settings *)_data;
- lp_set_cmdline(global_loadparm, "ntlmssp client:keyexchange", settings->keyexchange?"True":"False");
- lp_set_cmdline(global_loadparm, "ntlmssp_client:ntlm2", settings->ntlm2?"True":"False");
- lp_set_cmdline(global_loadparm, "ntlmssp_client:lm_key", settings->lm_key?"True":"False");
+ lp_set_cmdline(torture->lp_ctx, "ntlmssp client:keyexchange", settings->keyexchange?"True":"False");
+ lp_set_cmdline(torture->lp_ctx, "ntlmssp_client:ntlm2", settings->ntlm2?"True":"False");
+ lp_set_cmdline(torture->lp_ctx, "ntlmssp_client:lm_key", settings->lm_key?"True":"False");
torture_assert_ntstatus_ok(torture, torture_rpc_binding(torture, &binding),
"Getting bindoptions");
torture_assert_ntstatus_ok(tctx, dcerpc_register_ep_server(&ep_server),
"unable to register spoolss server");
- lp_set_cmdline(global_loadparm, "dcerpc endpoint servers", "spoolss");
+ lp_set_cmdline(tctx->lp_ctx, "dcerpc endpoint servers", "spoolss");
address = iface_n_ip(0);
torture_comment(tctx, "Listening for callbacks on %s\n", address);
- status = smbsrv_add_socket(p->conn->event_ctx, &single_ops, address);
+ status = smbsrv_add_socket(p->conn->event_ctx, tctx->lp_ctx, &single_ops, address);
torture_assert_ntstatus_ok(tctx, status, "starting smb server");
status = dcesrv_init_context(tctx, endpoints, &dce_ctx);
int policy_min_pw_len = 0;
struct test_join *join;
char *random_pw;
- const char *dc_binding = lp_parm_string(global_loadparm, NULL, "torture", "dc_binding");
+ const char *dc_binding = torture_setting_string(torture, "dc_binding", NULL);
join = talloc(NULL, struct test_join);
if (join == NULL) {
u.info21.description.string = talloc_asprintf(join,
"Samba4 torture account created by host %s: %s",
- lp_netbios_name(global_loadparm),
+ lp_netbios_name(torture->lp_ctx),
timestring(join, time(NULL)));
printf("Resetting ACB flags, force pw change time\n");
NTSTATUS status;
struct wkssvc_NetrWkstaUserGetInfo r;
union wkssvc_NetrWkstaUserInfo info;
- const char *dom = lp_workgroup(global_loadparm);
+ const char *dom = lp_workgroup(tctx->lp_ctx);
struct cli_credentials *creds = cmdline_credentials;
const char *user = cli_credentials_get_username(creds);
int i;
NTSTATUS status;
struct wkssvc_NetrLogonDomainNameAdd r;
- r.in.domain_name = lp_workgroup(global_loadparm);
+ r.in.domain_name = lp_workgroup(tctx->lp_ctx);
torture_comment(tctx, "testing NetrLogonDomainNameAdd\n");
NTSTATUS status;
struct wkssvc_NetrLogonDomainNameDel r;
- r.in.domain_name = lp_workgroup(global_loadparm);
+ r.in.domain_name = lp_workgroup(tctx->lp_ctx);
torture_comment(tctx, "testing NetrLogonDomainNameDel\n");
for (i=0; i<ARRAY_SIZE(levels); i++) {
r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
- r.in.name = lp_workgroup(global_loadparm);
+ r.in.name = lp_workgroup(tctx->lp_ctx);
r.in.Account = NULL;
r.in.Password = NULL;
r.in.name_type = levels[i];
for (i=0; i<ARRAY_SIZE(levels); i++) {
r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
- r.in.name = lp_workgroup(global_loadparm);
+ r.in.name = lp_workgroup(tctx->lp_ctx);
r.in.Account = NULL;
r.in.EncryptedPassword = NULL;
r.in.name_type = levels[i];
const char **ous = NULL;
r.in.server_name = dcerpc_server_name(p);
- r.in.domain_name = lp_workgroup(global_loadparm);
+ r.in.domain_name = lp_workgroup(tctx->lp_ctx);
r.in.Account = NULL;
r.in.unknown = NULL;
r.in.num_ous = r.out.num_ous = &num_ous;
const char **ous = NULL;
r.in.server_name = dcerpc_server_name(p);
- r.in.domain_name = lp_workgroup(global_loadparm);
+ r.in.domain_name = lp_workgroup(tctx->lp_ctx);
r.in.Account = NULL;
r.in.EncryptedPassword = NULL;
r.in.num_ous = r.out.num_ous = &num_ous;
const char *admin_account = NULL;
admin_account = talloc_asprintf(tctx, "%s\\%s",
- lp_workgroup(global_loadparm),
+ lp_workgroup(tctx->lp_ctx),
user);
r.in.server_name = dcerpc_server_name(p);
const char *admin_account = NULL;
admin_account = talloc_asprintf(tctx, "%s\\%s",
- lp_workgroup(global_loadparm),
+ lp_workgroup(tctx->lp_ctx),
user);
r.in.server_name = dcerpc_server_name(p);
- r.in.domain_name = lp_realm(global_loadparm);
+ r.in.domain_name = lp_realm(tctx->lp_ctx);
r.in.account_ou = NULL;
r.in.Account = admin_account;
r.in.password = NULL;
struct smb2_handle h1, h2;
NTSTATUS status;
- if (!torture_smb2_connection(mem_ctx, &tree)) {
+ if (!torture_smb2_connection(torture, &tree)) {
return false;
}
struct smb2_tree *tree;
bool ret = true;
- if (!torture_smb2_connection(mem_ctx, &tree)) {
+ if (!torture_smb2_connection(torture, &tree)) {
return false;
}
bool ret = true;
NTSTATUS status;
- if (!torture_smb2_connection(mem_ctx, &tree)) {
+ if (!torture_smb2_connection(torture, &tree)) {
return false;
}
bool ret = true;
NTSTATUS status;
- if (!torture_smb2_connection(mem_ctx, &tree)) {
+ if (!torture_smb2_connection(torture, &tree)) {
return false;
}
/*
test writing
*/
-static NTSTATUS torture_smb2_write(TALLOC_CTX *mem_ctx,
+static NTSTATUS torture_smb2_write(struct torture_context *tctx,
struct smb2_tree *tree,
struct smb2_handle handle)
{
int min = 1;
while (max > min) {
- TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+ TALLOC_CTX *tmp_ctx = talloc_new(tctx);
len = 1+(min+max)/2;
/* vista bug */
printf("coping with server disconnect\n");
talloc_free(tree);
- if (!torture_smb2_connection(mem_ctx, &tree)) {
+ if (!torture_smb2_connection(torture, &tree)) {
printf("failed to reconnect\n");
return NT_STATUS_NET_WRITE_FAULT;
}
*/
bool torture_smb2_maxwrite(struct torture_context *torture)
{
- TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
struct smb2_handle h1;
NTSTATUS status;
- if (!torture_smb2_connection(mem_ctx, &tree)) {
+ if (!torture_smb2_connection(torture, &tree)) {
return false;
}
h1 = torture_smb2_create(tree, FNAME);
- status = torture_smb2_write(mem_ctx, tree, h1);
+ status = torture_smb2_write(torture, tree, h1);
if (!NT_STATUS_IS_OK(status)) {
printf("Write failed - %s\n", nt_errstr(status));
return false;
}
- talloc_free(mem_ctx);
-
return true;
}
*/
bool torture_smb2_notify(struct torture_context *torture)
{
- TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
bool ret = true;
- if (!torture_smb2_connection(mem_ctx, &tree)) {
+ if (!torture_smb2_connection(torture, &tree)) {
return false;
}
- ret &= test_valid_request(mem_ctx, tree);
-
- talloc_free(mem_ctx);
+ ret &= test_valid_request(torture, tree);
return ret;
}
*/
bool torture_smb2_getinfo_scan(struct torture_context *torture)
{
- TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
NTSTATUS status;
struct smb2_getinfo io;
struct smb2_handle fhandle, dhandle;
int c, i;
- if (!torture_smb2_connection(mem_ctx, &tree)) {
+ if (!torture_smb2_connection(torture, &tree)) {
return false;
}
io.in.level = (i<<8) | c;
io.in.file.handle = fhandle;
- status = smb2_getinfo(tree, mem_ctx, &io);
+ status = smb2_getinfo(tree, torture, &io);
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS) &&
!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER) &&
!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
}
io.in.file.handle = dhandle;
- status = smb2_getinfo(tree, mem_ctx, &io);
+ status = smb2_getinfo(tree, torture, &io);
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS) &&
!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER) &&
!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
}
}
- talloc_free(mem_ctx);
-
return true;
}
*/
bool torture_smb2_setinfo_scan(struct torture_context *torture)
{
- TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
NTSTATUS status;
struct smb2_setinfo io;
struct smb2_handle handle;
int c, i;
- if (!torture_smb2_connection(mem_ctx, &tree)) {
+ if (!torture_smb2_connection(torture, &tree)) {
return false;
}
torture_smb2_testfile(tree, FNAME, &handle);
ZERO_STRUCT(io);
- io.in.blob = data_blob_talloc_zero(mem_ctx, 1024);
+ io.in.blob = data_blob_talloc_zero(torture, 1024);
for (c=1;c<5;c++) {
for (i=0;i<0x100;i++) {
}
}
- talloc_free(mem_ctx);
-
return true;
}
*/
bool torture_smb2_find_scan(struct torture_context *torture)
{
- TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
NTSTATUS status;
struct smb2_find io;
struct smb2_handle handle;
int i;
- if (!torture_smb2_connection(mem_ctx, &tree)) {
+ if (!torture_smb2_connection(torture, &tree)) {
return false;
}
io.in.level = i;
io.in.file.handle = handle;
- status = smb2_find(tree, mem_ctx, &io);
+ status = smb2_find(tree, torture, &io);
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS) &&
!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER) &&
!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
}
}
- talloc_free(mem_ctx);
-
return true;
}
{
struct smb2_tree *tree;
bool ret = true;
- TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_handle handle;
char *fname;
char *fname_new;
ZERO_STRUCT(handle);
- fname = talloc_asprintf(mem_ctx, BASEDIR "fnum_test_%d.txt", n);
- fname_new = talloc_asprintf(mem_ctx, BASEDIR "fnum_test_new_%d.txt", n);
+ fname = talloc_asprintf(torture, BASEDIR "fnum_test_%d.txt", n);
+ fname_new = talloc_asprintf(torture, BASEDIR "fnum_test_new_%d.txt", n);
- if (!torture_smb2_connection(mem_ctx, &tree)) {
+ if (!torture_smb2_connection(torture, &tree)) {
return false;
}
do { if (NT_STATUS_IS_OK(status)) { \
finfo2.generic.level = RAW_FILEINFO_ ## call; \
finfo2.generic.in.file.handle = handle; \
- status2 = smb2_getinfo_file(tree, mem_ctx, &finfo2); \
+ status2 = smb2_getinfo_file(tree, torture, &finfo2); \
if (!NT_STATUS_IS_OK(status2)) { \
printf("(%s) %s - %s\n", __location__, #call, nt_errstr(status2)); \
ret = false; \
call_name, #stype, #field, \
(uint_t)value, \
(uint_t)nt_time_to_unix(finfo2.stype.out.field)); \
- printf("\t%s", timestring(mem_ctx, value)); \
- printf("\t%s\n", nt_time_string(mem_ctx, finfo2.stype.out.field)); \
+ printf("\t%s", timestring(torture, value)); \
+ printf("\t%s\n", nt_time_string(torture, finfo2.stype.out.field)); \
torture_smb2_all_info(tree, handle); \
ret = false; \
goto done; \
CHECK1(SEC_DESC);
sd = finfo2.query_secdesc.out.sd;
- test_sid = dom_sid_parse_talloc(mem_ctx, "S-1-5-32-1234-5432");
+ test_sid = dom_sid_parse_talloc(torture, "S-1-5-32-1234-5432");
ZERO_STRUCT(ace);
ace.type = SEC_ACE_TYPE_ACCESS_ALLOWED;
ace.flags = 0;
}
smb2_util_unlink(tree, fname);
- talloc_free(mem_ctx);
return ret;
}
/*
open a smb2 connection
*/
-bool torture_smb2_connection(TALLOC_CTX *mem_ctx, struct smb2_tree **tree)
+bool torture_smb2_connection(struct torture_context *tctx, struct smb2_tree **tree)
{
NTSTATUS status;
- const char *host = lp_parm_string(global_loadparm, NULL, "torture", "host");
- const char *share = lp_parm_string(global_loadparm, NULL, "torture", "share");
+ const char *host = torture_setting_string(tctx, "host", NULL);
+ const char *share = torture_setting_string(tctx, "share", NULL);
struct cli_credentials *credentials = cmdline_credentials;
- status = smb2_connect(mem_ctx, host, share, credentials, tree,
- event_context_find(mem_ctx));
+ status = smb2_connect(tctx, host, share, credentials, tree,
+ event_context_find(tctx));
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
host, share, nt_errstr(status));
return ret;
}
-static void parse_dns(const char *dns)
+static bool parse_target(struct loadparm_context *lp_ctx, const char *target)
+{
+ char *host = NULL, *share = NULL;
+ struct dcerpc_binding *binding_struct;
+ NTSTATUS status;
+
+ /* see if its a RPC transport specifier */
+ if (!smbcli_parse_unc(target, NULL, &host, &share)) {
+ status = dcerpc_parse_binding(talloc_autofree_context(), target, &binding_struct);
+ if (NT_STATUS_IS_ERR(status)) {
+ d_printf("Invalid option: %s is not a valid torture target (share or binding string)\n\n", target);
+ return false;
+ }
+ lp_set_cmdline(lp_ctx, "torture:host", binding_struct->host);
+ if (lp_parm_string(lp_ctx, NULL, "torture", "share") == NULL)
+ lp_set_cmdline(lp_ctx, "torture:share", "IPC$");
+ lp_set_cmdline(lp_ctx, "torture:binding", target);
+ } else {
+ lp_set_cmdline(lp_ctx, "torture:host", host);
+ lp_set_cmdline(lp_ctx, "torture:share", share);
+ lp_set_cmdline(lp_ctx, "torture:binding", host);
+ }
+
+ return true;
+}
+
+static void parse_dns(struct loadparm_context *lp_ctx, const char *dns)
{
char *userdn, *basedn, *secret;
char *p, *d;
/* retrievieng the userdn */
p = strchr_m(dns, '#');
if (!p) {
- lp_set_cmdline(global_loadparm, "torture:ldap_userdn", "");
- lp_set_cmdline(global_loadparm, "torture:ldap_basedn", "");
- lp_set_cmdline(global_loadparm, "torture:ldap_secret", "");
+ lp_set_cmdline(lp_ctx, "torture:ldap_userdn", "");
+ lp_set_cmdline(lp_ctx, "torture:ldap_basedn", "");
+ lp_set_cmdline(lp_ctx, "torture:ldap_secret", "");
return;
}
userdn = strndup(dns, p - dns);
- lp_set_cmdline(global_loadparm, "torture:ldap_userdn", userdn);
+ lp_set_cmdline(lp_ctx, "torture:ldap_userdn", userdn);
/* retrieve the basedn */
d = p + 1;
p = strchr_m(d, '#');
if (!p) {
- lp_set_cmdline(global_loadparm, "torture:ldap_basedn", "");
- lp_set_cmdline(global_loadparm, "torture:ldap_secret", "");
+ lp_set_cmdline(lp_ctx, "torture:ldap_basedn", "");
+ lp_set_cmdline(lp_ctx, "torture:ldap_secret", "");
return;
}
basedn = strndup(d, p - d);
- lp_set_cmdline(global_loadparm, "torture:ldap_basedn", basedn);
+ lp_set_cmdline(lp_ctx, "torture:ldap_basedn", basedn);
/* retrieve the secret */
p = p + 1;
if (!p) {
- lp_set_cmdline(global_loadparm, "torture:ldap_secret", "");
+ lp_set_cmdline(lp_ctx, "torture:ldap_secret", "");
return;
}
secret = strdup(p);
- lp_set_cmdline(global_loadparm, "torture:ldap_secret", secret);
+ lp_set_cmdline(lp_ctx, "torture:ldap_secret", secret);
printf ("%s - %s - %s\n", userdn, basedn, secret);
char **argv_new;
poptContext pc;
static const char *target = "other";
- struct dcerpc_binding *binding_struct;
NTSTATUS status;
int shell = false;
static const char *ui_ops_name = "simple";
const char *basedir = NULL;
const char *extra_module = NULL;
static int list_tests = 0;
- char *host = NULL, *share = NULL;
enum {OPT_LOADFILE=1000,OPT_UNCLIST,OPT_TIMELIMIT,OPT_DNS, OPT_LIST,
OPT_DANGEROUS,OPT_SMB_PORTS,OPT_ASYNC,OPT_NUMPROGS};
lp_set_cmdline(global_loadparm, "torture:nprocs", poptGetOptArg(pc));
break;
case OPT_DNS:
- parse_dns(poptGetOptArg(pc));
+ parse_dns(global_loadparm, poptGetOptArg(pc));
break;
case OPT_DANGEROUS:
lp_set_cmdline(global_loadparm, "torture:dangerous", "Yes");
exit(1);
}
- /* see if its a RPC transport specifier */
- if (!smbcli_parse_unc(argv_new[1], NULL, &host, &share)) {
- status = dcerpc_parse_binding(talloc_autofree_context(), argv_new[1], &binding_struct);
- if (NT_STATUS_IS_ERR(status)) {
- d_printf("Invalid option: %s is not a valid torture target (share or binding string)\n\n", argv_new[1]);
- usage(pc);
- return false;
- }
- lp_set_cmdline(global_loadparm, "torture:host", binding_struct->host);
- if (lp_parm_string(global_loadparm, NULL, "torture", "share") == NULL)
- lp_set_cmdline(global_loadparm, "torture:share", "IPC$");
- lp_set_cmdline(global_loadparm, "torture:binding", argv_new[1]);
- } else {
- lp_set_cmdline(global_loadparm, "torture:host", host);
- lp_set_cmdline(global_loadparm, "torture:share", share);
- lp_set_cmdline(global_loadparm, "torture:binding", host);
+ if (!parse_target(global_loadparm, argv_new[1])) {
+ usage(pc);
+ exit(1);
}
if (!strcmp(ui_ops_name, "simple")) {
torture->outputdir = pwd;
}
+ torture->lp_ctx = global_loadparm;
+
if (argc_new == 0) {
printf("You must specify a test to run, or 'ALL'\n");
} else if (shell) {
int torture_setting_int(struct torture_context *test, const char *name,
int default_value)
{
- return lp_parm_int(global_loadparm, NULL, "torture", name, default_value);
+ return lp_parm_int(test->lp_ctx, NULL, "torture", name, default_value);
}
double torture_setting_double(struct torture_context *test, const char *name,
double default_value)
{
- return lp_parm_double(global_loadparm, NULL, "torture", name, default_value);
+ return lp_parm_double(test->lp_ctx, NULL, "torture", name, default_value);
}
bool torture_setting_bool(struct torture_context *test, const char *name,
bool default_value)
{
- return lp_parm_bool(global_loadparm, NULL, "torture", name, default_value);
+ return lp_parm_bool(test->lp_ctx, NULL, "torture", name, default_value);
}
const char *torture_setting_string(struct torture_context *test,
const char *name,
const char *default_value)
{
- const char *ret = lp_parm_string(global_loadparm, NULL, "torture", name);
+ const char *ret = lp_parm_string(test->lp_ctx, NULL, "torture", name);
if (ret == NULL)
return default_value;
const char *outputdir;
int level;
struct event_context *ev;
+
+ struct loadparm_context *lp_ctx;
};
/*
struct dom_sid ** sid_list;
};
-static struct smbcli_state *connect_to_server(void *mem_ctx,
+static struct smbcli_state *connect_to_server(struct torture_context *tctx,
struct cli_credentials *creds)
{
NTSTATUS status;
struct smbcli_state *cli;
- const char *host = lp_parm_string(global_loadparm, NULL, "torture", "host");
- const char *share = lp_parm_string(global_loadparm, NULL, "torture", "share");
+ const char *host = torture_setting_string(tctx, "host", NULL);
+ const char *share = torture_setting_string(tctx, "share", NULL);
- status = smbcli_full_connection(mem_ctx, &cli,
+ status = smbcli_full_connection(tctx, &cli,
host, share, NULL,
creds, NULL);
struct smbcli_state *cli;
struct cli_credentials *anon_credentials;
struct smb_whoami whoami;
- void *mem_ctx;
- mem_ctx = talloc_init("smb_query_posix_whoami");
- torture_assert(torture, mem_ctx != NULL, "malloc failed");
-
- if (!(cli = connect_to_server(mem_ctx, cmdline_credentials))) {
- goto fail;
+ if (!(cli = connect_to_server(torture, cmdline_credentials))) {
+ return false;
}
/* Test basic authenticated mapping. */
printf("calling SMB_QFS_POSIX_WHOAMI on an authenticated connection\n");
- if (!smb_raw_query_posix_whoami(mem_ctx, torture,
+ if (!smb_raw_query_posix_whoami(torture, torture,
cli, &whoami, 0xFFFF)) {
smbcli_tdis(cli);
- goto fail;
+ return false;
}
/* Test that the server drops the UID and GID list. */
printf("calling SMB_QFS_POSIX_WHOAMI with a small buffer\n");
- if (!smb_raw_query_posix_whoami(mem_ctx, torture,
+ if (!smb_raw_query_posix_whoami(torture, torture,
cli, &whoami, 0x40)) {
smbcli_tdis(cli);
- goto fail;
+ return false;
}
torture_assert_int_equal(torture, whoami.num_gids, 0,
smbcli_tdis(cli);
printf("calling SMB_QFS_POSIX_WHOAMI on an anonymous connection\n");
- anon_credentials = cli_credentials_init_anon(mem_ctx);
+ anon_credentials = cli_credentials_init_anon(torture);
- if (!(cli = connect_to_server(mem_ctx, anon_credentials))) {
- goto fail;
+ if (!(cli = connect_to_server(torture, anon_credentials))) {
+ return false;
}
- if (!smb_raw_query_posix_whoami(mem_ctx, torture,
+ if (!smb_raw_query_posix_whoami(torture, torture,
cli, &whoami, 0xFFFF)) {
smbcli_tdis(cli);
- goto fail;
+ return false;
}
smbcli_tdis(cli);
printf("server does not support SMB_WHOAMI_GUEST flag\n");
}
- talloc_free(mem_ctx);
return true;
-
-fail:
- talloc_free(mem_ctx);
- return false;
-
}
/* vim: set sts=8 sw=8 : */
srandom(((int)mypid) ^ ((int)time(NULL)));
asprintf(&myname, "CLIENT%d", i);
- lp_set_cmdline(global_loadparm, "netbios name", myname);
+ lp_set_cmdline(tctx->lp_ctx, "netbios name", myname);
free(myname);
separator = torture_setting_string(torture,
"winbindd separator",
- lp_winbind_separator(global_loadparm));
+ lp_winbind_separator(torture->lp_ctx));
torture_assert_int_equal(torture,
rep.data.info.winbind_separator,
*separator,
torture_assert(torture, got_dir, "NULL WINBINDD_PRIV_PIPE_DIR\n");
- default_dir = lock_path(torture, global_loadparm,
+ default_dir = lock_path(torture, torture->lp_ctx,
WINBINDD_PRIV_SOCKET_SUBDIR);
expected_dir = torture_setting_string(torture,
"winbindd private pipe dir",
expected = torture_setting_string(torture,
"winbindd netbios name",
- lp_netbios_name(global_loadparm));
+ lp_netbios_name(torture->lp_ctx));
torture_assert_str_equal(torture,
rep.data.netbios_name, expected,
expected = torture_setting_string(torture,
"winbindd netbios domain",
- lp_workgroup(global_loadparm));
+ lp_workgroup(torture->lp_ctx));
get_winbind_domain(torture, &domain);
task->private = edata;
- edata->tls_params = tls_initialise(edata);
+ edata->tls_params = tls_initialise(edata, task->lp_ctx);
NT_STATUS_HAVE_NO_MEMORY(edata->tls_params);
return NT_STATUS_OK;