summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/com/simple.c3
-rw-r--r--source4/torture/ldap/basic.c7
-rw-r--r--source4/torture/raw/composite.c8
-rw-r--r--source4/torture/raw/context.c27
-rw-r--r--source4/torture/rpc/bind.c7
-rw-r--r--source4/torture/rpc/samlogon.c32
-rw-r--r--source4/torture/rpc/samsync.c20
-rw-r--r--source4/torture/rpc/schannel.c10
-rw-r--r--source4/torture/torture.c42
9 files changed, 72 insertions, 84 deletions
diff --git a/source4/torture/com/simple.c b/source4/torture/com/simple.c
index dfc3beff4e..128d84d1c7 100644
--- a/source4/torture/com/simple.c
+++ b/source4/torture/com/simple.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "lib/com/com.h"
#include "librpc/gen_ndr/com_dcom.h"
+#include "lib/cmdline/popt_common.h"
#define DEFAULT_TRANS 4096
@@ -39,7 +40,7 @@ static BOOL test_readwrite(TALLOC_CTX *mem_ctx, const char *host)
int i;
com_init(&ctx);
- dcom_client_init(ctx, lp_parm_string(-1, "torture", "userdomain"), lp_parm_string(-1, "torture", "username"), lp_parm_string(-1, "torture", "password"));
+ dcom_client_init(ctx, cmdline_credentials);
GUID_from_string(COM_ISTREAM_UUID, &IID[0]);
GUID_from_string(COM_IUNKNOWN_UUID, &IID[1]);
diff --git a/source4/torture/ldap/basic.c b/source4/torture/ldap/basic.c
index 936a8dbe51..d0255abe01 100644
--- a/source4/torture/ldap/basic.c
+++ b/source4/torture/ldap/basic.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "libcli/ldap/ldap.h"
+#include "lib/cmdline/popt_common.h"
BOOL test_bind_simple(struct ldap_connection *conn, const char *userdn, const char *password)
{
@@ -188,9 +189,9 @@ BOOL torture_ldap_basic(void)
TALLOC_CTX *mem_ctx;
BOOL ret = True;
const char *host = lp_parm_string(-1, "torture", "host");
- const char *username = lp_parm_string(-1, "torture", "username");
- const char *domain = lp_parm_string(-1, "torture", "userdomain");
- const char *password = lp_parm_string(-1, "torture", "password");
+ const char *username = cli_credentials_get_username(cmdline_credentials);
+ const char *domain = cli_credentials_get_domain(cmdline_credentials);
+ const char *password = cli_credentials_get_password(cmdline_credentials);
const char *userdn = lp_parm_string(-1, "torture", "ldap_userdn");
/*const char *basedn = lp_parm_string(-1, "torture", "ldap_basedn");*/
const char *secret = lp_parm_string(-1, "torture", "ldap_secret");
diff --git a/source4/torture/raw/composite.c b/source4/torture/raw/composite.c
index 9a0f924bfc..b9c7609b5f 100644
--- a/source4/torture/raw/composite.c
+++ b/source4/torture/raw/composite.c
@@ -24,6 +24,7 @@
#include "lib/events/events.h"
#include "libcli/raw/libcliraw.h"
#include "libcli/composite/composite.h"
+#include "lib/cmdline/popt_common.h"
#define BASEDIR "\\composite"
@@ -149,9 +150,10 @@ static BOOL test_fetchfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
io2.in.calling_name = lp_netbios_name();
io2.in.service = lp_parm_string(-1, "torture", "share");
io2.in.service_type = "A:";
- io2.in.user = lp_parm_string(-1, "torture", "username");
- io2.in.domain = lp_parm_string(-1, "torture", "userdomain");
- io2.in.password = lp_parm_string(-1, "torture", "password");
+
+ io2.in.user = cli_credentials_get_username(cmdline_credentials);
+ io2.in.domain = cli_credentials_get_domain(cmdline_credentials);
+ io2.in.password = cli_credentials_get_password(cmdline_credentials);
io2.in.filename = fname;
printf("testing parallel fetchfile with %d ops\n", torture_numops);
diff --git a/source4/torture/raw/context.c b/source4/torture/raw/context.c
index cdf8388e93..3eb848eebd 100644
--- a/source4/torture/raw/context.c
+++ b/source4/torture/raw/context.c
@@ -22,6 +22,7 @@
#include "libcli/raw/libcliraw.h"
#include "librpc/gen_ndr/ndr_security.h"
#include "libcli/composite/composite.h"
+#include "lib/cmdline/popt_common.h"
#define BASEDIR "\\rawcontext"
@@ -57,7 +58,6 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
BOOL ret = True;
- const char *username, *domain, *password;
struct smbcli_session *session;
struct smbcli_session *session2;
struct smbcli_session *session3;
@@ -76,18 +76,14 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
return False;
}
- username = lp_parm_string(-1, "torture", "username");
- password = lp_parm_string(-1, "torture", "password");
- domain = lp_parm_string(-1, "torture", "userdomain");
-
printf("create a second security context on the same transport\n");
session = smbcli_session_init(cli->transport, mem_ctx, 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.password = password;
- setup.in.user = username;
- setup.in.domain = domain;
+ setup.in.password = cli_credentials_get_password(cmdline_credentials);
+ setup.in.user = cli_credentials_get_username(cmdline_credentials);
+ setup.in.domain = cli_credentials_get_domain(cmdline_credentials);
status = smb_composite_sesssetup(session, &setup);
CHECK_STATUS(status, NT_STATUS_OK);
@@ -100,9 +96,10 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
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.password = password;
- setup.in.user = username;
- setup.in.domain = domain;
+
+ setup.in.password = cli_credentials_get_password(cmdline_credentials);
+ setup.in.user = cli_credentials_get_username(cmdline_credentials);
+ setup.in.domain = cli_credentials_get_domain(cmdline_credentials);
status = smb_composite_sesssetup(session2, &setup);
CHECK_STATUS(status, NT_STATUS_OK);
@@ -120,9 +117,11 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
session3->vuid = session->vuid;
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = 0; /* force a non extended security login (should fail) */
- setup.in.password = password;
- setup.in.user = username;
- setup.in.domain = domain;
+
+
+ setup.in.password = cli_credentials_get_password(cmdline_credentials);
+ setup.in.user = cli_credentials_get_username(cmdline_credentials);
+ setup.in.domain = cli_credentials_get_domain(cmdline_credentials);
status = smb_composite_sesssetup(session3, &setup);
CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED);
diff --git a/source4/torture/rpc/bind.c b/source4/torture/rpc/bind.c
index 3eb02c31eb..71eaec4f92 100644
--- a/source4/torture/rpc/bind.c
+++ b/source4/torture/rpc/bind.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "librpc/gen_ndr/ndr_lsa.h"
+#include "lib/cmdline/popt_common.h"
/*
This test is 'bogus' in that it doesn't actually perform to the
@@ -37,10 +38,6 @@
BOOL torture_multi_bind(void)
{
struct dcerpc_pipe *p;
- const char *workstation = lp_netbios_name();
- const char *domain = lp_parm_string(-1, "torture", "userdomain");
- const char *username = lp_parm_string(-1, "torture", "username");
- const char *password = lp_parm_string(-1, "torture", "password");
const char *pipe_uuid = DCERPC_LSARPC_UUID;
uint32_t pipe_version = DCERPC_LSARPC_VERSION;
struct dcerpc_binding *binding;
@@ -68,7 +65,7 @@ BOOL torture_multi_bind(void)
}
status = dcerpc_pipe_auth(p, binding, pipe_uuid, pipe_version,
- workstation, domain, username, password);
+ cmdline_credentials);
if (NT_STATUS_IS_OK(status)) {
printf("(incorrectly) allowed re-bind to uuid %s - %s\n",
diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c
index e08eaca22e..1ee8f36b8e 100644
--- a/source4/torture/rpc/samlogon.c
+++ b/source4/torture/rpc/samlogon.c
@@ -26,6 +26,7 @@
#include "librpc/gen_ndr/ndr_netlogon.h"
#include "auth/auth.h"
#include "lib/crypto/crypto.h"
+#include "lib/cmdline/popt_common.h"
#define TEST_MACHINE_NAME "samlogontest"
#define TEST_USER_NAME "samlogontestuser"
@@ -1215,6 +1216,7 @@ BOOL torture_rpc_samlogon(void)
NTSTATUS status;
struct dcerpc_pipe *p;
struct dcerpc_binding *b;
+ struct cli_credentials credentials;
TALLOC_CTX *mem_ctx = talloc_init("torture_rpc_netlogon");
BOOL ret = True;
struct test_join *join_ctx;
@@ -1245,27 +1247,29 @@ BOOL torture_rpc_samlogon(void)
BOOL network_login;
} usercreds[] = {
{
- lp_parm_string(-1, "torture", "userdomain"),
- lp_parm_string(-1, "torture", "username"),
- lp_parm_string(-1, "torture", "password"),
+ cli_credentials_get_domain(cmdline_credentials),
+ cli_credentials_get_username(cmdline_credentials),
+ cli_credentials_get_password(cmdline_credentials),
True
},
{
NULL,
talloc_asprintf(mem_ctx,
"%s@%s",
- lp_parm_string(-1, "torture", "username"),
- lp_parm_string(-1, "torture", "userdomain")),
- lp_parm_string(-1, "torture", "password"),
+ cli_credentials_get_domain(cmdline_credentials),
+ cli_credentials_get_username(cmdline_credentials)
+ ),
+ cli_credentials_get_password(cmdline_credentials),
False
},
{
NULL,
talloc_asprintf(mem_ctx,
"%s@%s",
- lp_parm_string(-1, "torture", "username"),
- lp_realm()),
- lp_parm_string(-1, "torture", "password"),
+ cli_credentials_get_username(cmdline_credentials),
+ cli_credentials_get_realm(cmdline_credentials)
+ ),
+ cli_credentials_get_password(cmdline_credentials),
True
},
#if 0
@@ -1334,13 +1338,15 @@ BOOL torture_rpc_samlogon(void)
b->flags &= ~DCERPC_AUTH_OPTIONS;
b->flags |= DCERPC_SCHANNEL_WORKSTATION | DCERPC_SIGN | DCERPC_SCHANNEL_128;
+ cli_credentials_set_workstation(&credentials, TEST_MACHINE_NAME, CRED_SPECIFIED);
+ cli_credentials_set_domain(&credentials, lp_workgroup(), CRED_SPECIFIED);
+ cli_credentials_set_username(&credentials, test_machine_account, CRED_SPECIFIED);
+ cli_credentials_set_password(&credentials, machine_password, CRED_SPECIFIED);
+
status = dcerpc_pipe_connect_b(&p, b,
DCERPC_NETLOGON_UUID,
DCERPC_NETLOGON_VERSION,
- TEST_MACHINE_NAME,
- lp_workgroup(),
- test_machine_account,
- machine_password);
+ &credentials);
if (!NT_STATUS_IS_OK(status)) {
ret = False;
diff --git a/source4/torture/rpc/samsync.c b/source4/torture/rpc/samsync.c
index 505e331d19..b92752227c 100644
--- a/source4/torture/rpc/samsync.c
+++ b/source4/torture/rpc/samsync.c
@@ -1295,6 +1295,7 @@ BOOL torture_rpc_samsync(void)
struct lsa_ObjectAttribute attr;
struct lsa_QosInfo qos;
struct lsa_OpenPolicy2 r;
+ struct cli_credentials credentials;
struct samsync_state *samsync_state;
@@ -1418,13 +1419,15 @@ BOOL torture_rpc_samsync(void)
b->flags &= ~DCERPC_AUTH_OPTIONS;
b->flags |= DCERPC_SCHANNEL_BDC | DCERPC_SIGN;
+ cli_credentials_set_workstation(&credentials, TEST_MACHINE_NAME, CRED_SPECIFIED);
+ cli_credentials_set_domain(&credentials, lp_workgroup(), CRED_SPECIFIED);
+ cli_credentials_set_username(&credentials, test_machine_account, CRED_SPECIFIED);
+ cli_credentials_set_password(&credentials, machine_password, CRED_SPECIFIED);
+
status = dcerpc_pipe_connect_b(&samsync_state->p, b,
DCERPC_NETLOGON_UUID,
DCERPC_NETLOGON_VERSION,
- TEST_MACHINE_NAME,
- lp_workgroup(),
- test_machine_account,
- machine_password);
+ &credentials);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
@@ -1449,14 +1452,15 @@ BOOL torture_rpc_samsync(void)
b_netlogon_wksta->flags &= ~DCERPC_AUTH_OPTIONS;
b_netlogon_wksta->flags |= DCERPC_SCHANNEL_WORKSTATION | DCERPC_SIGN;
+ cli_credentials_set_workstation(&credentials, TEST_WKSTA_MACHINE_NAME, CRED_SPECIFIED);
+ cli_credentials_set_username(&credentials, test_wksta_machine_account, CRED_SPECIFIED);
+ cli_credentials_set_password(&credentials, wksta_machine_password, CRED_SPECIFIED);
+
status = dcerpc_pipe_connect_b(&samsync_state->p_netlogon_wksta,
b_netlogon_wksta,
DCERPC_NETLOGON_UUID,
DCERPC_NETLOGON_VERSION,
- TEST_WKSTA_MACHINE_NAME,
- lp_workgroup(),
- test_wksta_machine_account,
- wksta_machine_password);
+ &credentials);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to server as a Workstation: %s\n", nt_errstr(status));
diff --git a/source4/torture/rpc/schannel.c b/source4/torture/rpc/schannel.c
index 1b10e2a4f2..f572933bf5 100644
--- a/source4/torture/rpc/schannel.c
+++ b/source4/torture/rpc/schannel.c
@@ -127,6 +127,7 @@ static BOOL test_schannel(TALLOC_CTX *mem_ctx,
struct dcerpc_pipe *p = NULL;
struct dcerpc_pipe *p_netlogon = NULL;
struct creds_CredentialState *creds;
+ struct cli_credentials credentials;
char *test_machine_account = talloc_asprintf(NULL, "%s$", TEST_MACHINE_NAME);
join_ctx = torture_create_testuser(test_machine_account, lp_workgroup(),
@@ -145,13 +146,14 @@ static BOOL test_schannel(TALLOC_CTX *mem_ctx,
b->flags &= ~DCERPC_AUTH_OPTIONS;
b->flags |= dcerpc_flags;
+ cli_credentials_set_domain(&credentials, lp_workgroup(), CRED_SPECIFIED);
+ cli_credentials_set_workstation(&credentials, TEST_MACHINE_NAME, CRED_SPECIFIED);
+ cli_credentials_set_username(&credentials, test_machine_account, CRED_SPECIFIED);
+ cli_credentials_set_password(&credentials, machine_password, CRED_SPECIFIED);
status = dcerpc_pipe_connect_b(&p, b,
DCERPC_SAMR_UUID,
DCERPC_SAMR_VERSION,
- TEST_MACHINE_NAME,
- lp_workgroup(),
- test_machine_account,
- machine_password);
+ &credentials);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect with schannel: %s\n", nt_errstr(status));
goto failed;
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index c7762f1b8a..dce91452f1 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -80,9 +80,9 @@ BOOL torture_open_connection_share(struct smbcli_state **c,
const char *sharename)
{
NTSTATUS status;
- const char *username = lp_parm_string(-1, "torture", "username");
- const char *userdomain = lp_parm_string(-1, "torture", "userdomain");
- const char *password = lp_parm_string(-1, "torture", "password");
+ const char *username = cli_credentials_get_username(cmdline_credentials);
+ const char *userdomain = cli_credentials_get_domain(cmdline_credentials);
+ const char *password = cli_credentials_get_password(cmdline_credentials);
status = smbcli_full_connection(NULL,
c, lp_netbios_name(),
@@ -138,10 +138,7 @@ NTSTATUS torture_rpc_connection(struct dcerpc_pipe **p,
}
status = dcerpc_pipe_connect(p, binding, pipe_uuid, pipe_version,
- lp_netbios_name(),
- lp_parm_string(-1, "torture", "userdomain"),
- lp_parm_string(-1, "torture", "username"),
- lp_parm_string(-1, "torture", "password"));
+ cmdline_credentials);
return status;
}
@@ -173,10 +170,8 @@ NTSTATUS torture_rpc_connection_transport(struct dcerpc_pipe **p,
b->transport = transport;
status = dcerpc_pipe_connect_b(p, b, pipe_uuid, pipe_version,
- lp_netbios_name(),
- lp_parm_string(-1, "torture", "userdomain"),
- lp_parm_string(-1, "torture", "username"),
- lp_parm_string(-1, "torture", "password"));
+ cmdline_credentials);
+
return status;
}
@@ -731,9 +726,9 @@ static BOOL run_tcon_devtype_test(void)
BOOL ret = True;
const char *host = lp_parm_string(-1, "torture", "host");
const char *share = lp_parm_string(-1, "torture", "share");
- const char *username = lp_parm_string(-1, "torture", "username");
- const char *userdomain = lp_parm_string(-1, "torture", "userdomain");
- const char *password = lp_parm_string(-1, "torture", "password");
+ const char *username = cli_credentials_get_username(cmdline_credentials);
+ const char *userdomain = cli_credentials_get_domain(cmdline_credentials);
+ const char *password = cli_credentials_get_password(cmdline_credentials);
status = smbcli_full_connection(NULL,
&cli1, lp_netbios_name(),
@@ -2728,25 +2723,6 @@ static BOOL is_binding_string(const char *binding_string)
lp_set_cmdline("torture:binding", binding);
}
- if (!lp_parm_string(-1,"torture","username")) {
- lp_set_cmdline("torture:username", cli_credentials_get_username(cmdline_credentials));
- }
- if (!lp_parm_string(-1,"torture","userdomain")) {
- /*
- * backward compatibility
- * maybe we should remove this to make this consistent
- * for all cmdline tools
- * --metze
- */
- if (strequal(lp_netbios_name(),cli_credentials_get_domain(cmdline_credentials))) {
- cli_credentials_set_domain(cmdline_credentials, lp_workgroup(), CRED_SPECIFIED);
- }
- lp_set_cmdline("torture:userdomain", cli_credentials_get_domain(cmdline_credentials));
- }
- if (!lp_parm_string(-1,"torture","password")) {
- lp_set_cmdline("torture:password", cli_credentials_get_password(cmdline_credentials));
- }
-
if (argc_new == 0) {
printf("You must specify a test to run, or 'ALL'\n");
} else {