| 1 |
/* |
| 2 |
Unix SMB/CIFS implementation. |
| 3 |
SMB torture tester |
| 4 |
Copyright (C) Andrew Tridgell 1997-2003 |
| 5 |
Copyright (C) Jelmer Vernooij 2006 |
| 6 |
|
| 7 |
This program is free software; you can redistribute it and/or modify |
| 8 |
it under the terms of the GNU General Public License as published by |
| 9 |
the Free Software Foundation; either version 3 of the License, or |
| 10 |
(at your option) any later version. |
| 11 |
|
| 12 |
This program is distributed in the hope that it will be useful, |
| 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
#include "includes.h" |
| 22 |
#include "lib/cmdline/cmdline.h" |
| 23 |
#include "torture/rpc/torture_rpc.h" |
| 24 |
#include "torture/smbtorture.h" |
| 25 |
#include "librpc/ndr/ndr_table.h" |
| 26 |
#include "../lib/util/dlinklist.h" |
| 27 |
|
| 28 |
static bool torture_rpc_teardown (struct torture_context *tcase, |
| 29 |
void *data) |
| 30 |
{ |
| 31 |
struct torture_rpc_tcase_data *tcase_data = |
| 32 |
(struct torture_rpc_tcase_data *)data; |
| 33 |
if (tcase_data->join_ctx != NULL) |
| 34 |
torture_leave_domain(tcase, tcase_data->join_ctx); |
| 35 |
talloc_free(tcase_data); |
| 36 |
return true; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Obtain the DCE/RPC binding context associated with a torture context. |
| 41 |
* |
| 42 |
* @param tctx Torture context |
| 43 |
* @param binding Pointer to store DCE/RPC binding |
| 44 |
*/ |
| 45 |
NTSTATUS torture_rpc_binding(struct torture_context *tctx, |
| 46 |
struct dcerpc_binding **binding) |
| 47 |
{ |
| 48 |
NTSTATUS status; |
| 49 |
const char *binding_string = torture_setting_string(tctx, "binding", |
| 50 |
NULL); |
| 51 |
|
| 52 |
if (binding_string == NULL) { |
| 53 |
torture_comment(tctx, |
| 54 |
"You must specify a DCE/RPC binding string\n"); |
| 55 |
return NT_STATUS_INVALID_PARAMETER; |
| 56 |
} |
| 57 |
|
| 58 |
status = dcerpc_parse_binding(tctx, binding_string, binding); |
| 59 |
if (NT_STATUS_IS_ERR(status)) { |
| 60 |
torture_comment(tctx, |
| 61 |
"Failed to parse dcerpc binding '%s'\n", |
| 62 |
binding_string); |
| 63 |
return status; |
| 64 |
} |
| 65 |
|
| 66 |
return NT_STATUS_OK; |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* open a rpc connection to the chosen binding string |
| 71 |
*/ |
| 72 |
_PUBLIC_ NTSTATUS torture_rpc_connection(struct torture_context *tctx, |
| 73 |
struct dcerpc_pipe **p, |
| 74 |
const struct ndr_interface_table *table) |
| 75 |
{ |
| 76 |
NTSTATUS status; |
| 77 |
struct dcerpc_binding *binding; |
| 78 |
|
| 79 |
status = torture_rpc_binding(tctx, &binding); |
| 80 |
if (NT_STATUS_IS_ERR(status)) { |
| 81 |
return status; |
| 82 |
} |
| 83 |
|
| 84 |
return torture_rpc_connection_with_binding(tctx, binding, p, table); |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* open a rpc connection to the chosen binding string |
| 89 |
*/ |
| 90 |
_PUBLIC_ NTSTATUS torture_rpc_connection_with_binding(struct torture_context *tctx, |
| 91 |
struct dcerpc_binding *binding, |
| 92 |
struct dcerpc_pipe **p, |
| 93 |
const struct ndr_interface_table *table) |
| 94 |
{ |
| 95 |
NTSTATUS status; |
| 96 |
|
| 97 |
dcerpc_init(); |
| 98 |
|
| 99 |
status = dcerpc_pipe_connect_b(tctx, |
| 100 |
p, binding, table, |
| 101 |
samba_cmdline_get_creds(), |
| 102 |
tctx->ev, tctx->lp_ctx); |
| 103 |
|
| 104 |
if (NT_STATUS_IS_ERR(status)) { |
| 105 |
torture_warning(tctx, "Failed to connect to remote server: %s %s\n", |
| 106 |
dcerpc_binding_string(tctx, binding), nt_errstr(status)); |
| 107 |
} |
| 108 |
|
| 109 |
return status; |
| 110 |
} |
| 111 |
|
| 112 |
/** |
| 113 |
* open a rpc connection to a specific transport |
| 114 |
*/ |
| 115 |
NTSTATUS torture_rpc_connection_transport(struct torture_context *tctx, |
| 116 |
struct dcerpc_pipe **p, |
| 117 |
const struct ndr_interface_table *table, |
| 118 |
enum dcerpc_transport_t transport, |
| 119 |
uint32_t assoc_group_id, |
| 120 |
uint32_t extra_flags) |
| 121 |
{ |
| 122 |
NTSTATUS status; |
| 123 |
struct dcerpc_binding *binding; |
| 124 |
|
| 125 |
*p = NULL; |
| 126 |
|
| 127 |
status = torture_rpc_binding(tctx, &binding); |
| 128 |
if (!NT_STATUS_IS_OK(status)) { |
| 129 |
return status; |
| 130 |
} |
| 131 |
|
| 132 |
status = dcerpc_binding_set_transport(binding, transport); |
| 133 |
if (!NT_STATUS_IS_OK(status)) { |
| 134 |
return status; |
| 135 |
} |
| 136 |
|
| 137 |
status = dcerpc_binding_set_assoc_group_id(binding, assoc_group_id); |
| 138 |
if (!NT_STATUS_IS_OK(status)) { |
| 139 |
return status; |
| 140 |
} |
| 141 |
|
| 142 |
status = dcerpc_binding_set_flags(binding, extra_flags, 0); |
| 143 |
if (!NT_STATUS_IS_OK(status)) { |
| 144 |
return status; |
| 145 |
} |
| 146 |
|
| 147 |
status = dcerpc_pipe_connect_b(tctx, p, binding, table, |
| 148 |
samba_cmdline_get_creds(), |
| 149 |
tctx->ev, tctx->lp_ctx); |
| 150 |
if (!NT_STATUS_IS_OK(status)) { |
| 151 |
*p = NULL; |
| 152 |
return status; |
| 153 |
} |
| 154 |
|
| 155 |
return NT_STATUS_OK; |
| 156 |
} |
| 157 |
|
| 158 |
static bool torture_rpc_setup_machine_workstation(struct torture_context *tctx, |
| 159 |
void **data) |
| 160 |
{ |
| 161 |
NTSTATUS status; |
| 162 |
struct dcerpc_binding *binding; |
| 163 |
struct torture_rpc_tcase *tcase = talloc_get_type(tctx->active_tcase, |
| 164 |
struct torture_rpc_tcase); |
| 165 |
struct torture_rpc_tcase_data *tcase_data; |
| 166 |
|
| 167 |
status = torture_rpc_binding(tctx, &binding); |
| 168 |
if (NT_STATUS_IS_ERR(status)) |
| 169 |
return false; |
| 170 |
|
| 171 |
*data = tcase_data = talloc_zero(tctx, struct torture_rpc_tcase_data); |
| 172 |
tcase_data->credentials = samba_cmdline_get_creds(); |
| 173 |
tcase_data->join_ctx = torture_join_domain(tctx, tcase->machine_name, |
| 174 |
ACB_WSTRUST, |
| 175 |
&tcase_data->credentials); |
| 176 |
if (tcase_data->join_ctx == NULL) |
| 177 |
torture_fail(tctx, "Failed to join as WORKSTATION"); |
| 178 |
|
| 179 |
status = dcerpc_pipe_connect_b(tctx, |
| 180 |
&(tcase_data->pipe), |
| 181 |
binding, |
| 182 |
tcase->table, |
| 183 |
tcase_data->credentials, tctx->ev, tctx->lp_ctx); |
| 184 |
|
| 185 |
torture_assert_ntstatus_ok(tctx, status, "Error connecting to server"); |
| 186 |
|
| 187 |
return NT_STATUS_IS_OK(status); |
| 188 |
} |
| 189 |
|
| 190 |
static bool torture_rpc_setup_machine_bdc(struct torture_context *tctx, |
| 191 |
void **data) |
| 192 |
{ |
| 193 |
NTSTATUS status; |
| 194 |
struct dcerpc_binding *binding; |
| 195 |
struct torture_rpc_tcase *tcase = talloc_get_type(tctx->active_tcase, |
| 196 |
struct torture_rpc_tcase); |
| 197 |
struct torture_rpc_tcase_data *tcase_data; |
| 198 |
|
| 199 |
status = torture_rpc_binding(tctx, &binding); |
| 200 |
if (NT_STATUS_IS_ERR(status)) |
| 201 |
return false; |
| 202 |
|
| 203 |
*data = tcase_data = talloc_zero(tctx, struct torture_rpc_tcase_data); |
| 204 |
tcase_data->credentials = samba_cmdline_get_creds(); |
| 205 |
tcase_data->join_ctx = torture_join_domain(tctx, tcase->machine_name, |
| 206 |
ACB_SVRTRUST, |
| 207 |
&tcase_data->credentials); |
| 208 |
if (tcase_data->join_ctx == NULL) |
| 209 |
torture_fail(tctx, "Failed to join as BDC"); |
| 210 |
|
| 211 |
status = dcerpc_pipe_connect_b(tctx, |
| 212 |
&(tcase_data->pipe), |
| 213 |
binding, |
| 214 |
tcase->table, |
| 215 |
tcase_data->credentials, tctx->ev, tctx->lp_ctx); |
| 216 |
|
| 217 |
torture_assert_ntstatus_ok(tctx, status, "Error connecting to server"); |
| 218 |
|
| 219 |
return NT_STATUS_IS_OK(status); |
| 220 |
} |
| 221 |
|
| 222 |
_PUBLIC_ struct torture_rpc_tcase *torture_suite_add_machine_workstation_rpc_iface_tcase( |
| 223 |
struct torture_suite *suite, |
| 224 |
const char *name, |
| 225 |
const struct ndr_interface_table *table, |
| 226 |
const char *machine_name) |
| 227 |
{ |
| 228 |
struct torture_rpc_tcase *tcase = talloc(suite, |
| 229 |
struct torture_rpc_tcase); |
| 230 |
|
| 231 |
torture_suite_init_rpc_tcase(suite, tcase, name, table); |
| 232 |
|
| 233 |
tcase->machine_name = talloc_strdup(tcase, machine_name); |
| 234 |
tcase->tcase.setup = torture_rpc_setup_machine_workstation; |
| 235 |
tcase->tcase.teardown = torture_rpc_teardown; |
| 236 |
|
| 237 |
return tcase; |
| 238 |
} |
| 239 |
|
| 240 |
_PUBLIC_ struct torture_rpc_tcase *torture_suite_add_machine_bdc_rpc_iface_tcase( |
| 241 |
struct torture_suite *suite, |
| 242 |
const char *name, |
| 243 |
const struct ndr_interface_table *table, |
| 244 |
const char *machine_name) |
| 245 |
{ |
| 246 |
struct torture_rpc_tcase *tcase = talloc(suite, |
| 247 |
struct torture_rpc_tcase); |
| 248 |
|
| 249 |
torture_suite_init_rpc_tcase(suite, tcase, name, table); |
| 250 |
|
| 251 |
tcase->machine_name = talloc_strdup(tcase, machine_name); |
| 252 |
tcase->tcase.setup = torture_rpc_setup_machine_bdc; |
| 253 |
tcase->tcase.teardown = torture_rpc_teardown; |
| 254 |
|
| 255 |
return tcase; |
| 256 |
} |
| 257 |
|
| 258 |
_PUBLIC_ bool torture_suite_init_rpc_tcase(struct torture_suite *suite, |
| 259 |
struct torture_rpc_tcase *tcase, |
| 260 |
const char *name, |
| 261 |
const struct ndr_interface_table *table) |
| 262 |
{ |
| 263 |
if (!torture_suite_init_tcase(suite, (struct torture_tcase *)tcase, name)) |
| 264 |
return false; |
| 265 |
|
| 266 |
tcase->table = table; |
| 267 |
|
| 268 |
return true; |
| 269 |
} |
| 270 |
|
| 271 |
static bool torture_rpc_setup_anonymous(struct torture_context *tctx, |
| 272 |
void **data) |
| 273 |
{ |
| 274 |
NTSTATUS status; |
| 275 |
struct dcerpc_binding *binding; |
| 276 |
struct torture_rpc_tcase_data *tcase_data; |
| 277 |
struct torture_rpc_tcase *tcase = talloc_get_type(tctx->active_tcase, |
| 278 |
struct torture_rpc_tcase); |
| 279 |
|
| 280 |
status = torture_rpc_binding(tctx, &binding); |
| 281 |
if (NT_STATUS_IS_ERR(status)) |
| 282 |
return false; |
| 283 |
|
| 284 |
*data = tcase_data = talloc_zero(tctx, struct torture_rpc_tcase_data); |
| 285 |
tcase_data->credentials = cli_credentials_init_anon(tctx); |
| 286 |
|
| 287 |
status = dcerpc_pipe_connect_b(tctx, |
| 288 |
&(tcase_data->pipe), |
| 289 |
binding, |
| 290 |
tcase->table, |
| 291 |
tcase_data->credentials, tctx->ev, tctx->lp_ctx); |
| 292 |
|
| 293 |
torture_assert_ntstatus_ok(tctx, status, "Error connecting to server"); |
| 294 |
|
| 295 |
return NT_STATUS_IS_OK(status); |
| 296 |
} |
| 297 |
|
| 298 |
static bool torture_rpc_setup (struct torture_context *tctx, void **data) |
| 299 |
{ |
| 300 |
NTSTATUS status; |
| 301 |
struct torture_rpc_tcase *tcase = talloc_get_type( |
| 302 |
tctx->active_tcase, struct torture_rpc_tcase); |
| 303 |
struct torture_rpc_tcase_data *tcase_data; |
| 304 |
|
| 305 |
*data = tcase_data = talloc_zero(tctx, struct torture_rpc_tcase_data); |
| 306 |
tcase_data->credentials = samba_cmdline_get_creds(); |
| 307 |
|
| 308 |
status = torture_rpc_connection(tctx, |
| 309 |
&(tcase_data->pipe), |
| 310 |
tcase->table); |
| 311 |
|
| 312 |
torture_assert_ntstatus_ok(tctx, status, "Error connecting to server"); |
| 313 |
|
| 314 |
return NT_STATUS_IS_OK(status); |
| 315 |
} |
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
_PUBLIC_ struct torture_rpc_tcase *torture_suite_add_anon_rpc_iface_tcase(struct torture_suite *suite, |
| 320 |
const char *name, |
| 321 |
const struct ndr_interface_table *table) |
| 322 |
{ |
| 323 |
struct torture_rpc_tcase *tcase = talloc(suite, struct torture_rpc_tcase); |
| 324 |
|
| 325 |
torture_suite_init_rpc_tcase(suite, tcase, name, table); |
| 326 |
|
| 327 |
tcase->tcase.setup = torture_rpc_setup_anonymous; |
| 328 |
tcase->tcase.teardown = torture_rpc_teardown; |
| 329 |
|
| 330 |
return tcase; |
| 331 |
} |
| 332 |
|
| 333 |
|
| 334 |
_PUBLIC_ struct torture_rpc_tcase *torture_suite_add_rpc_iface_tcase(struct torture_suite *suite, |
| 335 |
const char *name, |
| 336 |
const struct ndr_interface_table *table) |
| 337 |
{ |
| 338 |
struct torture_rpc_tcase *tcase = talloc(suite, struct torture_rpc_tcase); |
| 339 |
|
| 340 |
torture_suite_init_rpc_tcase(suite, tcase, name, table); |
| 341 |
|
| 342 |
tcase->tcase.setup = torture_rpc_setup; |
| 343 |
tcase->tcase.teardown = torture_rpc_teardown; |
| 344 |
|
| 345 |
return tcase; |
| 346 |
} |
| 347 |
|
| 348 |
static bool torture_rpc_wrap_test(struct torture_context *tctx, |
| 349 |
struct torture_tcase *tcase, |
| 350 |
struct torture_test *test) |
| 351 |
{ |
| 352 |
bool (*fn) (struct torture_context *, struct dcerpc_pipe *); |
| 353 |
struct torture_rpc_tcase_data *tcase_data = |
| 354 |
(struct torture_rpc_tcase_data *)tcase->data; |
| 355 |
|
| 356 |
fn = test->fn; |
| 357 |
|
| 358 |
return fn(tctx, tcase_data->pipe); |
| 359 |
} |
| 360 |
|
| 361 |
static bool torture_rpc_wrap_test_ex(struct torture_context *tctx, |
| 362 |
struct torture_tcase *tcase, |
| 363 |
struct torture_test *test) |
| 364 |
{ |
| 365 |
bool (*fn) (struct torture_context *, struct dcerpc_pipe *, const void *); |
| 366 |
struct torture_rpc_tcase_data *tcase_data = |
| 367 |
(struct torture_rpc_tcase_data *)tcase->data; |
| 368 |
|
| 369 |
fn = test->fn; |
| 370 |
|
| 371 |
return fn(tctx, tcase_data->pipe, test->data); |
| 372 |
} |
| 373 |
|
| 374 |
|
| 375 |
static bool torture_rpc_wrap_test_creds(struct torture_context *tctx, |
| 376 |
struct torture_tcase *tcase, |
| 377 |
struct torture_test *test) |
| 378 |
{ |
| 379 |
bool (*fn) (struct torture_context *, struct dcerpc_pipe *, struct cli_credentials *); |
| 380 |
struct torture_rpc_tcase_data *tcase_data = |
| 381 |
(struct torture_rpc_tcase_data *)tcase->data; |
| 382 |
|
| 383 |
fn = test->fn; |
| 384 |
|
| 385 |
return fn(tctx, tcase_data->pipe, tcase_data->credentials); |
| 386 |
} |
| 387 |
|
| 388 |
static bool torture_rpc_wrap_test_join(struct torture_context *tctx, |
| 389 |
struct torture_tcase *tcase, |
| 390 |
struct torture_test *test) |
| 391 |
{ |
| 392 |
bool (*fn) (struct torture_context *, struct dcerpc_pipe *, struct cli_credentials *, struct test_join *); |
| 393 |
struct torture_rpc_tcase_data *tcase_data = |
| 394 |
(struct torture_rpc_tcase_data *)tcase->data; |
| 395 |
|
| 396 |
fn = test->fn; |
| 397 |
|
| 398 |
return fn(tctx, tcase_data->pipe, tcase_data->credentials, tcase_data->join_ctx); |
| 399 |
} |
| 400 |
|
| 401 |
_PUBLIC_ struct torture_test *torture_rpc_tcase_add_test( |
| 402 |
struct torture_rpc_tcase *tcase, |
| 403 |
const char *name, |
| 404 |
bool (*fn) (struct torture_context *, struct dcerpc_pipe *)) |
| 405 |
{ |
| 406 |
struct torture_test *test; |
| 407 |
|
| 408 |
test = talloc(tcase, struct torture_test); |
| 409 |
|
| 410 |
test->name = talloc_strdup(test, name); |
| 411 |
test->description = NULL; |
| 412 |
test->run = torture_rpc_wrap_test; |
| 413 |
test->dangerous = false; |
| 414 |
test->data = NULL; |
| 415 |
test->fn = fn; |
| 416 |
|
| 417 |
DLIST_ADD_END(tcase->tcase.tests, test); |
| 418 |
|
| 419 |
return test; |
| 420 |
} |
| 421 |
|
| 422 |
_PUBLIC_ struct torture_test *torture_rpc_tcase_add_test_creds( |
| 423 |
struct torture_rpc_tcase *tcase, |
| 424 |
const char *name, |
| 425 |
bool (*fn) (struct torture_context *, struct dcerpc_pipe *, struct cli_credentials *)) |
| 426 |
{ |
| 427 |
struct torture_test *test; |
| 428 |
|
| 429 |
test = talloc(tcase, struct torture_test); |
| 430 |
|
| 431 |
test->name = talloc_strdup(test, name); |
| 432 |
test->description = NULL; |
| 433 |
test->run = torture_rpc_wrap_test_creds; |
| 434 |
test->dangerous = false; |
| 435 |
test->data = NULL; |
| 436 |
test->fn = fn; |
| 437 |
|
| 438 |
DLIST_ADD_END(tcase->tcase.tests, test); |
| 439 |
|
| 440 |
return test; |
| 441 |
} |
| 442 |
|
| 443 |
_PUBLIC_ struct torture_test *torture_rpc_tcase_add_test_join( |
| 444 |
struct torture_rpc_tcase *tcase, |
| 445 |
const char *name, |
| 446 |
bool (*fn) (struct torture_context *, struct dcerpc_pipe *, |
| 447 |
struct cli_credentials *, struct test_join *)) |
| 448 |
{ |
| 449 |
struct torture_test *test; |
| 450 |
|
| 451 |
test = talloc(tcase, struct torture_test); |
| 452 |
|
| 453 |
test->name = talloc_strdup(test, name); |
| 454 |
test->description = NULL; |
| 455 |
test->run = torture_rpc_wrap_test_join; |
| 456 |
test->dangerous = false; |
| 457 |
test->data = NULL; |
| 458 |
test->fn = fn; |
| 459 |
|
| 460 |
DLIST_ADD_END(tcase->tcase.tests, test); |
| 461 |
|
| 462 |
return test; |
| 463 |
} |
| 464 |
|
| 465 |
_PUBLIC_ struct torture_test *torture_rpc_tcase_add_test_ex( |
| 466 |
struct torture_rpc_tcase *tcase, |
| 467 |
const char *name, |
| 468 |
bool (*fn) (struct torture_context *, struct dcerpc_pipe *, |
| 469 |
void *), |
| 470 |
void *userdata) |
| 471 |
{ |
| 472 |
struct torture_test *test; |
| 473 |
|
| 474 |
test = talloc(tcase, struct torture_test); |
| 475 |
|
| 476 |
test->name = talloc_strdup(test, name); |
| 477 |
test->description = NULL; |
| 478 |
test->run = torture_rpc_wrap_test_ex; |
| 479 |
test->dangerous = false; |
| 480 |
test->data = userdata; |
| 481 |
test->fn = fn; |
| 482 |
|
| 483 |
DLIST_ADD_END(tcase->tcase.tests, test); |
| 484 |
|
| 485 |
return test; |
| 486 |
} |
| 487 |
|
| 488 |
static bool torture_rpc_wrap_test_setup(struct torture_context *tctx, |
| 489 |
struct torture_tcase *tcase, |
| 490 |
struct torture_test *test) |
| 491 |
{ |
| 492 |
bool (*fn)(struct torture_context *, struct dcerpc_pipe *, const void *); |
| 493 |
struct torture_rpc_tcase *rpc_tcase = talloc_get_type_abort( |
| 494 |
tctx->active_tcase, struct torture_rpc_tcase); |
| 495 |
struct torture_rpc_tcase_data *tcase_data = talloc_get_type_abort( |
| 496 |
tcase->data, struct torture_rpc_tcase_data); |
| 497 |
void *data = discard_const_p(void, test->data); |
| 498 |
bool ok; |
| 499 |
|
| 500 |
ok = rpc_tcase->setup_fn(tctx, tcase_data->pipe, data); |
| 501 |
if (!ok) { |
| 502 |
return false; |
| 503 |
} |
| 504 |
|
| 505 |
fn = test->fn; |
| 506 |
|
| 507 |
ok = fn(tctx, tcase_data->pipe, data); |
| 508 |
if (!ok) { |
| 509 |
return false; |
| 510 |
} |
| 511 |
|
| 512 |
ok = rpc_tcase->teardown_fn(tctx, tcase_data->pipe, data); |
| 513 |
if (!ok) { |
| 514 |
return false; |
| 515 |
} |
| 516 |
|
| 517 |
return true; |
| 518 |
} |
| 519 |
|
| 520 |
_PUBLIC_ struct torture_test *torture_rpc_tcase_add_test_setup( |
| 521 |
struct torture_rpc_tcase *tcase, |
| 522 |
const char *name, |
| 523 |
bool (*fn)(struct torture_context *, |
| 524 |
struct dcerpc_pipe *, |
| 525 |
void *), |
| 526 |
void *userdata) |
| 527 |
{ |
| 528 |
struct torture_test *test = NULL; |
| 529 |
|
| 530 |
test = talloc(tcase, struct torture_test); |
| 531 |
|
| 532 |
test->name = talloc_strdup(test, name); |
| 533 |
test->description = NULL; |
| 534 |
test->run = torture_rpc_wrap_test_setup; |
| 535 |
test->dangerous = false; |
| 536 |
test->data = userdata; |
| 537 |
test->fn = fn; |
| 538 |
|
| 539 |
DLIST_ADD_END(tcase->tcase.tests, test); |
| 540 |
|
| 541 |
return test; |
| 542 |
} |
| 543 |
|
| 544 |
_PUBLIC_ struct torture_rpc_tcase *torture_suite_add_rpc_setup_tcase( |
| 545 |
struct torture_suite *suite, |
| 546 |
const char *name, |
| 547 |
const struct ndr_interface_table *table, |
| 548 |
bool (*setup_fn)(struct torture_context *, |
| 549 |
struct dcerpc_pipe *, |
| 550 |
void *), |
| 551 |
bool (*teardown_fn)(struct torture_context *, |
| 552 |
struct dcerpc_pipe *, |
| 553 |
void *)) |
| 554 |
{ |
| 555 |
struct torture_rpc_tcase *tcase = talloc( |
| 556 |
suite, struct torture_rpc_tcase); |
| 557 |
|
| 558 |
torture_suite_init_rpc_tcase(suite, tcase, name, table); |
| 559 |
|
| 560 |
tcase->setup_fn = setup_fn; |
| 561 |
tcase->teardown_fn = teardown_fn; |
| 562 |
tcase->tcase.setup = torture_rpc_setup; |
| 563 |
tcase->tcase.teardown = torture_rpc_teardown; |
| 564 |
|
| 565 |
return tcase; |
| 566 |
} |
| 567 |
|
| 568 |
NTSTATUS torture_rpc_init(TALLOC_CTX *ctx) |
| 569 |
{ |
| 570 |
struct torture_suite *suite = torture_suite_create(ctx, "rpc"); |
| 571 |
|
| 572 |
ndr_table_init(); |
| 573 |
|
| 574 |
torture_suite_add_simple_test(suite, "lsa", torture_rpc_lsa); |
| 575 |
torture_suite_add_simple_test(suite, "lsalookup", torture_rpc_lsa_lookup); |
| 576 |
torture_suite_add_simple_test(suite, "lsa-getuser", torture_rpc_lsa_get_user); |
| 577 |
torture_suite_add_suite(suite, torture_rpc_lsa_lookup_sids(suite)); |
| 578 |
torture_suite_add_suite(suite, torture_rpc_lsa_lookup_names(suite)); |
| 579 |
torture_suite_add_suite(suite, torture_rpc_lsa_secrets(suite)); |
| 580 |
torture_suite_add_suite(suite, torture_rpc_lsa_trusted_domains(suite)); |
| 581 |
torture_suite_add_suite(suite, torture_rpc_lsa_forest_trust(suite)); |
| 582 |
torture_suite_add_suite(suite, torture_rpc_lsa_privileges(suite)); |
| 583 |
torture_suite_add_suite(suite, torture_rpc_echo(suite)); |
| 584 |
torture_suite_add_suite(suite, torture_rpc_dfs(suite)); |
| 585 |
torture_suite_add_suite(suite, torture_rpc_frsapi(suite)); |
| 586 |
torture_suite_add_suite(suite, torture_rpc_unixinfo(suite)); |
| 587 |
torture_suite_add_suite(suite, torture_rpc_eventlog(suite)); |
| 588 |
torture_suite_add_suite(suite, torture_rpc_atsvc(suite)); |
| 589 |
torture_suite_add_suite(suite, torture_rpc_wkssvc(suite)); |
| 590 |
torture_suite_add_suite(suite, torture_rpc_handles(suite)); |
| 591 |
torture_suite_add_suite(suite, torture_rpc_object_uuid(suite)); |
| 592 |
torture_suite_add_suite(suite, torture_rpc_winreg(suite)); |
| 593 |
torture_suite_add_suite(suite, torture_rpc_spoolss(suite)); |
| 594 |
#ifdef WITH_NTVFS_FILESERVER |
| 595 |
torture_suite_add_suite(suite, torture_rpc_spoolss_notify(suite)); |
| 596 |
#endif |
| 597 |
torture_suite_add_suite(suite, torture_rpc_spoolss_win(suite)); |
| 598 |
torture_suite_add_suite(suite, torture_rpc_spoolss_driver(suite)); |
| 599 |
torture_suite_add_suite(suite, torture_rpc_spoolss_access(suite)); |
| 600 |
torture_suite_add_suite(suite, torture_rpc_iremotewinspool(suite)); |
| 601 |
torture_suite_add_suite(suite, torture_rpc_iremotewinspool_drv(suite)); |
| 602 |
torture_suite_add_simple_test(suite, "samr", torture_rpc_samr); |
| 603 |
torture_suite_add_simple_test(suite, "samr.users", torture_rpc_samr_users); |
| 604 |
torture_suite_add_simple_test(suite, "samr.passwords.default", torture_rpc_samr_passwords); |
| 605 |
torture_suite_add_suite(suite, torture_rpc_netlogon(suite)); |
| 606 |
torture_suite_add_suite(suite, torture_rpc_netlogon_s3(suite)); |
| 607 |
torture_suite_add_suite(suite, torture_rpc_netlogon_admin(suite)); |
| 608 |
torture_suite_add_suite(suite, torture_rpc_netlogon_zerologon(suite)); |
| 609 |
torture_suite_add_suite(suite, torture_rpc_netlogon_crypto_fips(suite)); |
| 610 |
torture_suite_add_suite(suite, torture_rpc_remote_pac(suite)); |
| 611 |
torture_suite_add_simple_test(suite, "samlogon", torture_rpc_samlogon); |
| 612 |
torture_suite_add_simple_test(suite, "samsync", torture_rpc_samsync); |
| 613 |
torture_suite_add_simple_test(suite, "schannel", torture_rpc_schannel); |
| 614 |
torture_suite_add_simple_test(suite, "schannel2", torture_rpc_schannel2); |
| 615 |
torture_suite_add_simple_test(suite, "bench-schannel1", torture_rpc_schannel_bench1); |
| 616 |
torture_suite_add_simple_test(suite, "schannel_anon_setpw", torture_rpc_schannel_anon_setpw); |
| 617 |
torture_suite_add_suite(suite, torture_rpc_srvsvc(suite)); |
| 618 |
torture_suite_add_suite(suite, torture_rpc_svcctl(suite)); |
| 619 |
torture_suite_add_suite(suite, torture_rpc_samr_accessmask(suite)); |
| 620 |
torture_suite_add_suite(suite, torture_rpc_samr_handletype(suite)); |
| 621 |
torture_suite_add_suite(suite, torture_rpc_samr_workstation_auth(suite)); |
| 622 |
torture_suite_add_suite(suite, torture_rpc_samr_passwords_pwdlastset(suite)); |
| 623 |
torture_suite_add_suite(suite, torture_rpc_samr_passwords_badpwdcount(suite)); |
| 624 |
torture_suite_add_suite(suite, torture_rpc_samr_passwords_lockout(suite)); |
| 625 |
torture_suite_add_suite(suite, torture_rpc_samr_passwords_validate(suite)); |
| 626 |
torture_suite_add_suite(suite, torture_rpc_samr_user_privileges(suite)); |
| 627 |
torture_suite_add_suite(suite, torture_rpc_samr_large_dc(suite)); |
| 628 |
torture_suite_add_suite(suite, torture_rpc_samr_priv(suite)); |
| 629 |
torture_suite_add_suite(suite, torture_rpc_epmapper(suite)); |
| 630 |
torture_suite_add_suite(suite, torture_rpc_initshutdown(suite)); |
| 631 |
torture_suite_add_simple_test(suite, "mgmt", torture_rpc_mgmt); |
| 632 |
torture_suite_add_simple_test(suite, "scanner", torture_rpc_scanner); |
| 633 |
torture_suite_add_simple_test(suite, "countcalls", torture_rpc_countcalls); |
| 634 |
torture_suite_add_simple_test(suite, "authcontext", torture_bind_authcontext); |
| 635 |
torture_suite_add_suite(suite, torture_rpc_samba3(suite)); |
| 636 |
torture_rpc_drsuapi_tcase(suite); |
| 637 |
torture_rpc_drsuapi_w2k8_tcase(suite); |
| 638 |
torture_rpc_drsuapi_cracknames_tcase(suite); |
| 639 |
torture_suite_add_suite(suite, torture_rpc_dssetup(suite)); |
| 640 |
torture_suite_add_suite(suite, torture_rpc_browser(suite)); |
| 641 |
torture_suite_add_simple_test(suite, "altercontext", torture_rpc_alter_context); |
| 642 |
torture_suite_add_simple_test(suite, "join", torture_rpc_join); |
| 643 |
torture_drs_rpc_dsgetinfo_tcase(suite); |
| 644 |
torture_suite_add_simple_test(suite, "bench-rpc", torture_bench_rpc); |
| 645 |
torture_suite_add_simple_test(suite, "asyncbind", torture_async_bind); |
| 646 |
torture_suite_add_suite(suite, torture_rpc_ntsvcs(suite)); |
| 647 |
torture_suite_add_suite(suite, torture_rpc_bind(suite)); |
| 648 |
#ifdef AD_DC_BUILD_IS_ENABLED |
| 649 |
torture_suite_add_suite(suite, torture_rpc_backupkey(suite)); |
| 650 |
#endif |
| 651 |
torture_suite_add_suite(suite, torture_rpc_fsrvp(suite)); |
| 652 |
torture_suite_add_suite(suite, torture_rpc_clusapi(suite)); |
| 653 |
torture_suite_add_suite(suite, torture_rpc_witness(suite)); |
| 654 |
torture_suite_add_suite(suite, torture_rpc_mdssvc(suite)); |
| 655 |
|
| 656 |
suite->description = talloc_strdup(suite, "DCE/RPC protocol and interface tests"); |
| 657 |
|
| 658 |
torture_register_suite(ctx, suite); |
| 659 |
|
| 660 |
return NT_STATUS_OK; |
| 661 |
} |