08c1b09b07607a90cc7e7aa90a982dcc42418ef9
[gd/samba-autobuild/.git] / source4 / torture / rpc / schannel.c
1 /*
2    Unix SMB/CIFS implementation.
3
4    test suite for schannel operations
5
6    Copyright (C) Andrew Tridgell 2004
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include "includes.h"
23 #include "librpc/gen_ndr/ndr_netlogon_c.h"
24 #include "librpc/gen_ndr/ndr_lsa_c.h"
25 #include "librpc/gen_ndr/ndr_samr_c.h"
26 #include "auth/credentials/credentials.h"
27 #include "auth/credentials/credentials_krb5.h"
28 #include "torture/rpc/torture_rpc.h"
29 #include "lib/cmdline/popt_common.h"
30 #include "../libcli/auth/schannel.h"
31 #include "libcli/auth/libcli_auth.h"
32 #include "libcli/security/security.h"
33 #include "system/filesys.h"
34 #include "param/param.h"
35 #include "librpc/rpc/dcerpc_proto.h"
36 #include "libcli/composite/composite.h"
37 #include "lib/events/events.h"
38
39 #define TEST_MACHINE_NAME "schannel"
40
41 /*
42   try a netlogon SamLogon
43 */
44 bool test_netlogon_ex_ops(struct dcerpc_pipe *p, struct torture_context *tctx,
45                           struct cli_credentials *credentials,
46                           struct netlogon_creds_CredentialState *creds)
47 {
48         NTSTATUS status;
49         struct netr_LogonSamLogonEx r;
50         struct netr_NetworkInfo ninfo;
51         union netr_LogonLevel logon;
52         union netr_Validation validation;
53         uint8_t authoritative = 0;
54         uint32_t _flags = 0;
55         DATA_BLOB names_blob, chal, lm_resp, nt_resp;
56         int i;
57         int flags = CLI_CRED_NTLM_AUTH;
58         struct dcerpc_binding_handle *b = p->binding_handle;
59
60         struct netr_UserSessionKey key;
61         struct netr_LMSessionKey LMSessKey;
62         uint32_t validation_levels[] = { 2, 3 };
63         struct netr_SamBaseInfo *base = NULL;
64         const char *crypto_alg = "";
65         bool can_do_validation_6 = true;
66         enum dcerpc_AuthLevel auth_level = DCERPC_AUTH_LEVEL_NONE;
67
68         if (lpcfg_client_lanman_auth(tctx->lp_ctx)) {
69                 flags |= CLI_CRED_LANMAN_AUTH;
70         }
71
72         if (lpcfg_client_ntlmv2_auth(tctx->lp_ctx)) {
73                 flags |= CLI_CRED_NTLMv2_AUTH;
74         }
75
76         cli_credentials_get_ntlm_username_domain(cmdline_credentials, tctx,
77                                                  &ninfo.identity_info.account_name.string,
78                                                  &ninfo.identity_info.domain_name.string);
79
80         generate_random_buffer(ninfo.challenge,
81                                sizeof(ninfo.challenge));
82         chal = data_blob_const(ninfo.challenge,
83                                sizeof(ninfo.challenge));
84
85         names_blob = NTLMv2_generate_names_blob(tctx, cli_credentials_get_workstation(credentials),
86                                                 cli_credentials_get_domain(credentials));
87
88         status = cli_credentials_get_ntlm_response(cmdline_credentials, tctx,
89                                                    &flags,
90                                                    chal,
91                                                    NULL, /* server_timestamp */
92                                                    names_blob,
93                                                    &lm_resp, &nt_resp,
94                                                    NULL, NULL);
95         torture_assert_ntstatus_ok(tctx, status,
96                                    "cli_credentials_get_ntlm_response failed");
97
98         ninfo.lm.data = lm_resp.data;
99         ninfo.lm.length = lm_resp.length;
100
101         ninfo.nt.data = nt_resp.data;
102         ninfo.nt.length = nt_resp.length;
103
104         ninfo.identity_info.parameter_control = 0;
105         ninfo.identity_info.logon_id_low = 0;
106         ninfo.identity_info.logon_id_high = 0;
107         ninfo.identity_info.workstation.string = cli_credentials_get_workstation(credentials);
108
109         logon.network = &ninfo;
110
111         r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
112         r.in.computer_name = cli_credentials_get_workstation(credentials);
113         r.in.logon_level = NetlogonNetworkInformation;
114         r.in.logon= &logon;
115         r.in.flags = &_flags;
116         r.out.validation = &validation;
117         r.out.authoritative = &authoritative;
118         r.out.flags = &_flags;
119
120         /*
121         - retrieve level6
122         - save usrsession and lmsession key
123         - retrieve level 2
124         - calculate, compare
125         - retrieve level 3
126         - calculate, compare
127         */
128
129         if (creds) {
130                 if (creds->negotiate_flags & NETLOGON_NEG_SUPPORTS_AES) {
131                         crypto_alg = "AES";
132                 } else if (creds->negotiate_flags & NETLOGON_NEG_ARCFOUR) {
133                         crypto_alg = "ARCFOUR";
134                 }
135         }
136
137         dcerpc_binding_handle_auth_info(b, NULL, &auth_level);
138         if (auth_level == DCERPC_AUTH_LEVEL_PRIVACY) {
139                 r.in.validation_level = 6;
140
141                 torture_comment(tctx,
142                                 "Testing LogonSamLogonEx with name %s using %s and validation_level: %d\n",
143                                 ninfo.identity_info.account_name.string, crypto_alg,
144                                 r.in.validation_level);
145
146                 torture_assert_ntstatus_ok(tctx,
147                         dcerpc_netr_LogonSamLogonEx_r(b, tctx, &r),
148                         "LogonSamLogonEx failed");
149         } else {
150                 torture_comment(tctx,
151                                 "Skip auth_level[%u] Testing LogonSamLogonEx with name %s using %s and validation_level: %d\n",
152                                 auth_level, ninfo.identity_info.account_name.string, crypto_alg,
153                                 r.in.validation_level);
154                 r.out.result = NT_STATUS_INVALID_INFO_CLASS;
155         }
156
157         if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_INVALID_INFO_CLASS)) {
158                 can_do_validation_6 = false;
159         } else {
160                 torture_assert_ntstatus_ok(tctx, r.out.result,
161                         "LogonSamLogonEx failed");
162
163                 key = r.out.validation->sam6->base.key;
164                 LMSessKey = r.out.validation->sam6->base.LMSessKey;
165
166                 DEBUG(1,("unencrypted session keys from validation_level 6:\n"));
167                 dump_data(1, r.out.validation->sam6->base.key.key, 16);
168                 dump_data(1, r.out.validation->sam6->base.LMSessKey.key, 8);
169         }
170
171         for (i=0; i < ARRAY_SIZE(validation_levels); i++) {
172
173                 r.in.validation_level = validation_levels[i];
174
175                 torture_comment(tctx,
176                         "Testing LogonSamLogonEx with name %s using %s and validation_level: %d\n",
177                         ninfo.identity_info.account_name.string, crypto_alg,
178                         r.in.validation_level);
179
180                 torture_assert_ntstatus_ok(tctx,
181                         dcerpc_netr_LogonSamLogonEx_r(b, tctx, &r),
182                         "LogonSamLogonEx failed");
183                 torture_assert_ntstatus_ok(tctx, r.out.result,
184                         "LogonSamLogonEx failed");
185
186                 if (creds == NULL) {
187                         /* when this test is called without creds no point in
188                          * testing the session keys */
189                         continue;
190                 }
191
192                 switch (validation_levels[i]) {
193                 case 2:
194                         base = &r.out.validation->sam2->base;
195                         break;
196                 case 3:
197                         base = &r.out.validation->sam3->base;
198                         break;
199                 default:
200                         break;
201                 }
202
203                 DEBUG(1,("encrypted keys validation_level %d:\n",
204                         validation_levels[i]));
205                 dump_data(1, base->key.key, 16);
206                 dump_data(1, base->LMSessKey.key, 8);
207
208                 if (creds->negotiate_flags & NETLOGON_NEG_SUPPORTS_AES) {
209                         netlogon_creds_aes_decrypt(creds, base->key.key, 16);
210                         netlogon_creds_aes_decrypt(creds, base->LMSessKey.key, 8);
211                 } else if (creds->negotiate_flags & NETLOGON_NEG_ARCFOUR) {
212                         netlogon_creds_arcfour_crypt(creds, base->key.key, 16);
213                         netlogon_creds_arcfour_crypt(creds, base->LMSessKey.key, 8);
214                 }
215
216                 DEBUG(1,("decryped keys validation_level %d\n",
217                         validation_levels[i]));
218
219                 dump_data(1, base->key.key, 16);
220                 dump_data(1, base->LMSessKey.key, 8);
221
222                 if (!can_do_validation_6) {
223                         /* we cant compare against unencrypted keys */
224                         continue;
225                 }
226
227                 torture_assert_mem_equal(tctx,
228                                          base->key.key,
229                                          key.key,
230                                          16,
231                                          "unexpected user session key\n");
232                 torture_assert_mem_equal(tctx,
233                                          base->LMSessKey.key,
234                                          LMSessKey.key,
235                                          8,
236                                          "unexpected LM session key\n");
237         }
238
239         return true;
240 }
241
242 /*
243   do some samr ops using the schannel connection
244  */
245 static bool test_samr_ops(struct torture_context *tctx,
246                           struct dcerpc_binding_handle *b)
247 {
248         struct samr_GetDomPwInfo r;
249         struct samr_PwInfo info;
250         struct samr_Connect connect_r;
251         struct samr_OpenDomain opendom;
252         int i;
253         struct lsa_String name;
254         struct policy_handle handle;
255         struct policy_handle domain_handle;
256
257         name.string = lpcfg_workgroup(tctx->lp_ctx);
258         r.in.domain_name = &name;
259         r.out.info = &info;
260
261         connect_r.in.system_name = 0;
262         connect_r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
263         connect_r.out.connect_handle = &handle;
264
265         torture_comment(tctx, "Testing Connect and OpenDomain on BUILTIN\n");
266
267         torture_assert_ntstatus_ok(tctx, dcerpc_samr_Connect_r(b, tctx, &connect_r),
268                 "Connect failed");
269         if (!NT_STATUS_IS_OK(connect_r.out.result)) {
270                 if (NT_STATUS_EQUAL(connect_r.out.result, NT_STATUS_ACCESS_DENIED)) {
271                         torture_comment(tctx, "Connect failed (expected, schannel mapped to anonymous): %s\n",
272                                nt_errstr(connect_r.out.result));
273                 } else {
274                         torture_comment(tctx, "Connect failed - %s\n", nt_errstr(connect_r.out.result));
275                         return false;
276                 }
277         } else {
278                 opendom.in.connect_handle = &handle;
279                 opendom.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
280                 opendom.in.sid = dom_sid_parse_talloc(tctx, "S-1-5-32");
281                 opendom.out.domain_handle = &domain_handle;
282
283                 torture_assert_ntstatus_ok(tctx, dcerpc_samr_OpenDomain_r(b, tctx, &opendom),
284                         "OpenDomain failed");
285                 if (!NT_STATUS_IS_OK(opendom.out.result)) {
286                         torture_comment(tctx, "OpenDomain failed - %s\n", nt_errstr(opendom.out.result));
287                         return false;
288                 }
289         }
290
291         torture_comment(tctx, "Testing GetDomPwInfo with name %s\n", r.in.domain_name->string);
292
293         /* do several ops to test credential chaining */
294         for (i=0;i<5;i++) {
295                 torture_assert_ntstatus_ok(tctx, dcerpc_samr_GetDomPwInfo_r(b, tctx, &r),
296                         "GetDomPwInfo failed");
297                 if (!NT_STATUS_IS_OK(r.out.result)) {
298                         if (!NT_STATUS_EQUAL(r.out.result, NT_STATUS_ACCESS_DENIED)) {
299                                 torture_comment(tctx, "GetDomPwInfo op %d failed - %s\n", i, nt_errstr(r.out.result));
300                                 return false;
301                         }
302                 }
303         }
304
305         return true;
306 }
307
308
309 /*
310   do some lsa ops using the schannel connection
311  */
312 static bool test_lsa_ops(struct torture_context *tctx, struct dcerpc_pipe *p)
313 {
314         struct lsa_GetUserName r;
315         bool ret = true;
316         struct lsa_String *account_name_p = NULL;
317         struct lsa_String *authority_name_p = NULL;
318         struct dcerpc_binding_handle *b = p->binding_handle;
319
320         torture_comment(tctx, "\nTesting GetUserName\n");
321
322         r.in.system_name = "\\";
323         r.in.account_name = &account_name_p;
324         r.in.authority_name = &authority_name_p;
325         r.out.account_name = &account_name_p;
326
327         /* do several ops to test credential chaining and various operations */
328         torture_assert_ntstatus_ok(tctx, dcerpc_lsa_GetUserName_r(b, tctx, &r),
329                 "lsa_GetUserName failed");
330
331         authority_name_p = *r.out.authority_name;
332
333         if (!NT_STATUS_IS_OK(r.out.result)) {
334                 torture_comment(tctx, "GetUserName failed - %s\n", nt_errstr(r.out.result));
335                 return false;
336         } else {
337                 if (!r.out.account_name) {
338                         return false;
339                 }
340
341                 if (strcmp(account_name_p->string, "ANONYMOUS LOGON") != 0) {
342                         torture_comment(tctx, "GetUserName returned wrong user: %s, expected %s\n",
343                                account_name_p->string, "ANONYMOUS LOGON");
344                         /* FIXME: gd */
345                         if (!torture_setting_bool(tctx, "samba3", false)) {
346                                 return false;
347                         }
348                 }
349                 if (!authority_name_p || !authority_name_p->string) {
350                         return false;
351                 }
352
353                 if (strcmp(authority_name_p->string, "NT AUTHORITY") != 0) {
354                         torture_comment(tctx, "GetUserName returned wrong user: %s, expected %s\n",
355                                authority_name_p->string, "NT AUTHORITY");
356                         /* FIXME: gd */
357                         if (!torture_setting_bool(tctx, "samba3", false)) {
358                                 return false;
359                         }
360                 }
361         }
362
363         return ret;
364 }
365
366
367 /*
368   test a schannel connection with the given flags
369  */
370 static bool test_schannel(struct torture_context *tctx,
371                           uint16_t acct_flags, uint32_t dcerpc_flags,
372                           int i)
373 {
374         struct test_join *join_ctx;
375         NTSTATUS status;
376         const char *binding = torture_setting_string(tctx, "binding", NULL);
377         struct dcerpc_binding *b;
378         struct dcerpc_pipe *p = NULL;
379         struct dcerpc_pipe *p_netlogon = NULL;
380         struct dcerpc_pipe *p_netlogon2 = NULL;
381         struct dcerpc_pipe *p_netlogon3 = NULL;
382         struct dcerpc_pipe *p_samr2 = NULL;
383         struct dcerpc_pipe *p_lsa = NULL;
384         struct netlogon_creds_CredentialState *creds;
385         struct cli_credentials *credentials;
386         enum dcerpc_transport_t transport;
387
388         join_ctx = torture_join_domain(tctx,
389                                        talloc_asprintf(tctx, "%s%d", TEST_MACHINE_NAME, i),
390                                        acct_flags, &credentials);
391         torture_assert(tctx, join_ctx != NULL, "Failed to join domain");
392
393         status = dcerpc_parse_binding(tctx, binding, &b);
394         torture_assert_ntstatus_ok(tctx, status, "Bad binding string");
395
396         status = dcerpc_binding_set_flags(b, dcerpc_flags, DCERPC_AUTH_OPTIONS);
397         torture_assert_ntstatus_ok(tctx, status, "set flags");
398
399         status = dcerpc_pipe_connect_b(tctx, &p, b, &ndr_table_samr,
400                                        credentials, tctx->ev, tctx->lp_ctx);
401         torture_assert_ntstatus_ok(tctx, status,
402                 "Failed to connect to samr with schannel");
403
404         torture_assert(tctx, test_samr_ops(tctx, p->binding_handle),
405                        "Failed to process schannel secured SAMR ops");
406
407         /* Also test that when we connect to the netlogon pipe, that
408          * the credentials we setup on the first pipe are valid for
409          * the second */
410
411         /* Swap the binding details from SAMR to NETLOGON */
412         status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, tctx->ev, tctx->lp_ctx);
413         torture_assert_ntstatus_ok(tctx, status, "epm map");
414
415         status = dcerpc_binding_set_flags(b, dcerpc_flags, DCERPC_AUTH_OPTIONS);
416         torture_assert_ntstatus_ok(tctx, status, "set flags");
417
418         status = dcerpc_secondary_auth_connection(p, b, &ndr_table_netlogon,
419                                                   credentials, tctx->lp_ctx,
420                                                   tctx, &p_netlogon);
421         torture_assert_ntstatus_ok(tctx, status, "Failed to create secondary connection");
422
423         creds = cli_credentials_get_netlogon_creds(credentials);
424         torture_assert(tctx, (creds != NULL), "schannel creds");
425
426         /* checks the capabilities */
427         torture_assert(tctx, test_netlogon_capabilities(p_netlogon, tctx, credentials, creds),
428                        "Failed to process schannel secured capability ops (on fresh connection)");
429
430         /* do a couple of logins */
431         torture_assert(tctx, test_netlogon_ops(p_netlogon, tctx, credentials, creds),
432                 "Failed to process schannel secured NETLOGON ops");
433
434         torture_assert(tctx, test_netlogon_ex_ops(p_netlogon, tctx, credentials, creds),
435                 "Failed to process schannel secured NETLOGON EX ops");
436
437         /* we *MUST* use ncacn_np for openpolicy etc. */
438         transport = dcerpc_binding_get_transport(b);
439         status = dcerpc_binding_set_transport(b, NCACN_NP);
440         torture_assert_ntstatus_ok(tctx, status, "set transport");
441
442         /* Swap the binding details from SAMR to LSARPC */
443         status = dcerpc_epm_map_binding(tctx, b, &ndr_table_lsarpc, tctx->ev, tctx->lp_ctx);
444         torture_assert_ntstatus_ok(tctx, status, "epm map");
445
446         torture_assert_ntstatus_ok(tctx,
447                 dcerpc_pipe_connect_b(tctx, &p_lsa, b, &ndr_table_lsarpc,
448                                       credentials, tctx->ev, tctx->lp_ctx),
449                 "failed to connect lsarpc with schannel");
450
451         torture_assert(tctx, test_lsa_ops(tctx, p_lsa),
452                 "Failed to process schannel secured LSA ops");
453
454         talloc_free(p_lsa);
455         p_lsa = NULL;
456
457         /* we *MUST* use ncacn_ip_tcp for lookupsids3/lookupnames4 */
458         status = dcerpc_binding_set_transport(b, NCACN_IP_TCP);
459         torture_assert_ntstatus_ok(tctx, status, "set transport");
460
461         torture_assert_ntstatus_ok(tctx,
462                 dcerpc_epm_map_binding(tctx, b, &ndr_table_lsarpc, tctx->ev, tctx->lp_ctx),
463                 "failed to call epm map");
464
465         torture_assert_ntstatus_ok(tctx,
466                 dcerpc_pipe_connect_b(tctx, &p_lsa, b, &ndr_table_lsarpc,
467                                       credentials, tctx->ev, tctx->lp_ctx),
468                 "failed to connect lsarpc with schannel");
469
470         torture_assert(tctx,
471                 test_many_LookupSids(p_lsa, tctx, NULL),
472                 "LsaLookupSids3 failed!\n");
473
474         status = dcerpc_binding_set_transport(b, transport);
475         torture_assert_ntstatus_ok(tctx, status, "set transport");
476
477
478         /* Drop the socket, we want to start from scratch */
479         talloc_free(p);
480         p = NULL;
481
482         /* Now see what we are still allowed to do */
483
484         status = dcerpc_parse_binding(tctx, binding, &b);
485         torture_assert_ntstatus_ok(tctx, status, "Bad binding string");
486
487         status = dcerpc_binding_set_flags(b, dcerpc_flags, DCERPC_AUTH_OPTIONS);
488         torture_assert_ntstatus_ok(tctx, status, "set flags");
489
490         status = dcerpc_pipe_connect_b(tctx, &p_samr2, b, &ndr_table_samr,
491                                        credentials, tctx->ev, tctx->lp_ctx);
492         torture_assert_ntstatus_ok(tctx, status,
493                 "Failed to connect with schannel");
494
495         /* do a some SAMR operations.  We have *not* done a new serverauthenticate */
496         torture_assert (tctx, test_samr_ops(tctx, p_samr2->binding_handle),
497                         "Failed to process schannel secured SAMR ops (on fresh connection)");
498
499         /* Swap the binding details from SAMR to NETLOGON */
500         status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, tctx->ev, tctx->lp_ctx);
501         torture_assert_ntstatus_ok(tctx, status, "epm");
502
503         status = dcerpc_binding_set_flags(b, dcerpc_flags, DCERPC_AUTH_OPTIONS);
504         torture_assert_ntstatus_ok(tctx, status, "set flags");
505
506         status = dcerpc_secondary_auth_connection(p_samr2, b, &ndr_table_netlogon,
507                                                   credentials, tctx->lp_ctx,
508                                                   tctx, &p_netlogon2);
509         torture_assert_ntstatus_ok(tctx, status, "Failed to create secondary connection");
510
511         /* checks the capabilities */
512         torture_assert(tctx, test_netlogon_capabilities(p_netlogon2, tctx, credentials, creds),
513                        "Failed to process schannel secured capability ops (on fresh connection)");
514
515         /* Try the schannel-only SamLogonEx operation */
516         torture_assert(tctx, test_netlogon_ex_ops(p_netlogon2, tctx, credentials, creds),
517                        "Failed to process schannel secured NETLOGON EX ops (on fresh connection)");
518
519
520         /* And the more traditional style, proving that the
521          * credentials chaining state is fully present */
522         torture_assert(tctx, test_netlogon_ops(p_netlogon2, tctx, credentials, creds),
523                              "Failed to process schannel secured NETLOGON ops (on fresh connection)");
524
525         /* Drop the socket, we want to start from scratch (again) */
526         talloc_free(p_samr2);
527
528         /* We don't want schannel for this test */
529         status = dcerpc_binding_set_flags(b, 0, DCERPC_AUTH_OPTIONS);
530         torture_assert_ntstatus_ok(tctx, status, "set flags");
531
532         status = dcerpc_pipe_connect_b(tctx, &p_netlogon3, b, &ndr_table_netlogon,
533                                        credentials, tctx->ev, tctx->lp_ctx);
534         torture_assert_ntstatus_ok(tctx, status, "Failed to connect without schannel");
535
536         torture_assert(tctx, !test_netlogon_ex_ops(p_netlogon3, tctx, credentials, creds),
537                         "Processed NOT schannel secured NETLOGON EX ops without SCHANNEL (unsafe)");
538
539         /* Required because the previous call will mark the current context as having failed */
540         tctx->last_result = TORTURE_OK;
541         tctx->last_reason = NULL;
542
543         torture_assert(tctx, test_netlogon_ops(p_netlogon3, tctx, credentials, creds),
544                         "Failed to processed NOT schannel secured NETLOGON ops without new ServerAuth");
545
546         torture_leave_domain(tctx, join_ctx);
547         return true;
548 }
549
550 /*
551  * Purpose of this test is to demonstrate that a netlogon server carefully deals
552  * with anonymous attempts to set passwords, in particular when the server
553  * enforces the use of schannel. This test makes most sense to be run in an
554  * environment where the netlogon server enforces use of schannel.
555  */
556
557 static bool test_schannel_anonymous_setPassword(struct torture_context *tctx,
558                                                 uint32_t dcerpc_flags,
559                                                 bool use2)
560 {
561         NTSTATUS status, result;
562         const char *binding = torture_setting_string(tctx, "binding", NULL);
563         struct dcerpc_binding *b;
564         struct dcerpc_pipe *p = NULL;
565         struct cli_credentials *credentials;
566         bool ok = true;
567
568         credentials = cli_credentials_init(NULL);
569         torture_assert(tctx, credentials != NULL, "Bad credentials");
570         cli_credentials_set_anonymous(credentials);
571
572         status = dcerpc_parse_binding(tctx, binding, &b);
573         torture_assert_ntstatus_ok(tctx, status, "Bad binding string");
574
575         status = dcerpc_binding_set_flags(b, dcerpc_flags, DCERPC_AUTH_OPTIONS);
576         torture_assert_ntstatus_ok(tctx, status, "set flags");
577
578         status = dcerpc_pipe_connect_b(tctx,
579                                        &p,
580                                        b,
581                                        &ndr_table_netlogon,
582                                        credentials,
583                                        tctx->ev,
584                                        tctx->lp_ctx);
585         torture_assert_ntstatus_ok(tctx, status, "Failed to connect without schannel");
586
587         if (use2) {
588                 struct netr_ServerPasswordSet2 r = {};
589                 struct netr_Authenticator credential = {};
590                 struct netr_Authenticator return_authenticator = {};
591                 struct netr_CryptPassword new_password = {};
592
593                 r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
594                 r.in.account_name = talloc_asprintf(tctx, "%s$", TEST_MACHINE_NAME);
595                 r.in.secure_channel_type = 0;
596                 r.in.computer_name = TEST_MACHINE_NAME;
597                 r.in.credential = &credential;
598                 r.in.new_password = &new_password;
599                 r.out.return_authenticator = &return_authenticator;
600
601                 status = dcerpc_netr_ServerPasswordSet2_r(p->binding_handle, tctx, &r);
602                 result = r.out.result;
603         } else {
604                 struct netr_ServerPasswordSet r = {};
605                 struct netr_Authenticator credential = {};
606                 struct netr_Authenticator return_authenticator = {};
607                 struct samr_Password new_password = {};
608
609                 r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
610                 r.in.account_name = talloc_asprintf(tctx, "%s$", TEST_MACHINE_NAME);
611                 r.in.secure_channel_type = 0;
612                 r.in.computer_name = TEST_MACHINE_NAME;
613                 r.in.credential = &credential;
614                 r.in.new_password = &new_password;
615                 r.out.return_authenticator = &return_authenticator;
616
617                 status = dcerpc_netr_ServerPasswordSet_r(p->binding_handle, tctx, &r);
618                 result = r.out.result;
619         }
620
621         torture_assert_ntstatus_ok(tctx, status, "ServerPasswordSet failed");
622
623         if (NT_STATUS_IS_OK(result)) {
624                 torture_fail(tctx, "unexpectedly received NT_STATUS_OK");
625         }
626
627         return ok;
628 }
629
630
631 /*
632   a schannel test suite
633  */
634 bool torture_rpc_schannel(struct torture_context *torture)
635 {
636         bool ret = true;
637         struct {
638                 uint16_t acct_flags;
639                 uint32_t dcerpc_flags;
640         } tests[] = {
641                 { ACB_WSTRUST,   DCERPC_SCHANNEL | DCERPC_SIGN | DCERPC_SCHANNEL_AUTO},
642                 { ACB_WSTRUST,   DCERPC_SCHANNEL | DCERPC_SEAL | DCERPC_SCHANNEL_AUTO},
643                 { ACB_WSTRUST,   DCERPC_SCHANNEL | DCERPC_SIGN | DCERPC_SCHANNEL_128},
644                 { ACB_WSTRUST,   DCERPC_SCHANNEL | DCERPC_SEAL | DCERPC_SCHANNEL_128 },
645                 { ACB_WSTRUST,   DCERPC_SCHANNEL | DCERPC_SIGN | DCERPC_SCHANNEL_AES},
646                 { ACB_WSTRUST,   DCERPC_SCHANNEL | DCERPC_SEAL | DCERPC_SCHANNEL_AES },
647                 { ACB_SVRTRUST,  DCERPC_SCHANNEL | DCERPC_SIGN | DCERPC_SCHANNEL_AUTO},
648                 { ACB_SVRTRUST,  DCERPC_SCHANNEL | DCERPC_SEAL | DCERPC_SCHANNEL_AUTO},
649                 { ACB_SVRTRUST,  DCERPC_SCHANNEL | DCERPC_SIGN | DCERPC_SCHANNEL_128 },
650                 { ACB_SVRTRUST,  DCERPC_SCHANNEL | DCERPC_SEAL | DCERPC_SCHANNEL_128 },
651                 { ACB_SVRTRUST,  DCERPC_SCHANNEL | DCERPC_SIGN | DCERPC_SCHANNEL_AES },
652                 { ACB_SVRTRUST,  DCERPC_SCHANNEL | DCERPC_SEAL | DCERPC_SCHANNEL_AES }
653         };
654         int i;
655
656         for (i=0;i<ARRAY_SIZE(tests);i++) {
657                 torture_comment(torture, "Testing with acct_flags=0x%x dcerpc_flags=0x%x \n",
658                        tests[i].acct_flags, tests[i].dcerpc_flags);
659
660                 if (!test_schannel(torture,
661                                    tests[i].acct_flags, tests[i].dcerpc_flags,
662                                    i)) {
663                         torture_comment(torture, "Failed with acct_flags=0x%x dcerpc_flags=0x%x \n",
664                                tests[i].acct_flags, tests[i].dcerpc_flags);
665                         ret = false;
666                 }
667         }
668
669         return ret;
670 }
671
672 bool torture_rpc_schannel_anon_setpw(struct torture_context *torture)
673 {
674         bool ret = true;
675         bool ok;
676         uint32_t dcerpc_flags = DCERPC_SCHANNEL | DCERPC_SIGN | DCERPC_SCHANNEL_AUTO;
677
678         ok = test_schannel_anonymous_setPassword(torture,
679                                                  dcerpc_flags,
680                                                  true);
681         if (!ok) {
682                 torture_comment(torture,
683                                 "Failed with dcerpc_flags=0x%x\n",
684                                 dcerpc_flags);
685                 ret = false;
686         }
687
688         ok = test_schannel_anonymous_setPassword(torture,
689                                                  dcerpc_flags,
690                                                  false);
691         if (!ok) {
692                 torture_comment(torture,
693                                 "Failed with dcerpc_flags=0x%x\n",
694                                 dcerpc_flags);
695                 ret = false;
696         }
697
698         return ret;
699 }
700
701 /*
702   test two schannel connections
703  */
704 bool torture_rpc_schannel2(struct torture_context *torture)
705 {
706         struct test_join *join_ctx;
707         NTSTATUS status;
708         const char *binding = torture_setting_string(torture, "binding", NULL);
709         struct dcerpc_binding *b;
710         struct dcerpc_pipe *p1 = NULL, *p2 = NULL;
711         struct cli_credentials *credentials1, *credentials2;
712         uint32_t dcerpc_flags = DCERPC_SCHANNEL | DCERPC_SCHANNEL_AUTO | DCERPC_SIGN;
713
714         join_ctx = torture_join_domain(torture, talloc_asprintf(torture, "%s2", TEST_MACHINE_NAME),
715                                        ACB_WSTRUST, &credentials1);
716         torture_assert(torture, join_ctx != NULL,
717                        "Failed to join domain with acct_flags=ACB_WSTRUST");
718
719         credentials2 = cli_credentials_shallow_copy(torture, credentials1);
720         cli_credentials_set_netlogon_creds(credentials1, NULL);
721         cli_credentials_set_netlogon_creds(credentials2, NULL);
722
723         status = dcerpc_parse_binding(torture, binding, &b);
724         torture_assert_ntstatus_ok(torture, status, "Bad binding string");
725
726         status = dcerpc_binding_set_flags(b, dcerpc_flags, DCERPC_AUTH_OPTIONS);
727         torture_assert_ntstatus_ok(torture, status, "set flags");
728
729         torture_comment(torture, "Opening first connection\n");
730         status = dcerpc_pipe_connect_b(torture, &p1, b, &ndr_table_netlogon,
731                                        credentials1, torture->ev, torture->lp_ctx);
732         torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
733
734         torture_comment(torture, "Opening second connection\n");
735         status = dcerpc_pipe_connect_b(torture, &p2, b, &ndr_table_netlogon,
736                                        credentials2, torture->ev, torture->lp_ctx);
737         torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
738
739         cli_credentials_set_netlogon_creds(credentials1, NULL);
740         cli_credentials_set_netlogon_creds(credentials2, NULL);
741
742         torture_comment(torture, "Testing logon on pipe1\n");
743         if (!test_netlogon_ex_ops(p1, torture, credentials1, NULL))
744                 return false;
745
746         torture_comment(torture, "Testing logon on pipe2\n");
747         if (!test_netlogon_ex_ops(p2, torture, credentials2, NULL))
748                 return false;
749
750         torture_comment(torture, "Again on pipe1\n");
751         if (!test_netlogon_ex_ops(p1, torture, credentials1, NULL))
752                 return false;
753
754         torture_comment(torture, "Again on pipe2\n");
755         if (!test_netlogon_ex_ops(p2, torture, credentials2, NULL))
756                 return false;
757
758         torture_leave_domain(torture, join_ctx);
759         return true;
760 }
761
762 struct torture_schannel_bench;
763
764 struct torture_schannel_bench_conn {
765         struct torture_schannel_bench *s;
766         int index;
767         struct cli_credentials *wks_creds;
768         struct dcerpc_pipe *pipe;
769         struct netr_LogonSamLogonEx r;
770         struct netr_NetworkInfo ninfo;
771         TALLOC_CTX *tmp;
772         uint64_t total;
773         uint32_t count;
774 };
775
776 struct torture_schannel_bench {
777         struct torture_context *tctx;
778         bool progress;
779         int timelimit;
780         int nprocs;
781         int nconns;
782         struct torture_schannel_bench_conn *conns;
783         struct test_join *join_ctx1;
784         struct cli_credentials *wks_creds1;
785         struct test_join *join_ctx2;
786         struct cli_credentials *wks_creds2;
787         struct cli_credentials *user1_creds;
788         struct cli_credentials *user2_creds;
789         struct dcerpc_binding *b;
790         NTSTATUS error;
791         uint64_t total;
792         uint32_t count;
793         bool stopped;
794 };
795
796 #if 0
797 static void torture_schannel_bench_connected(struct composite_context *c)
798 {
799         struct torture_schannel_bench_conn *conn =
800                 (struct torture_schannel_bench_conn *)c->async.private_data;
801         struct torture_schannel_bench *s = talloc_get_type(conn->s,
802                                            struct torture_schannel_bench);
803
804         s->error = dcerpc_pipe_connect_b_recv(c, s->conns, &conn->pipe);
805         torture_comment(s->tctx, "conn[%u]: %s\n", conn->index, nt_errstr(s->error));
806         if (NT_STATUS_IS_OK(s->error)) {
807                 s->nconns++;
808         }
809 }
810 #endif
811
812 static void torture_schannel_bench_recv(struct tevent_req *subreq);
813
814 static bool torture_schannel_bench_start(struct torture_schannel_bench_conn *conn)
815 {
816         struct torture_schannel_bench *s = conn->s;
817         NTSTATUS status;
818         DATA_BLOB names_blob, chal, lm_resp, nt_resp;
819         int flags = CLI_CRED_NTLM_AUTH;
820         struct tevent_req *subreq;
821         struct cli_credentials *user_creds;
822
823         if (conn->total % 2) {
824                 user_creds = s->user1_creds;
825         } else {
826                 user_creds = s->user2_creds;
827         }
828
829         if (lpcfg_client_lanman_auth(s->tctx->lp_ctx)) {
830                 flags |= CLI_CRED_LANMAN_AUTH;
831         }
832
833         if (lpcfg_client_ntlmv2_auth(s->tctx->lp_ctx)) {
834                 flags |= CLI_CRED_NTLMv2_AUTH;
835         }
836
837         talloc_free(conn->tmp);
838         conn->tmp = talloc_new(s);
839         ZERO_STRUCT(conn->ninfo);
840         ZERO_STRUCT(conn->r);
841
842         cli_credentials_get_ntlm_username_domain(user_creds, conn->tmp,
843                                                  &conn->ninfo.identity_info.account_name.string,
844                                                  &conn->ninfo.identity_info.domain_name.string);
845
846         generate_random_buffer(conn->ninfo.challenge,
847                                sizeof(conn->ninfo.challenge));
848         chal = data_blob_const(conn->ninfo.challenge,
849                                sizeof(conn->ninfo.challenge));
850
851         names_blob = NTLMv2_generate_names_blob(conn->tmp,
852                                                 cli_credentials_get_workstation(conn->wks_creds),
853                                                 cli_credentials_get_domain(conn->wks_creds));
854
855         status = cli_credentials_get_ntlm_response(user_creds, conn->tmp,
856                                                    &flags,
857                                                    chal,
858                                                    NULL, /* server_timestamp */
859                                                    names_blob,
860                                                    &lm_resp, &nt_resp,
861                                                    NULL, NULL);
862         torture_assert_ntstatus_ok(s->tctx, status,
863                                    "cli_credentials_get_ntlm_response failed");
864
865         conn->ninfo.lm.data = lm_resp.data;
866         conn->ninfo.lm.length = lm_resp.length;
867
868         conn->ninfo.nt.data = nt_resp.data;
869         conn->ninfo.nt.length = nt_resp.length;
870
871         conn->ninfo.identity_info.parameter_control = 0;
872         conn->ninfo.identity_info.logon_id_low = 0;
873         conn->ninfo.identity_info.logon_id_high = 0;
874         conn->ninfo.identity_info.workstation.string = cli_credentials_get_workstation(conn->wks_creds);
875
876         conn->r.in.server_name = talloc_asprintf(conn->tmp, "\\\\%s", dcerpc_server_name(conn->pipe));
877         conn->r.in.computer_name = cli_credentials_get_workstation(conn->wks_creds);
878         conn->r.in.logon_level = NetlogonNetworkInformation;
879         conn->r.in.logon = talloc(conn->tmp, union netr_LogonLevel);
880         conn->r.in.logon->network = &conn->ninfo;
881         conn->r.in.flags = talloc(conn->tmp, uint32_t);
882         conn->r.in.validation_level = 2;
883         conn->r.out.validation = talloc(conn->tmp, union netr_Validation);
884         conn->r.out.authoritative = talloc(conn->tmp, uint8_t);
885         conn->r.out.flags = conn->r.in.flags;
886
887         subreq = dcerpc_netr_LogonSamLogonEx_r_send(s, s->tctx->ev,
888                                                     conn->pipe->binding_handle,
889                                                     &conn->r);
890         torture_assert(s->tctx, subreq, "Failed to setup LogonSamLogonEx request");
891
892         tevent_req_set_callback(subreq, torture_schannel_bench_recv, conn);
893
894         return true;
895 }
896
897 static void torture_schannel_bench_recv(struct tevent_req *subreq)
898 {
899         bool ret;
900         struct torture_schannel_bench_conn *conn =
901                 (struct torture_schannel_bench_conn *)tevent_req_callback_data_void(subreq);
902         struct torture_schannel_bench *s = talloc_get_type(conn->s,
903                                            struct torture_schannel_bench);
904
905         s->error = dcerpc_netr_LogonSamLogonEx_r_recv(subreq, subreq);
906         TALLOC_FREE(subreq);
907         if (!NT_STATUS_IS_OK(s->error)) {
908                 return;
909         }
910
911         conn->total++;
912         conn->count++;
913
914         if (s->stopped) {
915                 return;
916         }
917
918         ret = torture_schannel_bench_start(conn);
919         if (!ret) {
920                 s->error = NT_STATUS_INTERNAL_ERROR;
921         }
922 }
923
924 /*
925   test multiple schannel connection in parallel
926  */
927 bool torture_rpc_schannel_bench1(struct torture_context *torture)
928 {
929         bool ret = true;
930         NTSTATUS status;
931         const char *binding = torture_setting_string(torture, "binding", NULL);
932         struct torture_schannel_bench *s;
933         struct timeval start;
934         struct timeval end;
935         int i;
936         const char *tmp;
937
938         s = talloc_zero(torture, struct torture_schannel_bench);
939         s->tctx = torture;
940         s->progress = torture_setting_bool(torture, "progress", true);
941         s->timelimit = torture_setting_int(torture, "timelimit", 10);
942         s->nprocs = torture_setting_int(torture, "nprocs", 4);
943         s->conns = talloc_zero_array(s, struct torture_schannel_bench_conn, s->nprocs);
944
945         s->user1_creds = cli_credentials_shallow_copy(s, cmdline_credentials);
946         tmp = torture_setting_string(s->tctx, "extra_user1", NULL);
947         if (tmp) {
948                 cli_credentials_parse_string(s->user1_creds, tmp, CRED_SPECIFIED);
949         }
950         s->user2_creds = cli_credentials_shallow_copy(s, cmdline_credentials);
951         tmp = torture_setting_string(s->tctx, "extra_user2", NULL);
952         if (tmp) {
953                 cli_credentials_parse_string(s->user1_creds, tmp, CRED_SPECIFIED);
954         }
955
956         s->join_ctx1 = torture_join_domain(s->tctx, talloc_asprintf(s, "%sb", TEST_MACHINE_NAME),
957                                            ACB_WSTRUST, &s->wks_creds1);
958         torture_assert(torture, s->join_ctx1 != NULL,
959                        "Failed to join domain with acct_flags=ACB_WSTRUST");
960         s->join_ctx2 = torture_join_domain(s->tctx, talloc_asprintf(s, "%sc", TEST_MACHINE_NAME),
961                                            ACB_WSTRUST, &s->wks_creds2);
962         torture_assert(torture, s->join_ctx2 != NULL,
963                        "Failed to join domain with acct_flags=ACB_WSTRUST");
964
965         cli_credentials_set_kerberos_state(s->wks_creds1, CRED_DONT_USE_KERBEROS);
966         cli_credentials_set_kerberos_state(s->wks_creds2, CRED_DONT_USE_KERBEROS);
967
968         for (i=0; i < s->nprocs; i++) {
969                 struct cli_credentials *wks = s->wks_creds1;
970
971                 if ((i % 2) && (torture_setting_bool(torture, "multijoin", false))) {
972                         wks = s->wks_creds2;
973                 }
974
975                 s->conns[i].s = s;
976                 s->conns[i].index = i;
977                 s->conns[i].wks_creds = cli_credentials_shallow_copy(s->conns, wks);
978                 cli_credentials_set_netlogon_creds(s->conns[i].wks_creds, NULL);
979         }
980
981         status = dcerpc_parse_binding(s, binding, &s->b);
982         torture_assert_ntstatus_ok(torture, status, "Bad binding string");
983
984         status = dcerpc_binding_set_flags(s->b, DCERPC_SCHANNEL | DCERPC_SIGN,
985                                           DCERPC_AUTH_OPTIONS);
986         torture_assert_ntstatus_ok(torture, status, "set flags");
987
988         torture_comment(torture, "Opening %d connections in parallel\n", s->nprocs);
989         for (i=0; i < s->nprocs; i++) {
990 #if 1
991                 s->error = dcerpc_pipe_connect_b(s->conns, &s->conns[i].pipe, s->b,
992                                                  &ndr_table_netlogon,
993                                                  s->conns[i].wks_creds,
994                                                  torture->ev, torture->lp_ctx);
995                 torture_assert_ntstatus_ok(torture, s->error, "Failed to connect with schannel");
996 #else
997                 /*
998                  * This path doesn't work against windows,
999                  * because of windows drops the connections
1000                  * which haven't reached a session setup yet
1001                  *
1002                  * The same as the reset on zero vc stuff.
1003                  */
1004                 struct composite_context *c;
1005                 c = dcerpc_pipe_connect_b_send(s->conns, s->b,
1006                                                &ndr_table_netlogon,
1007                                                s->conns[i].wks_creds,
1008                                                torture->ev,
1009                                                torture->lp_ctx);
1010                 torture_assert(torture, c != NULL, "Failed to setup connect");
1011                 c->async.fn = torture_schannel_bench_connected;
1012                 c->async.private_data = &s->conns[i];
1013         }
1014
1015         while (NT_STATUS_IS_OK(s->error) && s->nprocs != s->nconns) {
1016                 int ev_ret = tevent_loop_once(torture->ev);
1017                 torture_assert(torture, ev_ret == 0, "tevent_loop_once failed");
1018 #endif
1019         }
1020         torture_assert_ntstatus_ok(torture, s->error, "Failed establish a connect");
1021
1022         /*
1023          * Change the workstation password after establishing the netlogon
1024          * schannel connections to prove that existing connections are not
1025          * affected by a wks pwchange.
1026          */
1027
1028         {
1029                 struct netr_ServerPasswordSet pwset;
1030                 char *password = generate_random_password(s->join_ctx1, 8, 255);
1031                 struct netlogon_creds_CredentialState *creds_state;
1032                 struct dcerpc_pipe *net_pipe;
1033                 struct netr_Authenticator credential, return_authenticator;
1034                 struct samr_Password new_password;
1035
1036                 status = dcerpc_pipe_connect_b(s, &net_pipe, s->b,
1037                                                &ndr_table_netlogon,
1038                                                s->wks_creds1,
1039                                                torture->ev, torture->lp_ctx);
1040
1041                 torture_assert_ntstatus_ok(torture, status,
1042                                            "dcerpc_pipe_connect_b failed");
1043
1044                 pwset.in.server_name = talloc_asprintf(
1045                         net_pipe, "\\\\%s", dcerpc_server_name(net_pipe));
1046                 pwset.in.computer_name =
1047                         cli_credentials_get_workstation(s->wks_creds1);
1048                 pwset.in.account_name = talloc_asprintf(
1049                         net_pipe, "%s$", pwset.in.computer_name);
1050                 pwset.in.secure_channel_type = SEC_CHAN_WKSTA;
1051                 pwset.in.credential = &credential;
1052                 pwset.in.new_password = &new_password;
1053                 pwset.out.return_authenticator = &return_authenticator;
1054
1055                 E_md4hash(password, new_password.hash);
1056
1057                 creds_state = cli_credentials_get_netlogon_creds(
1058                         s->wks_creds1);
1059                 netlogon_creds_des_encrypt(creds_state, &new_password);
1060                 netlogon_creds_client_authenticator(creds_state, &credential);
1061
1062                 torture_assert_ntstatus_ok(torture, dcerpc_netr_ServerPasswordSet_r(net_pipe->binding_handle, torture, &pwset),
1063                         "ServerPasswordSet failed");
1064                 torture_assert_ntstatus_ok(torture, pwset.out.result,
1065                                            "ServerPasswordSet failed");
1066
1067                 if (!netlogon_creds_client_check(creds_state,
1068                                         &pwset.out.return_authenticator->cred)) {
1069                         torture_comment(torture, "Credential chaining failed\n");
1070                 }
1071
1072                 cli_credentials_set_password(s->wks_creds1, password,
1073                                              CRED_SPECIFIED);
1074
1075                 talloc_free(net_pipe);
1076
1077                 /* Just as a test, connect with the new creds */
1078
1079                 cli_credentials_set_netlogon_creds(s->wks_creds1, NULL);
1080
1081                 status = dcerpc_pipe_connect_b(s, &net_pipe, s->b,
1082                                                &ndr_table_netlogon,
1083                                                s->wks_creds1,
1084                                                torture->ev, torture->lp_ctx);
1085
1086                 torture_assert_ntstatus_ok(torture, status,
1087                                            "dcerpc_pipe_connect_b failed");
1088
1089                 talloc_free(net_pipe);
1090         }
1091
1092         torture_comment(torture, "Start looping LogonSamLogonEx on %d connections for %d secs\n",
1093                         s->nprocs, s->timelimit);
1094         for (i=0; i < s->nprocs; i++) {
1095                 ret = torture_schannel_bench_start(&s->conns[i]);
1096                 torture_assert(torture, ret, "Failed to setup LogonSamLogonEx");
1097         }
1098
1099         start = timeval_current();
1100         end = timeval_add(&start, s->timelimit, 0);
1101
1102         while (NT_STATUS_IS_OK(s->error) && !timeval_expired(&end)) {
1103                 int ev_ret = tevent_loop_once(torture->ev);
1104                 torture_assert(torture, ev_ret == 0, "tevent_loop_once failed");
1105         }
1106         torture_assert_ntstatus_ok(torture, s->error, "Failed some request");
1107         s->stopped = true;
1108         talloc_free(s->conns);
1109
1110         for (i=0; i < s->nprocs; i++) {
1111                 s->total += s->conns[i].total;
1112         }
1113
1114         torture_comment(torture,
1115                         "Total ops[%llu] (%u ops/s)\n",
1116                         (unsigned long long)s->total,
1117                         (unsigned)s->total/s->timelimit);
1118
1119         torture_leave_domain(torture, s->join_ctx1);
1120         torture_leave_domain(torture, s->join_ctx2);
1121         return true;
1122 }