| 1 |
/* |
| 2 |
Unix SMB/CIFS implementation. |
| 3 |
test suite for rpc dfs operations |
| 4 |
|
| 5 |
Copyright (C) Andrew Tridgell 2003 |
| 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, write to the Free Software |
| 19 |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 |
*/ |
| 21 |
|
| 22 |
#include "includes.h" |
| 23 |
#include "torture/rpc/torture_rpc.h" |
| 24 |
#include "librpc/gen_ndr/ndr_dfs_c.h" |
| 25 |
#include "libnet/libnet.h" |
| 26 |
#include "torture/util.h" |
| 27 |
#include "libcli/libcli.h" |
| 28 |
#include "lib/cmdline/cmdline.h" |
| 29 |
|
| 30 |
#define SMBTORTURE_DFS_SHARENAME "smbtorture_dfs_share" |
| 31 |
#define SMBTORTURE_DFS_DIRNAME "\\smbtorture_dfs_dir" |
| 32 |
#define SMBTORTURE_DFS_PATHNAME "C:"SMBTORTURE_DFS_DIRNAME |
| 33 |
|
| 34 |
#define IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3(x,y)\ |
| 35 |
if (x == DFS_MANAGER_VERSION_W2K3) {\ |
| 36 |
if (!W_ERROR_EQUAL(y,WERR_NOT_SUPPORTED)) {\ |
| 37 |
printf("expected WERR_NOT_SUPPORTED\n");\ |
| 38 |
return false;\ |
| 39 |
}\ |
| 40 |
return true;\ |
| 41 |
}\ |
| 42 |
|
| 43 |
static bool test_NetShareAdd(struct torture_context *tctx, |
| 44 |
const char *host, |
| 45 |
const char *sharename, |
| 46 |
const char *dir) |
| 47 |
{ |
| 48 |
NTSTATUS status; |
| 49 |
struct srvsvc_NetShareInfo2 i; |
| 50 |
struct libnet_context* libnetctx; |
| 51 |
struct libnet_AddShare r; |
| 52 |
|
| 53 |
printf("Creating share %s\n", sharename); |
| 54 |
|
| 55 |
if (!(libnetctx = libnet_context_init(tctx, tctx->ev, tctx->lp_ctx))) { |
| 56 |
return false; |
| 57 |
} |
| 58 |
|
| 59 |
libnetctx->cred = samba_cmdline_get_creds(); |
| 60 |
|
| 61 |
i.name = sharename; |
| 62 |
i.type = STYPE_DISKTREE; |
| 63 |
i.path = dir; |
| 64 |
i.max_users = (uint32_t) -1; |
| 65 |
i.comment = "created by smbtorture"; |
| 66 |
i.password = NULL; |
| 67 |
i.permissions = 0x0; |
| 68 |
i.current_users = 0x0; |
| 69 |
|
| 70 |
r.level = 2; |
| 71 |
r.in.server_name = host; |
| 72 |
r.in.share = i; |
| 73 |
|
| 74 |
status = libnet_AddShare(libnetctx, tctx, &r); |
| 75 |
if (!NT_STATUS_IS_OK(status)) { |
| 76 |
d_printf("Failed to add new share: %s (%s)\n", |
| 77 |
nt_errstr(status), r.out.error_string); |
| 78 |
return false; |
| 79 |
} |
| 80 |
|
| 81 |
return true; |
| 82 |
} |
| 83 |
|
| 84 |
static bool test_NetShareDel(struct torture_context *tctx, |
| 85 |
const char *host, |
| 86 |
const char *sharename) |
| 87 |
{ |
| 88 |
NTSTATUS status; |
| 89 |
struct libnet_context* libnetctx; |
| 90 |
struct libnet_DelShare r; |
| 91 |
|
| 92 |
torture_comment(tctx, "Deleting share %s\n", sharename); |
| 93 |
|
| 94 |
if (!(libnetctx = libnet_context_init(tctx, tctx->ev, tctx->lp_ctx))) { |
| 95 |
return false; |
| 96 |
} |
| 97 |
|
| 98 |
libnetctx->cred = samba_cmdline_get_creds(); |
| 99 |
|
| 100 |
r.in.share_name = sharename; |
| 101 |
r.in.server_name = host; |
| 102 |
|
| 103 |
status = libnet_DelShare(libnetctx, tctx, &r); |
| 104 |
if (!NT_STATUS_IS_OK(status)) { |
| 105 |
d_printf("Failed to delete share: %s (%s)\n", |
| 106 |
nt_errstr(status), r.out.error_string); |
| 107 |
return false; |
| 108 |
} |
| 109 |
|
| 110 |
return true; |
| 111 |
} |
| 112 |
|
| 113 |
static bool test_CreateDir(TALLOC_CTX *mem_ctx, |
| 114 |
struct smbcli_state **cli, |
| 115 |
struct torture_context *tctx, |
| 116 |
const char *host, |
| 117 |
const char *share, |
| 118 |
const char *dir) |
| 119 |
{ |
| 120 |
printf("Creating directory %s\n", dir); |
| 121 |
|
| 122 |
if (!torture_open_connection_share(mem_ctx, cli, tctx, host, share, tctx->ev)) { |
| 123 |
return false; |
| 124 |
} |
| 125 |
|
| 126 |
if (!torture_setup_dir(*cli, dir)) { |
| 127 |
return false; |
| 128 |
} |
| 129 |
|
| 130 |
return true; |
| 131 |
} |
| 132 |
|
| 133 |
static bool test_DeleteDir(struct torture_context *tctx, |
| 134 |
struct smbcli_state *cli, |
| 135 |
const char *dir) |
| 136 |
{ |
| 137 |
torture_comment(tctx, "Deleting directory %s\n", dir); |
| 138 |
|
| 139 |
if (smbcli_deltree(cli->tree, dir) == -1) { |
| 140 |
printf("Unable to delete dir %s - %s\n", dir, |
| 141 |
smbcli_errstr(cli->tree)); |
| 142 |
return false; |
| 143 |
} |
| 144 |
|
| 145 |
return true; |
| 146 |
} |
| 147 |
|
| 148 |
static bool test_GetManagerVersion_opts(struct torture_context *tctx, |
| 149 |
struct dcerpc_binding_handle *b, |
| 150 |
enum dfs_ManagerVersion *version_p) |
| 151 |
{ |
| 152 |
struct dfs_GetManagerVersion r; |
| 153 |
enum dfs_ManagerVersion version; |
| 154 |
|
| 155 |
r.out.version = &version; |
| 156 |
|
| 157 |
torture_assert_ntstatus_ok(tctx, |
| 158 |
dcerpc_dfs_GetManagerVersion_r(b, tctx, &r), |
| 159 |
"GetManagerVersion failed"); |
| 160 |
|
| 161 |
if (version_p) { |
| 162 |
*version_p = version; |
| 163 |
} |
| 164 |
|
| 165 |
return true; |
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
static bool test_GetManagerVersion(struct torture_context *tctx, |
| 170 |
struct dcerpc_pipe *p) |
| 171 |
{ |
| 172 |
struct dcerpc_binding_handle *b = p->binding_handle; |
| 173 |
|
| 174 |
return test_GetManagerVersion_opts(tctx, b, NULL); |
| 175 |
} |
| 176 |
|
| 177 |
static bool test_ManagerInitialize(struct torture_context *tctx, |
| 178 |
struct dcerpc_pipe *p) |
| 179 |
{ |
| 180 |
enum dfs_ManagerVersion version; |
| 181 |
struct dfs_ManagerInitialize r; |
| 182 |
struct dcerpc_binding_handle *b = p->binding_handle; |
| 183 |
const char *host = torture_setting_string(tctx, "host", NULL); |
| 184 |
|
| 185 |
torture_comment(tctx, "Testing ManagerInitialize\n"); |
| 186 |
|
| 187 |
torture_assert(tctx, |
| 188 |
test_GetManagerVersion_opts(tctx, b, &version), |
| 189 |
"GetManagerVersion failed"); |
| 190 |
|
| 191 |
r.in.servername = host; |
| 192 |
r.in.flags = 0; |
| 193 |
|
| 194 |
torture_assert_ntstatus_ok(tctx, |
| 195 |
dcerpc_dfs_ManagerInitialize_r(b, tctx, &r), |
| 196 |
"ManagerInitialize failed"); |
| 197 |
if (!W_ERROR_IS_OK(r.out.result)) { |
| 198 |
torture_warning(tctx, "dfs_ManagerInitialize failed - %s\n", |
| 199 |
win_errstr(r.out.result)); |
| 200 |
IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3(version, r.out.result); |
| 201 |
return false; |
| 202 |
} |
| 203 |
|
| 204 |
return true; |
| 205 |
} |
| 206 |
|
| 207 |
static bool test_GetInfoLevel(struct torture_context *tctx, |
| 208 |
struct dcerpc_binding_handle *b, |
| 209 |
uint16_t level, |
| 210 |
const char *root) |
| 211 |
{ |
| 212 |
struct dfs_GetInfo r; |
| 213 |
union dfs_Info info; |
| 214 |
|
| 215 |
torture_comment(tctx, "Testing GetInfo level %u on '%s'\n", level, root); |
| 216 |
|
| 217 |
r.in.dfs_entry_path = root; |
| 218 |
r.in.servername = NULL; |
| 219 |
r.in.sharename = NULL; |
| 220 |
r.in.level = level; |
| 221 |
r.out.info = &info; |
| 222 |
|
| 223 |
torture_assert_ntstatus_ok(tctx, |
| 224 |
dcerpc_dfs_GetInfo_r(b, tctx, &r), |
| 225 |
"GetInfo failed"); |
| 226 |
|
| 227 |
if (!W_ERROR_IS_OK(r.out.result) && |
| 228 |
!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result)) { |
| 229 |
torture_warning(tctx, "dfs_GetInfo failed - %s\n", win_errstr(r.out.result)); |
| 230 |
return false; |
| 231 |
} |
| 232 |
|
| 233 |
return true; |
| 234 |
} |
| 235 |
|
| 236 |
static bool test_GetInfo(struct torture_context *tctx, |
| 237 |
struct dcerpc_binding_handle *b, |
| 238 |
const char *root) |
| 239 |
{ |
| 240 |
bool ret = true; |
| 241 |
/* 103, 104, 105, 106 is only available on Set */ |
| 242 |
uint16_t levels[] = {1, 2, 3, 4, 5, 6, 7, 100, 101, 102, 103, 104, 105, 106}; |
| 243 |
int i; |
| 244 |
|
| 245 |
for (i=0;i<ARRAY_SIZE(levels);i++) { |
| 246 |
if (!test_GetInfoLevel(tctx, b, levels[i], root)) { |
| 247 |
ret = false; |
| 248 |
} |
| 249 |
} |
| 250 |
return ret; |
| 251 |
} |
| 252 |
|
| 253 |
static bool test_EnumLevelEx(struct torture_context *tctx, |
| 254 |
struct dcerpc_binding_handle *b, |
| 255 |
uint16_t level, |
| 256 |
const char *dfs_name) |
| 257 |
{ |
| 258 |
struct dfs_EnumEx rex; |
| 259 |
uint32_t total=0; |
| 260 |
struct dfs_EnumStruct e; |
| 261 |
struct dfs_Info1 s; |
| 262 |
struct dfs_EnumArray1 e1; |
| 263 |
bool ret = true; |
| 264 |
|
| 265 |
rex.in.level = level; |
| 266 |
rex.in.bufsize = (uint32_t)-1; |
| 267 |
rex.in.total = &total; |
| 268 |
rex.in.info = &e; |
| 269 |
rex.in.dfs_name = dfs_name; |
| 270 |
|
| 271 |
e.level = rex.in.level; |
| 272 |
e.e.info1 = &e1; |
| 273 |
e.e.info1->count = 0; |
| 274 |
e.e.info1->s = &s; |
| 275 |
s.path = NULL; |
| 276 |
|
| 277 |
torture_comment(tctx, "Testing EnumEx level %u on '%s'\n", level, dfs_name); |
| 278 |
|
| 279 |
torture_assert_ntstatus_ok(tctx, |
| 280 |
dcerpc_dfs_EnumEx_r(b, tctx, &rex), |
| 281 |
"EnumEx failed"); |
| 282 |
torture_assert_werr_ok(tctx, rex.out.result, |
| 283 |
"EnumEx failed"); |
| 284 |
|
| 285 |
if (level == 1 && rex.out.total) { |
| 286 |
int i; |
| 287 |
for (i=0;i<*rex.out.total;i++) { |
| 288 |
const char *root = rex.out.info->e.info1->s[i].path; |
| 289 |
if (!test_GetInfo(tctx, b, root)) { |
| 290 |
ret = false; |
| 291 |
} |
| 292 |
} |
| 293 |
} |
| 294 |
|
| 295 |
if (level == 300 && rex.out.total) { |
| 296 |
int i,k; |
| 297 |
for (i=0;i<*rex.out.total;i++) { |
| 298 |
uint16_t levels[] = {1, 2, 3, 4, 200}; /* 300 */ |
| 299 |
const char *root = rex.out.info->e.info300->s[i].dom_root; |
| 300 |
for (k=0;k<ARRAY_SIZE(levels);k++) { |
| 301 |
if (!test_EnumLevelEx(tctx, b, |
| 302 |
levels[k], root)) |
| 303 |
{ |
| 304 |
ret = false; |
| 305 |
} |
| 306 |
} |
| 307 |
if (!test_GetInfo(tctx, b, root)) { |
| 308 |
ret = false; |
| 309 |
} |
| 310 |
} |
| 311 |
} |
| 312 |
|
| 313 |
return ret; |
| 314 |
} |
| 315 |
|
| 316 |
|
| 317 |
static bool test_EnumLevel(struct torture_context *tctx, |
| 318 |
struct dcerpc_binding_handle *b, |
| 319 |
uint16_t level) |
| 320 |
{ |
| 321 |
struct dfs_Enum r; |
| 322 |
uint32_t total=0; |
| 323 |
struct dfs_EnumStruct e; |
| 324 |
struct dfs_Info1 s; |
| 325 |
struct dfs_EnumArray1 e1; |
| 326 |
bool ret = true; |
| 327 |
|
| 328 |
r.in.level = level; |
| 329 |
r.in.bufsize = (uint32_t)-1; |
| 330 |
r.in.total = &total; |
| 331 |
r.in.info = &e; |
| 332 |
|
| 333 |
e.level = r.in.level; |
| 334 |
e.e.info1 = &e1; |
| 335 |
e.e.info1->count = 0; |
| 336 |
e.e.info1->s = &s; |
| 337 |
s.path = NULL; |
| 338 |
|
| 339 |
torture_comment(tctx, "Testing Enum level %u\n", level); |
| 340 |
|
| 341 |
torture_assert_ntstatus_ok(tctx, |
| 342 |
dcerpc_dfs_Enum_r(b, tctx, &r), |
| 343 |
"Enum failed"); |
| 344 |
|
| 345 |
if (!W_ERROR_IS_OK(r.out.result) && |
| 346 |
!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result)) { |
| 347 |
torture_warning(tctx, "dfs_Enum failed - %s\n", win_errstr(r.out.result)); |
| 348 |
return false; |
| 349 |
} |
| 350 |
|
| 351 |
if (level == 1 && r.out.total) { |
| 352 |
int i; |
| 353 |
for (i=0;i<*r.out.total;i++) { |
| 354 |
const char *root = r.out.info->e.info1->s[i].path; |
| 355 |
if (!test_GetInfo(tctx, b, root)) { |
| 356 |
ret = false; |
| 357 |
} |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
return ret; |
| 362 |
} |
| 363 |
|
| 364 |
|
| 365 |
static bool test_Enum(struct torture_context *tctx, |
| 366 |
struct dcerpc_pipe *p) |
| 367 |
{ |
| 368 |
bool ret = true; |
| 369 |
uint16_t levels[] = {1, 2, 3, 4, 5, 6, 200, 300}; |
| 370 |
int i; |
| 371 |
struct dcerpc_binding_handle *b = p->binding_handle; |
| 372 |
|
| 373 |
for (i=0;i<ARRAY_SIZE(levels);i++) { |
| 374 |
if (!test_EnumLevel(tctx, b, levels[i])) { |
| 375 |
ret = false; |
| 376 |
} |
| 377 |
} |
| 378 |
|
| 379 |
return ret; |
| 380 |
} |
| 381 |
|
| 382 |
static bool test_EnumEx(struct torture_context *tctx, |
| 383 |
struct dcerpc_pipe *p) |
| 384 |
{ |
| 385 |
bool ret = true; |
| 386 |
uint16_t levels[] = {1, 2, 3, 4, 5, 6, 200, 300}; |
| 387 |
int i; |
| 388 |
struct dcerpc_binding_handle *b = p->binding_handle; |
| 389 |
const char *host = torture_setting_string(tctx, "host", NULL); |
| 390 |
|
| 391 |
for (i=0;i<ARRAY_SIZE(levels);i++) { |
| 392 |
if (!test_EnumLevelEx(tctx, b, levels[i], host)) { |
| 393 |
ret = false; |
| 394 |
} |
| 395 |
} |
| 396 |
|
| 397 |
return ret; |
| 398 |
} |
| 399 |
|
| 400 |
static bool test_RemoveStdRoot(struct torture_context *tctx, |
| 401 |
struct dcerpc_binding_handle *b, |
| 402 |
const char *host, |
| 403 |
const char *sharename) |
| 404 |
{ |
| 405 |
struct dfs_RemoveStdRoot r; |
| 406 |
|
| 407 |
torture_comment(tctx, "Testing RemoveStdRoot\n"); |
| 408 |
|
| 409 |
r.in.servername = host; |
| 410 |
r.in.rootshare = sharename; |
| 411 |
r.in.flags = 0; |
| 412 |
|
| 413 |
torture_assert_ntstatus_ok(tctx, |
| 414 |
dcerpc_dfs_RemoveStdRoot_r(b, tctx, &r), |
| 415 |
"RemoveStdRoot failed"); |
| 416 |
torture_assert_werr_ok(tctx, r.out.result, |
| 417 |
"dfs_RemoveStdRoot failed"); |
| 418 |
|
| 419 |
return true; |
| 420 |
} |
| 421 |
|
| 422 |
static bool test_AddStdRoot(struct torture_context *tctx, |
| 423 |
struct dcerpc_binding_handle *b, |
| 424 |
const char *host, |
| 425 |
const char *sharename) |
| 426 |
{ |
| 427 |
struct dfs_AddStdRoot r; |
| 428 |
|
| 429 |
torture_comment(tctx, "Testing AddStdRoot\n"); |
| 430 |
|
| 431 |
r.in.servername = host; |
| 432 |
r.in.rootshare = sharename; |
| 433 |
r.in.comment = "standard dfs standalone DFS root created by smbtorture (dfs_AddStdRoot)"; |
| 434 |
r.in.flags = 0; |
| 435 |
|
| 436 |
torture_assert_ntstatus_ok(tctx, |
| 437 |
dcerpc_dfs_AddStdRoot_r(b, tctx, &r), |
| 438 |
"AddStdRoot failed"); |
| 439 |
torture_assert_werr_ok(tctx, r.out.result, |
| 440 |
"AddStdRoot failed"); |
| 441 |
|
| 442 |
return true; |
| 443 |
} |
| 444 |
|
| 445 |
static bool test_AddStdRootForced(struct torture_context *tctx, |
| 446 |
struct dcerpc_binding_handle *b, |
| 447 |
const char *host, |
| 448 |
const char *sharename) |
| 449 |
{ |
| 450 |
struct dfs_AddStdRootForced r; |
| 451 |
enum dfs_ManagerVersion version; |
| 452 |
|
| 453 |
torture_comment(tctx, "Testing AddStdRootForced\n"); |
| 454 |
|
| 455 |
torture_assert(tctx, |
| 456 |
test_GetManagerVersion_opts(tctx, b, &version), |
| 457 |
"GetManagerVersion failed"); |
| 458 |
|
| 459 |
r.in.servername = host; |
| 460 |
r.in.rootshare = sharename; |
| 461 |
r.in.comment = "standard dfs forced standalone DFS root created by smbtorture (dfs_AddStdRootForced)"; |
| 462 |
r.in.store = SMBTORTURE_DFS_PATHNAME; |
| 463 |
|
| 464 |
torture_assert_ntstatus_ok(tctx, |
| 465 |
dcerpc_dfs_AddStdRootForced_r(b, tctx, &r), |
| 466 |
"AddStdRootForced failed"); |
| 467 |
if (!W_ERROR_IS_OK(r.out.result)) { |
| 468 |
torture_warning(tctx, "dfs_AddStdRootForced failed - %s\n", |
| 469 |
win_errstr(r.out.result)); |
| 470 |
IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3(version, r.out.result); |
| 471 |
return false; |
| 472 |
} |
| 473 |
|
| 474 |
return test_RemoveStdRoot(tctx, b, host, sharename); |
| 475 |
} |
| 476 |
|
| 477 |
static void test_cleanup_stdroot(struct torture_context *tctx, |
| 478 |
struct dcerpc_binding_handle *b, |
| 479 |
const char *host, |
| 480 |
const char *sharename, |
| 481 |
const char *dir) |
| 482 |
{ |
| 483 |
struct smbcli_state *cli; |
| 484 |
|
| 485 |
torture_comment(tctx, "Cleaning up StdRoot\n"); |
| 486 |
|
| 487 |
test_RemoveStdRoot(tctx, b, host, sharename); |
| 488 |
test_NetShareDel(tctx, host, sharename); |
| 489 |
if (torture_open_connection_share(tctx, &cli, tctx, host, "C$", tctx->ev)) { |
| 490 |
test_DeleteDir(tctx, cli, dir); |
| 491 |
torture_close_connection(cli); |
| 492 |
} |
| 493 |
} |
| 494 |
|
| 495 |
static bool test_StdRoot(struct torture_context *tctx, |
| 496 |
struct dcerpc_pipe *p) |
| 497 |
{ |
| 498 |
const char *sharename = SMBTORTURE_DFS_SHARENAME; |
| 499 |
const char *dir = SMBTORTURE_DFS_DIRNAME; |
| 500 |
const char *path = SMBTORTURE_DFS_PATHNAME; |
| 501 |
struct smbcli_state *cli; |
| 502 |
bool ret = true; |
| 503 |
const char *host = torture_setting_string(tctx, "host", NULL); |
| 504 |
struct dcerpc_binding_handle *b = p->binding_handle; |
| 505 |
|
| 506 |
torture_comment(tctx, "Testing StdRoot\n"); |
| 507 |
|
| 508 |
test_cleanup_stdroot(tctx, b, host, sharename, dir); |
| 509 |
|
| 510 |
torture_assert(tctx, |
| 511 |
test_CreateDir(tctx, &cli, tctx, host, "C$", dir), |
| 512 |
"failed to connect C$ share and to create directory"); |
| 513 |
torture_assert(tctx, |
| 514 |
test_NetShareAdd(tctx, host, sharename, path), |
| 515 |
"failed to create new share"); |
| 516 |
|
| 517 |
ret &= test_AddStdRoot(tctx, b, host, sharename); |
| 518 |
ret &= test_RemoveStdRoot(tctx, b, host, sharename); |
| 519 |
ret &= test_AddStdRootForced(tctx, b, host, sharename); |
| 520 |
ret &= test_NetShareDel(tctx, host, sharename); |
| 521 |
ret &= test_DeleteDir(tctx, cli, dir); |
| 522 |
|
| 523 |
torture_close_connection(cli); |
| 524 |
|
| 525 |
return ret; |
| 526 |
} |
| 527 |
|
| 528 |
static bool test_GetDcAddress(struct torture_context *tctx, |
| 529 |
struct dcerpc_binding_handle *b, |
| 530 |
const char *host) |
| 531 |
{ |
| 532 |
struct dfs_GetDcAddress r; |
| 533 |
uint8_t is_root = 0; |
| 534 |
uint32_t ttl = 0; |
| 535 |
const char *ptr; |
| 536 |
|
| 537 |
torture_comment(tctx, "Testing GetDcAddress\n"); |
| 538 |
|
| 539 |
ptr = host; |
| 540 |
|
| 541 |
r.in.servername = host; |
| 542 |
r.in.server_fullname = r.out.server_fullname = &ptr; |
| 543 |
r.in.is_root = r.out.is_root = &is_root; |
| 544 |
r.in.ttl = r.out.ttl = &ttl; |
| 545 |
|
| 546 |
torture_assert_ntstatus_ok(tctx, |
| 547 |
dcerpc_dfs_GetDcAddress_r(b, tctx, &r), |
| 548 |
"GetDcAddress failed"); |
| 549 |
torture_assert_werr_ok(tctx, r.out.result, |
| 550 |
"dfs_GetDcAddress failed"); |
| 551 |
|
| 552 |
return true; |
| 553 |
} |
| 554 |
|
| 555 |
static bool test_SetDcAddress(struct torture_context *tctx, |
| 556 |
struct dcerpc_binding_handle *b, |
| 557 |
const char *host) |
| 558 |
{ |
| 559 |
struct dfs_SetDcAddress r; |
| 560 |
|
| 561 |
torture_comment(tctx, "Testing SetDcAddress\n"); |
| 562 |
|
| 563 |
r.in.servername = host; |
| 564 |
r.in.server_fullname = host; |
| 565 |
r.in.flags = 0; |
| 566 |
r.in.ttl = 1000; |
| 567 |
|
| 568 |
torture_assert_ntstatus_ok(tctx, |
| 569 |
dcerpc_dfs_SetDcAddress_r(b, tctx, &r), |
| 570 |
"SetDcAddress failed"); |
| 571 |
torture_assert_werr_ok(tctx, r.out.result, |
| 572 |
"dfs_SetDcAddress failed"); |
| 573 |
|
| 574 |
return true; |
| 575 |
} |
| 576 |
|
| 577 |
static bool test_DcAddress(struct torture_context *tctx, |
| 578 |
struct dcerpc_pipe *p) |
| 579 |
{ |
| 580 |
const char *host = torture_setting_string(tctx, "host", NULL); |
| 581 |
struct dcerpc_binding_handle *b = p->binding_handle; |
| 582 |
|
| 583 |
if (!test_GetDcAddress(tctx, b, host)) { |
| 584 |
return false; |
| 585 |
} |
| 586 |
|
| 587 |
if (!test_SetDcAddress(tctx, b, host)) { |
| 588 |
return false; |
| 589 |
} |
| 590 |
|
| 591 |
return true; |
| 592 |
} |
| 593 |
|
| 594 |
static bool test_FlushFtTable(struct torture_context *tctx, |
| 595 |
struct dcerpc_binding_handle *b, |
| 596 |
const char *host, |
| 597 |
const char *sharename) |
| 598 |
{ |
| 599 |
struct dfs_FlushFtTable r; |
| 600 |
enum dfs_ManagerVersion version; |
| 601 |
|
| 602 |
torture_comment(tctx, "Testing FlushFtTable\n"); |
| 603 |
|
| 604 |
torture_assert(tctx, |
| 605 |
test_GetManagerVersion_opts(tctx, b, &version), |
| 606 |
"GetManagerVersion failed"); |
| 607 |
|
| 608 |
r.in.servername = host; |
| 609 |
r.in.rootshare = sharename; |
| 610 |
|
| 611 |
torture_assert_ntstatus_ok(tctx, |
| 612 |
dcerpc_dfs_FlushFtTable_r(b, tctx, &r), |
| 613 |
"FlushFtTable failed"); |
| 614 |
if (!W_ERROR_IS_OK(r.out.result)) { |
| 615 |
torture_warning(tctx, "dfs_FlushFtTable failed - %s\n", |
| 616 |
win_errstr(r.out.result)); |
| 617 |
IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3(version, r.out.result); |
| 618 |
return false; |
| 619 |
} |
| 620 |
|
| 621 |
return true; |
| 622 |
} |
| 623 |
|
| 624 |
static bool test_FtRoot(struct torture_context *tctx, |
| 625 |
struct dcerpc_pipe *p) |
| 626 |
{ |
| 627 |
const char *sharename = SMBTORTURE_DFS_SHARENAME; |
| 628 |
const char *host = torture_setting_string(tctx, "host", NULL); |
| 629 |
struct dcerpc_binding_handle *b = p->binding_handle; |
| 630 |
|
| 631 |
return test_FlushFtTable(tctx, b, host, sharename); |
| 632 |
} |
| 633 |
|
| 634 |
struct torture_suite *torture_rpc_dfs(TALLOC_CTX *mem_ctx) |
| 635 |
{ |
| 636 |
struct torture_rpc_tcase *tcase; |
| 637 |
struct torture_suite *suite = torture_suite_create(mem_ctx, "dfs"); |
| 638 |
|
| 639 |
tcase = torture_suite_add_rpc_iface_tcase(suite, "netdfs", |
| 640 |
&ndr_table_netdfs); |
| 641 |
|
| 642 |
torture_rpc_tcase_add_test(tcase, "GetManagerVersion", test_GetManagerVersion); |
| 643 |
torture_rpc_tcase_add_test(tcase, "ManagerInitialize", test_ManagerInitialize); |
| 644 |
torture_rpc_tcase_add_test(tcase, "Enum", test_Enum); |
| 645 |
torture_rpc_tcase_add_test(tcase, "EnumEx", test_EnumEx); |
| 646 |
torture_rpc_tcase_add_test(tcase, "StdRoot", test_StdRoot); |
| 647 |
torture_rpc_tcase_add_test(tcase, "FtRoot", test_FtRoot); |
| 648 |
torture_rpc_tcase_add_test(tcase, "DcAddress", test_DcAddress); |
| 649 |
|
| 650 |
return suite; |
| 651 |
} |