| 1 | /*
|
|---|
| 2 | Unix SMB/CIFS implementation.
|
|---|
| 3 | test suite for wkssvc rpc operations
|
|---|
| 4 |
|
|---|
| 5 | Copyright (C) Andrew Tridgell 2003
|
|---|
| 6 | Copyright (C) GÃŒnther Deschner 2007
|
|---|
| 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 "torture/torture.h"
|
|---|
| 24 | #include "librpc/gen_ndr/ndr_wkssvc_c.h"
|
|---|
| 25 | #include "torture/rpc/rpc.h"
|
|---|
| 26 | #include "lib/cmdline/popt_common.h"
|
|---|
| 27 | #include "param/param.h"
|
|---|
| 28 | #include "../lib/crypto/crypto.h"
|
|---|
| 29 | #include "libcli/auth/libcli_auth.h"
|
|---|
| 30 |
|
|---|
| 31 | #define SMBTORTURE_MACHINE_NAME "smbtrt_name"
|
|---|
| 32 | #define SMBTORTURE_ALTERNATE_NAME "smbtrt_altname"
|
|---|
| 33 | #define SMBTORTURE_TRANSPORT_NAME "\\Device\\smbtrt_transport_name"
|
|---|
| 34 | #define SMBTORTURE_USE_NAME "S:"
|
|---|
| 35 | #define SMBTORTURE_MESSAGE "You are currently tortured by Samba"
|
|---|
| 36 |
|
|---|
| 37 | static bool test_NetWkstaGetInfo(struct torture_context *tctx,
|
|---|
| 38 | struct dcerpc_pipe *p)
|
|---|
| 39 | {
|
|---|
| 40 | NTSTATUS status;
|
|---|
| 41 | struct wkssvc_NetWkstaGetInfo r;
|
|---|
| 42 | union wkssvc_NetWkstaInfo info;
|
|---|
| 43 | uint16_t levels[] = {100, 101, 102, 502};
|
|---|
| 44 | int i;
|
|---|
| 45 |
|
|---|
| 46 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 47 | r.out.info = &info;
|
|---|
| 48 |
|
|---|
| 49 | for (i=0;i<ARRAY_SIZE(levels);i++) {
|
|---|
| 50 | r.in.level = levels[i];
|
|---|
| 51 | torture_comment(tctx, "testing NetWkstaGetInfo level %u\n",
|
|---|
| 52 | r.in.level);
|
|---|
| 53 | status = dcerpc_wkssvc_NetWkstaGetInfo(p, tctx, &r);
|
|---|
| 54 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 55 | talloc_asprintf(tctx, "NetWkstaGetInfo level %u failed",
|
|---|
| 56 | r.in.level));
|
|---|
| 57 | torture_assert_werr_ok(tctx, r.out.result,
|
|---|
| 58 | talloc_asprintf(tctx, "NetWkstaGetInfo level %u failed",
|
|---|
| 59 | r.in.level));
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | return true;
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | static bool test_NetWkstaTransportEnum(struct torture_context *tctx,
|
|---|
| 66 | struct dcerpc_pipe *p)
|
|---|
| 67 | {
|
|---|
| 68 | NTSTATUS status;
|
|---|
| 69 | struct wkssvc_NetWkstaTransportEnum r;
|
|---|
| 70 | uint32_t resume_handle = 0;
|
|---|
| 71 | struct wkssvc_NetWkstaTransportInfo info;
|
|---|
| 72 | union wkssvc_NetWkstaTransportCtr ctr;
|
|---|
| 73 | struct wkssvc_NetWkstaTransportCtr0 ctr0;
|
|---|
| 74 | uint32_t total_entries = 0;
|
|---|
| 75 |
|
|---|
| 76 | ZERO_STRUCT(ctr0);
|
|---|
| 77 | ctr.ctr0 = &ctr0;
|
|---|
| 78 |
|
|---|
| 79 | info.level = 0;
|
|---|
| 80 | info.ctr = ctr;
|
|---|
| 81 |
|
|---|
| 82 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 83 | r.in.info = &info;
|
|---|
| 84 | r.in.max_buffer = (uint32_t)-1;
|
|---|
| 85 | r.in.resume_handle = &resume_handle;
|
|---|
| 86 | r.out.total_entries = &total_entries;
|
|---|
| 87 | r.out.info = &info;
|
|---|
| 88 | r.out.resume_handle = &resume_handle;
|
|---|
| 89 |
|
|---|
| 90 | torture_comment(tctx, "testing NetWkstaTransportEnum level 0\n");
|
|---|
| 91 |
|
|---|
| 92 | status = dcerpc_wkssvc_NetWkstaTransportEnum(p, tctx, &r);
|
|---|
| 93 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 94 | "NetWkstaTransportEnum failed");
|
|---|
| 95 | torture_assert_werr_ok(tctx, r.out.result, talloc_asprintf(tctx,
|
|---|
| 96 | "NetWkstaTransportEnum level %u failed",
|
|---|
| 97 | info.level));
|
|---|
| 98 |
|
|---|
| 99 | return true;
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | static bool test_NetrWkstaTransportAdd(struct torture_context *tctx,
|
|---|
| 103 | struct dcerpc_pipe *p)
|
|---|
| 104 | {
|
|---|
| 105 | NTSTATUS status;
|
|---|
| 106 | struct wkssvc_NetrWkstaTransportAdd r;
|
|---|
| 107 | struct wkssvc_NetWkstaTransportInfo0 info0;
|
|---|
| 108 | uint32_t parm_err = 0;
|
|---|
| 109 |
|
|---|
| 110 | ZERO_STRUCT(info0);
|
|---|
| 111 |
|
|---|
| 112 | info0.quality_of_service = 0xffff;
|
|---|
| 113 | info0.vc_count = 0;
|
|---|
| 114 | info0.name = SMBTORTURE_TRANSPORT_NAME;
|
|---|
| 115 | info0.address = "000000000000";
|
|---|
| 116 | info0.wan_link = 0x400;
|
|---|
| 117 |
|
|---|
| 118 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 119 | r.in.level = 0;
|
|---|
| 120 | r.in.info0 = &info0;
|
|---|
| 121 | r.in.parm_err = r.out.parm_err = &parm_err;
|
|---|
| 122 |
|
|---|
| 123 | torture_comment(tctx, "testing NetrWkstaTransportAdd level 0\n");
|
|---|
| 124 |
|
|---|
| 125 | status = dcerpc_wkssvc_NetrWkstaTransportAdd(p, tctx, &r);
|
|---|
| 126 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 127 | "NetrWkstaTransportAdd failed");
|
|---|
| 128 | torture_assert_werr_equal(tctx, r.out.result,
|
|---|
| 129 | WERR_INVALID_PARAM,
|
|---|
| 130 | "NetrWkstaTransportAdd level 0 failed");
|
|---|
| 131 |
|
|---|
| 132 | return true;
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | static bool test_NetrWkstaTransportDel(struct torture_context *tctx,
|
|---|
| 136 | struct dcerpc_pipe *p)
|
|---|
| 137 | {
|
|---|
| 138 | NTSTATUS status;
|
|---|
| 139 | struct wkssvc_NetrWkstaTransportDel r;
|
|---|
| 140 |
|
|---|
| 141 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 142 | r.in.transport_name = SMBTORTURE_TRANSPORT_NAME;
|
|---|
| 143 | r.in.unknown3 = 0;
|
|---|
| 144 |
|
|---|
| 145 | torture_comment(tctx, "testing NetrWkstaTransportDel\n");
|
|---|
| 146 |
|
|---|
| 147 | status = dcerpc_wkssvc_NetrWkstaTransportDel(p, tctx, &r);
|
|---|
| 148 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 149 | "NetrWkstaTransportDel failed");
|
|---|
| 150 | torture_assert_werr_ok(tctx, r.out.result,
|
|---|
| 151 | "NetrWkstaTransportDel");
|
|---|
| 152 |
|
|---|
| 153 | return true;
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | static bool test_NetWkstaEnumUsers(struct torture_context *tctx,
|
|---|
| 157 | struct dcerpc_pipe *p)
|
|---|
| 158 | {
|
|---|
| 159 | NTSTATUS status;
|
|---|
| 160 | struct wkssvc_NetWkstaEnumUsers r;
|
|---|
| 161 | uint32_t handle = 0;
|
|---|
| 162 | uint32_t entries_read = 0;
|
|---|
| 163 | struct wkssvc_NetWkstaEnumUsersInfo info;
|
|---|
| 164 | struct wkssvc_NetWkstaEnumUsersCtr0 *user0;
|
|---|
| 165 | struct wkssvc_NetWkstaEnumUsersCtr1 *user1;
|
|---|
| 166 | uint32_t levels[] = { 0, 1 };
|
|---|
| 167 | int i;
|
|---|
| 168 |
|
|---|
| 169 | for (i=0; i<ARRAY_SIZE(levels); i++) {
|
|---|
| 170 |
|
|---|
| 171 | ZERO_STRUCT(info);
|
|---|
| 172 |
|
|---|
| 173 | info.level = levels[i];
|
|---|
| 174 | switch (info.level) {
|
|---|
| 175 | case 0:
|
|---|
| 176 | user0 = talloc_zero(tctx,
|
|---|
| 177 | struct wkssvc_NetWkstaEnumUsersCtr0);
|
|---|
| 178 | info.ctr.user0 = user0;
|
|---|
| 179 | break;
|
|---|
| 180 | case 1:
|
|---|
| 181 | user1 = talloc_zero(tctx,
|
|---|
| 182 | struct wkssvc_NetWkstaEnumUsersCtr1);
|
|---|
| 183 | info.ctr.user1 = user1;
|
|---|
| 184 | break;
|
|---|
| 185 | default:
|
|---|
| 186 | break;
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 190 | r.in.prefmaxlen = (uint32_t)-1;
|
|---|
| 191 | r.in.info = r.out.info = &info;
|
|---|
| 192 | r.in.resume_handle = r.out.resume_handle = &handle;
|
|---|
| 193 |
|
|---|
| 194 | r.out.entries_read = &entries_read;
|
|---|
| 195 |
|
|---|
| 196 | torture_comment(tctx, "testing NetWkstaEnumUsers level %u\n",
|
|---|
| 197 | levels[i]);
|
|---|
| 198 |
|
|---|
| 199 | status = dcerpc_wkssvc_NetWkstaEnumUsers(p, tctx, &r);
|
|---|
| 200 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 201 | "NetWkstaEnumUsers failed");
|
|---|
| 202 | torture_assert_werr_ok(tctx, r.out.result,
|
|---|
| 203 | "NetWkstaEnumUsers failed");
|
|---|
| 204 | }
|
|---|
| 205 |
|
|---|
| 206 | return true;
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | static bool test_NetrWkstaUserGetInfo(struct torture_context *tctx,
|
|---|
| 210 | struct dcerpc_pipe *p)
|
|---|
| 211 | {
|
|---|
| 212 | NTSTATUS status;
|
|---|
| 213 | struct wkssvc_NetrWkstaUserGetInfo r;
|
|---|
| 214 | union wkssvc_NetrWkstaUserInfo info;
|
|---|
| 215 | const char *dom = lp_workgroup(tctx->lp_ctx);
|
|---|
| 216 | struct cli_credentials *creds = cmdline_credentials;
|
|---|
| 217 | const char *user = cli_credentials_get_username(creds);
|
|---|
| 218 | int i;
|
|---|
| 219 |
|
|---|
| 220 | const struct {
|
|---|
| 221 | const char *unknown;
|
|---|
| 222 | uint32_t level;
|
|---|
| 223 | WERROR result;
|
|---|
| 224 | } tests[] = {
|
|---|
| 225 | { NULL, 0, WERR_NO_SUCH_LOGON_SESSION },
|
|---|
| 226 | { NULL, 1, WERR_NO_SUCH_LOGON_SESSION },
|
|---|
| 227 | { NULL, 1101, WERR_OK },
|
|---|
| 228 | { dom, 0, WERR_INVALID_PARAM },
|
|---|
| 229 | { dom, 1, WERR_INVALID_PARAM },
|
|---|
| 230 | { dom, 1101, WERR_INVALID_PARAM },
|
|---|
| 231 | { user, 0, WERR_INVALID_PARAM },
|
|---|
| 232 | { user, 1, WERR_INVALID_PARAM },
|
|---|
| 233 | { user, 1101, WERR_INVALID_PARAM },
|
|---|
| 234 | };
|
|---|
| 235 |
|
|---|
| 236 | for (i=0; i<ARRAY_SIZE(tests); i++) {
|
|---|
| 237 | r.in.unknown = tests[i].unknown;
|
|---|
| 238 | r.in.level = tests[i].level;
|
|---|
| 239 | r.out.info = &info;
|
|---|
| 240 |
|
|---|
| 241 | torture_comment(tctx, "testing NetrWkstaUserGetInfo level %u\n",
|
|---|
| 242 | r.in.level);
|
|---|
| 243 |
|
|---|
| 244 | status = dcerpc_wkssvc_NetrWkstaUserGetInfo(p, tctx, &r);
|
|---|
| 245 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 246 | "NetrWkstaUserGetInfo failed");
|
|---|
| 247 | torture_assert_werr_equal(tctx, r.out.result,
|
|---|
| 248 | tests[i].result,
|
|---|
| 249 | "NetrWkstaUserGetInfo failed");
|
|---|
| 250 | }
|
|---|
| 251 |
|
|---|
| 252 | return true;
|
|---|
| 253 | }
|
|---|
| 254 |
|
|---|
| 255 | static bool test_NetrUseEnum(struct torture_context *tctx,
|
|---|
| 256 | struct dcerpc_pipe *p)
|
|---|
| 257 | {
|
|---|
| 258 | NTSTATUS status;
|
|---|
| 259 | struct wkssvc_NetrUseEnum r;
|
|---|
| 260 | uint32_t handle = 0;
|
|---|
| 261 | uint32_t entries_read = 0;
|
|---|
| 262 | struct wkssvc_NetrUseEnumInfo info;
|
|---|
| 263 | struct wkssvc_NetrUseEnumCtr0 *use0;
|
|---|
| 264 | struct wkssvc_NetrUseEnumCtr1 *use1;
|
|---|
| 265 | struct wkssvc_NetrUseEnumCtr2 *use2;
|
|---|
| 266 | uint32_t levels[] = { 0, 1, 2 };
|
|---|
| 267 | int i;
|
|---|
| 268 |
|
|---|
| 269 | for (i=0; i<ARRAY_SIZE(levels); i++) {
|
|---|
| 270 |
|
|---|
| 271 | ZERO_STRUCT(info);
|
|---|
| 272 |
|
|---|
| 273 | info.level = levels[i];
|
|---|
| 274 | switch (info.level) {
|
|---|
| 275 | case 0:
|
|---|
| 276 | use0 = talloc_zero(tctx, struct wkssvc_NetrUseEnumCtr0);
|
|---|
| 277 | info.ctr.ctr0 = use0;
|
|---|
| 278 | break;
|
|---|
| 279 | case 1:
|
|---|
| 280 | use1 = talloc_zero(tctx, struct wkssvc_NetrUseEnumCtr1);
|
|---|
| 281 | info.ctr.ctr1 = use1;
|
|---|
| 282 | break;
|
|---|
| 283 | case 2:
|
|---|
| 284 | use2 = talloc_zero(tctx, struct wkssvc_NetrUseEnumCtr2);
|
|---|
| 285 | info.ctr.ctr2 = use2;
|
|---|
| 286 | break;
|
|---|
| 287 | default:
|
|---|
| 288 | break;
|
|---|
| 289 | }
|
|---|
| 290 |
|
|---|
| 291 | r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
|
|---|
| 292 | r.in.prefmaxlen = (uint32_t)-1;
|
|---|
| 293 | r.in.info = r.out.info = &info;
|
|---|
| 294 | r.in.resume_handle = r.out.resume_handle = &handle;
|
|---|
| 295 |
|
|---|
| 296 | r.out.entries_read = &entries_read;
|
|---|
| 297 |
|
|---|
| 298 | torture_comment(tctx, "testing NetrUseEnum level %u\n",
|
|---|
| 299 | levels[i]);
|
|---|
| 300 |
|
|---|
| 301 | status = dcerpc_wkssvc_NetrUseEnum(p, tctx, &r);
|
|---|
| 302 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 303 | "NetrUseEnum failed");
|
|---|
| 304 | torture_assert_werr_ok(tctx, r.out.result,
|
|---|
| 305 | "NetrUseEnum failed");
|
|---|
| 306 | }
|
|---|
| 307 |
|
|---|
| 308 | return true;
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | static bool test_NetrUseAdd(struct torture_context *tctx,
|
|---|
| 312 | struct dcerpc_pipe *p)
|
|---|
| 313 | {
|
|---|
| 314 | NTSTATUS status;
|
|---|
| 315 | struct wkssvc_NetrUseAdd r;
|
|---|
| 316 | struct wkssvc_NetrUseInfo0 info0;
|
|---|
| 317 | struct wkssvc_NetrUseInfo1 info1;
|
|---|
| 318 | union wkssvc_NetrUseGetInfoCtr *ctr;
|
|---|
| 319 | uint32_t parm_err = 0;
|
|---|
| 320 |
|
|---|
| 321 | ctr = talloc(tctx, union wkssvc_NetrUseGetInfoCtr);
|
|---|
| 322 |
|
|---|
| 323 | ZERO_STRUCT(info0);
|
|---|
| 324 |
|
|---|
| 325 | info0.local = SMBTORTURE_USE_NAME;
|
|---|
| 326 | info0.remote = "\\\\localhost\\c$";
|
|---|
| 327 |
|
|---|
| 328 | ctr->info0 = &info0;
|
|---|
| 329 |
|
|---|
| 330 | r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
|
|---|
| 331 | r.in.level = 0;
|
|---|
| 332 | r.in.ctr = ctr;
|
|---|
| 333 | r.in.parm_err = r.out.parm_err = &parm_err;
|
|---|
| 334 |
|
|---|
| 335 | torture_comment(tctx, "testing NetrUseAdd level %u\n",
|
|---|
| 336 | r.in.level);
|
|---|
| 337 |
|
|---|
| 338 | status = dcerpc_wkssvc_NetrUseAdd(p, tctx, &r);
|
|---|
| 339 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 340 | "NetrUseAdd failed");
|
|---|
| 341 | torture_assert_werr_equal(tctx, r.out.result, WERR_UNKNOWN_LEVEL,
|
|---|
| 342 | "NetrUseAdd failed");
|
|---|
| 343 |
|
|---|
| 344 | ZERO_STRUCT(r);
|
|---|
| 345 | ZERO_STRUCT(info1);
|
|---|
| 346 |
|
|---|
| 347 | info1.local = SMBTORTURE_USE_NAME;
|
|---|
| 348 | info1.remote = "\\\\localhost\\sysvol";
|
|---|
| 349 | info1.password = NULL;
|
|---|
| 350 |
|
|---|
| 351 | ctr->info1 = &info1;
|
|---|
| 352 |
|
|---|
| 353 | r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
|
|---|
| 354 | r.in.level = 1;
|
|---|
| 355 | r.in.ctr = ctr;
|
|---|
| 356 | r.in.parm_err = r.out.parm_err = &parm_err;
|
|---|
| 357 |
|
|---|
| 358 | torture_comment(tctx, "testing NetrUseAdd level %u\n",
|
|---|
| 359 | r.in.level);
|
|---|
| 360 |
|
|---|
| 361 | status = dcerpc_wkssvc_NetrUseAdd(p, tctx, &r);
|
|---|
| 362 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 363 | "NetrUseAdd failed");
|
|---|
| 364 | torture_assert_werr_ok(tctx, r.out.result,
|
|---|
| 365 | "NetrUseAdd failed");
|
|---|
| 366 |
|
|---|
| 367 | return true;
|
|---|
| 368 | }
|
|---|
| 369 |
|
|---|
| 370 | static bool test_NetrUseDel(struct torture_context *tctx,
|
|---|
| 371 | struct dcerpc_pipe *p)
|
|---|
| 372 | {
|
|---|
| 373 | NTSTATUS status;
|
|---|
| 374 | struct wkssvc_NetrUseDel r;
|
|---|
| 375 |
|
|---|
| 376 | r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
|
|---|
| 377 | r.in.use_name = SMBTORTURE_USE_NAME;
|
|---|
| 378 | r.in.force_cond = 0;
|
|---|
| 379 |
|
|---|
| 380 | torture_comment(tctx, "testing NetrUseDel\n");
|
|---|
| 381 |
|
|---|
| 382 | status = dcerpc_wkssvc_NetrUseDel(p, tctx, &r);
|
|---|
| 383 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 384 | "NetrUseDel failed");
|
|---|
| 385 | torture_assert_werr_ok(tctx, r.out.result,
|
|---|
| 386 | "NetrUseDel failed");
|
|---|
| 387 | return true;
|
|---|
| 388 | }
|
|---|
| 389 |
|
|---|
| 390 | static bool test_NetrUseGetInfo_level(struct torture_context *tctx,
|
|---|
| 391 | struct dcerpc_pipe *p,
|
|---|
| 392 | const char *use_name,
|
|---|
| 393 | uint32_t level,
|
|---|
| 394 | WERROR werr)
|
|---|
| 395 | {
|
|---|
| 396 | NTSTATUS status;
|
|---|
| 397 | struct wkssvc_NetrUseGetInfo r;
|
|---|
| 398 | union wkssvc_NetrUseGetInfoCtr ctr;
|
|---|
| 399 |
|
|---|
| 400 | ZERO_STRUCT(ctr);
|
|---|
| 401 |
|
|---|
| 402 | r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
|
|---|
| 403 | r.in.use_name = use_name;
|
|---|
| 404 | r.in.level = level;
|
|---|
| 405 | r.out.ctr = &ctr;
|
|---|
| 406 | status = dcerpc_wkssvc_NetrUseGetInfo(p, tctx, &r);
|
|---|
| 407 |
|
|---|
| 408 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 409 | "NetrUseGetInfo failed");
|
|---|
| 410 | torture_assert_werr_equal(tctx, r.out.result, werr,
|
|---|
| 411 | "NetrUseGetInfo failed");
|
|---|
| 412 | return true;
|
|---|
| 413 | }
|
|---|
| 414 |
|
|---|
| 415 | static bool test_NetrUseGetInfo(struct torture_context *tctx,
|
|---|
| 416 | struct dcerpc_pipe *p)
|
|---|
| 417 | {
|
|---|
| 418 | NTSTATUS status;
|
|---|
| 419 | struct wkssvc_NetrUseEnum r;
|
|---|
| 420 | uint32_t handle = 0;
|
|---|
| 421 | uint32_t entries_read = 0;
|
|---|
| 422 | struct wkssvc_NetrUseEnumInfo info;
|
|---|
| 423 | struct wkssvc_NetrUseEnumCtr0 *use0;
|
|---|
| 424 | uint32_t levels[] = { 0, 1, 2 };
|
|---|
| 425 | const char *use_name = NULL;
|
|---|
| 426 | int i, k;
|
|---|
| 427 |
|
|---|
| 428 | ZERO_STRUCT(info);
|
|---|
| 429 |
|
|---|
| 430 | info.level = 0;
|
|---|
| 431 | use0 = talloc_zero(tctx, struct wkssvc_NetrUseEnumCtr0);
|
|---|
| 432 | info.ctr.ctr0 = use0;
|
|---|
| 433 |
|
|---|
| 434 | r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
|
|---|
| 435 | r.in.prefmaxlen = (uint32_t)-1;
|
|---|
| 436 | r.in.info = r.out.info = &info;
|
|---|
| 437 | r.in.resume_handle = r.out.resume_handle = &handle;
|
|---|
| 438 | r.out.entries_read = &entries_read;
|
|---|
| 439 |
|
|---|
| 440 | status = dcerpc_wkssvc_NetrUseEnum(p, tctx, &r);
|
|---|
| 441 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 442 | "NetrUseEnum failed");
|
|---|
| 443 | torture_assert_werr_ok(tctx, r.out.result,
|
|---|
| 444 | "NetrUseEnum failed");
|
|---|
| 445 |
|
|---|
| 446 | for (k=0; k < r.out.info->ctr.ctr0->count; k++) {
|
|---|
| 447 |
|
|---|
| 448 | use_name = r.out.info->ctr.ctr0->array[k].local;
|
|---|
| 449 |
|
|---|
| 450 | for (i=0; i<ARRAY_SIZE(levels); i++) {
|
|---|
| 451 |
|
|---|
| 452 | if (!test_NetrUseGetInfo_level(tctx, p, use_name,
|
|---|
| 453 | levels[i],
|
|---|
| 454 | WERR_OK))
|
|---|
| 455 | {
|
|---|
| 456 | if (levels[i] != 0) {
|
|---|
| 457 | return false;
|
|---|
| 458 | }
|
|---|
| 459 | }
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | use_name = r.out.info->ctr.ctr0->array[k].remote;
|
|---|
| 463 |
|
|---|
| 464 | for (i=0; i<ARRAY_SIZE(levels); i++) {
|
|---|
| 465 |
|
|---|
| 466 | if (!test_NetrUseGetInfo_level(tctx, p, use_name,
|
|---|
| 467 | levels[i],
|
|---|
| 468 | WERR_NOT_CONNECTED))
|
|---|
| 469 | {
|
|---|
| 470 | if (levels[i] != 0) {
|
|---|
| 471 | return false;
|
|---|
| 472 | }
|
|---|
| 473 | }
|
|---|
| 474 | }
|
|---|
| 475 | }
|
|---|
| 476 |
|
|---|
| 477 | return true;
|
|---|
| 478 | }
|
|---|
| 479 |
|
|---|
| 480 | static bool test_NetrLogonDomainNameAdd(struct torture_context *tctx,
|
|---|
| 481 | struct dcerpc_pipe *p)
|
|---|
| 482 | {
|
|---|
| 483 | NTSTATUS status;
|
|---|
| 484 | struct wkssvc_NetrLogonDomainNameAdd r;
|
|---|
| 485 |
|
|---|
| 486 | r.in.domain_name = lp_workgroup(tctx->lp_ctx);
|
|---|
| 487 |
|
|---|
| 488 | torture_comment(tctx, "testing NetrLogonDomainNameAdd\n");
|
|---|
| 489 |
|
|---|
| 490 | status = dcerpc_wkssvc_NetrLogonDomainNameAdd(p, tctx, &r);
|
|---|
| 491 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 492 | "NetrLogonDomainNameAdd failed");
|
|---|
| 493 | torture_assert_werr_equal(tctx, r.out.result, WERR_NOT_SUPPORTED,
|
|---|
| 494 | "NetrLogonDomainNameAdd failed");
|
|---|
| 495 | return true;
|
|---|
| 496 | }
|
|---|
| 497 |
|
|---|
| 498 | static bool test_NetrLogonDomainNameDel(struct torture_context *tctx,
|
|---|
| 499 | struct dcerpc_pipe *p)
|
|---|
| 500 | {
|
|---|
| 501 | NTSTATUS status;
|
|---|
| 502 | struct wkssvc_NetrLogonDomainNameDel r;
|
|---|
| 503 |
|
|---|
| 504 | r.in.domain_name = lp_workgroup(tctx->lp_ctx);
|
|---|
| 505 |
|
|---|
| 506 | torture_comment(tctx, "testing NetrLogonDomainNameDel\n");
|
|---|
| 507 |
|
|---|
| 508 | status = dcerpc_wkssvc_NetrLogonDomainNameDel(p, tctx, &r);
|
|---|
| 509 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 510 | "NetrLogonDomainNameDel failed");
|
|---|
| 511 | torture_assert_werr_equal(tctx, r.out.result, WERR_NOT_SUPPORTED,
|
|---|
| 512 | "NetrLogonDomainNameDel failed");
|
|---|
| 513 | return true;
|
|---|
| 514 | }
|
|---|
| 515 |
|
|---|
| 516 | static bool test_NetrEnumerateComputerNames_level(struct torture_context *tctx,
|
|---|
| 517 | struct dcerpc_pipe *p,
|
|---|
| 518 | uint16_t level,
|
|---|
| 519 | const char ***names,
|
|---|
| 520 | int *num_names)
|
|---|
| 521 | {
|
|---|
| 522 | NTSTATUS status;
|
|---|
| 523 | struct wkssvc_NetrEnumerateComputerNames r;
|
|---|
| 524 | struct wkssvc_ComputerNamesCtr *ctr;
|
|---|
| 525 | int i;
|
|---|
| 526 |
|
|---|
| 527 | ctr = talloc_zero(tctx, struct wkssvc_ComputerNamesCtr);
|
|---|
| 528 |
|
|---|
| 529 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 530 | r.in.name_type = level;
|
|---|
| 531 | r.in.Reserved = 0;
|
|---|
| 532 | r.out.ctr = &ctr;
|
|---|
| 533 |
|
|---|
| 534 | torture_comment(tctx, "testing NetrEnumerateComputerNames level %u\n",
|
|---|
| 535 | r.in.name_type);
|
|---|
| 536 |
|
|---|
| 537 | status = dcerpc_wkssvc_NetrEnumerateComputerNames(p, tctx, &r);
|
|---|
| 538 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 539 | "NetrEnumerateComputerNames failed");
|
|---|
| 540 | torture_assert_werr_ok(tctx, r.out.result,
|
|---|
| 541 | "NetrEnumerateComputerNames failed");
|
|---|
| 542 |
|
|---|
| 543 | if ((level == NetPrimaryComputerName) && ctr->count != 1) {
|
|---|
| 544 | torture_comment(tctx,
|
|---|
| 545 | "NetrEnumerateComputerNames did not return one "
|
|---|
| 546 | "name but %u\n", ctr->count);
|
|---|
| 547 | return false;
|
|---|
| 548 | }
|
|---|
| 549 |
|
|---|
| 550 | if (names && num_names) {
|
|---|
| 551 | *num_names = 0;
|
|---|
| 552 | *names = NULL;
|
|---|
| 553 | for (i=0; i<ctr->count; i++) {
|
|---|
| 554 | if (!add_string_to_array(tctx,
|
|---|
| 555 | ctr->computer_name[i].string,
|
|---|
| 556 | names,
|
|---|
| 557 | num_names))
|
|---|
| 558 | {
|
|---|
| 559 | return false;
|
|---|
| 560 | }
|
|---|
| 561 | }
|
|---|
| 562 | }
|
|---|
| 563 |
|
|---|
| 564 | return true;
|
|---|
| 565 | }
|
|---|
| 566 |
|
|---|
| 567 | static bool test_NetrEnumerateComputerNames(struct torture_context *tctx,
|
|---|
| 568 | struct dcerpc_pipe *p)
|
|---|
| 569 | {
|
|---|
| 570 | uint16_t levels[] = {0,1,2};
|
|---|
| 571 | int i;
|
|---|
| 572 |
|
|---|
| 573 | for (i=0; i<ARRAY_SIZE(levels); i++) {
|
|---|
| 574 |
|
|---|
| 575 | if (!test_NetrEnumerateComputerNames_level(tctx,
|
|---|
| 576 | p,
|
|---|
| 577 | levels[i],
|
|---|
| 578 | NULL, NULL))
|
|---|
| 579 | {
|
|---|
| 580 | return false;
|
|---|
| 581 | }
|
|---|
| 582 | }
|
|---|
| 583 |
|
|---|
| 584 | return true;
|
|---|
| 585 | }
|
|---|
| 586 |
|
|---|
| 587 | static bool test_NetrValidateName(struct torture_context *tctx,
|
|---|
| 588 | struct dcerpc_pipe *p)
|
|---|
| 589 | {
|
|---|
| 590 | NTSTATUS status;
|
|---|
| 591 | struct wkssvc_NetrValidateName r;
|
|---|
| 592 | uint16_t levels[] = {0,1,2,3,4,5};
|
|---|
| 593 | int i;
|
|---|
| 594 |
|
|---|
| 595 | for (i=0; i<ARRAY_SIZE(levels); i++) {
|
|---|
| 596 |
|
|---|
| 597 | r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
|
|---|
| 598 | r.in.name = lp_workgroup(tctx->lp_ctx);
|
|---|
| 599 | r.in.Account = NULL;
|
|---|
| 600 | r.in.Password = NULL;
|
|---|
| 601 | r.in.name_type = levels[i];
|
|---|
| 602 |
|
|---|
| 603 | torture_comment(tctx, "testing NetrValidateName level %u\n",
|
|---|
| 604 | r.in.name_type);
|
|---|
| 605 |
|
|---|
| 606 | status = dcerpc_wkssvc_NetrValidateName(p, tctx, &r);
|
|---|
| 607 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 608 | "NetrValidateName failed");
|
|---|
| 609 | torture_assert_werr_equal(tctx, r.out.result,
|
|---|
| 610 | WERR_NOT_SUPPORTED,
|
|---|
| 611 | "NetrValidateName failed");
|
|---|
| 612 | }
|
|---|
| 613 |
|
|---|
| 614 | return true;
|
|---|
| 615 | }
|
|---|
| 616 |
|
|---|
| 617 | static bool test_NetrValidateName2(struct torture_context *tctx,
|
|---|
| 618 | struct dcerpc_pipe *p)
|
|---|
| 619 | {
|
|---|
| 620 | NTSTATUS status;
|
|---|
| 621 | struct wkssvc_NetrValidateName2 r;
|
|---|
| 622 | uint16_t levels[] = {0,1,2,3,4,5};
|
|---|
| 623 | int i;
|
|---|
| 624 |
|
|---|
| 625 | for (i=0; i<ARRAY_SIZE(levels); i++) {
|
|---|
| 626 |
|
|---|
| 627 | r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
|
|---|
| 628 | r.in.name = lp_workgroup(tctx->lp_ctx);
|
|---|
| 629 | r.in.Account = NULL;
|
|---|
| 630 | r.in.EncryptedPassword = NULL;
|
|---|
| 631 | r.in.name_type = levels[i];
|
|---|
| 632 |
|
|---|
| 633 | torture_comment(tctx, "testing NetrValidateName2 level %u\n",
|
|---|
| 634 | r.in.name_type);
|
|---|
| 635 |
|
|---|
| 636 | status = dcerpc_wkssvc_NetrValidateName2(p, tctx, &r);
|
|---|
| 637 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 638 | "NetrValidateName2 failed");
|
|---|
| 639 | torture_assert_werr_equal(tctx, r.out.result,
|
|---|
| 640 | WERR_RPC_E_REMOTE_DISABLED,
|
|---|
| 641 | "NetrValidateName2 failed");
|
|---|
| 642 | }
|
|---|
| 643 |
|
|---|
| 644 | return true;
|
|---|
| 645 | }
|
|---|
| 646 |
|
|---|
| 647 | static bool test_NetrAddAlternateComputerName(struct torture_context *tctx,
|
|---|
| 648 | struct dcerpc_pipe *p)
|
|---|
| 649 | {
|
|---|
| 650 | NTSTATUS status;
|
|---|
| 651 | struct wkssvc_NetrAddAlternateComputerName r;
|
|---|
| 652 | const char **names = NULL;
|
|---|
| 653 | int num_names = 0;
|
|---|
| 654 | int i;
|
|---|
| 655 |
|
|---|
| 656 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 657 | r.in.NewAlternateMachineName = SMBTORTURE_ALTERNATE_NAME;
|
|---|
| 658 | r.in.Account = NULL;
|
|---|
| 659 | r.in.EncryptedPassword = NULL;
|
|---|
| 660 | r.in.Reserved = 0;
|
|---|
| 661 |
|
|---|
| 662 | torture_comment(tctx, "testing NetrAddAlternateComputerName\n");
|
|---|
| 663 |
|
|---|
| 664 | status = dcerpc_wkssvc_NetrAddAlternateComputerName(p, tctx, &r);
|
|---|
| 665 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 666 | "NetrAddAlternateComputerName failed");
|
|---|
| 667 | torture_assert_werr_ok(tctx, r.out.result,
|
|---|
| 668 | "NetrAddAlternateComputerName failed");
|
|---|
| 669 |
|
|---|
| 670 | if (!test_NetrEnumerateComputerNames_level(tctx, p,
|
|---|
| 671 | NetAlternateComputerNames,
|
|---|
| 672 | &names, &num_names))
|
|---|
| 673 | {
|
|---|
| 674 | return false;
|
|---|
| 675 | }
|
|---|
| 676 |
|
|---|
| 677 | for (i=0; i<num_names; i++) {
|
|---|
| 678 | if (strequal(names[i], SMBTORTURE_ALTERNATE_NAME)) {
|
|---|
| 679 | return true;
|
|---|
| 680 | }
|
|---|
| 681 | }
|
|---|
| 682 |
|
|---|
| 683 | torture_comment(tctx, "new alternate name not set\n");
|
|---|
| 684 |
|
|---|
| 685 | return false;
|
|---|
| 686 | }
|
|---|
| 687 |
|
|---|
| 688 | static bool test_NetrRemoveAlternateComputerName(struct torture_context *tctx,
|
|---|
| 689 | struct dcerpc_pipe *p)
|
|---|
| 690 | {
|
|---|
| 691 | NTSTATUS status;
|
|---|
| 692 | struct wkssvc_NetrRemoveAlternateComputerName r;
|
|---|
| 693 | const char **names = NULL;
|
|---|
| 694 | int num_names = 0;
|
|---|
| 695 | int i;
|
|---|
| 696 |
|
|---|
| 697 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 698 | r.in.AlternateMachineNameToRemove = SMBTORTURE_ALTERNATE_NAME;
|
|---|
| 699 | r.in.Account = NULL;
|
|---|
| 700 | r.in.EncryptedPassword = NULL;
|
|---|
| 701 | r.in.Reserved = 0;
|
|---|
| 702 |
|
|---|
| 703 | torture_comment(tctx, "testing NetrRemoveAlternateComputerName\n");
|
|---|
| 704 |
|
|---|
| 705 | status = dcerpc_wkssvc_NetrRemoveAlternateComputerName(p, tctx, &r);
|
|---|
| 706 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 707 | "NetrRemoveAlternateComputerName failed");
|
|---|
| 708 | torture_assert_werr_ok(tctx, r.out.result,
|
|---|
| 709 | "NetrRemoveAlternateComputerName failed");
|
|---|
| 710 |
|
|---|
| 711 | if (!test_NetrEnumerateComputerNames_level(tctx, p,
|
|---|
| 712 | NetAlternateComputerNames,
|
|---|
| 713 | &names, &num_names))
|
|---|
| 714 | {
|
|---|
| 715 | return false;
|
|---|
| 716 | }
|
|---|
| 717 |
|
|---|
| 718 | for (i=0; i<num_names; i++) {
|
|---|
| 719 | if (strequal(names[i], SMBTORTURE_ALTERNATE_NAME)) {
|
|---|
| 720 | return false;
|
|---|
| 721 | }
|
|---|
| 722 | }
|
|---|
| 723 |
|
|---|
| 724 | return true;
|
|---|
| 725 | }
|
|---|
| 726 |
|
|---|
| 727 | static bool test_NetrSetPrimaryComputername_name(struct torture_context *tctx,
|
|---|
| 728 | struct dcerpc_pipe *p,
|
|---|
| 729 | const char *name)
|
|---|
| 730 | {
|
|---|
| 731 | NTSTATUS status;
|
|---|
| 732 | struct wkssvc_NetrSetPrimaryComputername r;
|
|---|
| 733 |
|
|---|
| 734 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 735 | r.in.primary_name = name;
|
|---|
| 736 | r.in.Account = NULL;
|
|---|
| 737 | r.in.EncryptedPassword = NULL;
|
|---|
| 738 | r.in.Reserved = 0;
|
|---|
| 739 |
|
|---|
| 740 | status = dcerpc_wkssvc_NetrSetPrimaryComputername(p, tctx, &r);
|
|---|
| 741 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 742 | "NetrSetPrimaryComputername failed");
|
|---|
| 743 | torture_assert_werr_ok(tctx, r.out.result,
|
|---|
| 744 | "NetrSetPrimaryComputername failed");
|
|---|
| 745 | return true;
|
|---|
| 746 | }
|
|---|
| 747 |
|
|---|
| 748 |
|
|---|
| 749 | static bool test_NetrSetPrimaryComputername(struct torture_context *tctx,
|
|---|
| 750 | struct dcerpc_pipe *p)
|
|---|
| 751 | {
|
|---|
| 752 | /*
|
|---|
| 753 | add alternate,
|
|---|
| 754 | check if there
|
|---|
| 755 | store old primary
|
|---|
| 756 | set new primary (alternate)
|
|---|
| 757 | check if there
|
|---|
| 758 | later: check if del is possible
|
|---|
| 759 | set primary back to origin
|
|---|
| 760 | check if there
|
|---|
| 761 | del alternate
|
|---|
| 762 | */
|
|---|
| 763 |
|
|---|
| 764 | const char **names_o = NULL, **names = NULL;
|
|---|
| 765 | int num_names_o = 0, num_names = 0;
|
|---|
| 766 |
|
|---|
| 767 | torture_comment(tctx, "testing NetrSetPrimaryComputername\n");
|
|---|
| 768 |
|
|---|
| 769 | if (!test_NetrAddAlternateComputerName(tctx, p)) {
|
|---|
| 770 | return false;
|
|---|
| 771 | }
|
|---|
| 772 |
|
|---|
| 773 | if (!test_NetrEnumerateComputerNames_level(tctx, p,
|
|---|
| 774 | NetPrimaryComputerName,
|
|---|
| 775 | &names_o, &num_names_o))
|
|---|
| 776 | {
|
|---|
| 777 | return false;
|
|---|
| 778 | }
|
|---|
| 779 |
|
|---|
| 780 | if (num_names_o != 1) {
|
|---|
| 781 | return false;
|
|---|
| 782 | }
|
|---|
| 783 |
|
|---|
| 784 | if (!test_NetrSetPrimaryComputername_name(tctx, p,
|
|---|
| 785 | SMBTORTURE_ALTERNATE_NAME))
|
|---|
| 786 | {
|
|---|
| 787 | return false;
|
|---|
| 788 | }
|
|---|
| 789 |
|
|---|
| 790 | if (!test_NetrEnumerateComputerNames_level(tctx, p,
|
|---|
| 791 | NetPrimaryComputerName,
|
|---|
| 792 | &names, &num_names))
|
|---|
| 793 | {
|
|---|
| 794 | return false;
|
|---|
| 795 | }
|
|---|
| 796 |
|
|---|
| 797 | if (num_names != 1) {
|
|---|
| 798 | return false;
|
|---|
| 799 | }
|
|---|
| 800 |
|
|---|
| 801 | if (!strequal(names[0], SMBTORTURE_ALTERNATE_NAME)) {
|
|---|
| 802 | torture_comment(tctx,
|
|---|
| 803 | "name mismatch (%s != %s) after NetrSetPrimaryComputername!\n",
|
|---|
| 804 | names[0], SMBTORTURE_ALTERNATE_NAME);
|
|---|
| 805 | /*return false */;
|
|---|
| 806 | }
|
|---|
| 807 |
|
|---|
| 808 | if (!test_NetrSetPrimaryComputername_name(tctx, p,
|
|---|
| 809 | names_o[0]))
|
|---|
| 810 | {
|
|---|
| 811 | return false;
|
|---|
| 812 | }
|
|---|
| 813 |
|
|---|
| 814 | if (!test_NetrRemoveAlternateComputerName(tctx, p)) {
|
|---|
| 815 | return false;
|
|---|
| 816 | }
|
|---|
| 817 |
|
|---|
| 818 |
|
|---|
| 819 | return true;
|
|---|
| 820 | }
|
|---|
| 821 |
|
|---|
| 822 | static bool test_NetrRenameMachineInDomain(struct torture_context *tctx,
|
|---|
| 823 | struct dcerpc_pipe *p)
|
|---|
| 824 | {
|
|---|
| 825 | NTSTATUS status;
|
|---|
| 826 | struct wkssvc_NetrRenameMachineInDomain r;
|
|---|
| 827 |
|
|---|
| 828 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 829 | r.in.NewMachineName = SMBTORTURE_MACHINE_NAME;
|
|---|
| 830 | r.in.Account = NULL;
|
|---|
| 831 | r.in.password = NULL;
|
|---|
| 832 | r.in.RenameOptions = 0;
|
|---|
| 833 |
|
|---|
| 834 | torture_comment(tctx, "testing NetrRenameMachineInDomain\n");
|
|---|
| 835 |
|
|---|
| 836 | status = dcerpc_wkssvc_NetrRenameMachineInDomain(p, tctx, &r);
|
|---|
| 837 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 838 | "NetrRenameMachineInDomain failed");
|
|---|
| 839 | torture_assert_werr_equal(tctx, r.out.result, WERR_NOT_SUPPORTED,
|
|---|
| 840 | "NetrRenameMachineInDomain failed");
|
|---|
| 841 | return true;
|
|---|
| 842 | }
|
|---|
| 843 |
|
|---|
| 844 | static bool test_NetrRenameMachineInDomain2_name(struct torture_context *tctx,
|
|---|
| 845 | struct dcerpc_pipe *p,
|
|---|
| 846 | const char *new_name)
|
|---|
| 847 | {
|
|---|
| 848 | NTSTATUS status;
|
|---|
| 849 | struct wkssvc_NetrRenameMachineInDomain2 r;
|
|---|
| 850 |
|
|---|
| 851 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 852 | r.in.NewMachineName = new_name;
|
|---|
| 853 | r.in.Account = NULL;
|
|---|
| 854 | r.in.EncryptedPassword = NULL;
|
|---|
| 855 | r.in.RenameOptions = 0;
|
|---|
| 856 |
|
|---|
| 857 | status = dcerpc_wkssvc_NetrRenameMachineInDomain2(p, tctx, &r);
|
|---|
| 858 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 859 | "NetrRenameMachineInDomain2 failed");
|
|---|
| 860 | torture_assert_werr_ok(tctx, r.out.result,
|
|---|
| 861 | "NetrRenameMachineInDomain2 failed");
|
|---|
| 862 | return true;
|
|---|
| 863 | }
|
|---|
| 864 |
|
|---|
| 865 | static bool test_NetrRenameMachineInDomain2(struct torture_context *tctx,
|
|---|
| 866 | struct dcerpc_pipe *p)
|
|---|
| 867 | {
|
|---|
| 868 | const char **names_o = NULL, **names = NULL;
|
|---|
| 869 | int num_names_o = 0, num_names = 0;
|
|---|
| 870 |
|
|---|
| 871 | torture_comment(tctx, "testing NetrRenameMachineInDomain2\n");
|
|---|
| 872 |
|
|---|
| 873 | if (!test_NetrEnumerateComputerNames_level(tctx, p,
|
|---|
| 874 | NetPrimaryComputerName,
|
|---|
| 875 | &names_o, &num_names_o))
|
|---|
| 876 | {
|
|---|
| 877 | return false;
|
|---|
| 878 | }
|
|---|
| 879 |
|
|---|
| 880 | if (num_names_o != 1) {
|
|---|
| 881 | return false;
|
|---|
| 882 | }
|
|---|
| 883 |
|
|---|
| 884 | if (!test_NetrRenameMachineInDomain2_name(tctx, p,
|
|---|
| 885 | SMBTORTURE_MACHINE_NAME))
|
|---|
| 886 | {
|
|---|
| 887 | return false;
|
|---|
| 888 | }
|
|---|
| 889 |
|
|---|
| 890 | if (!test_NetrEnumerateComputerNames_level(tctx, p,
|
|---|
| 891 | NetPrimaryComputerName,
|
|---|
| 892 | &names, &num_names))
|
|---|
| 893 | {
|
|---|
| 894 | return false;
|
|---|
| 895 | }
|
|---|
| 896 |
|
|---|
| 897 | if (num_names != 1) {
|
|---|
| 898 | return false;
|
|---|
| 899 | }
|
|---|
| 900 |
|
|---|
| 901 | if (strequal(names[0], names_o[0])) {
|
|---|
| 902 | test_NetrRenameMachineInDomain2_name(tctx, p, names_o[0]);
|
|---|
| 903 | return false;
|
|---|
| 904 | }
|
|---|
| 905 |
|
|---|
| 906 | if (!strequal(names[0], SMBTORTURE_MACHINE_NAME)) {
|
|---|
| 907 | test_NetrRenameMachineInDomain2_name(tctx, p, names_o[0]);
|
|---|
| 908 | return false;
|
|---|
| 909 | }
|
|---|
| 910 |
|
|---|
| 911 | if (!test_NetrRenameMachineInDomain2_name(tctx, p, names_o[0]))
|
|---|
| 912 | {
|
|---|
| 913 | return false;
|
|---|
| 914 | }
|
|---|
| 915 |
|
|---|
| 916 | if (!test_NetrEnumerateComputerNames_level(tctx, p,
|
|---|
| 917 | NetPrimaryComputerName,
|
|---|
| 918 | &names, &num_names))
|
|---|
| 919 | {
|
|---|
| 920 | return false;
|
|---|
| 921 | }
|
|---|
| 922 |
|
|---|
| 923 | if (num_names != 1) {
|
|---|
| 924 | return false;
|
|---|
| 925 | }
|
|---|
| 926 |
|
|---|
| 927 | if (!strequal(names[0], names_o[0])) {
|
|---|
| 928 | return false;
|
|---|
| 929 | }
|
|---|
| 930 |
|
|---|
| 931 | return true;
|
|---|
| 932 | }
|
|---|
| 933 |
|
|---|
| 934 | static bool test_NetrWorkstationStatisticsGet(struct torture_context *tctx,
|
|---|
| 935 | struct dcerpc_pipe *p)
|
|---|
| 936 | {
|
|---|
| 937 | NTSTATUS status;
|
|---|
| 938 | struct wkssvc_NetrWorkstationStatisticsGet r;
|
|---|
| 939 | struct wkssvc_NetrWorkstationStatistics *info;
|
|---|
| 940 |
|
|---|
| 941 | ZERO_STRUCT(r);
|
|---|
| 942 |
|
|---|
| 943 | info = talloc_zero(tctx, struct wkssvc_NetrWorkstationStatistics);
|
|---|
| 944 |
|
|---|
| 945 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 946 | r.out.info = &info;
|
|---|
| 947 |
|
|---|
| 948 | torture_comment(tctx, "testing NetrWorkstationStatisticsGet\n");
|
|---|
| 949 |
|
|---|
| 950 | status = dcerpc_wkssvc_NetrWorkstationStatisticsGet(p, tctx, &r);
|
|---|
| 951 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 952 | "NetrWorkstationStatisticsGet failed");
|
|---|
| 953 | torture_assert_werr_ok(tctx, r.out.result,
|
|---|
| 954 | "NetrWorkstationStatisticsGet failed");
|
|---|
| 955 | return true;
|
|---|
| 956 | }
|
|---|
| 957 |
|
|---|
| 958 | /* only succeeds as long as the local messenger service is running - Guenther */
|
|---|
| 959 |
|
|---|
| 960 | static bool test_NetrMessageBufferSend(struct torture_context *tctx,
|
|---|
| 961 | struct dcerpc_pipe *p)
|
|---|
| 962 | {
|
|---|
| 963 | NTSTATUS status;
|
|---|
| 964 | struct wkssvc_NetrMessageBufferSend r;
|
|---|
| 965 | const char *message = SMBTORTURE_MESSAGE;
|
|---|
| 966 | size_t size;
|
|---|
| 967 | uint16_t *msg;
|
|---|
| 968 |
|
|---|
| 969 | if (!push_ucs2_talloc(tctx, &msg, message, &size)) {
|
|---|
| 970 | return false;
|
|---|
| 971 | }
|
|---|
| 972 |
|
|---|
| 973 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 974 | r.in.message_name = dcerpc_server_name(p);
|
|---|
| 975 | r.in.message_sender_name = dcerpc_server_name(p);
|
|---|
| 976 | r.in.message_buffer = (uint8_t *)msg;
|
|---|
| 977 | r.in.message_size = size;
|
|---|
| 978 |
|
|---|
| 979 | torture_comment(tctx, "testing NetrMessageBufferSend\n");
|
|---|
| 980 |
|
|---|
| 981 | status = dcerpc_wkssvc_NetrMessageBufferSend(p, tctx, &r);
|
|---|
| 982 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 983 | "NetrMessageBufferSend failed");
|
|---|
| 984 | torture_assert_werr_ok(tctx, r.out.result,
|
|---|
| 985 | "NetrMessageBufferSend failed");
|
|---|
| 986 | return true;
|
|---|
| 987 | }
|
|---|
| 988 |
|
|---|
| 989 | static bool test_NetrGetJoinInformation(struct torture_context *tctx,
|
|---|
| 990 | struct dcerpc_pipe *p)
|
|---|
| 991 | {
|
|---|
| 992 | NTSTATUS status;
|
|---|
| 993 | struct wkssvc_NetrGetJoinInformation r;
|
|---|
| 994 | enum wkssvc_NetJoinStatus join_status;
|
|---|
| 995 | const char *name_buffer = "";
|
|---|
| 996 |
|
|---|
| 997 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 998 | r.in.name_buffer = r.out.name_buffer = &name_buffer;
|
|---|
| 999 | r.out.name_type = &join_status;
|
|---|
| 1000 |
|
|---|
| 1001 | torture_comment(tctx, "testing NetrGetJoinInformation\n");
|
|---|
| 1002 |
|
|---|
| 1003 | status = dcerpc_wkssvc_NetrGetJoinInformation(p, tctx, &r);
|
|---|
| 1004 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 1005 | "NetrGetJoinInformation failed");
|
|---|
| 1006 | torture_assert_werr_ok(tctx, r.out.result,
|
|---|
| 1007 | "NetrGetJoinInformation failed");
|
|---|
| 1008 | return true;
|
|---|
| 1009 | }
|
|---|
| 1010 |
|
|---|
| 1011 | static bool test_GetJoinInformation(struct torture_context *tctx,
|
|---|
| 1012 | struct dcerpc_pipe *p,
|
|---|
| 1013 | enum wkssvc_NetJoinStatus *join_status_p,
|
|---|
| 1014 | const char **name)
|
|---|
| 1015 | {
|
|---|
| 1016 | NTSTATUS status;
|
|---|
| 1017 | struct wkssvc_NetrGetJoinInformation r;
|
|---|
| 1018 | enum wkssvc_NetJoinStatus join_status;
|
|---|
| 1019 | const char *name_buffer = "";
|
|---|
| 1020 |
|
|---|
| 1021 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 1022 | r.in.name_buffer = r.out.name_buffer = &name_buffer;
|
|---|
| 1023 | r.out.name_type = &join_status;
|
|---|
| 1024 |
|
|---|
| 1025 | status = dcerpc_wkssvc_NetrGetJoinInformation(p, tctx, &r);
|
|---|
| 1026 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 1027 | "NetrGetJoinInformation failed");
|
|---|
| 1028 | torture_assert_werr_ok(tctx, r.out.result,
|
|---|
| 1029 | "NetrGetJoinInformation failed");
|
|---|
| 1030 |
|
|---|
| 1031 | if (join_status_p) {
|
|---|
| 1032 | *join_status_p = join_status;
|
|---|
| 1033 | }
|
|---|
| 1034 |
|
|---|
| 1035 | if (*name) {
|
|---|
| 1036 | *name = talloc_strdup(tctx, name_buffer);
|
|---|
| 1037 | }
|
|---|
| 1038 |
|
|---|
| 1039 | return true;
|
|---|
| 1040 |
|
|---|
| 1041 | }
|
|---|
| 1042 |
|
|---|
| 1043 | static bool test_NetrGetJoinableOus(struct torture_context *tctx,
|
|---|
| 1044 | struct dcerpc_pipe *p)
|
|---|
| 1045 | {
|
|---|
| 1046 | NTSTATUS status;
|
|---|
| 1047 | struct wkssvc_NetrGetJoinableOus r;
|
|---|
| 1048 | uint32_t num_ous = 0;
|
|---|
| 1049 | const char **ous = NULL;
|
|---|
| 1050 |
|
|---|
| 1051 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 1052 | r.in.domain_name = lp_workgroup(tctx->lp_ctx);
|
|---|
| 1053 | r.in.Account = NULL;
|
|---|
| 1054 | r.in.unknown = NULL;
|
|---|
| 1055 | r.in.num_ous = r.out.num_ous = &num_ous;
|
|---|
| 1056 | r.out.ous = &ous;
|
|---|
| 1057 |
|
|---|
| 1058 | torture_comment(tctx, "testing NetrGetJoinableOus\n");
|
|---|
| 1059 |
|
|---|
| 1060 | status = dcerpc_wkssvc_NetrGetJoinableOus(p, tctx, &r);
|
|---|
| 1061 | torture_assert_ntstatus_ok(tctx, status, "NetrGetJoinableOus failed");
|
|---|
| 1062 | torture_assert_werr_equal(tctx, r.out.result,
|
|---|
| 1063 | WERR_NOT_SUPPORTED,
|
|---|
| 1064 | "NetrGetJoinableOus failed");
|
|---|
| 1065 |
|
|---|
| 1066 | return true;
|
|---|
| 1067 | }
|
|---|
| 1068 |
|
|---|
| 1069 | static bool test_NetrGetJoinableOus2(struct torture_context *tctx,
|
|---|
| 1070 | struct dcerpc_pipe *p)
|
|---|
| 1071 | {
|
|---|
| 1072 | NTSTATUS status;
|
|---|
| 1073 | struct wkssvc_NetrGetJoinableOus2 r;
|
|---|
| 1074 | uint32_t num_ous = 0;
|
|---|
| 1075 | const char **ous = NULL;
|
|---|
| 1076 |
|
|---|
| 1077 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 1078 | r.in.domain_name = lp_workgroup(tctx->lp_ctx);
|
|---|
| 1079 | r.in.Account = NULL;
|
|---|
| 1080 | r.in.EncryptedPassword = NULL;
|
|---|
| 1081 | r.in.num_ous = r.out.num_ous = &num_ous;
|
|---|
| 1082 | r.out.ous = &ous;
|
|---|
| 1083 |
|
|---|
| 1084 | torture_comment(tctx, "testing NetrGetJoinableOus2\n");
|
|---|
| 1085 |
|
|---|
| 1086 | status = dcerpc_wkssvc_NetrGetJoinableOus2(p, tctx, &r);
|
|---|
| 1087 | torture_assert_ntstatus_ok(tctx, status, "NetrGetJoinableOus2 failed");
|
|---|
| 1088 | torture_assert_werr_equal(tctx, r.out.result,
|
|---|
| 1089 | WERR_RPC_E_REMOTE_DISABLED,
|
|---|
| 1090 | "NetrGetJoinableOus2 failed");
|
|---|
| 1091 |
|
|---|
| 1092 | return true;
|
|---|
| 1093 | }
|
|---|
| 1094 |
|
|---|
| 1095 | static bool test_NetrUnjoinDomain(struct torture_context *tctx,
|
|---|
| 1096 | struct dcerpc_pipe *p)
|
|---|
| 1097 | {
|
|---|
| 1098 | NTSTATUS status;
|
|---|
| 1099 | struct wkssvc_NetrUnjoinDomain r;
|
|---|
| 1100 | struct cli_credentials *creds = cmdline_credentials;
|
|---|
| 1101 | const char *user = cli_credentials_get_username(creds);
|
|---|
| 1102 | const char *admin_account = NULL;
|
|---|
| 1103 |
|
|---|
| 1104 | admin_account = talloc_asprintf(tctx, "%s\\%s",
|
|---|
| 1105 | lp_workgroup(tctx->lp_ctx),
|
|---|
| 1106 | user);
|
|---|
| 1107 |
|
|---|
| 1108 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 1109 | r.in.Account = admin_account;
|
|---|
| 1110 | r.in.password = NULL;
|
|---|
| 1111 | r.in.unjoin_flags = 0;
|
|---|
| 1112 |
|
|---|
| 1113 | torture_comment(tctx, "testing NetrUnjoinDomain\n");
|
|---|
| 1114 |
|
|---|
| 1115 | status = dcerpc_wkssvc_NetrUnjoinDomain(p, tctx, &r);
|
|---|
| 1116 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 1117 | "NetrUnjoinDomain failed");
|
|---|
| 1118 | torture_assert_werr_equal(tctx, r.out.result, WERR_NOT_SUPPORTED,
|
|---|
| 1119 | "NetrUnjoinDomain failed");
|
|---|
| 1120 | return true;
|
|---|
| 1121 | }
|
|---|
| 1122 |
|
|---|
| 1123 | static bool test_NetrJoinDomain(struct torture_context *tctx,
|
|---|
| 1124 | struct dcerpc_pipe *p)
|
|---|
| 1125 | {
|
|---|
| 1126 | NTSTATUS status;
|
|---|
| 1127 | struct wkssvc_NetrJoinDomain r;
|
|---|
| 1128 | struct cli_credentials *creds = cmdline_credentials;
|
|---|
| 1129 | const char *user = cli_credentials_get_username(creds);
|
|---|
| 1130 | const char *admin_account = NULL;
|
|---|
| 1131 |
|
|---|
| 1132 | admin_account = talloc_asprintf(tctx, "%s\\%s",
|
|---|
| 1133 | lp_workgroup(tctx->lp_ctx),
|
|---|
| 1134 | user);
|
|---|
| 1135 |
|
|---|
| 1136 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 1137 | r.in.domain_name = lp_realm(tctx->lp_ctx);
|
|---|
| 1138 | r.in.account_ou = NULL;
|
|---|
| 1139 | r.in.Account = admin_account;
|
|---|
| 1140 | r.in.password = NULL;
|
|---|
| 1141 | r.in.join_flags = 0;
|
|---|
| 1142 |
|
|---|
| 1143 | torture_comment(tctx, "testing NetrJoinDomain\n");
|
|---|
| 1144 |
|
|---|
| 1145 | status = dcerpc_wkssvc_NetrJoinDomain(p, tctx, &r);
|
|---|
| 1146 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 1147 | "NetrJoinDomain failed");
|
|---|
| 1148 | torture_assert_werr_equal(tctx, r.out.result, WERR_NOT_SUPPORTED,
|
|---|
| 1149 | "NetrJoinDomain failed");
|
|---|
| 1150 | return true;
|
|---|
| 1151 | }
|
|---|
| 1152 |
|
|---|
| 1153 | /*
|
|---|
| 1154 | * prerequisites for remotely joining an unjoined XP SP2 workstation:
|
|---|
| 1155 | * - firewall needs to be disabled (or open for ncacn_np access)
|
|---|
| 1156 | * - HKLM\System\CurrentControlSet\Control\Lsa\forceguest needs to 0
|
|---|
| 1157 | * see also:
|
|---|
| 1158 | * http://support.microsoft.com/kb/294355/EN-US/ and
|
|---|
| 1159 | * http://support.microsoft.com/kb/290403/EN-US/
|
|---|
| 1160 | */
|
|---|
| 1161 |
|
|---|
| 1162 | static bool test_NetrJoinDomain2(struct torture_context *tctx,
|
|---|
| 1163 | struct dcerpc_pipe *p)
|
|---|
| 1164 | {
|
|---|
| 1165 | NTSTATUS status;
|
|---|
| 1166 | struct wkssvc_NetrJoinDomain2 r;
|
|---|
| 1167 | const char *domain_admin_account = NULL;
|
|---|
| 1168 | const char *domain_admin_password = NULL;
|
|---|
| 1169 | const char *domain_name = NULL;
|
|---|
| 1170 | struct wkssvc_PasswordBuffer *pwd_buf;
|
|---|
| 1171 | enum wkssvc_NetJoinStatus join_status;
|
|---|
| 1172 | const char *join_name = NULL;
|
|---|
| 1173 | WERROR expected_err;
|
|---|
| 1174 | DATA_BLOB session_key;
|
|---|
| 1175 |
|
|---|
| 1176 | /* FIXME: this test assumes to join workstations / servers and does not
|
|---|
| 1177 | * handle DCs (WERR_SETUP_DOMAIN_CONTROLLER) */
|
|---|
| 1178 |
|
|---|
| 1179 | if (!test_GetJoinInformation(tctx, p, &join_status, &join_name))
|
|---|
| 1180 | {
|
|---|
| 1181 | return false;
|
|---|
| 1182 | }
|
|---|
| 1183 |
|
|---|
| 1184 | switch (join_status) {
|
|---|
| 1185 | case NET_SETUP_DOMAIN_NAME:
|
|---|
| 1186 | expected_err = WERR_SETUP_ALREADY_JOINED;
|
|---|
| 1187 | break;
|
|---|
| 1188 | case NET_SETUP_UNKNOWN_STATUS:
|
|---|
| 1189 | case NET_SETUP_UNJOINED:
|
|---|
| 1190 | case NET_SETUP_WORKGROUP_NAME:
|
|---|
| 1191 | default:
|
|---|
| 1192 | expected_err = WERR_OK;
|
|---|
| 1193 | break;
|
|---|
| 1194 | }
|
|---|
| 1195 |
|
|---|
| 1196 | domain_admin_account = torture_setting_string(tctx, "domain_admin_account", NULL);
|
|---|
| 1197 |
|
|---|
| 1198 | domain_admin_password = torture_setting_string(tctx, "domain_admin_password", NULL);
|
|---|
| 1199 |
|
|---|
| 1200 | domain_name = torture_setting_string(tctx, "domain_name", NULL);
|
|---|
| 1201 |
|
|---|
| 1202 | if ((domain_admin_account == NULL) ||
|
|---|
| 1203 | (domain_admin_password == NULL) ||
|
|---|
| 1204 | (domain_name == NULL)) {
|
|---|
| 1205 | torture_comment(tctx, "not enough input parameter\n");
|
|---|
| 1206 | return false;
|
|---|
| 1207 | }
|
|---|
| 1208 |
|
|---|
| 1209 | status = dcerpc_fetch_session_key(p, &session_key);
|
|---|
| 1210 | if (!NT_STATUS_IS_OK(status)) {
|
|---|
| 1211 | return false;
|
|---|
| 1212 | }
|
|---|
| 1213 |
|
|---|
| 1214 | encode_wkssvc_join_password_buffer(tctx, domain_admin_password,
|
|---|
| 1215 | &session_key, &pwd_buf);
|
|---|
| 1216 |
|
|---|
| 1217 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 1218 | r.in.domain_name = domain_name;
|
|---|
| 1219 | r.in.account_ou = NULL;
|
|---|
| 1220 | r.in.admin_account = domain_admin_account;
|
|---|
| 1221 | r.in.encrypted_password = pwd_buf;
|
|---|
| 1222 | r.in.join_flags = WKSSVC_JOIN_FLAGS_JOIN_TYPE |
|
|---|
| 1223 | WKSSVC_JOIN_FLAGS_ACCOUNT_CREATE;
|
|---|
| 1224 |
|
|---|
| 1225 | torture_comment(tctx, "testing NetrJoinDomain2 (assuming non-DC)\n");
|
|---|
| 1226 |
|
|---|
| 1227 | status = dcerpc_wkssvc_NetrJoinDomain2(p, tctx, &r);
|
|---|
| 1228 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 1229 | "NetrJoinDomain2 failed");
|
|---|
| 1230 | torture_assert_werr_equal(tctx, r.out.result, expected_err,
|
|---|
| 1231 | "NetrJoinDomain2 failed");
|
|---|
| 1232 |
|
|---|
| 1233 | if (!test_GetJoinInformation(tctx, p, &join_status, &join_name))
|
|---|
| 1234 | {
|
|---|
| 1235 | return false;
|
|---|
| 1236 | }
|
|---|
| 1237 |
|
|---|
| 1238 | if (join_status != NET_SETUP_DOMAIN_NAME) {
|
|---|
| 1239 | torture_comment(tctx,
|
|---|
| 1240 | "Join verify failed: got %d\n", join_status);
|
|---|
| 1241 | return false;
|
|---|
| 1242 | }
|
|---|
| 1243 |
|
|---|
| 1244 | return true;
|
|---|
| 1245 | }
|
|---|
| 1246 |
|
|---|
| 1247 | static bool test_NetrUnjoinDomain2(struct torture_context *tctx,
|
|---|
| 1248 | struct dcerpc_pipe *p)
|
|---|
| 1249 | {
|
|---|
| 1250 | NTSTATUS status;
|
|---|
| 1251 | struct wkssvc_NetrUnjoinDomain2 r;
|
|---|
| 1252 | const char *domain_admin_account = NULL;
|
|---|
| 1253 | const char *domain_admin_password = NULL;
|
|---|
| 1254 | struct wkssvc_PasswordBuffer *pwd_buf;
|
|---|
| 1255 | enum wkssvc_NetJoinStatus join_status;
|
|---|
| 1256 | const char *join_name = NULL;
|
|---|
| 1257 | WERROR expected_err;
|
|---|
| 1258 | DATA_BLOB session_key;
|
|---|
| 1259 |
|
|---|
| 1260 | /* FIXME: this test assumes to join workstations / servers and does not
|
|---|
| 1261 | * handle DCs (WERR_SETUP_DOMAIN_CONTROLLER) */
|
|---|
| 1262 |
|
|---|
| 1263 | if (!test_GetJoinInformation(tctx, p, &join_status, &join_name))
|
|---|
| 1264 | {
|
|---|
| 1265 | return false;
|
|---|
| 1266 | }
|
|---|
| 1267 |
|
|---|
| 1268 | switch (join_status) {
|
|---|
| 1269 | case NET_SETUP_UNJOINED:
|
|---|
| 1270 | expected_err = WERR_SETUP_NOT_JOINED;
|
|---|
| 1271 | break;
|
|---|
| 1272 | case NET_SETUP_DOMAIN_NAME:
|
|---|
| 1273 | case NET_SETUP_UNKNOWN_STATUS:
|
|---|
| 1274 | case NET_SETUP_WORKGROUP_NAME:
|
|---|
| 1275 | default:
|
|---|
| 1276 | expected_err = WERR_OK;
|
|---|
| 1277 | break;
|
|---|
| 1278 | }
|
|---|
| 1279 |
|
|---|
| 1280 | domain_admin_account = torture_setting_string(tctx, "domain_admin_account", NULL);
|
|---|
| 1281 |
|
|---|
| 1282 | domain_admin_password = torture_setting_string(tctx, "domain_admin_password", NULL);
|
|---|
| 1283 |
|
|---|
| 1284 | if ((domain_admin_account == NULL) ||
|
|---|
| 1285 | (domain_admin_password == NULL)) {
|
|---|
| 1286 | torture_comment(tctx, "not enough input parameter\n");
|
|---|
| 1287 | return false;
|
|---|
| 1288 | }
|
|---|
| 1289 |
|
|---|
| 1290 | status = dcerpc_fetch_session_key(p, &session_key);
|
|---|
| 1291 | if (!NT_STATUS_IS_OK(status)) {
|
|---|
| 1292 | return false;
|
|---|
| 1293 | }
|
|---|
| 1294 |
|
|---|
| 1295 | encode_wkssvc_join_password_buffer(tctx, domain_admin_password,
|
|---|
| 1296 | &session_key, &pwd_buf);
|
|---|
| 1297 |
|
|---|
| 1298 | r.in.server_name = dcerpc_server_name(p);
|
|---|
| 1299 | r.in.account = domain_admin_account;
|
|---|
| 1300 | r.in.encrypted_password = pwd_buf;
|
|---|
| 1301 | r.in.unjoin_flags = 0;
|
|---|
| 1302 |
|
|---|
| 1303 | torture_comment(tctx, "testing NetrUnjoinDomain2 (assuming non-DC)\n");
|
|---|
| 1304 |
|
|---|
| 1305 | status = dcerpc_wkssvc_NetrUnjoinDomain2(p, tctx, &r);
|
|---|
| 1306 | torture_assert_ntstatus_ok(tctx, status,
|
|---|
| 1307 | "NetrUnjoinDomain2 failed");
|
|---|
| 1308 | torture_assert_werr_equal(tctx, r.out.result, expected_err,
|
|---|
| 1309 | "NetrUnjoinDomain2 failed");
|
|---|
| 1310 |
|
|---|
| 1311 | if (!test_GetJoinInformation(tctx, p, &join_status, &join_name))
|
|---|
| 1312 | {
|
|---|
| 1313 | return false;
|
|---|
| 1314 | }
|
|---|
| 1315 |
|
|---|
| 1316 | switch (join_status) {
|
|---|
| 1317 | case NET_SETUP_UNJOINED:
|
|---|
| 1318 | case NET_SETUP_WORKGROUP_NAME:
|
|---|
| 1319 | break;
|
|---|
| 1320 | case NET_SETUP_UNKNOWN_STATUS:
|
|---|
| 1321 | case NET_SETUP_DOMAIN_NAME:
|
|---|
| 1322 | default:
|
|---|
| 1323 | torture_comment(tctx,
|
|---|
| 1324 | "Unjoin verify failed: got %d\n", join_status);
|
|---|
| 1325 | return false;
|
|---|
| 1326 | }
|
|---|
| 1327 |
|
|---|
| 1328 | return true;
|
|---|
| 1329 | }
|
|---|
| 1330 |
|
|---|
| 1331 |
|
|---|
| 1332 | struct torture_suite *torture_rpc_wkssvc(TALLOC_CTX *mem_ctx)
|
|---|
| 1333 | {
|
|---|
| 1334 | struct torture_suite *suite;
|
|---|
| 1335 | struct torture_rpc_tcase *tcase;
|
|---|
| 1336 | struct torture_test *test;
|
|---|
| 1337 |
|
|---|
| 1338 | suite = torture_suite_create(mem_ctx, "WKSSVC");
|
|---|
| 1339 | tcase = torture_suite_add_rpc_iface_tcase(suite, "wkssvc",
|
|---|
| 1340 | &ndr_table_wkssvc);
|
|---|
| 1341 |
|
|---|
| 1342 | torture_rpc_tcase_add_test(tcase, "NetWkstaGetInfo",
|
|---|
| 1343 | test_NetWkstaGetInfo);
|
|---|
| 1344 |
|
|---|
| 1345 | torture_rpc_tcase_add_test(tcase, "NetWkstaTransportEnum",
|
|---|
| 1346 | test_NetWkstaTransportEnum);
|
|---|
| 1347 | torture_rpc_tcase_add_test(tcase, "NetrWkstaTransportDel",
|
|---|
| 1348 | test_NetrWkstaTransportDel);
|
|---|
| 1349 | torture_rpc_tcase_add_test(tcase, "NetrWkstaTransportAdd",
|
|---|
| 1350 | test_NetrWkstaTransportAdd);
|
|---|
| 1351 |
|
|---|
| 1352 | torture_rpc_tcase_add_test(tcase, "NetWkstaEnumUsers",
|
|---|
| 1353 | test_NetWkstaEnumUsers);
|
|---|
| 1354 | torture_rpc_tcase_add_test(tcase, "NetrWkstaUserGetInfo",
|
|---|
| 1355 | test_NetrWkstaUserGetInfo);
|
|---|
| 1356 |
|
|---|
| 1357 | torture_rpc_tcase_add_test(tcase, "NetrUseDel",
|
|---|
| 1358 | test_NetrUseDel);
|
|---|
| 1359 | torture_rpc_tcase_add_test(tcase, "NetrUseGetInfo",
|
|---|
| 1360 | test_NetrUseGetInfo);
|
|---|
| 1361 | torture_rpc_tcase_add_test(tcase, "NetrUseEnum",
|
|---|
| 1362 | test_NetrUseEnum);
|
|---|
| 1363 | torture_rpc_tcase_add_test(tcase, "NetrUseAdd",
|
|---|
| 1364 | test_NetrUseAdd);
|
|---|
| 1365 |
|
|---|
| 1366 | torture_rpc_tcase_add_test(tcase, "NetrValidateName",
|
|---|
| 1367 | test_NetrValidateName);
|
|---|
| 1368 | torture_rpc_tcase_add_test(tcase, "NetrValidateName2",
|
|---|
| 1369 | test_NetrValidateName2);
|
|---|
| 1370 | torture_rpc_tcase_add_test(tcase, "NetrLogonDomainNameDel",
|
|---|
| 1371 | test_NetrLogonDomainNameDel);
|
|---|
| 1372 | torture_rpc_tcase_add_test(tcase, "NetrLogonDomainNameAdd",
|
|---|
| 1373 | test_NetrLogonDomainNameAdd);
|
|---|
| 1374 | torture_rpc_tcase_add_test(tcase, "NetrRemoveAlternateComputerName",
|
|---|
| 1375 | test_NetrRemoveAlternateComputerName);
|
|---|
| 1376 | torture_rpc_tcase_add_test(tcase, "NetrAddAlternateComputerName",
|
|---|
| 1377 | test_NetrAddAlternateComputerName);
|
|---|
| 1378 | test = torture_rpc_tcase_add_test(tcase, "NetrSetPrimaryComputername",
|
|---|
| 1379 | test_NetrSetPrimaryComputername);
|
|---|
| 1380 | test->dangerous = true;
|
|---|
| 1381 | test = torture_rpc_tcase_add_test(tcase, "NetrRenameMachineInDomain",
|
|---|
| 1382 | test_NetrRenameMachineInDomain);
|
|---|
| 1383 | test->dangerous = true;
|
|---|
| 1384 | test = torture_rpc_tcase_add_test(tcase, "NetrRenameMachineInDomain2",
|
|---|
| 1385 | test_NetrRenameMachineInDomain2);
|
|---|
| 1386 | test->dangerous = true;
|
|---|
| 1387 | torture_rpc_tcase_add_test(tcase, "NetrEnumerateComputerNames",
|
|---|
| 1388 | test_NetrEnumerateComputerNames);
|
|---|
| 1389 |
|
|---|
| 1390 | test = torture_rpc_tcase_add_test(tcase, "NetrJoinDomain2",
|
|---|
| 1391 | test_NetrJoinDomain2);
|
|---|
| 1392 | test->dangerous = true;
|
|---|
| 1393 | test = torture_rpc_tcase_add_test(tcase, "NetrUnjoinDomain2",
|
|---|
| 1394 | test_NetrUnjoinDomain2);
|
|---|
| 1395 | test->dangerous = true;
|
|---|
| 1396 |
|
|---|
| 1397 | torture_rpc_tcase_add_test(tcase, "NetrJoinDomain",
|
|---|
| 1398 | test_NetrJoinDomain);
|
|---|
| 1399 | test->dangerous = true;
|
|---|
| 1400 | torture_rpc_tcase_add_test(tcase, "NetrUnjoinDomain",
|
|---|
| 1401 | test_NetrUnjoinDomain);
|
|---|
| 1402 | test->dangerous = true;
|
|---|
| 1403 | torture_rpc_tcase_add_test(tcase, "NetrGetJoinInformation",
|
|---|
| 1404 | test_NetrGetJoinInformation);
|
|---|
| 1405 | torture_rpc_tcase_add_test(tcase, "NetrGetJoinableOus",
|
|---|
| 1406 | test_NetrGetJoinableOus);
|
|---|
| 1407 | torture_rpc_tcase_add_test(tcase, "NetrGetJoinableOus2",
|
|---|
| 1408 | test_NetrGetJoinableOus2);
|
|---|
| 1409 |
|
|---|
| 1410 | torture_rpc_tcase_add_test(tcase, "NetrWorkstationStatisticsGet",
|
|---|
| 1411 | test_NetrWorkstationStatisticsGet);
|
|---|
| 1412 | torture_rpc_tcase_add_test(tcase, "NetrMessageBufferSend",
|
|---|
| 1413 | test_NetrMessageBufferSend);
|
|---|
| 1414 |
|
|---|
| 1415 | return suite;
|
|---|
| 1416 | }
|
|---|