From 7d5603ff8bf491e4913c60f86c23e9dd79e3153f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 22 Nov 2005 20:55:59 +0000 Subject: r11868: Get the wks and user accounts from a file. Abartlet, please don't break this again, it's too darn useful for near-realistic load tests on an RPC infrastructure and can be quite easily expanded to more weird things a workstation might do during a login. Yes, I promise I will document this test, but this must wait until the weekend. I might add simulating a profile download quite soon, we have the information available from the info3. Thanks, Volker (This used to be commit 15ca9e16bbc120a4a29bedaededc266097204ec5) --- source4/torture/rpc/xplogin.c | 143 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 141 insertions(+), 2 deletions(-) (limited to 'source4/torture/rpc') diff --git a/source4/torture/rpc/xplogin.c b/source4/torture/rpc/xplogin.c index 5e3a4dfd8e..5eb336db65 100644 --- a/source4/torture/rpc/xplogin.c +++ b/source4/torture/rpc/xplogin.c @@ -1460,6 +1460,8 @@ static struct composite_context *xp_login_send(TALLOC_CTX *mem_ctx, cli_credentials_set_conf(state->wks_creds); cli_credentials_set_domain(state->wks_creds, wks_domain, CRED_SPECIFIED); + cli_credentials_set_workstation(state->wks_creds, wks_name, + CRED_SPECIFIED); cli_credentials_set_username(state->wks_creds, talloc_asprintf(state, "%s$", wks_name), CRED_SPECIFIED); @@ -1477,6 +1479,8 @@ static struct composite_context *xp_login_send(TALLOC_CTX *mem_ctx, if (state->conn.in.credentials == NULL) goto failed; cli_credentials_set_conf(state->conn.in.credentials); cli_credentials_set_anonymous(state->conn.in.credentials); + cli_credentials_set_workstation(state->conn.in.credentials, wks_name, + CRED_SPECIFIED); state->conn.in.fallback_to_anonymous = False; state->conn.in.workgroup = wks_domain; @@ -1759,6 +1763,100 @@ static void xp_login_done(struct composite_context *ctx) *count += 1; } +struct pwdentry { + const char *domain; + const char *name; + const char *pass; +}; + +static BOOL read_pwd_file(TALLOC_CTX *mem_ctx, + const char *fname, int *numlines, + struct pwdentry ***result) +{ + char **lines; + int i; + + lines = file_lines_load(fname, numlines, mem_ctx); + if (lines == NULL) { + DEBUG(0, ("Could not load file %s: %s\n", + fname, strerror(errno))); + return False; + } + + if (*numlines == 0) { + DEBUG(0, ("no entries in file %s\n", fname)); + return False; + } + + *result = talloc_array(mem_ctx, struct pwdentry *, *numlines); + if (*result == NULL) { + DEBUG(0, ("talloc failed\n")); + return False; + } + + for (i=0; i<(*numlines); i++) { + char *p, *q; + (*result)[i] = talloc_zero(*result, struct pwdentry); + if ((*result)[i] == NULL) { + DEBUG(0, ("talloc failed\n")); + return False; + } + + p = lines[i]; + q = strchr(p, '\\'); + if (q != NULL) { + *q = '\0'; + (*result)[i]->domain = lines[i]; + p = q+1; + } else { + (*result)[i]->domain = lp_workgroup(); + } + + q = strchr(p, '%'); + if (q == NULL) { + DEBUG(0, ("Invalid entry: %s\n", q)); + return False; + } + + *q = '\0'; + (*result)[i]->name = p; + (*result)[i]->pass = q+1; + } + + return True; +} + +#if 0 +/* Stolen from testjoin.c for easy mass-joining */p +static BOOL joinme(int i) +{ + TALLOC_CTX *mem_ctx; + struct test_join *join_ctx; + struct cli_credentials *machine_credentials; + const char *machine_password; + const char *name; + + mem_ctx = talloc_init("torture_rpc_netlogon"); + + name = talloc_asprintf(mem_ctx, "wks%3d", i); + + join_ctx = torture_join_domain(name, ACB_WSTRUST, + &machine_credentials); + if (!join_ctx) { + talloc_free(mem_ctx); + printf("Failed to join as BDC\n"); + return False; + } + + machine_password = cli_credentials_get_password(machine_credentials); + + printf("%s%%%s\n", name, machine_password); + + talloc_free(mem_ctx); + return True; +} +#endif + BOOL torture_rpc_login(void) { TALLOC_CTX *mem_ctx; @@ -1768,13 +1866,42 @@ BOOL torture_rpc_login(void) int i, num_events; int num_finished = 0; struct composite_context **ctx; + struct pwdentry **wks_list; + struct pwdentry **user_list; + int num_wks = 0; + int num_user = 0; + +#if 0 + for (i=0; i num_wks) { + DEBUG(0, ("more workstations (%d) than ops (%d) needed\n", + num_wks, torture_numops)); + return False; + } + + if (!read_pwd_file(mem_ctx, "user.pwd", &num_user, &user_list)) { + return False; + } + event_ctx = event_context_init(mem_ctx); if (event_ctx == NULL) { DEBUG(0, ("event_context_init failed\n")); @@ -1789,6 +1916,9 @@ BOOL torture_rpc_login(void) } for (i=0; iname, + wks_list[wks_idx]->pass, + user_list[user_idx]->domain, + user_list[user_idx]->name, + user_list[user_idx]->pass); if (ctx[i] == NULL) { DEBUG(0, ("xp_login_send failed\n")); goto done; } ctx[i]->async.fn = xp_login_done; ctx[i]->async.private_data = &num_finished; + + /* Avoid duplicate usage of workstation accounts. They would + * conflict if multiple reqchal/auth2/schannel-binds cross + * each other */ + wks_list[wks_idx] = wks_list[num_wks-1]; + num_wks -= 1; } num_events = 0; -- cgit