Changeset 745 for trunk/server/source4/torture/raw
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source4/torture/raw/acls.c
r414 r745 34 34 #define CHECK_STATUS(status, correct) do { \ 35 35 if (!NT_STATUS_EQUAL(status, correct)) { \ 36 printf("(%s) Incorrect status %s - should be %s\n", \ 36 ret = false; \ 37 torture_result(tctx, TORTURE_FAIL, "(%s) Incorrect status %s - should be %s\n", \ 37 38 __location__, nt_errstr(status), nt_errstr(correct)); \ 38 ret = false; \39 39 goto done; \ 40 40 }} while (0) 41 41 42 43 static bool test_sd(struct torture_context *tctx, 44 struct smbcli_state *cli) 42 #define FAIL_UNLESS(__cond) \ 43 do { \ 44 if (__cond) {} else { \ 45 ret = false; \ 46 torture_result(tctx, TORTURE_FAIL, "%s) condition violated: %s\n", \ 47 __location__, #__cond); \ 48 goto done; \ 49 } \ 50 } while(0) 51 52 #define CHECK_SECURITY_DESCRIPTOR(_sd1, _sd2) do { \ 53 if (!security_descriptor_equal(_sd1, _sd2)) { \ 54 torture_warning(tctx, "%s: security descriptors don't match!\n", __location__); \ 55 torture_warning(tctx, "got:\n"); \ 56 NDR_PRINT_DEBUG(security_descriptor, _sd1); \ 57 torture_warning(tctx, "expected:\n"); \ 58 NDR_PRINT_DEBUG(security_descriptor, _sd2); \ 59 ret = false; \ 60 } \ 61 } while (0) 62 63 /* 64 * Helper function to verify a security descriptor, by querying 65 * and comparing against the passed in sd. 66 * Copied to smb2_util_verify_sd() for SMB2. 67 */ 68 static bool verify_sd(TALLOC_CTX *tctx, struct smbcli_state *cli, 69 int fnum, struct security_descriptor *sd) 70 { 71 NTSTATUS status; 72 bool ret = true; 73 union smb_fileinfo q = {}; 74 75 if (sd) { 76 q.query_secdesc.level = RAW_FILEINFO_SEC_DESC; 77 q.query_secdesc.in.file.fnum = fnum; 78 q.query_secdesc.in.secinfo_flags = 79 SECINFO_OWNER | 80 SECINFO_GROUP | 81 SECINFO_DACL; 82 status = smb_raw_fileinfo(cli->tree, tctx, &q); 83 CHECK_STATUS(status, NT_STATUS_OK); 84 85 /* More work is needed if we're going to check this bit. */ 86 sd->type &= ~SEC_DESC_DACL_AUTO_INHERITED; 87 88 CHECK_SECURITY_DESCRIPTOR(q.query_secdesc.out.sd, sd); 89 } 90 91 done: 92 return ret; 93 } 94 95 /* 96 * Helper function to verify attributes, by querying 97 * and comparing against the passed attrib. 98 * Copied to smb2_util_verify_attrib() for SMB2. 99 */ 100 static bool verify_attrib(TALLOC_CTX *tctx, struct smbcli_state *cli, 101 int fnum, uint32_t attrib) 102 { 103 NTSTATUS status; 104 bool ret = true; 105 union smb_fileinfo q2 = {}; 106 107 if (attrib) { 108 q2.standard.level = RAW_FILEINFO_STANDARD; 109 q2.standard.in.file.fnum = fnum; 110 status = smb_raw_fileinfo(cli->tree, tctx, &q2); 111 CHECK_STATUS(status, NT_STATUS_OK); 112 113 q2.standard.out.attrib &= ~FILE_ATTRIBUTE_ARCHIVE; 114 115 if (q2.standard.out.attrib != attrib) { 116 torture_warning(tctx, "%s: attributes don't match! " 117 "got %x, expected %x\n", __location__, 118 (uint32_t)q2.standard.out.attrib, 119 (uint32_t)attrib); 120 ret = false; 121 } 122 } 123 124 done: 125 return ret; 126 } 127 128 /** 129 * Test setting and removing a DACL. 130 * Test copied to torture_smb2_setinfo() for SMB2. 131 */ 132 static bool test_sd(struct torture_context *tctx, struct smbcli_state *cli) 45 133 { 46 134 NTSTATUS status; … … 55 143 struct dom_sid *test_sid; 56 144 57 printf("TESTING SETFILEINFO EA_SET\n"); 145 if (!torture_setup_dir(cli, BASEDIR)) 146 return false; 147 148 torture_comment(tctx, "TESTING SETFILEINFO EA_SET\n"); 58 149 59 150 io.generic.level = RAW_OPEN_NTCREATEX; 60 io.ntcreatex.in.root_fid = 0;151 io.ntcreatex.in.root_fid.fnum = 0; 61 152 io.ntcreatex.in.flags = 0; 62 153 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 85 176 sd = q.query_secdesc.out.sd; 86 177 87 printf("add a new ACE to the DACL\n");88 89 test_sid = dom_sid_parse_talloc(tctx, "S-1-5-32-1234-5432");178 torture_comment(tctx, "add a new ACE to the DACL\n"); 179 180 test_sid = dom_sid_parse_talloc(tctx, SID_NT_AUTHENTICATED_USERS); 90 181 91 182 ace.type = SEC_ACE_TYPE_ACCESS_ALLOWED; … … 104 195 status = smb_raw_setfileinfo(cli->tree, &set); 105 196 CHECK_STATUS(status, NT_STATUS_OK); 106 107 status = smb_raw_fileinfo(cli->tree, tctx, &q); 108 CHECK_STATUS(status, NT_STATUS_OK); 109 110 if (!security_acl_equal(q.query_secdesc.out.sd->dacl, sd->dacl)) { 111 printf("%s: security descriptors don't match!\n", __location__); 112 printf("got:\n"); 113 NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); 114 printf("expected:\n"); 115 NDR_PRINT_DEBUG(security_descriptor, sd); 116 ret = false; 117 } 118 119 printf("remove it again\n"); 197 FAIL_UNLESS(verify_sd(tctx, cli, fnum, sd)); 198 199 torture_comment(tctx, "remove it again\n"); 120 200 121 201 status = security_descriptor_dacl_del(sd, test_sid); … … 124 204 status = smb_raw_setfileinfo(cli->tree, &set); 125 205 CHECK_STATUS(status, NT_STATUS_OK); 126 127 status = smb_raw_fileinfo(cli->tree, tctx, &q); 128 CHECK_STATUS(status, NT_STATUS_OK); 129 130 if (!security_acl_equal(q.query_secdesc.out.sd->dacl, sd->dacl)) { 131 printf("%s: security descriptors don't match!\n", __location__); 132 printf("got:\n"); 133 NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); 134 printf("expected:\n"); 135 NDR_PRINT_DEBUG(security_descriptor, sd); 136 ret = false; 137 } 206 FAIL_UNLESS(verify_sd(tctx, cli, fnum, sd)); 138 207 139 208 done: 140 209 smbcli_close(cli->tree, fnum); 210 smb_raw_exit(cli->session); 211 smbcli_deltree(cli->tree, BASEDIR); 212 141 213 return ret; 142 214 } … … 145 217 /* 146 218 test using nttrans create to create a file with an initial acl set 219 Test copied to test_create_acl() for SMB2. 147 220 */ 148 static bool test_nttrans_create (struct torture_context *tctx,149 struct smbcli_state *cli)221 static bool test_nttrans_create_ext(struct torture_context *tctx, 222 struct smbcli_state *cli, bool test_dir) 150 223 { 151 224 NTSTATUS status; … … 154 227 bool ret = true; 155 228 int fnum = -1; 156 union smb_fileinfo q ;229 union smb_fileinfo q = {}; 157 230 struct security_ace ace; 158 231 struct security_descriptor *sd; 159 232 struct dom_sid *test_sid; 160 161 printf("testing nttrans create with sec_desc\n"); 233 uint32_t attrib = 234 FILE_ATTRIBUTE_HIDDEN | 235 FILE_ATTRIBUTE_SYSTEM | 236 (test_dir ? FILE_ATTRIBUTE_DIRECTORY : 0); 237 NTSTATUS (*delete_func)(struct smbcli_tree *, const char *) = 238 test_dir ? smbcli_rmdir : smbcli_unlink; 239 240 if (!torture_setup_dir(cli, BASEDIR)) 241 return false; 162 242 163 243 io.generic.level = RAW_OPEN_NTTRANS_CREATE; 164 io.ntcreatex.in.root_fid = 0;244 io.ntcreatex.in.root_fid.fnum = 0; 165 245 io.ntcreatex.in.flags = 0; 166 246 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; 167 io.ntcreatex.in.create_options = 0; 247 io.ntcreatex.in.create_options = 248 test_dir ? NTCREATEX_OPTIONS_DIRECTORY : 0; 168 249 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 169 250 io.ntcreatex.in.share_access = … … 178 259 io.ntcreatex.in.ea_list = NULL; 179 260 180 printf("creating normal file\n");261 torture_comment(tctx, "basic create\n"); 181 262 182 263 status = smb_raw_open(cli->tree, tctx, &io); … … 184 265 fnum = io.ntcreatex.out.file.fnum; 185 266 186 printf("querying ACL\n");267 torture_comment(tctx, "querying ACL\n"); 187 268 188 269 q.query_secdesc.level = RAW_FILEINFO_SEC_DESC; … … 196 277 sd = q.query_secdesc.out.sd; 197 278 198 smbcli_close(cli->tree, fnum); 199 smbcli_unlink(cli->tree, fname); 200 201 printf("adding a new ACE\n"); 202 test_sid = dom_sid_parse_talloc(tctx, "S-1-5-32-1234-54321"); 279 status = smbcli_close(cli->tree, fnum); 280 CHECK_STATUS(status, NT_STATUS_OK); 281 282 status = delete_func(cli->tree, fname); 283 CHECK_STATUS(status, NT_STATUS_OK); 284 285 torture_comment(tctx, "adding a new ACE\n"); 286 test_sid = dom_sid_parse_talloc(tctx, SID_NT_AUTHENTICATED_USERS); 203 287 204 288 ace.type = SEC_ACE_TYPE_ACCESS_ALLOWED; … … 210 294 CHECK_STATUS(status, NT_STATUS_OK); 211 295 212 printf("creating a filewith an initial ACL\n");296 torture_comment(tctx, "creating with an initial ACL\n"); 213 297 214 298 io.ntcreatex.in.sec_desc = sd; … … 217 301 fnum = io.ntcreatex.out.file.fnum; 218 302 219 q.query_secdesc.in.file.fnum = fnum; 220 status = smb_raw_fileinfo(cli->tree, tctx, &q); 221 CHECK_STATUS(status, NT_STATUS_OK); 222 223 if (!security_acl_equal(q.query_secdesc.out.sd->dacl, sd->dacl)) { 224 printf("%s: security descriptors don't match!\n", __location__); 225 printf("got:\n"); 226 NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); 227 printf("expected:\n"); 228 NDR_PRINT_DEBUG(security_descriptor, sd); 229 ret = false; 230 } 231 232 done: 303 FAIL_UNLESS(verify_sd(tctx, cli, fnum, sd)); 304 305 status = smbcli_close(cli->tree, fnum); 306 CHECK_STATUS(status, NT_STATUS_OK); 307 status = delete_func(cli->tree, fname); 308 CHECK_STATUS(status, NT_STATUS_OK); 309 310 torture_comment(tctx, "creating with attributes\n"); 311 312 io.ntcreatex.in.sec_desc = NULL; 313 io.ntcreatex.in.file_attr = attrib; 314 status = smb_raw_open(cli->tree, tctx, &io); 315 CHECK_STATUS(status, NT_STATUS_OK); 316 fnum = io.ntcreatex.out.file.fnum; 317 318 FAIL_UNLESS(verify_attrib(tctx, cli, fnum, attrib)); 319 320 status = smbcli_close(cli->tree, fnum); 321 CHECK_STATUS(status, NT_STATUS_OK); 322 323 status = delete_func(cli->tree, fname); 324 CHECK_STATUS(status, NT_STATUS_OK); 325 326 torture_comment(tctx, "creating with attributes and ACL\n"); 327 328 io.ntcreatex.in.sec_desc = sd; 329 io.ntcreatex.in.file_attr = attrib; 330 status = smb_raw_open(cli->tree, tctx, &io); 331 CHECK_STATUS(status, NT_STATUS_OK); 332 fnum = io.ntcreatex.out.file.fnum; 333 334 FAIL_UNLESS(verify_sd(tctx, cli, fnum, sd)); 335 FAIL_UNLESS(verify_attrib(tctx, cli, fnum, attrib)); 336 337 status = smbcli_close(cli->tree, fnum); 338 CHECK_STATUS(status, NT_STATUS_OK); 339 status = delete_func(cli->tree, fname); 340 CHECK_STATUS(status, NT_STATUS_OK); 341 342 torture_comment(tctx, "creating with attributes, ACL and owner\n"); 343 344 sd = security_descriptor_dacl_create(tctx, 345 0, SID_WORLD, SID_BUILTIN_USERS, 346 SID_WORLD, 347 SEC_ACE_TYPE_ACCESS_ALLOWED, 348 SEC_RIGHTS_FILE_READ | SEC_STD_ALL, 349 0, 350 NULL); 351 352 io.ntcreatex.in.sec_desc = sd; 353 io.ntcreatex.in.file_attr = attrib; 354 status = smb_raw_open(cli->tree, tctx, &io); 355 CHECK_STATUS(status, NT_STATUS_OK); 356 fnum = io.ntcreatex.out.file.fnum; 357 358 FAIL_UNLESS(verify_sd(tctx, cli, fnum, sd)); 359 FAIL_UNLESS(verify_attrib(tctx, cli, fnum, attrib)); 360 361 status = smbcli_close(cli->tree, fnum); 362 CHECK_STATUS(status, NT_STATUS_OK); 363 status = delete_func(cli->tree, fname); 364 CHECK_STATUS(status, NT_STATUS_OK); 365 366 done: 233 367 smbcli_close(cli->tree, fnum); 368 smb_raw_exit(cli->session); 369 smbcli_deltree(cli->tree, BASEDIR); 234 370 return ret; 371 } 372 373 static bool test_nttrans_create_file(struct torture_context *tctx, 374 struct smbcli_state *cli) 375 { 376 torture_comment(tctx, "Testing nttrans create with sec_desc on files\n"); 377 378 return test_nttrans_create_ext(tctx, cli, false); 379 } 380 381 static bool test_nttrans_create_dir(struct torture_context *tctx, 382 struct smbcli_state *cli) 383 { 384 torture_comment(tctx, "Testing nttrans create with sec_desc on directories\n"); 385 386 return test_nttrans_create_ext(tctx, cli, true); 235 387 } 236 388 … … 242 394 CHECK_STATUS(status, NT_STATUS_OK); \ 243 395 if (_q.access_information.out.access_flags != (flags)) { \ 244 printf("(%s) Incorrect access_flags 0x%08x - should be 0x%08x\n", \ 396 ret = false; \ 397 torture_result(tctx, TORTURE_FAIL, "(%s) Incorrect access_flags 0x%08x - should be 0x%08x\n", \ 245 398 __location__, _q.access_information.out.access_flags, (flags)); \ 246 ret = false; \247 399 goto done; \ 248 400 } \ … … 251 403 /* 252 404 test using NTTRANS CREATE to create a file with a null ACL set 405 Test copied to test_create_null_dacl() for SMB2. 253 406 */ 254 407 static bool test_nttrans_create_null_dacl(struct torture_context *tctx, … … 257 410 NTSTATUS status; 258 411 union smb_open io; 259 const char *fname = BASEDIR "\\ acl3.txt";412 const char *fname = BASEDIR "\\nulldacl.txt"; 260 413 bool ret = true; 261 414 int fnum = -1; … … 265 418 struct security_acl dacl; 266 419 267 printf("TESTING SEC_DESC WITH A NULL DACL\n"); 420 if (!torture_setup_dir(cli, BASEDIR)) 421 return false; 422 423 torture_comment(tctx, "TESTING SEC_DESC WITH A NULL DACL\n"); 268 424 269 425 io.generic.level = RAW_OPEN_NTTRANS_CREATE; 270 io.ntcreatex.in.root_fid = 0;426 io.ntcreatex.in.root_fid.fnum = 0; 271 427 io.ntcreatex.in.flags = 0; 272 428 io.ntcreatex.in.access_mask = SEC_STD_READ_CONTROL | SEC_STD_WRITE_DAC … … 284 440 io.ntcreatex.in.ea_list = NULL; 285 441 286 printf("creating a file with a empty sd\n");442 torture_comment(tctx, "creating a file with a empty sd\n"); 287 443 status = smb_raw_open(cli->tree, tctx, &io); 288 444 CHECK_STATUS(status, NT_STATUS_OK); 289 445 fnum = io.ntcreatex.out.file.fnum; 290 446 291 printf("get the original sd\n");447 torture_comment(tctx, "get the original sd\n"); 292 448 q.query_secdesc.level = RAW_FILEINFO_SEC_DESC; 293 449 q.query_secdesc.in.file.fnum = fnum; … … 305 461 */ 306 462 if (!(q.query_secdesc.out.sd->type & SEC_DESC_DACL_PRESENT)) { 307 printf("DACL_PRESENT flag not set by the server!\n");308 463 ret = false; 464 torture_result(tctx, TORTURE_FAIL, "DACL_PRESENT flag not set by the server!\n"); 309 465 goto done; 310 466 } 311 467 if (q.query_secdesc.out.sd->dacl == NULL) { 312 printf("no DACL has been created on the server!\n");313 468 ret = false; 469 torture_result(tctx, TORTURE_FAIL, "no DACL has been created on the server!\n"); 314 470 goto done; 315 471 } 316 472 317 printf("set NULL DACL\n");473 torture_comment(tctx, "set NULL DACL\n"); 318 474 sd->type |= SEC_DESC_DACL_PRESENT; 319 475 … … 325 481 CHECK_STATUS(status, NT_STATUS_OK); 326 482 327 printf("get the sd\n");483 torture_comment(tctx, "get the sd\n"); 328 484 q.query_secdesc.level = RAW_FILEINFO_SEC_DESC; 329 485 q.query_secdesc.in.file.fnum = fnum; … … 337 493 /* Testing the modified DACL */ 338 494 if (!(q.query_secdesc.out.sd->type & SEC_DESC_DACL_PRESENT)) { 339 printf("DACL_PRESENT flag not set by the server!\n");340 495 ret = false; 496 torture_result(tctx, TORTURE_FAIL, "DACL_PRESENT flag not set by the server!\n"); 341 497 goto done; 342 498 } 343 499 if (q.query_secdesc.out.sd->dacl != NULL) { 344 printf("DACL has been created on the server!\n");345 500 ret = false; 501 torture_result(tctx, TORTURE_FAIL, "DACL has been created on the server!\n"); 346 502 goto done; 347 503 } 348 504 349 printf("try open for read control\n");505 torture_comment(tctx, "try open for read control\n"); 350 506 io.ntcreatex.in.access_mask = SEC_STD_READ_CONTROL; 351 507 status = smb_raw_open(cli->tree, tctx, &io); … … 355 511 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 356 512 357 printf("try open for write\n");513 torture_comment(tctx, "try open for write\n"); 358 514 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; 359 515 status = smb_raw_open(cli->tree, tctx, &io); … … 363 519 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 364 520 365 printf("try open for read\n");521 torture_comment(tctx, "try open for read\n"); 366 522 io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA; 367 523 status = smb_raw_open(cli->tree, tctx, &io); … … 371 527 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 372 528 373 printf("try open for generic write\n");529 torture_comment(tctx, "try open for generic write\n"); 374 530 io.ntcreatex.in.access_mask = SEC_GENERIC_WRITE; 375 531 status = smb_raw_open(cli->tree, tctx, &io); … … 379 535 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 380 536 381 printf("try open for generic read\n");537 torture_comment(tctx, "try open for generic read\n"); 382 538 io.ntcreatex.in.access_mask = SEC_GENERIC_READ; 383 539 status = smb_raw_open(cli->tree, tctx, &io); … … 387 543 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 388 544 389 printf("set DACL with 0 aces\n");545 torture_comment(tctx, "set DACL with 0 aces\n"); 390 546 ZERO_STRUCT(dacl); 391 547 dacl.revision = SECURITY_ACL_REVISION_NT4; … … 400 556 CHECK_STATUS(status, NT_STATUS_OK); 401 557 402 printf("get the sd\n");558 torture_comment(tctx, "get the sd\n"); 403 559 q.query_secdesc.level = RAW_FILEINFO_SEC_DESC; 404 560 q.query_secdesc.in.file.fnum = fnum; … … 412 568 /* Testing the modified DACL */ 413 569 if (!(q.query_secdesc.out.sd->type & SEC_DESC_DACL_PRESENT)) { 414 printf("DACL_PRESENT flag not set by the server!\n");415 570 ret = false; 571 torture_result(tctx, TORTURE_FAIL, "DACL_PRESENT flag not set by the server!\n"); 416 572 goto done; 417 573 } 418 574 if (q.query_secdesc.out.sd->dacl == NULL) { 419 printf("no DACL has been created on the server!\n");420 575 ret = false; 576 torture_result(tctx, TORTURE_FAIL, "no DACL has been created on the server!\n"); 421 577 goto done; 422 578 } 423 579 if (q.query_secdesc.out.sd->dacl->num_aces != 0) { 424 printf("DACL has %u aces!\n", 580 ret = false; 581 torture_result(tctx, TORTURE_FAIL, "DACL has %u aces!\n", 425 582 q.query_secdesc.out.sd->dacl->num_aces); 426 ret = false;427 583 goto done; 428 584 } 429 585 430 printf("try open for read control\n");586 torture_comment(tctx, "try open for read control\n"); 431 587 io.ntcreatex.in.access_mask = SEC_STD_READ_CONTROL; 432 588 status = smb_raw_open(cli->tree, tctx, &io); … … 436 592 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 437 593 438 printf("try open for write => access_denied\n");594 torture_comment(tctx, "try open for write => access_denied\n"); 439 595 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; 440 596 status = smb_raw_open(cli->tree, tctx, &io); 441 597 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 442 598 443 printf("try open for read => access_denied\n");599 torture_comment(tctx, "try open for read => access_denied\n"); 444 600 io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA; 445 601 status = smb_raw_open(cli->tree, tctx, &io); 446 602 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 447 603 448 printf("try open for generic write => access_denied\n");604 torture_comment(tctx, "try open for generic write => access_denied\n"); 449 605 io.ntcreatex.in.access_mask = SEC_GENERIC_WRITE; 450 606 status = smb_raw_open(cli->tree, tctx, &io); 451 607 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 452 608 453 printf("try open for generic read => access_denied\n");609 torture_comment(tctx, "try open for generic read => access_denied\n"); 454 610 io.ntcreatex.in.access_mask = SEC_GENERIC_READ; 455 611 status = smb_raw_open(cli->tree, tctx, &io); 456 612 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 457 613 458 printf("set empty sd\n");614 torture_comment(tctx, "set empty sd\n"); 459 615 sd->type &= ~SEC_DESC_DACL_PRESENT; 460 616 sd->dacl = NULL; … … 467 623 CHECK_STATUS(status, NT_STATUS_OK); 468 624 469 printf("get the sd\n");625 torture_comment(tctx, "get the sd\n"); 470 626 q.query_secdesc.level = RAW_FILEINFO_SEC_DESC; 471 627 q.query_secdesc.in.file.fnum = fnum; … … 479 635 /* Testing the modified DACL */ 480 636 if (!(q.query_secdesc.out.sd->type & SEC_DESC_DACL_PRESENT)) { 481 printf("DACL_PRESENT flag not set by the server!\n");482 637 ret = false; 638 torture_result(tctx, TORTURE_FAIL, "DACL_PRESENT flag not set by the server!\n"); 483 639 goto done; 484 640 } 485 641 if (q.query_secdesc.out.sd->dacl != NULL) { 486 printf("DACL has been created on the server!\n");487 642 ret = false; 643 torture_result(tctx, TORTURE_FAIL, "DACL has been created on the server!\n"); 488 644 goto done; 489 645 } 490 646 done: 491 647 smbcli_close(cli->tree, fnum); 648 smb_raw_exit(cli->session); 649 smbcli_deltree(cli->tree, BASEDIR); 492 650 return ret; 493 651 } … … 496 654 test the behaviour of the well known SID_CREATOR_OWNER sid, and some generic 497 655 mapping bits 656 Test copied to smb2/acls.c for SMB2. 498 657 */ 499 658 static bool test_creator_sid(struct torture_context *tctx, … … 510 669 const char *owner_sid; 511 670 512 printf("TESTING SID_CREATOR_OWNER\n"); 671 if (!torture_setup_dir(cli, BASEDIR)) 672 return false; 673 674 torture_comment(tctx, "TESTING SID_CREATOR_OWNER\n"); 513 675 514 676 io.generic.level = RAW_OPEN_NTCREATEX; 515 io.ntcreatex.in.root_fid = 0;677 io.ntcreatex.in.root_fid.fnum = 0; 516 678 io.ntcreatex.in.flags = 0; 517 679 io.ntcreatex.in.access_mask = SEC_STD_READ_CONTROL | SEC_STD_WRITE_DAC | SEC_STD_WRITE_OWNER; … … 530 692 fnum = io.ntcreatex.out.file.fnum; 531 693 532 printf("get the original sd\n");694 torture_comment(tctx, "get the original sd\n"); 533 695 q.query_secdesc.level = RAW_FILEINFO_SEC_DESC; 534 696 q.query_secdesc.in.file.fnum = fnum; … … 540 702 owner_sid = dom_sid_string(tctx, sd_orig->owner_sid); 541 703 542 printf("set a sec desc allowing no write by CREATOR_OWNER\n");704 torture_comment(tctx, "set a sec desc allowing no write by CREATOR_OWNER\n"); 543 705 sd = security_descriptor_dacl_create(tctx, 544 706 0, NULL, NULL, … … 557 719 CHECK_STATUS(status, NT_STATUS_OK); 558 720 559 printf("try open for write\n");721 torture_comment(tctx, "try open for write\n"); 560 722 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; 561 723 status = smb_raw_open(cli->tree, tctx, &io); 562 724 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 563 725 564 printf("try open for read\n");726 torture_comment(tctx, "try open for read\n"); 565 727 io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA; 566 728 status = smb_raw_open(cli->tree, tctx, &io); 567 729 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 568 730 569 printf("try open for generic write\n");731 torture_comment(tctx, "try open for generic write\n"); 570 732 io.ntcreatex.in.access_mask = SEC_GENERIC_WRITE; 571 733 status = smb_raw_open(cli->tree, tctx, &io); 572 734 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 573 735 574 printf("try open for generic read\n");736 torture_comment(tctx, "try open for generic read\n"); 575 737 io.ntcreatex.in.access_mask = SEC_GENERIC_READ; 576 738 status = smb_raw_open(cli->tree, tctx, &io); 577 739 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 578 740 579 printf("set a sec desc allowing no write by owner\n");741 torture_comment(tctx, "set a sec desc allowing no write by owner\n"); 580 742 sd = security_descriptor_dacl_create(tctx, 581 743 0, owner_sid, NULL, … … 593 755 CHECK_STATUS(status, NT_STATUS_OK); 594 756 595 printf("check that sd has been mapped correctly\n");757 torture_comment(tctx, "check that sd has been mapped correctly\n"); 596 758 status = smb_raw_fileinfo(cli->tree, tctx, &q); 597 759 CHECK_STATUS(status, NT_STATUS_OK); 598 if (!security_descriptor_equal(q.query_secdesc.out.sd, sd)) { 599 printf("%s: security descriptors don't match!\n", __location__); 600 printf("got:\n"); 601 NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); 602 printf("expected:\n"); 603 NDR_PRINT_DEBUG(security_descriptor, sd); 604 ret = false; 605 } 606 607 printf("try open for write\n"); 760 CHECK_SECURITY_DESCRIPTOR(q.query_secdesc.out.sd, sd); 761 762 torture_comment(tctx, "try open for write\n"); 608 763 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; 609 764 status = smb_raw_open(cli->tree, tctx, &io); 610 765 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 611 766 612 printf("try open for read\n");767 torture_comment(tctx, "try open for read\n"); 613 768 io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA; 614 769 status = smb_raw_open(cli->tree, tctx, &io); … … 619 774 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 620 775 621 printf("try open for generic write\n");776 torture_comment(tctx, "try open for generic write\n"); 622 777 io.ntcreatex.in.access_mask = SEC_GENERIC_WRITE; 623 778 status = smb_raw_open(cli->tree, tctx, &io); 624 779 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 625 780 626 printf("try open for generic read\n");781 torture_comment(tctx, "try open for generic read\n"); 627 782 io.ntcreatex.in.access_mask = SEC_GENERIC_READ; 628 783 status = smb_raw_open(cli->tree, tctx, &io); … … 632 787 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 633 788 634 printf("set a sec desc allowing generic read by owner\n");789 torture_comment(tctx, "set a sec desc allowing generic read by owner\n"); 635 790 sd = security_descriptor_dacl_create(tctx, 636 791 0, NULL, NULL, … … 645 800 CHECK_STATUS(status, NT_STATUS_OK); 646 801 647 printf("check that generic read has been mapped correctly\n");802 torture_comment(tctx, "check that generic read has been mapped correctly\n"); 648 803 sd2 = security_descriptor_dacl_create(tctx, 649 804 0, owner_sid, NULL, … … 656 811 status = smb_raw_fileinfo(cli->tree, tctx, &q); 657 812 CHECK_STATUS(status, NT_STATUS_OK); 658 if (!security_descriptor_equal(q.query_secdesc.out.sd, sd2)) { 659 printf("%s: security descriptors don't match!\n", __location__); 660 printf("got:\n"); 661 NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); 662 printf("expected:\n"); 663 NDR_PRINT_DEBUG(security_descriptor, sd2); 664 ret = false; 665 } 666 667 668 printf("try open for write\n"); 813 CHECK_SECURITY_DESCRIPTOR(q.query_secdesc.out.sd, sd2); 814 815 torture_comment(tctx, "try open for write\n"); 669 816 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; 670 817 status = smb_raw_open(cli->tree, tctx, &io); 671 818 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 672 819 673 printf("try open for read\n");820 torture_comment(tctx, "try open for read\n"); 674 821 io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA; 675 822 status = smb_raw_open(cli->tree, tctx, &io); … … 680 827 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 681 828 682 printf("try open for generic write\n");829 torture_comment(tctx, "try open for generic write\n"); 683 830 io.ntcreatex.in.access_mask = SEC_GENERIC_WRITE; 684 831 status = smb_raw_open(cli->tree, tctx, &io); 685 832 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 686 833 687 printf("try open for generic read\n");834 torture_comment(tctx, "try open for generic read\n"); 688 835 io.ntcreatex.in.access_mask = SEC_GENERIC_READ; 689 836 status = smb_raw_open(cli->tree, tctx, &io); … … 693 840 694 841 695 printf("put back original sd\n");842 torture_comment(tctx, "put back original sd\n"); 696 843 set.set_secdesc.in.sd = sd_orig; 697 844 status = smb_raw_setfileinfo(cli->tree, &set); … … 701 848 done: 702 849 smbcli_close(cli->tree, fnum); 850 smb_raw_exit(cli->session); 851 smbcli_deltree(cli->tree, BASEDIR); 703 852 return ret; 704 853 } … … 708 857 test the mapping of the SEC_GENERIC_xx bits to SEC_STD_xx and 709 858 SEC_FILE_xx bits 859 Test copied to smb2/acls.c for SMB2. 710 860 */ 711 861 static bool test_generic_bits(struct torture_context *tctx, … … 746 896 bool has_take_ownership_privilege; 747 897 748 printf("TESTING FILE GENERIC BITS\n"); 898 if (!torture_setup_dir(cli, BASEDIR)) 899 return false; 900 901 torture_comment(tctx, "TESTING FILE GENERIC BITS\n"); 749 902 750 903 io.generic.level = RAW_OPEN_NTCREATEX; 751 io.ntcreatex.in.root_fid = 0;904 io.ntcreatex.in.root_fid.fnum = 0; 752 905 io.ntcreatex.in.flags = 0; 753 906 io.ntcreatex.in.access_mask = … … 769 922 fnum = io.ntcreatex.out.file.fnum; 770 923 771 printf("get the original sd\n");924 torture_comment(tctx, "get the original sd\n"); 772 925 q.query_secdesc.level = RAW_FILEINFO_SEC_DESC; 773 926 q.query_secdesc.in.file.fnum = fnum; … … 779 932 owner_sid = dom_sid_string(tctx, sd_orig->owner_sid); 780 933 781 status = smblsa_sid_check_privilege(cli,934 status = torture_check_privilege(cli, 782 935 owner_sid, 783 936 sec_privilege_name(SEC_PRIV_RESTORE)); 784 937 has_restore_privilege = NT_STATUS_IS_OK(status); 785 938 if (!NT_STATUS_IS_OK(status)) { 786 printf("smblsa_sid_check_privilege - %s\n", nt_errstr(status)); 787 } 788 printf("SEC_PRIV_RESTORE - %s\n", has_restore_privilege?"Yes":"No"); 789 790 status = smblsa_sid_check_privilege(cli, 939 torture_warning(tctx, "torture_check_privilege - %s\n", 940 nt_errstr(status)); 941 } 942 torture_comment(tctx, "SEC_PRIV_RESTORE - %s\n", has_restore_privilege?"Yes":"No"); 943 944 status = torture_check_privilege(cli, 791 945 owner_sid, 792 946 sec_privilege_name(SEC_PRIV_TAKE_OWNERSHIP)); 793 947 has_take_ownership_privilege = NT_STATUS_IS_OK(status); 794 948 if (!NT_STATUS_IS_OK(status)) { 795 printf("smblsa_sid_check_privilege - %s\n", nt_errstr(status)); 796 } 797 printf("SEC_PRIV_TAKE_OWNERSHIP - %s\n", has_take_ownership_privilege?"Yes":"No"); 949 torture_warning(tctx, "torture_check_privilege - %s\n", 950 nt_errstr(status)); 951 } 952 torture_comment(tctx, "SEC_PRIV_TAKE_OWNERSHIP - %s\n", has_take_ownership_privilege?"Yes":"No"); 798 953 799 954 for (i=0;i<ARRAY_SIZE(file_mappings);i++) { … … 809 964 } 810 965 811 printf("testing generic bits 0x%08x\n",966 torture_comment(tctx, "Testing generic bits 0x%08x\n", 812 967 file_mappings[i].gen_bits); 813 968 sd = security_descriptor_dacl_create(tctx, … … 837 992 status = smb_raw_fileinfo(cli->tree, tctx, &q); 838 993 CHECK_STATUS(status, NT_STATUS_OK); 839 if (!security_descriptor_equal(q.query_secdesc.out.sd, sd2)) { 840 printf("%s: security descriptors don't match!\n", __location__); 841 printf("got:\n"); 842 NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); 843 printf("expected:\n"); 844 NDR_PRINT_DEBUG(security_descriptor, sd2); 845 ret = false; 846 } 994 CHECK_SECURITY_DESCRIPTOR(q.query_secdesc.out.sd, sd2); 847 995 848 996 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 857 1005 } 858 1006 859 printf("testing generic bits 0x%08x (anonymous)\n",1007 torture_comment(tctx, "Testing generic bits 0x%08x (anonymous)\n", 860 1008 file_mappings[i].gen_bits); 861 1009 sd = security_descriptor_dacl_create(tctx, … … 885 1033 status = smb_raw_fileinfo(cli->tree, tctx, &q); 886 1034 CHECK_STATUS(status, NT_STATUS_OK); 887 if (!security_descriptor_equal(q.query_secdesc.out.sd, sd2)) { 888 printf("%s: security descriptors don't match!\n", __location__); 889 printf("got:\n"); 890 NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); 891 printf("expected:\n"); 892 NDR_PRINT_DEBUG(security_descriptor, sd2); 893 ret = false; 894 } 1035 CHECK_SECURITY_DESCRIPTOR(q.query_secdesc.out.sd, sd2); 895 1036 896 1037 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 902 1043 } 903 1044 904 printf("put back original sd\n");1045 torture_comment(tctx, "put back original sd\n"); 905 1046 set.set_secdesc.in.sd = sd_orig; 906 1047 status = smb_raw_setfileinfo(cli->tree, &set); … … 911 1052 912 1053 913 printf("TESTING DIR GENERIC BITS\n");1054 torture_comment(tctx, "TESTING DIR GENERIC BITS\n"); 914 1055 915 1056 io.generic.level = RAW_OPEN_NTCREATEX; 916 io.ntcreatex.in.root_fid = 0;1057 io.ntcreatex.in.root_fid.fnum = 0; 917 1058 io.ntcreatex.in.flags = 0; 918 1059 io.ntcreatex.in.access_mask = … … 934 1075 fnum = io.ntcreatex.out.file.fnum; 935 1076 936 printf("get the original sd\n");1077 torture_comment(tctx, "get the original sd\n"); 937 1078 q.query_secdesc.level = RAW_FILEINFO_SEC_DESC; 938 1079 q.query_secdesc.in.file.fnum = fnum; … … 944 1085 owner_sid = dom_sid_string(tctx, sd_orig->owner_sid); 945 1086 946 status = smblsa_sid_check_privilege(cli,1087 status = torture_check_privilege(cli, 947 1088 owner_sid, 948 1089 sec_privilege_name(SEC_PRIV_RESTORE)); 949 1090 has_restore_privilege = NT_STATUS_IS_OK(status); 950 1091 if (!NT_STATUS_IS_OK(status)) { 951 printf("smblsa_sid_check_privilege - %s\n", nt_errstr(status)); 952 } 953 printf("SEC_PRIV_RESTORE - %s\n", has_restore_privilege?"Yes":"No"); 954 955 status = smblsa_sid_check_privilege(cli, 1092 torture_warning(tctx, "torture_check_privilege - %s\n", 1093 nt_errstr(status)); 1094 } 1095 torture_comment(tctx, "SEC_PRIV_RESTORE - %s\n", has_restore_privilege?"Yes":"No"); 1096 1097 status = torture_check_privilege(cli, 956 1098 owner_sid, 957 1099 sec_privilege_name(SEC_PRIV_TAKE_OWNERSHIP)); 958 1100 has_take_ownership_privilege = NT_STATUS_IS_OK(status); 959 1101 if (!NT_STATUS_IS_OK(status)) { 960 printf("smblsa_sid_check_privilege - %s\n", nt_errstr(status)); 961 } 962 printf("SEC_PRIV_TAKE_OWNERSHIP - %s\n", has_take_ownership_privilege?"Yes":"No"); 1102 torture_warning(tctx, "torture_check_privilege - %s\n", 1103 nt_errstr(status)); 1104 } 1105 torture_comment(tctx, "SEC_PRIV_TAKE_OWNERSHIP - %s\n", has_take_ownership_privilege?"Yes":"No"); 963 1106 964 1107 for (i=0;i<ARRAY_SIZE(dir_mappings);i++) { … … 974 1117 } 975 1118 976 printf("testing generic bits 0x%08x\n",1119 torture_comment(tctx, "Testing generic bits 0x%08x\n", 977 1120 file_mappings[i].gen_bits); 978 1121 sd = security_descriptor_dacl_create(tctx, … … 1002 1145 status = smb_raw_fileinfo(cli->tree, tctx, &q); 1003 1146 CHECK_STATUS(status, NT_STATUS_OK); 1004 if (!security_descriptor_equal(q.query_secdesc.out.sd, sd2)) { 1005 printf("%s: security descriptors don't match!\n", __location__); 1006 printf("got:\n"); 1007 NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); 1008 printf("expected:\n"); 1009 NDR_PRINT_DEBUG(security_descriptor, sd2); 1010 ret = false; 1011 } 1147 CHECK_SECURITY_DESCRIPTOR(q.query_secdesc.out.sd, sd2); 1012 1148 1013 1149 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 1022 1158 } 1023 1159 1024 printf("testing generic bits 0x%08x (anonymous)\n",1160 torture_comment(tctx, "Testing generic bits 0x%08x (anonymous)\n", 1025 1161 file_mappings[i].gen_bits); 1026 1162 sd = security_descriptor_dacl_create(tctx, … … 1050 1186 status = smb_raw_fileinfo(cli->tree, tctx, &q); 1051 1187 CHECK_STATUS(status, NT_STATUS_OK); 1052 if (!security_descriptor_equal(q.query_secdesc.out.sd, sd2)) { 1053 printf("%s: security descriptors don't match!\n", __location__); 1054 printf("got:\n"); 1055 NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); 1056 printf("expected:\n"); 1057 NDR_PRINT_DEBUG(security_descriptor, sd2); 1058 ret = false; 1059 } 1188 CHECK_SECURITY_DESCRIPTOR(q.query_secdesc.out.sd, sd2); 1060 1189 1061 1190 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 1067 1196 } 1068 1197 1069 printf("put back original sd\n");1198 torture_comment(tctx, "put back original sd\n"); 1070 1199 set.set_secdesc.in.sd = sd_orig; 1071 1200 status = smb_raw_setfileinfo(cli->tree, &set); … … 1077 1206 done: 1078 1207 smbcli_close(cli->tree, fnum); 1208 smb_raw_exit(cli->session); 1209 smbcli_deltree(cli->tree, BASEDIR); 1079 1210 return ret; 1080 1211 } … … 1083 1214 /* 1084 1215 see what access bits the owner of a file always gets 1216 Test copied to smb2/acls.c for SMB2. 1085 1217 */ 1086 1218 static bool test_owner_bits(struct torture_context *tctx, … … 1100 1232 uint32_t expected_bits; 1101 1233 1102 printf("TESTING FILE OWNER BITS\n"); 1234 if (!torture_setup_dir(cli, BASEDIR)) 1235 return false; 1236 1237 torture_comment(tctx, "TESTING FILE OWNER BITS\n"); 1103 1238 1104 1239 io.generic.level = RAW_OPEN_NTCREATEX; 1105 io.ntcreatex.in.root_fid = 0;1240 io.ntcreatex.in.root_fid.fnum = 0; 1106 1241 io.ntcreatex.in.flags = 0; 1107 1242 io.ntcreatex.in.access_mask = … … 1123 1258 fnum = io.ntcreatex.out.file.fnum; 1124 1259 1125 printf("get the original sd\n");1260 torture_comment(tctx, "get the original sd\n"); 1126 1261 q.query_secdesc.level = RAW_FILEINFO_SEC_DESC; 1127 1262 q.query_secdesc.in.file.fnum = fnum; … … 1133 1268 owner_sid = dom_sid_string(tctx, sd_orig->owner_sid); 1134 1269 1135 status = smblsa_sid_check_privilege(cli,1270 status = torture_check_privilege(cli, 1136 1271 owner_sid, 1137 1272 sec_privilege_name(SEC_PRIV_RESTORE)); 1138 1273 has_restore_privilege = NT_STATUS_IS_OK(status); 1139 1274 if (!NT_STATUS_IS_OK(status)) { 1140 printf("smblsa_sid_check_privilege - %s\n", nt_errstr(status));1141 } 1142 printf("SEC_PRIV_RESTORE - %s\n", has_restore_privilege?"Yes":"No");1143 1144 status = smblsa_sid_check_privilege(cli,1275 torture_warning(tctx, "torture_check_privilege - %s\n", nt_errstr(status)); 1276 } 1277 torture_comment(tctx, "SEC_PRIV_RESTORE - %s\n", has_restore_privilege?"Yes":"No"); 1278 1279 status = torture_check_privilege(cli, 1145 1280 owner_sid, 1146 1281 sec_privilege_name(SEC_PRIV_TAKE_OWNERSHIP)); 1147 1282 has_take_ownership_privilege = NT_STATUS_IS_OK(status); 1148 1283 if (!NT_STATUS_IS_OK(status)) { 1149 printf("smblsa_sid_check_privilege - %s\n", nt_errstr(status));1150 } 1151 printf("SEC_PRIV_TAKE_OWNERSHIP - %s\n", has_take_ownership_privilege?"Yes":"No");1284 torture_warning(tctx, "torture_check_privilege - %s\n", nt_errstr(status)); 1285 } 1286 torture_comment(tctx, "SEC_PRIV_TAKE_OWNERSHIP - %s\n", has_take_ownership_privilege?"Yes":"No"); 1152 1287 1153 1288 sd = security_descriptor_dacl_create(tctx, … … 1175 1310 if (expected_bits & bit) { 1176 1311 if (!NT_STATUS_IS_OK(status)) { 1177 printf("failed with access mask 0x%08x of expected 0x%08x\n",1312 torture_warning(tctx, "failed with access mask 0x%08x of expected 0x%08x\n", 1178 1313 bit, expected_bits); 1179 1314 } … … 1183 1318 } else { 1184 1319 if (NT_STATUS_IS_OK(status)) { 1185 printf("open succeeded with access mask 0x%08x of "1320 torture_warning(tctx, "open succeeded with access mask 0x%08x of " 1186 1321 "expected 0x%08x - should fail\n", 1187 1322 bit, expected_bits); … … 1191 1326 } 1192 1327 1193 printf("put back original sd\n");1328 torture_comment(tctx, "put back original sd\n"); 1194 1329 set.set_secdesc.in.sd = sd_orig; 1195 1330 status = smb_raw_setfileinfo(cli->tree, &set); … … 1199 1334 smbcli_close(cli->tree, fnum); 1200 1335 smbcli_unlink(cli->tree, fname); 1336 smb_raw_exit(cli->session); 1337 smbcli_deltree(cli->tree, BASEDIR); 1201 1338 return ret; 1202 1339 } … … 1206 1343 /* 1207 1344 test the inheritance of ACL flags onto new files and directories 1345 Test copied to smb2/acls.c for SMB2. 1208 1346 */ 1209 1347 static bool test_inheritance(struct torture_context *tctx, … … 1219 1357 union smb_fileinfo q; 1220 1358 union smb_setfileinfo set; 1221 struct security_descriptor *sd, *sd2, *sd_orig=NULL, *sd_def ;1222 const char *owner_sid ;1359 struct security_descriptor *sd, *sd2, *sd_orig=NULL, *sd_def1, *sd_def2; 1360 const char *owner_sid, *group_sid; 1223 1361 const struct dom_sid *creator_owner; 1224 1362 const struct { … … 1330 1468 }; 1331 1469 1332 smbcli_rmdir(cli->tree, dname); 1333 1334 printf("TESTING ACL INHERITANCE\n"); 1470 if (!torture_setup_dir(cli, BASEDIR)) 1471 return false; 1472 1473 torture_comment(tctx, "TESTING ACL INHERITANCE\n"); 1335 1474 1336 1475 io.generic.level = RAW_OPEN_NTCREATEX; 1337 io.ntcreatex.in.root_fid = 0;1476 io.ntcreatex.in.root_fid.fnum = 0; 1338 1477 io.ntcreatex.in.flags = 0; 1339 1478 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; … … 1351 1490 fnum = io.ntcreatex.out.file.fnum; 1352 1491 1353 printf("get the original sd\n");1492 torture_comment(tctx, "get the original sd\n"); 1354 1493 q.query_secdesc.level = RAW_FILEINFO_SEC_DESC; 1355 1494 q.query_secdesc.in.file.fnum = fnum; 1495 q.query_secdesc.in.secinfo_flags = SECINFO_DACL | SECINFO_OWNER | SECINFO_GROUP; 1496 status = smb_raw_fileinfo(cli->tree, tctx, &q); 1497 CHECK_STATUS(status, NT_STATUS_OK); 1498 sd_orig = q.query_secdesc.out.sd; 1499 1500 owner_sid = dom_sid_string(tctx, sd_orig->owner_sid); 1501 group_sid = dom_sid_string(tctx, sd_orig->group_sid); 1502 1503 torture_comment(tctx, "owner_sid is %s\n", owner_sid); 1504 torture_comment(tctx, "group_sid is %s\n", group_sid); 1505 1356 1506 q.query_secdesc.in.secinfo_flags = SECINFO_DACL | SECINFO_OWNER; 1357 status = smb_raw_fileinfo(cli->tree, tctx, &q); 1358 CHECK_STATUS(status, NT_STATUS_OK); 1359 sd_orig = q.query_secdesc.out.sd; 1360 1361 owner_sid = dom_sid_string(tctx, sd_orig->owner_sid); 1362 1363 printf("owner_sid is %s\n", owner_sid); 1364 1365 sd_def = security_descriptor_dacl_create(tctx, 1507 1508 if (torture_setting_bool(tctx, "samba4", false)) { 1509 /* the default ACL in Samba4 includes the group and 1510 other permissions */ 1511 sd_def1 = security_descriptor_dacl_create(tctx, 1512 0, owner_sid, NULL, 1513 owner_sid, 1514 SEC_ACE_TYPE_ACCESS_ALLOWED, 1515 SEC_RIGHTS_FILE_ALL, 1516 0, 1517 group_sid, 1518 SEC_ACE_TYPE_ACCESS_ALLOWED, 1519 SEC_RIGHTS_FILE_READ | SEC_FILE_EXECUTE, 1520 0, 1521 SID_WORLD, 1522 SEC_ACE_TYPE_ACCESS_ALLOWED, 1523 SEC_RIGHTS_FILE_READ | SEC_FILE_EXECUTE, 1524 0, 1525 SID_NT_SYSTEM, 1526 SEC_ACE_TYPE_ACCESS_ALLOWED, 1527 SEC_RIGHTS_FILE_ALL, 1528 0, 1529 NULL); 1530 } else { 1531 /* 1532 * The Windows Default ACL for a new file, when there is no ACL to be 1533 * inherited: FullControl for the owner and SYSTEM. 1534 */ 1535 sd_def1 = security_descriptor_dacl_create(tctx, 1536 0, owner_sid, NULL, 1537 owner_sid, 1538 SEC_ACE_TYPE_ACCESS_ALLOWED, 1539 SEC_RIGHTS_FILE_ALL, 1540 0, 1541 SID_NT_SYSTEM, 1542 SEC_ACE_TYPE_ACCESS_ALLOWED, 1543 SEC_RIGHTS_FILE_ALL, 1544 0, 1545 NULL); 1546 } 1547 1548 /* 1549 * Use this in the case the system being tested does not add an ACE for 1550 * the SYSTEM SID. 1551 */ 1552 sd_def2 = security_descriptor_dacl_create(tctx, 1366 1553 0, owner_sid, NULL, 1367 1554 owner_sid, 1368 SEC_ACE_TYPE_ACCESS_ALLOWED,1369 SEC_RIGHTS_FILE_ALL,1370 0,1371 SID_NT_SYSTEM,1372 1555 SEC_ACE_TYPE_ACCESS_ALLOWED, 1373 1556 SEC_RIGHTS_FILE_ALL, … … 1410 1593 1411 1594 if (!(test_flags[i].parent_flags & SEC_ACE_FLAG_OBJECT_INHERIT)) { 1412 if (!security_descriptor_equal(q.query_secdesc.out.sd, sd_def)) { 1413 printf("Expected default sd:\n"); 1414 NDR_PRINT_DEBUG(security_descriptor, sd_def); 1415 printf("at %d - got:\n", i); 1595 if (!security_descriptor_equal(q.query_secdesc.out.sd, sd_def1) && 1596 !security_descriptor_equal(q.query_secdesc.out.sd, sd_def2)) { 1597 torture_warning(tctx, "Expected default sd " 1598 "for i=%d:\n", i); 1599 NDR_PRINT_DEBUG(security_descriptor, sd_def1); 1600 torture_warning(tctx, "at %d - got:\n", i); 1416 1601 NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); 1417 1602 } … … 1424 1609 !dom_sid_equal(&q.query_secdesc.out.sd->dacl->aces[0].trustee, 1425 1610 sd_orig->owner_sid)) { 1426 printf("Bad sd in child file at %d\n", i); 1611 ret = false; 1612 torture_warning(tctx, "Bad sd in child file at %d\n", i); 1427 1613 NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); 1428 ret = false;1429 1614 goto check_dir; 1430 1615 } … … 1432 1617 if (q.query_secdesc.out.sd->dacl->aces[0].flags != 1433 1618 test_flags[i].file_flags) { 1434 printf("incorrect file_flags 0x%x - expected 0x%x for parent 0x%x with (i=%d)\n",1619 torture_warning(tctx, "incorrect file_flags 0x%x - expected 0x%x for parent 0x%x with (i=%d)\n", 1435 1620 q.query_secdesc.out.sd->dacl->aces[0].flags, 1436 1621 test_flags[i].file_flags, … … 1457 1642 (!(test_flags[i].parent_flags & SEC_ACE_FLAG_OBJECT_INHERIT) || 1458 1643 (test_flags[i].parent_flags & SEC_ACE_FLAG_NO_PROPAGATE_INHERIT))) { 1459 if (!security_descriptor_equal(q.query_secdesc.out.sd, sd_def)) { 1460 printf("Expected default sd for dir at %d:\n", i); 1461 NDR_PRINT_DEBUG(security_descriptor, sd_def); 1462 printf("got:\n"); 1644 if (!security_descriptor_equal(q.query_secdesc.out.sd, sd_def1) && 1645 !security_descriptor_equal(q.query_secdesc.out.sd, sd_def2)) { 1646 torture_warning(tctx, "Expected default sd for dir at %d:\n", i); 1647 NDR_PRINT_DEBUG(security_descriptor, sd_def1); 1648 torture_warning(tctx, "got:\n"); 1463 1649 NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); 1464 1650 } … … 1474 1660 sd_orig->owner_sid) || 1475 1661 q.query_secdesc.out.sd->dacl->aces[0].flags != test_flags[i].dir_flags) { 1476 printf("(CI & NP) Bad sd in child dir at %d (parent 0x%x)\n", 1477 i, test_flags[i].parent_flags); 1662 torture_warning(tctx, "(CI & NP) Bad sd in child dir - expected 0x%x for parent 0x%x (i=%d)\n", 1663 test_flags[i].dir_flags, 1664 test_flags[i].parent_flags, i); 1478 1665 NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); 1666 torture_comment(tctx, "FYI, here is the parent sd:\n"); 1667 NDR_PRINT_DEBUG(security_descriptor, sd); 1479 1668 ret = false; 1480 1669 continue; … … 1492 1681 q.query_secdesc.out.sd->dacl->aces[1].flags != 1493 1682 (test_flags[i].dir_flags | SEC_ACE_FLAG_INHERIT_ONLY)) { 1494 printf("(CI) Bad sd in child dir at %d (parent 0x%x)\n", 1495 i, test_flags[i].parent_flags); 1683 torture_warning(tctx, "(CI) Bad sd in child dir - expected 0x%x for parent 0x%x (i=%d)\n", 1684 test_flags[i].dir_flags, 1685 test_flags[i].parent_flags, i); 1496 1686 NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); 1687 torture_comment(tctx, "FYI, here is the parent sd:\n"); 1688 NDR_PRINT_DEBUG(security_descriptor, sd); 1497 1689 ret = false; 1498 1690 continue; … … 1505 1697 creator_owner) || 1506 1698 q.query_secdesc.out.sd->dacl->aces[0].flags != test_flags[i].dir_flags) { 1507 printf("(0) Bad sd in child dir at %d (parent 0x%x)\n", 1508 i, test_flags[i].parent_flags); 1699 torture_warning(tctx, "(0) Bad sd in child dir - expected 0x%x for parent 0x%x (i=%d)\n", 1700 test_flags[i].dir_flags, 1701 test_flags[i].parent_flags, i); 1509 1702 NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); 1703 torture_comment(tctx, "FYI, here is the parent sd:\n"); 1704 NDR_PRINT_DEBUG(security_descriptor, sd); 1510 1705 ret = false; 1511 1706 continue; … … 1514 1709 } 1515 1710 1516 printf("testing access checks on inherited create with %s\n", fname1);1711 torture_comment(tctx, "Testing access checks on inherited create with %s\n", fname1); 1517 1712 sd = security_descriptor_dacl_create(tctx, 1518 1713 0, NULL, NULL, … … 1533 1728 CHECK_STATUS(status, NT_STATUS_OK); 1534 1729 1730 /* Check DACL we just set. */ 1731 torture_comment(tctx, "checking new sd\n"); 1732 q.query_secdesc.in.file.fnum = fnum; 1733 q.query_secdesc.in.secinfo_flags = SECINFO_DACL; 1734 status = smb_raw_fileinfo(cli->tree, tctx, &q); 1735 CHECK_STATUS(status, NT_STATUS_OK); 1736 CHECK_SECURITY_DESCRIPTOR(q.query_secdesc.out.sd, sd); 1737 1535 1738 io.ntcreatex.in.fname = fname1; 1536 1739 io.ntcreatex.in.create_options = 0; … … 1555 1758 0, 1556 1759 NULL); 1557 if (!security_descriptor_equal(q.query_secdesc.out.sd, sd2)) { 1558 printf("%s: security descriptors don't match!\n", __location__); 1559 printf("got:\n"); 1560 NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); 1561 printf("expected:\n"); 1562 NDR_PRINT_DEBUG(security_descriptor, sd2); 1563 ret = false; 1564 } 1760 CHECK_SECURITY_DESCRIPTOR(q.query_secdesc.out.sd, sd2); 1565 1761 1566 1762 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; … … 1568 1764 status = smb_raw_open(cli->tree, tctx, &io); 1569 1765 if (NT_STATUS_IS_OK(status)) { 1570 printf("failed: w2k3 ACL bug (allowed open when ACL should deny)\n");1766 torture_warning(tctx, "failed: w2k3 ACL bug (allowed open when ACL should deny)\n"); 1571 1767 ret = false; 1572 1768 fnum2 = io.ntcreatex.out.file.fnum; … … 1574 1770 smbcli_close(cli->tree, fnum2); 1575 1771 } else { 1576 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 1577 } 1578 1579 printf("trying without execute\n"); 1772 if (TARGET_IS_WIN7(tctx)) { 1773 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); 1774 } else { 1775 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 1776 } 1777 } 1778 1779 torture_comment(tctx, "trying without execute\n"); 1580 1780 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; 1581 1781 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL & ~SEC_FILE_EXECUTE; 1582 1782 status = smb_raw_open(cli->tree, tctx, &io); 1583 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 1584 1585 printf("and with full permissions again\n"); 1783 if (TARGET_IS_WIN7(tctx)) { 1784 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); 1785 } else { 1786 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 1787 } 1788 1789 torture_comment(tctx, "and with full permissions again\n"); 1586 1790 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; 1587 1791 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1588 1792 status = smb_raw_open(cli->tree, tctx, &io); 1589 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 1793 if (TARGET_IS_WIN7(tctx)) { 1794 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); 1795 } else { 1796 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 1797 } 1590 1798 1591 1799 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; … … 1596 1804 smbcli_close(cli->tree, fnum2); 1597 1805 1598 printf("put back original sd\n");1806 torture_comment(tctx, "put back original sd\n"); 1599 1807 set.set_secdesc.level = RAW_SFILEINFO_SEC_DESC; 1600 1808 set.set_secdesc.in.file.fnum = fnum; … … 1608 1816 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1609 1817 status = smb_raw_open(cli->tree, tctx, &io); 1610 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 1818 if (TARGET_IS_WIN7(tctx)) { 1819 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); 1820 } else { 1821 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 1822 } 1611 1823 1612 1824 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; … … 1617 1829 smbcli_close(cli->tree, fnum2); 1618 1830 1831 done: 1832 if (sd_orig != NULL) { 1833 set.set_secdesc.level = RAW_SFILEINFO_SEC_DESC; 1834 set.set_secdesc.in.file.fnum = fnum; 1835 set.set_secdesc.in.secinfo_flags = SECINFO_DACL; 1836 set.set_secdesc.in.sd = sd_orig; 1837 status = smb_raw_setfileinfo(cli->tree, &set); 1838 } 1839 1840 smbcli_close(cli->tree, fnum); 1619 1841 smbcli_unlink(cli->tree, fname1); 1620 1842 smbcli_rmdir(cli->tree, dname); 1621 1622 done: 1623 set.set_secdesc.level = RAW_SFILEINFO_SEC_DESC; 1624 set.set_secdesc.in.file.fnum = fnum; 1625 set.set_secdesc.in.secinfo_flags = SECINFO_DACL; 1626 set.set_secdesc.in.sd = sd_orig; 1627 status = smb_raw_setfileinfo(cli->tree, &set); 1628 1629 smbcli_close(cli->tree, fnum); 1843 smb_raw_exit(cli->session); 1844 smbcli_deltree(cli->tree, BASEDIR); 1630 1845 return ret; 1631 1846 } 1632 1847 1848 static bool test_inheritance_flags(struct torture_context *tctx, 1849 struct smbcli_state *cli) 1850 { 1851 NTSTATUS status; 1852 union smb_open io; 1853 const char *dname = BASEDIR "\\inheritance"; 1854 const char *fname1 = BASEDIR "\\inheritance\\testfile"; 1855 bool ret = true; 1856 int fnum=0, fnum2, i, j; 1857 union smb_fileinfo q; 1858 union smb_setfileinfo set; 1859 struct security_descriptor *sd, *sd2, *sd_orig=NULL; 1860 const char *owner_sid; 1861 struct { 1862 uint32_t parent_set_sd_type; /* 3 options */ 1863 uint32_t parent_set_ace_inherit; /* 1 option */ 1864 uint32_t parent_get_sd_type; 1865 uint32_t parent_get_ace_inherit; 1866 uint32_t child_get_sd_type; 1867 uint32_t child_get_ace_inherit; 1868 } tflags[16]; /* 2^4 */ 1869 1870 for (i = 0; i < 15; i++) { 1871 torture_comment(tctx, "i=%d:", i); 1872 1873 ZERO_STRUCT(tflags[i]); 1874 1875 if (i & 1) { 1876 tflags[i].parent_set_sd_type |= 1877 SEC_DESC_DACL_AUTO_INHERITED; 1878 torture_comment(tctx, "AUTO_INHERITED, "); 1879 } 1880 if (i & 2) { 1881 tflags[i].parent_set_sd_type |= 1882 SEC_DESC_DACL_AUTO_INHERIT_REQ; 1883 torture_comment(tctx, "AUTO_INHERIT_REQ, "); 1884 } 1885 if (i & 4) { 1886 tflags[i].parent_set_sd_type |= 1887 SEC_DESC_DACL_PROTECTED; 1888 tflags[i].parent_get_sd_type |= 1889 SEC_DESC_DACL_PROTECTED; 1890 torture_comment(tctx, "PROTECTED, "); 1891 } 1892 if (i & 8) { 1893 tflags[i].parent_set_ace_inherit |= 1894 SEC_ACE_FLAG_INHERITED_ACE; 1895 tflags[i].parent_get_ace_inherit |= 1896 SEC_ACE_FLAG_INHERITED_ACE; 1897 torture_comment(tctx, "INHERITED, "); 1898 } 1899 1900 if ((tflags[i].parent_set_sd_type & 1901 (SEC_DESC_DACL_AUTO_INHERITED | SEC_DESC_DACL_AUTO_INHERIT_REQ)) == 1902 (SEC_DESC_DACL_AUTO_INHERITED | SEC_DESC_DACL_AUTO_INHERIT_REQ)) { 1903 tflags[i].parent_get_sd_type |= 1904 SEC_DESC_DACL_AUTO_INHERITED; 1905 tflags[i].child_get_sd_type |= 1906 SEC_DESC_DACL_AUTO_INHERITED; 1907 tflags[i].child_get_ace_inherit |= 1908 SEC_ACE_FLAG_INHERITED_ACE; 1909 torture_comment(tctx, " ... parent is AUTO INHERITED"); 1910 } 1911 1912 if (tflags[i].parent_set_ace_inherit & 1913 SEC_ACE_FLAG_INHERITED_ACE) { 1914 tflags[i].parent_get_ace_inherit = 1915 SEC_ACE_FLAG_INHERITED_ACE; 1916 torture_comment(tctx, " ... parent ACE is INHERITED"); 1917 } 1918 1919 torture_comment(tctx, "\n"); 1920 } 1921 1922 if (!torture_setup_dir(cli, BASEDIR)) 1923 return false; 1924 1925 torture_comment(tctx, "TESTING ACL INHERITANCE FLAGS\n"); 1926 1927 io.generic.level = RAW_OPEN_NTCREATEX; 1928 io.ntcreatex.in.root_fid.fnum = 0; 1929 io.ntcreatex.in.flags = 0; 1930 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1931 io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; 1932 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY; 1933 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_MASK; 1934 io.ntcreatex.in.alloc_size = 0; 1935 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; 1936 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 1937 io.ntcreatex.in.security_flags = 0; 1938 io.ntcreatex.in.fname = dname; 1939 1940 torture_comment(tctx, "creating initial directory %s\n", dname); 1941 status = smb_raw_open(cli->tree, tctx, &io); 1942 CHECK_STATUS(status, NT_STATUS_OK); 1943 fnum = io.ntcreatex.out.file.fnum; 1944 1945 torture_comment(tctx, "getting original sd\n"); 1946 q.query_secdesc.level = RAW_FILEINFO_SEC_DESC; 1947 q.query_secdesc.in.file.fnum = fnum; 1948 q.query_secdesc.in.secinfo_flags = SECINFO_DACL | SECINFO_OWNER; 1949 status = smb_raw_fileinfo(cli->tree, tctx, &q); 1950 CHECK_STATUS(status, NT_STATUS_OK); 1951 sd_orig = q.query_secdesc.out.sd; 1952 1953 owner_sid = dom_sid_string(tctx, sd_orig->owner_sid); 1954 torture_comment(tctx, "owner_sid is %s\n", owner_sid); 1955 1956 for (i=0; i < ARRAY_SIZE(tflags); i++) { 1957 torture_comment(tctx, "setting a new sd on directory, pass #%d\n", i); 1958 1959 sd = security_descriptor_dacl_create(tctx, 1960 tflags[i].parent_set_sd_type, 1961 NULL, NULL, 1962 owner_sid, 1963 SEC_ACE_TYPE_ACCESS_ALLOWED, 1964 SEC_FILE_WRITE_DATA | SEC_STD_WRITE_DAC, 1965 SEC_ACE_FLAG_OBJECT_INHERIT | 1966 SEC_ACE_FLAG_CONTAINER_INHERIT | 1967 tflags[i].parent_set_ace_inherit, 1968 SID_WORLD, 1969 SEC_ACE_TYPE_ACCESS_ALLOWED, 1970 SEC_FILE_ALL | SEC_STD_ALL, 1971 0, 1972 NULL); 1973 set.set_secdesc.level = RAW_SFILEINFO_SEC_DESC; 1974 set.set_secdesc.in.file.fnum = fnum; 1975 set.set_secdesc.in.secinfo_flags = SECINFO_DACL; 1976 set.set_secdesc.in.sd = sd; 1977 status = smb_raw_setfileinfo(cli->tree, &set); 1978 CHECK_STATUS(status, NT_STATUS_OK); 1979 1980 /* 1981 * Check DACL we just set, except change the bits to what they 1982 * should be. 1983 */ 1984 torture_comment(tctx, " checking new sd\n"); 1985 1986 /* REQ bit should always be false. */ 1987 sd->type &= ~SEC_DESC_DACL_AUTO_INHERIT_REQ; 1988 1989 if ((tflags[i].parent_get_sd_type & SEC_DESC_DACL_AUTO_INHERITED) == 0) 1990 sd->type &= ~SEC_DESC_DACL_AUTO_INHERITED; 1991 1992 q.query_secdesc.in.file.fnum = fnum; 1993 q.query_secdesc.in.secinfo_flags = SECINFO_DACL; 1994 status = smb_raw_fileinfo(cli->tree, tctx, &q); 1995 CHECK_STATUS(status, NT_STATUS_OK); 1996 CHECK_SECURITY_DESCRIPTOR(q.query_secdesc.out.sd, sd); 1997 1998 /* Create file. */ 1999 torture_comment(tctx, " creating file %s\n", fname1); 2000 io.ntcreatex.in.fname = fname1; 2001 io.ntcreatex.in.create_options = 0; 2002 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 2003 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 2004 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; 2005 status = smb_raw_open(cli->tree, tctx, &io); 2006 CHECK_STATUS(status, NT_STATUS_OK); 2007 fnum2 = io.ntcreatex.out.file.fnum; 2008 CHECK_ACCESS_FLAGS(fnum2, SEC_RIGHTS_FILE_ALL); 2009 2010 q.query_secdesc.in.file.fnum = fnum2; 2011 q.query_secdesc.in.secinfo_flags = SECINFO_DACL | SECINFO_OWNER; 2012 status = smb_raw_fileinfo(cli->tree, tctx, &q); 2013 CHECK_STATUS(status, NT_STATUS_OK); 2014 2015 torture_comment(tctx, " checking sd on file %s\n", fname1); 2016 sd2 = security_descriptor_dacl_create(tctx, 2017 tflags[i].child_get_sd_type, 2018 owner_sid, NULL, 2019 owner_sid, 2020 SEC_ACE_TYPE_ACCESS_ALLOWED, 2021 SEC_FILE_WRITE_DATA | SEC_STD_WRITE_DAC, 2022 tflags[i].child_get_ace_inherit, 2023 NULL); 2024 CHECK_SECURITY_DESCRIPTOR(q.query_secdesc.out.sd, sd2); 2025 2026 /* 2027 * Set new sd on file ... prove that the bits have nothing to 2028 * do with the parents bits when manually setting an ACL. The 2029 * _AUTO_INHERITED bit comes directly from the ACL set. 2030 */ 2031 for (j = 0; j < ARRAY_SIZE(tflags); j++) { 2032 torture_comment(tctx, " setting new file sd, pass #%d\n", j); 2033 2034 /* Change sd type. */ 2035 sd2->type &= ~(SEC_DESC_DACL_AUTO_INHERITED | 2036 SEC_DESC_DACL_AUTO_INHERIT_REQ | 2037 SEC_DESC_DACL_PROTECTED); 2038 sd2->type |= tflags[j].parent_set_sd_type; 2039 2040 sd2->dacl->aces[0].flags &= 2041 ~SEC_ACE_FLAG_INHERITED_ACE; 2042 sd2->dacl->aces[0].flags |= 2043 tflags[j].parent_set_ace_inherit; 2044 2045 set.set_secdesc.level = RAW_SFILEINFO_SEC_DESC; 2046 set.set_secdesc.in.file.fnum = fnum2; 2047 set.set_secdesc.in.secinfo_flags = SECINFO_DACL; 2048 set.set_secdesc.in.sd = sd2; 2049 status = smb_raw_setfileinfo(cli->tree, &set); 2050 CHECK_STATUS(status, NT_STATUS_OK); 2051 2052 /* Check DACL we just set. */ 2053 sd2->type &= ~SEC_DESC_DACL_AUTO_INHERIT_REQ; 2054 if ((tflags[j].parent_get_sd_type & SEC_DESC_DACL_AUTO_INHERITED) == 0) 2055 sd2->type &= ~SEC_DESC_DACL_AUTO_INHERITED; 2056 2057 q.query_secdesc.in.file.fnum = fnum2; 2058 q.query_secdesc.in.secinfo_flags = SECINFO_DACL | SECINFO_OWNER; 2059 status = smb_raw_fileinfo(cli->tree, tctx, &q); 2060 CHECK_STATUS(status, NT_STATUS_OK); 2061 2062 CHECK_SECURITY_DESCRIPTOR(q.query_secdesc.out.sd, sd2); 2063 } 2064 2065 smbcli_close(cli->tree, fnum2); 2066 smbcli_unlink(cli->tree, fname1); 2067 } 2068 2069 done: 2070 smbcli_close(cli->tree, fnum); 2071 smb_raw_exit(cli->session); 2072 smbcli_deltree(cli->tree, BASEDIR); 2073 return ret; 2074 } 1633 2075 1634 2076 /* 1635 2077 test dynamic acl inheritance 2078 Test copied to smb2/acls.c for SMB2. 1636 2079 */ 1637 2080 static bool test_inheritance_dynamic(struct torture_context *tctx, … … 1640 2083 NTSTATUS status; 1641 2084 union smb_open io; 1642 const char *dname = BASEDIR "\\inheritance ";1643 const char *fname1 = BASEDIR "\\inheritance \\testfile";2085 const char *dname = BASEDIR "\\inheritance2"; 2086 const char *fname1 = BASEDIR "\\inheritance2\\testfile"; 1644 2087 bool ret = true; 1645 2088 int fnum=0, fnum2; … … 1649 2092 const char *owner_sid; 1650 2093 1651 printf("TESTING DYNAMIC ACL INHERITANCE\n");1652 1653 if (!torture_setup_dir(cli, BASEDIR)) {2094 torture_comment(tctx, "TESTING DYNAMIC ACL INHERITANCE\n"); 2095 2096 if (!torture_setup_dir(cli, BASEDIR)) 1654 2097 return false; 1655 }1656 2098 1657 2099 io.generic.level = RAW_OPEN_NTCREATEX; 1658 io.ntcreatex.in.root_fid = 0;2100 io.ntcreatex.in.root_fid.fnum = 0; 1659 2101 io.ntcreatex.in.flags = 0; 1660 2102 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; … … 1672 2114 fnum = io.ntcreatex.out.file.fnum; 1673 2115 1674 printf("get the original sd\n");2116 torture_comment(tctx, "get the original sd\n"); 1675 2117 q.query_secdesc.level = RAW_FILEINFO_SEC_DESC; 1676 2118 q.query_secdesc.in.file.fnum = fnum; … … 1682 2124 owner_sid = dom_sid_string(tctx, sd_orig->owner_sid); 1683 2125 1684 printf("owner_sid is %s\n", owner_sid);2126 torture_comment(tctx, "owner_sid is %s\n", owner_sid); 1685 2127 1686 2128 sd = security_descriptor_dacl_create(tctx, … … 1700 2142 CHECK_STATUS(status, NT_STATUS_OK); 1701 2143 1702 printf("create a file with an inherited acl\n");2144 torture_comment(tctx, "create a file with an inherited acl\n"); 1703 2145 io.ntcreatex.in.fname = fname1; 1704 2146 io.ntcreatex.in.create_options = 0; … … 1710 2152 smbcli_close(cli->tree, fnum2); 1711 2153 1712 printf("try and access file with base rights - should be OK\n");2154 torture_comment(tctx, "try and access file with base rights - should be OK\n"); 1713 2155 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; 1714 2156 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; … … 1718 2160 smbcli_close(cli->tree, fnum2); 1719 2161 1720 printf("try and access file with extra rights - should be denied\n");2162 torture_comment(tctx, "try and access file with extra rights - should be denied\n"); 1721 2163 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA | SEC_FILE_EXECUTE; 1722 2164 status = smb_raw_open(cli->tree, tctx, &io); 1723 2165 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 1724 2166 1725 printf("update parent sd\n");2167 torture_comment(tctx, "update parent sd\n"); 1726 2168 sd = security_descriptor_dacl_create(tctx, 1727 2169 0, NULL, NULL, … … 1737 2179 CHECK_STATUS(status, NT_STATUS_OK); 1738 2180 1739 printf("try and access file with base rights - should be OK\n");2181 torture_comment(tctx, "try and access file with base rights - should be OK\n"); 1740 2182 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; 1741 2183 status = smb_raw_open(cli->tree, tctx, &io); … … 1745 2187 1746 2188 1747 printf("try and access now - should be OK if dynamic inheritance works\n");2189 torture_comment(tctx, "try and access now - should be OK if dynamic inheritance works\n"); 1748 2190 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA | SEC_FILE_EXECUTE; 1749 2191 status = smb_raw_open(cli->tree, tctx, &io); 1750 2192 if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { 1751 printf("Server does not have dynamic inheritance\n");2193 torture_comment(tctx, "Server does not have dynamic inheritance\n"); 1752 2194 } 1753 2195 if (NT_STATUS_EQUAL(status, NT_STATUS_OK)) { 1754 printf("Server does have dynamic inheritance\n");2196 torture_comment(tctx, "Server does have dynamic inheritance\n"); 1755 2197 } 1756 2198 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); … … 1759 2201 1760 2202 done: 1761 printf("put back original sd\n");2203 torture_comment(tctx, "put back original sd\n"); 1762 2204 set.set_secdesc.level = RAW_SFILEINFO_SEC_DESC; 1763 2205 set.set_secdesc.in.file.fnum = fnum; … … 1768 2210 smbcli_close(cli->tree, fnum); 1769 2211 smbcli_rmdir(cli->tree, dname); 2212 smb_raw_exit(cli->session); 2213 smbcli_deltree(cli->tree, BASEDIR); 1770 2214 1771 2215 return ret; … … 1784 2228 if (NT_STATUS_IS_OK(status)) { \ 1785 2229 if (!(granted & access)) {\ 1786 printf("(%s) %s but flags 0x%08X are not granted! granted[0x%08X] desired[0x%08X]\n", \ 2230 ret = false; \ 2231 torture_result(tctx, TORTURE_FAIL, "(%s) %s but flags 0x%08X are not granted! granted[0x%08X] desired[0x%08X]\n", \ 1787 2232 __location__, nt_errstr(status), access, granted, desired); \ 1788 ret = false; \1789 2233 goto done; \ 1790 2234 } \ 1791 2235 } else { \ 1792 2236 if (granted & access) {\ 1793 printf("(%s) %s but flags 0x%08X are granted! granted[0x%08X] desired[0x%08X]\n", \ 2237 ret = false; \ 2238 torture_result(tctx, TORTURE_FAIL, "(%s) %s but flags 0x%08X are granted! granted[0x%08X] desired[0x%08X]\n", \ 1794 2239 __location__, nt_errstr(status), access, granted, desired); \ 1795 ret = false; \1796 2240 goto done; \ 1797 2241 } \ … … 1800 2244 } while (0) 1801 2245 1802 /* test what access mask is needed for getting and setting security_descriptors */ 2246 /* test what access mask is needed for getting and setting security_descriptors 2247 Test copied to smb2/acls.c for SMB2. */ 1803 2248 static bool test_sd_get_set(struct torture_context *tctx, 1804 2249 struct smbcli_state *cli) … … 1836 2281 uint64_t set_sacl_bits = SEC_FLAG_SYSTEM_SECURITY; 1837 2282 1838 printf("TESTING ACCESS MASKS FOR SD GET/SET\n"); 2283 if (!torture_setup_dir(cli, BASEDIR)) 2284 return false; 2285 2286 torture_comment(tctx, "TESTING ACCESS MASKS FOR SD GET/SET\n"); 1839 2287 1840 2288 /* first create a file with full access for everyone */ … … 1849 2297 sd->sacl = NULL; 1850 2298 io.ntcreatex.level = RAW_OPEN_NTTRANS_CREATE; 1851 io.ntcreatex.in.root_fid = 0;2299 io.ntcreatex.in.root_fid.fnum = 0; 1852 2300 io.ntcreatex.in.flags = 0; 1853 2301 io.ntcreatex.in.access_mask = SEC_GENERIC_ALL; … … 1979 2427 smbcli_close(cli->tree, fnum); 1980 2428 smbcli_unlink(cli->tree, fname); 2429 smb_raw_exit(cli->session); 2430 smbcli_deltree(cli->tree, BASEDIR); 1981 2431 1982 2432 return ret; … … 1987 2437 basic testing of security descriptor calls 1988 2438 */ 1989 bool torture_raw_acls(struct torture_context *tctx, struct smbcli_state *cli)2439 struct torture_suite *torture_raw_acls(TALLOC_CTX *mem_ctx) 1990 2440 { 1991 bool ret = true; 1992 1993 if (!torture_setup_dir(cli, BASEDIR)) { 1994 return false; 1995 } 1996 1997 ret &= test_sd(tctx, cli); 1998 ret &= test_nttrans_create(tctx, cli); 1999 ret &= test_nttrans_create_null_dacl(tctx, cli); 2000 ret &= test_creator_sid(tctx, cli); 2001 ret &= test_generic_bits(tctx, cli); 2002 ret &= test_owner_bits(tctx, cli); 2003 ret &= test_inheritance(tctx, cli); 2004 ret &= test_inheritance_dynamic(tctx, cli); 2005 ret &= test_sd_get_set(tctx, cli); 2006 2007 smb_raw_exit(cli->session); 2008 smbcli_deltree(cli->tree, BASEDIR); 2009 2010 return ret; 2441 struct torture_suite *suite = torture_suite_create(mem_ctx, "acls"); 2442 2443 torture_suite_add_1smb_test(suite, "sd", test_sd); 2444 torture_suite_add_1smb_test(suite, "create_file", test_nttrans_create_file); 2445 torture_suite_add_1smb_test(suite, "create_dir", test_nttrans_create_dir); 2446 torture_suite_add_1smb_test(suite, "nulldacl", test_nttrans_create_null_dacl); 2447 torture_suite_add_1smb_test(suite, "creator", test_creator_sid); 2448 torture_suite_add_1smb_test(suite, "generic", test_generic_bits); 2449 torture_suite_add_1smb_test(suite, "owner", test_owner_bits); 2450 torture_suite_add_1smb_test(suite, "inheritance", test_inheritance); 2451 2452 /* torture_suite_add_1smb_test(suite, "INHERITFLAGS", test_inheritance_flags); */ 2453 torture_suite_add_1smb_test(suite, "dynamic", test_inheritance_dynamic); 2454 /* XXX This test does not work against XP or Vista. 2455 torture_suite_add_1smb_test(suite, "GETSET", test_sd_get_set); 2456 */ 2457 2458 return suite; 2011 2459 } -
trunk/server/source4/torture/raw/chkpath.c
r414 r745 20 20 #include "includes.h" 21 21 #include "system/locale.h" 22 #include "torture/torture.h"23 22 #include "libcli/raw/libcliraw.h" 24 #include "libcli/raw/raw_proto.h"25 23 #include "libcli/libcli.h" 26 24 #include "torture/util.h" … … 179 177 give different NT status returns for chkpth and findfirst. */ 180 178 181 printf(" testing findfirst on %s\n", "\\.\\\\\\\\\\\\.");179 printf("Testing findfirst on %s\n", "\\.\\\\\\\\\\\\."); 182 180 status = single_search(cli, tctx, "\\.\\\\\\\\\\\\."); 183 181 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID,NT_STATUS_DOS(ERRDOS,ERRinvalidname)); … … 186 184 187 185 /* We expect this open to fail with the same error code as the chkpath below. */ 188 printf(" testing Open on %s\n", "\\.\\\\\\\\\\\\.");186 printf("Testing Open on %s\n", "\\.\\\\\\\\\\\\."); 189 187 /* findfirst seems to fail with a different error. */ 190 188 fnum1 = smbcli_nt_create_full(cli->tree, "\\.\\\\\\\\\\\\.", … … 227 225 228 226 /* We expect this open to fail with the same error code as the chkpath below. */ 229 printf(" testing Open on %s\n", BASEDIR".\\.\\.\\.\\foo\\..\\.\\");227 printf("Testing Open on %s\n", BASEDIR".\\.\\.\\.\\foo\\..\\.\\"); 230 228 /* findfirst seems to fail with a different error. */ 231 229 fnum1 = smbcli_nt_create_full(cli->tree, BASEDIR".\\.\\.\\.\\foo\\..\\.\\", … … 240 238 CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath)); 241 239 242 printf(" testing findfirst on %s\n", BASEDIR".\\.\\.\\.\\foo\\..\\.\\");240 printf("Testing findfirst on %s\n", BASEDIR".\\.\\.\\.\\foo\\..\\.\\"); 243 241 status = single_search(cli, tctx, BASEDIR".\\.\\.\\.\\foo\\..\\.\\"); 244 242 CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath)); … … 246 244 /* We expect this open to fail with the same error code as the chkpath below. */ 247 245 /* findfirst seems to fail with a different error. */ 248 printf(" testing Open on %s\n", BASEDIR "\\nt\\V S\\VB98\\vb6.exe\\3");246 printf("Testing Open on %s\n", BASEDIR "\\nt\\V S\\VB98\\vb6.exe\\3"); 249 247 fnum1 = smbcli_nt_create_full(cli->tree, BASEDIR "\\nt\\V S\\VB98\\vb6.exe\\3", 250 248 0, SEC_RIGHTS_FILE_ALL, -
trunk/server/source4/torture/raw/close.c
r414 r745 68 68 CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE); 69 69 70 printf(" testing close.in.write_time\n");70 printf("Testing close.in.write_time\n"); 71 71 72 72 /* the file should have the write time set */ … … 84 84 } 85 85 86 printf(" testing other times\n");86 printf("Testing other times\n"); 87 87 88 88 /* none of the other times should be set to that time */ … … 134 134 } 135 135 136 printf(" testing splclose\n");136 printf("Testing splclose\n"); 137 137 138 138 /* check splclose on a file */ … … 143 143 CHECK_STATUS(status, NT_STATUS_DOS(ERRSRV, ERRerror)); 144 144 145 printf(" testing flush\n");145 printf("Testing flush\n"); 146 146 smbcli_close(cli->tree, fnum); 147 147 -
trunk/server/source4/torture/raw/composite.c
r414 r745 66 66 io1.in.size = len; 67 67 68 printf(" testing savefile\n");68 printf("Testing savefile\n"); 69 69 70 70 status = smb_composite_savefile(cli->tree, &io1); … … 76 76 io2.in.fname = fname; 77 77 78 printf(" testing parallel loadfile with %d ops\n", num_ops);78 printf("Testing parallel loadfile with %d ops\n", num_ops); 79 79 80 80 c = talloc_array(tctx, struct composite_context *, num_ops); … … 146 146 io1.in.size = len; 147 147 148 printf(" testing savefile\n");148 printf("Testing savefile\n"); 149 149 150 150 status = smb_composite_savefile(cli->tree, &io1); … … 155 155 156 156 io2.in.dest_host = torture_setting_string(tctx, "host", NULL); 157 io2.in.ports = lp _smb_ports(tctx->lp_ctx);157 io2.in.ports = lpcfg_smb_ports(tctx->lp_ctx); 158 158 io2.in.called_name = torture_setting_string(tctx, "host", NULL); 159 159 io2.in.service = torture_setting_string(tctx, "share", NULL); … … 161 161 162 162 io2.in.credentials = cmdline_credentials; 163 io2.in.workgroup = lp _workgroup(tctx->lp_ctx);163 io2.in.workgroup = lpcfg_workgroup(tctx->lp_ctx); 164 164 io2.in.filename = fname; 165 io2.in.resolve_ctx = lp_resolve_context(tctx->lp_ctx); 166 io2.in.iconv_convenience = lp_iconv_convenience(tctx->lp_ctx); 167 io2.in.gensec_settings = lp_gensec_settings(tctx, tctx->lp_ctx); 168 lp_smbcli_options(tctx->lp_ctx, &io2.in.options); 169 lp_smbcli_session_options(tctx->lp_ctx, &io2.in.session_options); 170 171 printf("testing parallel fetchfile with %d ops\n", torture_numops); 165 io2.in.resolve_ctx = lpcfg_resolve_context(tctx->lp_ctx); 166 io2.in.gensec_settings = lpcfg_gensec_settings(tctx, tctx->lp_ctx); 167 lpcfg_smbcli_options(tctx->lp_ctx, &io2.in.options); 168 lpcfg_smbcli_session_options(tctx->lp_ctx, &io2.in.session_options); 169 170 printf("Testing parallel fetchfile with %d ops\n", torture_numops); 172 171 173 172 event_ctx = cli->transport->socket->event.ctx; … … 285 284 /* set parameters for appendacl async call */ 286 285 287 printf(" testing parallel appendacl with %d ops\n", num_ops);286 printf("Testing parallel appendacl with %d ops\n", num_ops); 288 287 289 288 c = talloc_array(tctx, struct composite_context *, num_ops); … … 348 347 349 348 io1.in.dest_host = torture_setting_string(tctx, "host", NULL); 350 io1.in.dest_ports = lp _smb_ports(tctx->lp_ctx);351 io1.in.socket_options = lp _socket_options(tctx->lp_ctx);349 io1.in.dest_ports = lpcfg_smb_ports(tctx->lp_ctx); 350 io1.in.socket_options = lpcfg_socket_options(tctx->lp_ctx); 352 351 io1.in.called_name = torture_setting_string(tctx, "host", NULL); 353 352 io1.in.service = torture_setting_string(tctx, "share", NULL); 354 353 io1.in.service_type = "A:"; 355 354 io1.in.credentials = cmdline_credentials; 356 io1.in.workgroup = lp _workgroup(tctx->lp_ctx);355 io1.in.workgroup = lpcfg_workgroup(tctx->lp_ctx); 357 356 io1.in.level = RAW_QFS_OBJECTID_INFORMATION; 358 io1.in. iconv_convenience = lp_iconv_convenience(tctx->lp_ctx);359 io1.in.gensec_settings = lp_gensec_settings(tctx, tctx->lp_ctx); 360 361 printf("testing parallel queryfsinfo [Object ID] with %d ops\n",torture_numops);357 io1.in.gensec_settings = lpcfg_gensec_settings(tctx, tctx->lp_ctx); 358 359 printf("Testing parallel queryfsinfo [Object ID] with %d ops\n", 360 torture_numops); 362 361 363 362 event_ctx = tctx->ev; … … 365 364 366 365 for (i=0; i<torture_numops; i++) { 367 c[i] = smb_composite_fsinfo_send(cli->tree, &io1, lp _resolve_context(tctx->lp_ctx));366 c[i] = smb_composite_fsinfo_send(cli->tree, &io1, lpcfg_resolve_context(tctx->lp_ctx)); 368 367 c[i]->async.fn = loadfile_complete; 369 368 c[i]->async.private_data = count; -
trunk/server/source4/torture/raw/context.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "torture/torture.h"22 21 #include "libcli/raw/libcliraw.h" 23 22 #include "libcli/raw/raw_proto.h" 24 #include "libcli/composite/composite.h"25 23 #include "libcli/smb_composite/smb_composite.h" 26 24 #include "lib/cmdline/popt_common.h" 27 #include "lib/events/events.h"28 25 #include "libcli/libcli.h" 29 26 #include "torture/util.h" … … 93 90 printf("create a second security context on the same transport\n"); 94 91 95 lp _smbcli_session_options(tctx->lp_ctx, &options);96 gensec_settings = lp _gensec_settings(tctx, tctx->lp_ctx);92 lpcfg_smbcli_session_options(tctx->lp_ctx, &options); 93 gensec_settings = lpcfg_gensec_settings(tctx, tctx->lp_ctx); 97 94 98 95 session = smbcli_session_init(cli->transport, tctx, false, options); … … 100 97 setup.in.sesskey = cli->transport->negotiate.sesskey; 101 98 setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */ 102 setup.in.workgroup = lp _workgroup(tctx->lp_ctx);99 setup.in.workgroup = lpcfg_workgroup(tctx->lp_ctx); 103 100 104 101 setup.in.credentials = cmdline_credentials; … … 116 113 setup.in.sesskey = cli->transport->negotiate.sesskey; 117 114 setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */ 118 setup.in.workgroup = lp _workgroup(tctx->lp_ctx);115 setup.in.workgroup = lpcfg_workgroup(tctx->lp_ctx); 119 116 120 117 setup.in.credentials = cmdline_credentials; … … 143 140 setup.in.sesskey = cli->transport->negotiate.sesskey; 144 141 setup.in.capabilities &= ~CAP_EXTENDED_SECURITY; /* force a non extended security login (should fail) */ 145 setup.in.workgroup = lp _workgroup(tctx->lp_ctx);142 setup.in.workgroup = lpcfg_workgroup(tctx->lp_ctx); 146 143 147 144 setup.in.credentials = cmdline_credentials; … … 156 153 setup.in.sesskey = cli->transport->negotiate.sesskey; 157 154 setup.in.capabilities &= ~CAP_EXTENDED_SECURITY; /* force a non extended security login (should fail) */ 158 setup.in.workgroup = lp _workgroup(tctx->lp_ctx);155 setup.in.workgroup = lpcfg_workgroup(tctx->lp_ctx); 159 156 160 157 anon_creds = cli_credentials_init(tctx); … … 176 173 printf("create a file using the new vuid\n"); 177 174 io.generic.level = RAW_OPEN_NTCREATEX; 178 io.ntcreatex.in.root_fid = 0;175 io.ntcreatex.in.root_fid.fnum = 0; 179 176 io.ntcreatex.in.flags = 0; 180 177 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 233 230 setups[i].in.sesskey = cli->transport->negotiate.sesskey; 234 231 setups[i].in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */ 235 setups[i].in.workgroup = lp _workgroup(tctx->lp_ctx);232 setups[i].in.workgroup = lpcfg_workgroup(tctx->lp_ctx); 236 233 237 234 setups[i].in.credentials = cmdline_credentials; … … 312 309 printf("create a file using the new tid\n"); 313 310 io.generic.level = RAW_OPEN_NTCREATEX; 314 io.ntcreatex.in.root_fid = 0;311 io.ntcreatex.in.root_fid.fnum = 0; 315 312 io.ntcreatex.in.flags = 0; 316 313 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 398 395 host = torture_setting_string(tctx, "host", NULL); 399 396 400 lp _smbcli_session_options(tctx->lp_ctx, &options);397 lpcfg_smbcli_session_options(tctx->lp_ctx, &options); 401 398 402 399 printf("create the first new sessions\n"); … … 404 401 setup.in.sesskey = cli->transport->negotiate.sesskey; 405 402 setup.in.capabilities = cli->transport->negotiate.capabilities; 406 setup.in.workgroup = lp _workgroup(tctx->lp_ctx);403 setup.in.workgroup = lpcfg_workgroup(tctx->lp_ctx); 407 404 setup.in.credentials = cmdline_credentials; 408 setup.in.gensec_settings = lp _gensec_settings(tctx, tctx->lp_ctx);405 setup.in.gensec_settings = lpcfg_gensec_settings(tctx, tctx->lp_ctx); 409 406 status = smb_composite_sesssetup(session1, &setup); 410 407 CHECK_STATUS(status, NT_STATUS_OK); … … 426 423 printf("create a file using vuid1\n"); 427 424 io.generic.level = RAW_OPEN_NTCREATEX; 428 io.ntcreatex.in.root_fid = 0;425 io.ntcreatex.in.root_fid.fnum = 0; 429 426 io.ntcreatex.in.flags = 0; 430 427 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 461 458 setup.in.sesskey = cli->transport->negotiate.sesskey; 462 459 setup.in.capabilities = cli->transport->negotiate.capabilities; 463 setup.in.workgroup = lp _workgroup(tctx->lp_ctx);460 setup.in.workgroup = lpcfg_workgroup(tctx->lp_ctx); 464 461 setup.in.credentials = cmdline_credentials; 465 setup.in.gensec_settings = lp _gensec_settings(tctx, tctx->lp_ctx);462 setup.in.gensec_settings = lpcfg_gensec_settings(tctx, tctx->lp_ctx); 466 463 status = smb_composite_sesssetup(session2, &setup); 467 464 CHECK_STATUS(status, NT_STATUS_OK); … … 474 471 printf("create a file using vuid2\n"); 475 472 io.generic.level = RAW_OPEN_NTCREATEX; 476 io.ntcreatex.in.root_fid = 0;473 io.ntcreatex.in.root_fid.fnum = 0; 477 474 io.ntcreatex.in.flags = 0; 478 475 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 552 549 cli->session->pid = pid1; 553 550 io.generic.level = RAW_OPEN_NTCREATEX; 554 io.ntcreatex.in.root_fid = 0;551 io.ntcreatex.in.root_fid.fnum = 0; 555 552 io.ntcreatex.in.flags = 0; 556 553 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 655 652 } 656 653 657 lp _smbcli_session_options(tctx->lp_ctx, &options);654 lpcfg_smbcli_session_options(tctx->lp_ctx, &options); 658 655 659 656 printf("create a second security context on the same transport\n"); … … 662 659 setup.in.sesskey = cli->transport->negotiate.sesskey; 663 660 setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */ 664 setup.in.workgroup = lp _workgroup(tctx->lp_ctx);661 setup.in.workgroup = lpcfg_workgroup(tctx->lp_ctx); 665 662 setup.in.credentials = cmdline_credentials; 666 setup.in.gensec_settings = lp _gensec_settings(tctx, tctx->lp_ctx);663 setup.in.gensec_settings = lpcfg_gensec_settings(tctx, tctx->lp_ctx); 667 664 668 665 status = smb_composite_sesssetup(session, &setup); … … 678 675 cli->session->vuid = vuid1; 679 676 io.generic.level = RAW_OPEN_NTCREATEX; 680 io.ntcreatex.in.root_fid = 0;677 io.ntcreatex.in.root_fid.fnum = 0; 681 678 io.ntcreatex.in.flags = 0; 682 679 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 786 783 cli->tree->tid = tid1; 787 784 io.generic.level = RAW_OPEN_NTCREATEX; 788 io.ntcreatex.in.root_fid = 0;785 io.ntcreatex.in.root_fid.fnum = 0; 789 786 io.ntcreatex.in.flags = 0; 790 787 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 817 814 cli->tree->tid = tid2; 818 815 io.generic.level = RAW_OPEN_NTCREATEX; 819 io.ntcreatex.in.root_fid = 0;816 io.ntcreatex.in.root_fid.fnum = 0; 820 817 io.ntcreatex.in.flags = 0; 821 818 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 907 904 { 908 905 bool ret = true; 909 if (lp _use_spnego(torture->lp_ctx)) {906 if (lpcfg_use_spnego(torture->lp_ctx)) { 910 907 ret &= torture_raw_context_int(torture, cli); 911 lp _set_cmdline(torture->lp_ctx, "use spnego", "False");908 lpcfg_set_cmdline(torture->lp_ctx, "use spnego", "False"); 912 909 } 913 910 -
trunk/server/source4/torture/raw/eas.c
r414 r745 1 /* 1 /* 2 2 Unix SMB/CIFS implementation. 3 3 … … 6 6 Copyright (C) Andrew Tridgell 2004 7 7 Copyright (C) Guenter Kukkukk 2005 8 8 9 9 This program is free software; you can redistribute it and/or modify 10 10 it under the terms of the GNU General Public License as published by 11 11 the Free Software Foundation; either version 3 of the License, or 12 12 (at your option) any later version. 13 13 14 14 This program is distributed in the hope that it will be useful, 15 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 17 GNU General Public License for more details. 18 18 19 19 You should have received a copy of the GNU General Public License 20 20 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 30 30 31 31 #define CHECK_STATUS(status, correct) do { \ 32 if (!NT_STATUS_EQUAL(status, correct)) { \ 33 printf("(%s) Incorrect status %s - should be %s\n", \ 34 __location__, nt_errstr(status), nt_errstr(correct)); \ 35 ret = false; \ 36 goto done; \ 37 }} while (0) 32 torture_assert_ntstatus_equal_goto(tctx, status, correct, ret, done, "Incorrect status"); \ 33 } while (0) 38 34 39 35 static bool maxeadebug; /* need that here, to allow no file delete in debug case */ 40 36 41 static bool check_ea(struct smbcli_state *cli, 37 static bool check_ea(struct smbcli_state *cli, 42 38 const char *fname, const char *eaname, const char *value) 43 39 { … … 46 42 } 47 43 48 static bool test_eas(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)44 static bool test_eas(struct smbcli_state *cli, struct torture_context *tctx) 49 45 { 50 46 NTSTATUS status; … … 55 51 int fnum = -1; 56 52 57 printf("TESTING SETFILEINFO EA_SET\n");53 torture_comment(tctx, "TESTING SETFILEINFO EA_SET\n"); 58 54 59 55 io.generic.level = RAW_OPEN_NTCREATEX; 60 io.ntcreatex.in.root_fid = 0;56 io.ntcreatex.in.root_fid.fnum = 0; 61 57 io.ntcreatex.in.flags = 0; 62 58 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; 63 59 io.ntcreatex.in.create_options = 0; 64 60 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 65 io.ntcreatex.in.share_access = 66 NTCREATEX_SHARE_ACCESS_READ | 61 io.ntcreatex.in.share_access = 62 NTCREATEX_SHARE_ACCESS_READ | 67 63 NTCREATEX_SHARE_ACCESS_WRITE; 68 64 io.ntcreatex.in.alloc_size = 0; … … 71 67 io.ntcreatex.in.security_flags = 0; 72 68 io.ntcreatex.in.fname = fname; 73 status = smb_raw_open(cli->tree, mem_ctx, &io);69 status = smb_raw_open(cli->tree, tctx, &io); 74 70 CHECK_STATUS(status, NT_STATUS_OK); 75 71 fnum = io.ntcreatex.out.file.fnum; 76 72 77 73 ret &= check_ea(cli, fname, "EAONE", NULL); 78 74 79 printf("Adding first two EAs\n");75 torture_comment(tctx, "Adding first two EAs\n"); 80 76 setfile.generic.level = RAW_SFILEINFO_EA_SET; 81 77 setfile.generic.in.file.fnum = fnum; 82 78 setfile.ea_set.in.num_eas = 2; 83 setfile.ea_set.in.eas = talloc_array( mem_ctx, struct ea_struct, 2);79 setfile.ea_set.in.eas = talloc_array(tctx, struct ea_struct, 2); 84 80 setfile.ea_set.in.eas[0].flags = 0; 85 81 setfile.ea_set.in.eas[0].name.s = "EAONE"; … … 95 91 ret &= check_ea(cli, fname, "SECONDEA", "ValueTwo"); 96 92 97 printf("Modifying 2nd EA\n");93 torture_comment(tctx, "Modifying 2nd EA\n"); 98 94 setfile.ea_set.in.num_eas = 1; 99 95 setfile.ea_set.in.eas[0].name.s = "SECONDEA"; … … 105 101 ret &= check_ea(cli, fname, "SECONDEA", " Changed Value"); 106 102 107 printf("Setting a NULL EA\n");103 torture_comment(tctx, "Setting a NULL EA\n"); 108 104 setfile.ea_set.in.eas[0].value = data_blob(NULL, 0); 109 105 setfile.ea_set.in.eas[0].name.s = "NULLEA"; … … 115 111 ret &= check_ea(cli, fname, "NULLEA", NULL); 116 112 117 printf("Deleting first EA\n");113 torture_comment(tctx, "Deleting first EA\n"); 118 114 setfile.ea_set.in.eas[0].flags = 0; 119 115 setfile.ea_set.in.eas[0].name.s = "EAONE"; … … 125 121 ret &= check_ea(cli, fname, "SECONDEA", " Changed Value"); 126 122 127 printf("Deleting second EA\n");123 torture_comment(tctx, "Deleting second EA\n"); 128 124 setfile.ea_set.in.eas[0].flags = 0; 129 125 setfile.ea_set.in.eas[0].name.s = "SECONDEA"; … … 144 140 * Helper function to retrieve the max. ea size for one ea name 145 141 */ 146 static int test_one_eamax(struct smbcli_state *cli, const int fnum, 147 const char *eaname, DATA_BLOB eablob, 148 const int eastart, const int eadebug) 142 static int test_one_eamax(struct torture_context *tctx, 143 struct smbcli_state *cli, const int fnum, 144 const char *eaname, DATA_BLOB eablob, 145 const int eastart, const int eadebug) 149 146 { 150 147 NTSTATUS status; … … 168 165 do { 169 166 if (eadebug) { 170 printf ("Testing EA size: %d\n", i);167 torture_comment(tctx, "Testing EA size: %d\n", i); 171 168 } 172 169 setfile.ea_set.in.eas->value.length = i; … … 176 173 if (NT_STATUS_EQUAL(status, NT_STATUS_OK)) { 177 174 if (eadebug) { 178 printf ("[%s] EA size %d succeeded! "179 "(high=%d low=%d)\n", 175 torture_comment(tctx, "[%s] EA size %d succeeded! " 176 "(high=%d low=%d)\n", 180 177 eaname, i, high, low); 181 178 } 182 179 low = i; 183 180 if (low == maxeasize) { 184 printf ("Max. EA size for \"%s\"=%d "185 "[but could be possibly larger]\n", 181 torture_comment(tctx, "Max. EA size for \"%s\"=%d " 182 "[but could be possibly larger]\n", 186 183 eaname, low); 187 184 break; 188 185 } 189 186 if (high - low == 1 && high != maxeasize) { 190 printf ("Max. EA size for \"%s\"=%d\n",187 torture_comment(tctx, "Max. EA size for \"%s\"=%d\n", 191 188 eaname, low); 192 189 break; … … 195 192 } else { 196 193 if (eadebug) { 197 printf ("[%s] EA size %d failed! "198 "(high=%d low=%d) [%s]\n", 199 eaname, i, high, low, 194 torture_comment(tctx, "[%s] EA size %d failed! " 195 "(high=%d low=%d) [%s]\n", 196 eaname, i, high, low, 200 197 nt_errstr(status)); 201 198 } 202 199 high = i; 203 200 if (high - low <= 1) { 204 printf ("Max. EA size for \"%s\"=%d\n",201 torture_comment(tctx, "Max. EA size for \"%s\"=%d\n", 205 202 eaname, low); 206 203 break; … … 245 242 int maxeastart; 246 243 247 printf("TESTING SETFILEINFO MAX. EA_SET\n");244 torture_comment(tctx, "TESTING SETFILEINFO MAX. EA_SET\n"); 248 245 249 246 maxeasize = torture_setting_int(tctx, "maxeasize", 65536); … … 254 251 /* Do some sanity check on possibly passed parms */ 255 252 if (maxeasize <= 0) { 256 printf("Invalid parameter 'maxeasize=%d'",maxeasize);253 torture_comment(tctx, "Invalid parameter 'maxeasize=%d'",maxeasize); 257 254 err = true; 258 255 } 259 256 if (maxeanames <= 0) { 260 printf("Invalid parameter 'maxeanames=%d'",maxeanames);257 torture_comment(tctx, "Invalid parameter 'maxeanames=%d'",maxeanames); 261 258 err = true; 262 259 } 263 260 if (maxeastart <= 0) { 264 printf("Invalid parameter 'maxeastart=%d'",maxeastart);261 torture_comment(tctx, "Invalid parameter 'maxeastart=%d'",maxeastart); 265 262 err = true; 266 263 } 267 264 if (maxeadebug < 0) { 268 printf("Invalid parameter 'maxeadebug=%d'",maxeadebug);265 torture_comment(tctx, "Invalid parameter 'maxeadebug=%d'",maxeadebug); 269 266 err = true; 270 267 } 271 268 if (err) { 272 printf("\n\n");269 torture_comment(tctx, "\n\n"); 273 270 goto done; 274 271 } 275 272 if (maxeastart > maxeasize) { 276 273 maxeastart = maxeasize; 277 printf ("'maxeastart' outside range - corrected to %d\n",274 torture_comment(tctx, "'maxeastart' outside range - corrected to %d\n", 278 275 maxeastart); 279 276 } 280 printf("MAXEA parms: maxeasize=%d maxeanames=%d maxeastart=%d"281 " maxeadebug=%d\n", maxeasize, maxeanames, maxeastart, 277 torture_comment(tctx, "MAXEA parms: maxeasize=%d maxeanames=%d maxeastart=%d" 278 " maxeadebug=%d\n", maxeasize, maxeanames, maxeastart, 282 279 maxeadebug); 283 280 284 281 io.generic.level = RAW_OPEN_NTCREATEX; 285 io.ntcreatex.in.root_fid = 0;282 io.ntcreatex.in.root_fid.fnum = 0; 286 283 io.ntcreatex.in.flags = 0; 287 284 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; 288 285 io.ntcreatex.in.create_options = 0; 289 286 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 290 io.ntcreatex.in.share_access = 291 NTCREATEX_SHARE_ACCESS_READ | 287 io.ntcreatex.in.share_access = 288 NTCREATEX_SHARE_ACCESS_READ | 292 289 NTCREATEX_SHARE_ACCESS_WRITE; 293 290 io.ntcreatex.in.alloc_size = 0; … … 299 296 CHECK_STATUS(status, NT_STATUS_OK); 300 297 fnum = io.ntcreatex.out.file.fnum; 301 298 302 299 eablob = data_blob_talloc(tctx, NULL, maxeasize); 303 300 if (eablob.data == NULL) { 304 301 goto done; 305 302 } 306 /* 307 * Fill in some EA data - the offset could be easily checked 303 /* 304 * Fill in some EA data - the offset could be easily checked 308 305 * during a hexdump. 309 306 */ … … 316 313 317 314 i = eablob.length % 4; 318 if (i-- > 0) { 315 if (i-- > 0) { 319 316 eablob.data[k] = k & 0xff; 320 if (i-- > 0) { 317 if (i-- > 0) { 321 318 eablob.data[k+1] = (k >> 8) & 0xff; 322 if (i-- > 0) { 319 if (i-- > 0) { 323 320 eablob.data[k+2] = (k >> 16) & 0xff; 324 321 } … … 340 337 goto done; 341 338 } 342 j = test_one_eamax( cli, fnum, eaname, eablob, last, maxeadebug);339 j = test_one_eamax(tctx, cli, fnum, eaname, eablob, last, maxeadebug); 343 340 if (j <= 0) { 344 341 break; … … 348 345 } 349 346 350 printf("Total EA size:%d\n", total);347 torture_comment(tctx, "Total EA size:%d\n", total); 351 348 if (i == maxeanames) { 352 printf ("NOTE: More EAs could be available!\n");353 } 349 torture_comment(tctx, "NOTE: More EAs could be available!\n"); 350 } 354 351 if (total == 0) { 355 352 ret = false; … … 363 360 test using NTTRANS CREATE to create a file with an initial EA set 364 361 */ 365 static bool test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)362 static bool test_nttrans_create(struct smbcli_state *cli, struct torture_context *tctx) 366 363 { 367 364 NTSTATUS status; … … 373 370 struct smb_ea_list ea_list; 374 371 375 printf("TESTING NTTRANS CREATE WITH EAS\n");372 torture_comment(tctx, "TESTING NTTRANS CREATE WITH EAS\n"); 376 373 377 374 io.generic.level = RAW_OPEN_NTTRANS_CREATE; 378 io.ntcreatex.in.root_fid = 0;375 io.ntcreatex.in.root_fid.fnum = 0; 379 376 io.ntcreatex.in.flags = 0; 380 377 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; 381 378 io.ntcreatex.in.create_options = 0; 382 379 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 383 io.ntcreatex.in.share_access = 384 NTCREATEX_SHARE_ACCESS_READ | 380 io.ntcreatex.in.share_access = 381 NTCREATEX_SHARE_ACCESS_READ | 385 382 NTCREATEX_SHARE_ACCESS_WRITE; 386 383 io.ntcreatex.in.alloc_size = 0; … … 408 405 io.ntcreatex.in.sec_desc = NULL; 409 406 410 status = smb_raw_open(cli->tree, mem_ctx, &io);407 status = smb_raw_open(cli->tree, tctx, &io); 411 408 CHECK_STATUS(status, NT_STATUS_OK); 412 409 fnum = io.ntcreatex.out.file.fnum; 413 410 414 411 ret &= check_ea(cli, fname, "EAONE", NULL); 415 412 ret &= check_ea(cli, fname, "1st EA", "Value One"); … … 419 416 smbcli_close(cli->tree, fnum); 420 417 421 printf("Trying to add EAs on non-create\n");418 torture_comment(tctx, "Trying to add EAs on non-create\n"); 422 419 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; 423 420 io.ntcreatex.in.fname = fname; … … 428 425 eas[0].value = data_blob_string_const("Value Four"); 429 426 430 status = smb_raw_open(cli->tree, mem_ctx, &io);427 status = smb_raw_open(cli->tree, tctx, &io); 431 428 CHECK_STATUS(status, NT_STATUS_OK); 432 429 fnum = io.ntcreatex.out.file.fnum; 433 430 434 431 ret &= check_ea(cli, fname, "1st EA", "Value One"); 435 432 ret &= check_ea(cli, fname, "2nd EA", "Second Value"); … … 442 439 } 443 440 444 /* 441 /* 445 442 basic testing of EA calls 446 443 */ … … 461 458 } 462 459 463 /* 460 /* 464 461 test max EA size 465 462 */ -
trunk/server/source4/torture/raw/ioctl.c
r414 r745 20 20 21 21 #include "includes.h" 22 #include "torture/torture.h"23 22 #include "libcli/raw/ioctl.h" 24 23 #include "libcli/raw/libcliraw.h" … … 100 99 } 101 100 101 printf("Trying FSCTL_FIND_FILES_BY_SID\n"); 102 nt.ioctl.level = RAW_IOCTL_NTIOCTL; 103 nt.ntioctl.in.function = FSCTL_FIND_FILES_BY_SID; 104 nt.ntioctl.in.file.fnum = fnum; 105 nt.ntioctl.in.fsctl = true; 106 nt.ntioctl.in.filter = 0; 107 nt.ntioctl.in.max_data = 0; 108 nt.ntioctl.in.blob = data_blob(NULL, 1024); 109 /* definitely not a sid... */ 110 generate_random_buffer(nt.ntioctl.in.blob.data, 111 nt.ntioctl.in.blob.length); 112 nt.ntioctl.in.blob.data[1] = 15+1; 113 status = smb_raw_ioctl(cli->tree, mem_ctx, &nt); 114 if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER) && 115 !NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED) && 116 !NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { 117 printf("Got unexpected error code: %s\n", 118 nt_errstr(status)); 119 ret = false; 120 goto done; 121 } 122 102 123 printf("trying sparse file\n"); 103 124 nt.ioctl.level = RAW_IOCTL_NTIOCTL; -
trunk/server/source4/torture/raw/lock.c
r414 r745 72 72 #define TARGET_IS_W2K8(_tctx) (torture_setting_bool(_tctx, "w2k8", false)) 73 73 #define TARGET_IS_WIN7(_tctx) (torture_setting_bool(_tctx, "win7", false)) 74 #define TARGET_IS_WINDOWS(_tctx) \ 75 ((torture_setting_bool(_tctx, "w2k3", false)) || \ 76 (torture_setting_bool(_tctx, "w2k8", false)) || \ 77 (torture_setting_bool(_tctx, "win7", false))) 74 78 #define TARGET_IS_SAMBA3(_tctx) (torture_setting_bool(_tctx, "samba3", false)) 75 79 #define TARGET_IS_SAMBA4(_tctx) (torture_setting_bool(_tctx, "samba4", false)) 80 81 #define TARGET_SUPPORTS_INVALID_LOCK_RANGE(_tctx) \ 82 (torture_setting_bool(_tctx, "invalid_lock_range_support", true)) 83 #define TARGET_SUPPORTS_SMBEXIT(_tctx) \ 84 (torture_setting_bool(_tctx, "smbexit_pdu_support", true)) 85 #define TARGET_SUPPORTS_SMBLOCK(_tctx) \ 86 (torture_setting_bool(_tctx, "smblock_pdu_support", true)) 87 #define TARGET_SUPPORTS_OPENX_DENY_DOS(_tctx) \ 88 (torture_setting_bool(_tctx, "openx_deny_dos_support", true)) 89 #define TARGET_RETURNS_RANGE_NOT_LOCKED(_tctx) \ 90 (torture_setting_bool(_tctx, "range_not_locked_on_file_close", true)) 76 91 /* 77 92 test SMBlock and SMBunlock ops … … 84 99 int fnum; 85 100 const char *fname = BASEDIR "\\test.txt"; 101 102 if (!TARGET_SUPPORTS_SMBLOCK(tctx)) 103 torture_skip(tctx, "Target does not support the SMBlock PDU"); 86 104 87 105 if (!torture_setup_dir(cli, BASEDIR)) { … … 366 384 lock[0].count = 2; 367 385 status = smb_raw_lock(cli->tree, &io); 368 if (TARGET_ IS_WIN7(tctx))386 if (TARGET_SUPPORTS_INVALID_LOCK_RANGE(tctx)) 369 387 CHECK_STATUS(status, NT_STATUS_INVALID_LOCK_RANGE); 370 388 else … … 489 507 const char *fname = BASEDIR "\\test.txt"; 490 508 time_t t; 491 struct smbcli_request *req ;509 struct smbcli_request *req, *req2; 492 510 struct smbcli_session_options options; 493 511 … … 496 514 } 497 515 498 lp _smbcli_session_options(tctx->lp_ctx, &options);516 lpcfg_smbcli_session_options(tctx->lp_ctx, &options); 499 517 500 518 torture_comment(tctx, "Testing LOCKING_ANDX_CANCEL_LOCK\n"); … … 515 533 lock[0].offset = 100; 516 534 lock[0].count = 10; 535 lock[1].pid = cli->session->pid; 536 lock[1].offset = 110; 537 lock[1].count = 10; 517 538 io.lockx.in.locks = &lock[0]; 518 539 status = smb_raw_lock(cli->tree, &io); 519 540 CHECK_STATUS(status, NT_STATUS_OK); 520 541 521 t = time (NULL);522 523 torture_comment(tctx, " testing cancel by CANCEL_LOCK\n");542 t = time_mono(NULL); 543 544 torture_comment(tctx, "Testing cancel by CANCEL_LOCK\n"); 524 545 525 546 /* setup a timed lock */ … … 554 575 CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT); 555 576 556 torture_assert(tctx,!(time (NULL) > t+2), talloc_asprintf(tctx,577 torture_assert(tctx,!(time_mono(NULL) > t+2), talloc_asprintf(tctx, 557 578 "lock cancel was not immediate (%s)\n", __location__)); 558 579 559 torture_comment(tctx, "testing cancel by unlock\n"); 580 /* MS-CIFS (2.2.4.32.1) states that a cancel is honored if and only 581 * if the lock vector contains one entry. When given mutliple cancel 582 * requests in a single PDU we expect the server to return an 583 * error. Samba4 handles this correctly. Windows servers seem to 584 * accept the request but only cancel the first lock. Samba3 585 * now does what Windows does (JRA). 586 */ 587 torture_comment(tctx, "Testing multiple cancel\n"); 588 589 /* acquire second lock */ 590 io.lockx.in.timeout = 0; 560 591 io.lockx.in.ulock_cnt = 0; 561 592 io.lockx.in.lock_cnt = 1; 562 593 io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES; 563 io.lockx.in.timeout = 0; 564 status = smb_raw_lock(cli->tree, &io); 565 CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT); 594 io.lockx.in.locks = &lock[1]; 595 status = smb_raw_lock(cli->tree, &io); 596 CHECK_STATUS(status, NT_STATUS_OK); 597 598 /* setup 2 timed locks */ 599 t = time_mono(NULL); 600 io.lockx.in.timeout = 10000; 601 io.lockx.in.lock_cnt = 1; 602 io.lockx.in.locks = &lock[0]; 603 req = smb_raw_lock_send(cli->tree, &io); 604 torture_assert(tctx,(req != NULL), talloc_asprintf(tctx, 605 "Failed to setup timed lock (%s)\n", __location__)); 606 io.lockx.in.locks = &lock[1]; 607 req2 = smb_raw_lock_send(cli->tree, &io); 608 torture_assert(tctx,(req2 != NULL), talloc_asprintf(tctx, 609 "Failed to setup timed lock (%s)\n", __location__)); 610 611 /* try to cancel both locks in the same packet */ 612 io.lockx.in.timeout = 0; 613 io.lockx.in.lock_cnt = 2; 614 io.lockx.in.mode = LOCKING_ANDX_CANCEL_LOCK | LOCKING_ANDX_LARGE_FILES; 615 io.lockx.in.locks = lock; 616 status = smb_raw_lock(cli->tree, &io); 617 CHECK_STATUS(status, NT_STATUS_OK); 618 619 torture_warning(tctx, "Target server accepted a lock cancel " 620 "request with multiple locks. This violates " 621 "MS-CIFS 2.2.4.32.1.\n"); 622 623 /* receive the failed lock requests */ 624 status = smbcli_request_simple_recv(req); 625 CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT); 626 627 torture_assert(tctx,!(time_mono(NULL) > t+2), talloc_asprintf(tctx, 628 "first lock was not cancelled immediately (%s)\n", 629 __location__)); 630 631 /* send cancel to second lock */ 632 io.lockx.in.timeout = 0; 633 io.lockx.in.lock_cnt = 1; 634 io.lockx.in.mode = LOCKING_ANDX_CANCEL_LOCK | 635 LOCKING_ANDX_LARGE_FILES; 636 io.lockx.in.locks = &lock[1]; 637 status = smb_raw_lock(cli->tree, &io); 638 CHECK_STATUS(status, NT_STATUS_OK); 639 640 status = smbcli_request_simple_recv(req2); 641 CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT); 642 643 torture_assert(tctx,!(time_mono(NULL) > t+2), talloc_asprintf(tctx, 644 "second lock was not cancelled immediately (%s)\n", 645 __location__)); 646 647 /* cleanup the second lock */ 648 io.lockx.in.ulock_cnt = 1; 649 io.lockx.in.lock_cnt = 0; 650 io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES; 651 io.lockx.in.locks = &lock[1]; 652 status = smb_raw_lock(cli->tree, &io); 653 CHECK_STATUS(status, NT_STATUS_OK); 654 655 /* If a lock request contained multiple ranges and we are cancelling 656 * one while it's still pending, what happens? */ 657 torture_comment(tctx, "Testing cancel 1/2 lock request\n"); 658 659 /* Send request with two ranges */ 660 io.lockx.in.timeout = -1; 661 io.lockx.in.ulock_cnt = 0; 662 io.lockx.in.lock_cnt = 2; 663 io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES; 664 io.lockx.in.locks = lock; 665 req = smb_raw_lock_send(cli->tree, &io); 666 torture_assert(tctx,(req != NULL), talloc_asprintf(tctx, 667 "Failed to setup pending lock (%s)\n", __location__)); 668 669 /* Try to cancel the first lock range */ 670 io.lockx.in.timeout = 0; 671 io.lockx.in.lock_cnt = 1; 672 io.lockx.in.mode = LOCKING_ANDX_CANCEL_LOCK | LOCKING_ANDX_LARGE_FILES; 673 io.lockx.in.locks = &lock[0]; 674 status = smb_raw_lock(cli->tree, &io); 675 CHECK_STATUS(status, NT_STATUS_OK); 676 677 /* Locking request should've failed and second range should be 678 * unlocked */ 679 status = smbcli_request_simple_recv(req); 680 CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT); 681 682 io.lockx.in.timeout = 0; 683 io.lockx.in.ulock_cnt = 0; 684 io.lockx.in.lock_cnt = 1; 685 io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES; 686 io.lockx.in.locks = &lock[1]; 687 status = smb_raw_lock(cli->tree, &io); 688 CHECK_STATUS(status, NT_STATUS_OK); 689 690 /* Cleanup both locks */ 691 io.lockx.in.ulock_cnt = 2; 692 io.lockx.in.lock_cnt = 0; 693 io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES; 694 io.lockx.in.locks = lock; 695 status = smb_raw_lock(cli->tree, &io); 696 CHECK_STATUS(status, NT_STATUS_OK); 697 698 torture_comment(tctx, "Testing cancel 2/2 lock request\n"); 699 700 /* Lock second range so it contends */ 701 io.lockx.in.timeout = 0; 702 io.lockx.in.ulock_cnt = 0; 703 io.lockx.in.lock_cnt = 1; 704 io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES; 705 io.lockx.in.locks = &lock[1]; 706 status = smb_raw_lock(cli->tree, &io); 707 CHECK_STATUS(status, NT_STATUS_OK); 708 709 /* Send request with two ranges */ 710 io.lockx.in.timeout = -1; 711 io.lockx.in.ulock_cnt = 0; 712 io.lockx.in.lock_cnt = 2; 713 io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES; 714 io.lockx.in.locks = lock; 715 req = smb_raw_lock_send(cli->tree, &io); 716 torture_assert(tctx,(req != NULL), talloc_asprintf(tctx, 717 "Failed to setup pending lock (%s)\n", __location__)); 718 719 /* Try to cancel the second lock range */ 720 io.lockx.in.timeout = 0; 721 io.lockx.in.lock_cnt = 1; 722 io.lockx.in.mode = LOCKING_ANDX_CANCEL_LOCK | LOCKING_ANDX_LARGE_FILES; 723 io.lockx.in.locks = &lock[1]; 724 status = smb_raw_lock(cli->tree, &io); 725 CHECK_STATUS(status, NT_STATUS_OK); 726 727 /* Locking request should've failed and first range should be 728 * unlocked */ 729 status = smbcli_request_simple_recv(req); 730 CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT); 731 732 io.lockx.in.timeout = 0; 733 io.lockx.in.ulock_cnt = 0; 734 io.lockx.in.lock_cnt = 1; 735 io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES; 736 io.lockx.in.locks = &lock[0]; 737 status = smb_raw_lock(cli->tree, &io); 738 CHECK_STATUS(status, NT_STATUS_OK); 739 740 /* Cleanup both locks */ 741 io.lockx.in.ulock_cnt = 2; 742 io.lockx.in.lock_cnt = 0; 743 io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES; 744 io.lockx.in.locks = lock; 745 status = smb_raw_lock(cli->tree, &io); 746 CHECK_STATUS(status, NT_STATUS_OK); 747 748 torture_comment(tctx, "Testing cancel by unlock\n"); 749 io.lockx.in.ulock_cnt = 0; 750 io.lockx.in.lock_cnt = 1; 751 io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES; 752 io.lockx.in.timeout = 0; 753 io.lockx.in.locks = &lock[0]; 754 status = smb_raw_lock(cli->tree, &io); 755 CHECK_STATUS(status, NT_STATUS_OK); 566 756 567 757 io.lockx.in.timeout = 5000; … … 575 765 CHECK_STATUS(status, NT_STATUS_OK); 576 766 577 t = time (NULL);767 t = time_mono(NULL); 578 768 status = smbcli_request_simple_recv(req); 579 769 CHECK_STATUS(status, NT_STATUS_OK); 580 770 581 torture_assert(tctx,!(time (NULL) > t+2), talloc_asprintf(tctx,771 torture_assert(tctx,!(time_mono(NULL) > t+2), talloc_asprintf(tctx, 582 772 "lock cancel by unlock was not immediate (%s) - took %d secs\n", 583 __location__, (int)(time (NULL)-t)));584 585 torture_comment(tctx, " testing cancel by close\n");773 __location__, (int)(time_mono(NULL)-t))); 774 775 torture_comment(tctx, "Testing cancel by close\n"); 586 776 io.lockx.in.ulock_cnt = 0; 587 777 io.lockx.in.lock_cnt = 1; … … 589 779 io.lockx.in.timeout = 0; 590 780 status = smb_raw_lock(cli->tree, &io); 591 CHECK_STATUS(status, NT_STATUS_ FILE_LOCK_CONFLICT);592 593 t = time (NULL);781 CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED); 782 783 t = time_mono(NULL); 594 784 io.lockx.in.timeout = 10000; 595 785 req = smb_raw_lock_send(cli->tree, &io); … … 601 791 602 792 status = smbcli_request_simple_recv(req); 603 CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED); 604 605 torture_assert(tctx,!(time(NULL) > t+2), talloc_asprintf(tctx, 793 if (TARGET_RETURNS_RANGE_NOT_LOCKED(tctx)) 794 CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED); 795 else 796 CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT); 797 798 torture_assert(tctx,!(time_mono(NULL) > t+2), talloc_asprintf(tctx, 606 799 "lock cancel by close was not immediate (%s)\n", __location__)); 607 800 … … 610 803 setup.in.sesskey = cli->transport->negotiate.sesskey; 611 804 setup.in.capabilities = cli->transport->negotiate.capabilities; 612 setup.in.workgroup = lp _workgroup(tctx->lp_ctx);805 setup.in.workgroup = lpcfg_workgroup(tctx->lp_ctx); 613 806 setup.in.credentials = cmdline_credentials; 614 setup.in.gensec_settings = lp _gensec_settings(tctx, tctx->lp_ctx);807 setup.in.gensec_settings = lpcfg_gensec_settings(tctx, tctx->lp_ctx); 615 808 status = smb_composite_sesssetup(session, &setup); 616 809 CHECK_STATUS(status, NT_STATUS_OK); … … 630 823 tree->tid = tcon.tconx.out.tid; 631 824 632 torture_comment(tctx, "testing cancel by exit\n"); 633 fname = BASEDIR "\\test_exit.txt"; 825 torture_comment(tctx, "Testing cancel by exit\n"); 826 if (TARGET_SUPPORTS_SMBEXIT(tctx)) { 827 fname = BASEDIR "\\test_exit.txt"; 828 fnum = smbcli_open(tree, fname, O_RDWR|O_CREAT, DENY_NONE); 829 torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx, 830 "Failed to reopen %s - %s\n", 831 fname, smbcli_errstr(tree))); 832 833 io.lockx.level = RAW_LOCK_LOCKX; 834 io.lockx.in.file.fnum = fnum; 835 io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES; 836 io.lockx.in.timeout = 0; 837 io.lockx.in.ulock_cnt = 0; 838 io.lockx.in.lock_cnt = 1; 839 lock[0].pid = session->pid; 840 lock[0].offset = 100; 841 lock[0].count = 10; 842 io.lockx.in.locks = &lock[0]; 843 status = smb_raw_lock(tree, &io); 844 CHECK_STATUS(status, NT_STATUS_OK); 845 846 io.lockx.in.ulock_cnt = 0; 847 io.lockx.in.lock_cnt = 1; 848 io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES; 849 io.lockx.in.timeout = 0; 850 status = smb_raw_lock(tree, &io); 851 CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED); 852 853 io.lockx.in.timeout = 10000; 854 t = time_mono(NULL); 855 req = smb_raw_lock_send(tree, &io); 856 torture_assert(tctx,(req != NULL), talloc_asprintf(tctx, 857 "Failed to setup timed lock (%s)\n", 858 __location__)); 859 860 status = smb_raw_exit(session); 861 CHECK_STATUS(status, NT_STATUS_OK); 862 863 status = smbcli_request_simple_recv(req); 864 if (TARGET_RETURNS_RANGE_NOT_LOCKED(tctx)) 865 CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED); 866 else 867 CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT); 868 869 torture_assert(tctx,!(time_mono(NULL) > t+2), talloc_asprintf(tctx, 870 "lock cancel by exit was not immediate (%s)\n", 871 __location__)); 872 } 873 else { 874 torture_comment(tctx, 875 " skipping test, SMBExit not supported\n"); 876 } 877 878 torture_comment(tctx, "Testing cancel by ulogoff\n"); 879 fname = BASEDIR "\\test_ulogoff.txt"; 634 880 fnum = smbcli_open(tree, fname, O_RDWR|O_CREAT, DENY_NONE); 635 881 torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx, … … 658 904 659 905 io.lockx.in.timeout = 10000; 660 t = time (NULL);906 t = time_mono(NULL); 661 907 req = smb_raw_lock_send(tree, &io); 662 908 torture_assert(tctx,(req != NULL), talloc_asprintf(tctx, 663 909 "Failed to setup timed lock (%s)\n", __location__)); 664 910 665 status = smb_raw_ exit(session);911 status = smb_raw_ulogoff(session); 666 912 CHECK_STATUS(status, NT_STATUS_OK); 667 913 668 914 status = smbcli_request_simple_recv(req); 669 CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED); 670 671 torture_assert(tctx,!(time(NULL) > t+2), talloc_asprintf(tctx, 672 "lock cancel by exit was not immediate (%s)\n", __location__)); 673 674 torture_comment(tctx, "testing cancel by ulogoff\n"); 675 fname = BASEDIR "\\test_ulogoff.txt"; 676 fnum = smbcli_open(tree, fname, O_RDWR|O_CREAT, DENY_NONE); 677 torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx, 678 "Failed to reopen %s - %s\n", 679 fname, smbcli_errstr(tree))); 680 681 io.lockx.level = RAW_LOCK_LOCKX; 682 io.lockx.in.file.fnum = fnum; 683 io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES; 684 io.lockx.in.timeout = 0; 685 io.lockx.in.ulock_cnt = 0; 686 io.lockx.in.lock_cnt = 1; 687 lock[0].pid = session->pid; 688 lock[0].offset = 100; 689 lock[0].count = 10; 690 io.lockx.in.locks = &lock[0]; 691 status = smb_raw_lock(tree, &io); 692 CHECK_STATUS(status, NT_STATUS_OK); 693 694 io.lockx.in.ulock_cnt = 0; 695 io.lockx.in.lock_cnt = 1; 696 io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES; 697 io.lockx.in.timeout = 0; 698 status = smb_raw_lock(tree, &io); 699 CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED); 700 701 io.lockx.in.timeout = 10000; 702 t = time(NULL); 703 req = smb_raw_lock_send(tree, &io); 704 torture_assert(tctx,(req != NULL), talloc_asprintf(tctx, 705 "Failed to setup timed lock (%s)\n", __location__)); 706 707 status = smb_raw_ulogoff(session); 708 CHECK_STATUS(status, NT_STATUS_OK); 709 710 status = smbcli_request_simple_recv(req); 711 if (NT_STATUS_EQUAL(NT_STATUS_FILE_LOCK_CONFLICT, status)) { 712 torture_result(tctx, TORTURE_FAIL, 713 "lock not canceled by ulogoff - %s (ignored because of vfs_vifs fails it)\n", 714 nt_errstr(status)); 715 smb_tree_disconnect(tree); 716 smb_raw_exit(session); 717 goto done; 718 } 719 CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED); 720 721 torture_assert(tctx,!(time(NULL) > t+2), talloc_asprintf(tctx, 915 if (TARGET_RETURNS_RANGE_NOT_LOCKED(tctx)) { 916 if (NT_STATUS_EQUAL(NT_STATUS_FILE_LOCK_CONFLICT, status)) { 917 torture_result(tctx, TORTURE_FAIL, 918 "lock not canceled by ulogoff - %s " 919 "(ignored because of vfs_vifs fails it)\n", 920 nt_errstr(status)); 921 smb_tree_disconnect(tree); 922 smb_raw_exit(session); 923 goto done; 924 } 925 CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED); 926 } else { 927 CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT); 928 } 929 930 torture_assert(tctx,!(time_mono(NULL) > t+2), talloc_asprintf(tctx, 722 931 "lock cancel by ulogoff was not immediate (%s)\n", __location__)); 723 932 724 torture_comment(tctx, " testing cancel by tdis\n");933 torture_comment(tctx, "Testing cancel by tdis\n"); 725 934 tree->session = cli->session; 726 935 … … 748 957 749 958 io.lockx.in.timeout = 10000; 750 t = time (NULL);959 t = time_mono(NULL); 751 960 req = smb_raw_lock_send(tree, &io); 752 961 torture_assert(tctx,(req != NULL), talloc_asprintf(tctx, … … 757 966 758 967 status = smbcli_request_simple_recv(req); 759 CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED); 760 761 torture_assert(tctx,!(time(NULL) > t+2), talloc_asprintf(tctx, 968 if (TARGET_RETURNS_RANGE_NOT_LOCKED(tctx)) 969 CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED); 970 else 971 CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT); 972 973 torture_assert(tctx,!(time_mono(NULL) > t+2), talloc_asprintf(tctx, 762 974 "lock cancel by tdis was not immediate (%s)\n", __location__)); 763 975 … … 785 997 int t; 786 998 int delay; 999 uint16_t deny_mode = 0; 787 1000 788 1001 if (!torture_setup_dir(cli, BASEDIR)) { … … 792 1005 torture_comment(tctx, "Testing LOCK_NOT_GRANTED vs. FILE_LOCK_CONFLICT\n"); 793 1006 794 torture_comment(tctx, " testing with timeout = 0\n");1007 torture_comment(tctx, "Testing with timeout = 0\n"); 795 1008 fname = BASEDIR "\\test0.txt"; 796 1009 t = 0; … … 801 1014 */ 802 1015 next_run: 803 /* 804 * use the DENY_DOS mode, that creates two fnum's of one low-level file handle, 805 * this demonstrates that the cache is per fnum 1016 /* 1017 * use the DENY_DOS mode, that creates two fnum's of one low-level 1018 * file handle, this demonstrates that the cache is per fnum, not 1019 * per file handle 806 1020 */ 1021 if (TARGET_SUPPORTS_OPENX_DENY_DOS(tctx)) 1022 deny_mode = OPENX_MODE_DENY_DOS; 1023 else 1024 deny_mode = OPENX_MODE_DENY_NONE; 1025 807 1026 op.openx.level = RAW_OPEN_OPENX; 808 1027 op.openx.in.fname = fname; 809 1028 op.openx.in.flags = OPENX_FLAGS_ADDITIONAL_INFO; 810 op.openx.in.open_mode = OPENX_MODE_ACCESS_RDWR | OPENX_MODE_DENY_DOS;1029 op.openx.in.open_mode = OPENX_MODE_ACCESS_RDWR | deny_mode; 811 1030 op.openx.in.open_func = OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE; 812 1031 op.openx.in.search_attrs = 0; … … 1059 1278 * demonstrate the a successful lock in a different range, 1060 1279 * doesn't reset the cache, the failing lock on the 2nd handle 1061 * resets the resets thecache1280 * resets the cache 1062 1281 */ 1063 1282 lock[0].offset = 120; … … 1089 1308 smb_raw_exit(cli->session); 1090 1309 t = 1; 1091 torture_comment(tctx, " testing with timeout > 0 (=%d)\n",1310 torture_comment(tctx, "Testing with timeout > 0 (=%d)\n", 1092 1311 t); 1093 1312 fname = BASEDIR "\\test1.txt"; … … 1096 1315 1097 1316 t = 4000; 1098 torture_comment(tctx, " testing special cases with timeout > 0 (=%d)\n",1317 torture_comment(tctx, "Testing special cases with timeout > 0 (=%d)\n", 1099 1318 t); 1100 1319 … … 1105 1324 */ 1106 1325 smb_raw_exit(cli->session); 1107 torture_comment(tctx, " testing a conflict while a lock is pending\n");1326 torture_comment(tctx, "Testing a conflict while a lock is pending\n"); 1108 1327 fname = BASEDIR "\\test2.txt"; 1109 1328 fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); … … 1125 1344 CHECK_STATUS(status, NT_STATUS_OK); 1126 1345 1127 start = time (NULL);1346 start = time_mono(NULL); 1128 1347 io.lockx.in.timeout = t; 1129 1348 req = smb_raw_lock_send(cli->tree, &io); … … 1145 1364 } 1146 1365 1147 torture_assert(tctx,!(time (NULL) < start+delay), talloc_asprintf(tctx,1366 torture_assert(tctx,!(time_mono(NULL) < start+delay), talloc_asprintf(tctx, 1148 1367 "lock comes back to early timeout[%d] delay[%d]" 1149 1368 "(%s)\n", t, delay, __location__)); … … 1172 1391 CHECK_STATUS(status, NT_STATUS_OK); 1173 1392 1174 start = time (NULL);1393 start = time_mono(NULL); 1175 1394 io.lockx.in.timeout = t; 1176 1395 req = smb_raw_lock_send(cli->tree, &io); … … 1192 1411 } 1193 1412 1194 torture_assert(tctx,!(time (NULL) < start+delay), talloc_asprintf(tctx,1413 torture_assert(tctx,!(time_mono(NULL) < start+delay), talloc_asprintf(tctx, 1195 1414 "lock comes back to early timeout[%d] delay[%d]" 1196 1415 "(%s)\n", t, delay, __location__)); … … 1221 1440 CHECK_STATUS(status, NT_STATUS_OK); 1222 1441 1223 start = time (NULL);1442 start = time_mono(NULL); 1224 1443 io.lockx.in.timeout = t; 1225 1444 req = smb_raw_lock_send(cli->tree, &io); … … 1239 1458 } 1240 1459 1241 torture_assert(tctx,!(time (NULL) < start+delay), talloc_asprintf(tctx,1460 torture_assert(tctx,!(time_mono(NULL) < start+delay), talloc_asprintf(tctx, 1242 1461 "lock comes back to early timeout[%d] delay[%d]" 1243 1462 "(%s)\n", t, delay, __location__)); … … 1327 1546 * Tests zero byte locks. 1328 1547 */ 1329 static conststruct double_lock_test zero_byte_tests[] = {1548 static struct double_lock_test zero_byte_tests[] = { 1330 1549 /* {pid, offset, count}, {pid, offset, count}, status */ 1331 1550 … … 1393 1612 torture_comment(tctx, " ... {%d, %llu, %llu} + {%d, %llu, %llu} = %s\n", 1394 1613 zero_byte_tests[i].lock1.pid, 1395 zero_byte_tests[i].lock1.offset,1396 zero_byte_tests[i].lock1.count,1614 (unsigned long long) zero_byte_tests[i].lock1.offset, 1615 (unsigned long long) zero_byte_tests[i].lock1.count, 1397 1616 zero_byte_tests[i].lock2.pid, 1398 zero_byte_tests[i].lock2.offset,1399 zero_byte_tests[i].lock2.count,1617 (unsigned long long) zero_byte_tests[i].lock2.offset, 1618 (unsigned long long) zero_byte_tests[i].lock2.count, 1400 1619 nt_errstr(zero_byte_tests[i].exp_status)); 1401 1620 … … 1404 1623 io.lockx.in.lock_cnt = 1; 1405 1624 1406 io.lockx.in.locks = &zero_byte_tests[i].lock1; 1625 io.lockx.in.locks = discard_const_p(struct smb_lock_entry, 1626 &zero_byte_tests[i].lock1); 1407 1627 status = smb_raw_lock(cli->tree, &io); 1408 1628 CHECK_STATUS(status, NT_STATUS_OK); 1409 1629 1410 io.lockx.in.locks = &zero_byte_tests[i].lock2; 1630 io.lockx.in.locks = discard_const_p(struct smb_lock_entry, 1631 &zero_byte_tests[i].lock2); 1411 1632 status = smb_raw_lock(cli->tree, &io); 1412 1633 … … 1433 1654 } 1434 1655 1435 io.lockx.in.locks = &zero_byte_tests[i].lock1; 1656 io.lockx.in.locks = discard_const_p(struct smb_lock_entry, 1657 &zero_byte_tests[i].lock1); 1436 1658 status = smb_raw_lock(cli->tree, &io); 1437 1659 CHECK_STATUS(status, NT_STATUS_OK); … … 1728 1950 io.lockx.in.lock_cnt = 0; 1729 1951 io.lockx.in.locks = &lock1; 1952 status = smb_raw_lock(cli->tree, &io); 1953 CHECK_STATUS(status, NT_STATUS_OK); 1954 1955 /* Test3: Request 2 locks, second will contend. What happens to the 1956 * first? */ 1957 torture_comment(tctx, " request 2 locks, second one will contend. " 1958 "Expect both to fail.\n"); 1959 1960 /* Lock the second range */ 1961 io.lockx.in.ulock_cnt = 0; 1962 io.lockx.in.lock_cnt = 1; 1963 io.lockx.in.locks = &lock2; 1964 status = smb_raw_lock(cli->tree, &io); 1965 CHECK_STATUS(status, NT_STATUS_OK); 1966 1967 /* Request both locks */ 1968 io.lockx.in.ulock_cnt = 0; 1969 io.lockx.in.lock_cnt = 2; 1970 io.lockx.in.locks = locks; 1971 1972 status = smb_raw_lock(cli->tree, &io); 1973 CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT); 1974 1975 /* First lock should be unlocked. */ 1976 io.lockx.in.ulock_cnt = 0; 1977 io.lockx.in.lock_cnt = 1; 1978 io.lockx.in.locks = &lock1; 1979 status = smb_raw_lock(cli->tree, &io); 1980 CHECK_STATUS(status, NT_STATUS_OK); 1981 1982 /* cleanup */ 1983 io.lockx.in.ulock_cnt = 2; 1984 io.lockx.in.lock_cnt = 0; 1985 io.lockx.in.locks = locks; 1986 status = smb_raw_lock(cli->tree, &io); 1987 CHECK_STATUS(status, NT_STATUS_OK); 1988 1989 /* Test4: Request unlock and lock. The lock contends, is the unlock 1990 * then re-locked? */ 1991 torture_comment(tctx, " request unlock and lock, second one will " 1992 "contend. Expect the unlock to succeed.\n"); 1993 1994 /* Lock both ranges */ 1995 io.lockx.in.ulock_cnt = 0; 1996 io.lockx.in.lock_cnt = 2; 1997 io.lockx.in.locks = locks; 1998 status = smb_raw_lock(cli->tree, &io); 1999 CHECK_STATUS(status, NT_STATUS_OK); 2000 2001 /* Attempt to unlock the first range and lock the second */ 2002 io.lockx.in.ulock_cnt = 1; 2003 io.lockx.in.lock_cnt = 1; 2004 io.lockx.in.locks = locks; 2005 status = smb_raw_lock(cli->tree, &io); 2006 CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT); 2007 2008 /* The first lock should've been unlocked */ 2009 io.lockx.in.ulock_cnt = 0; 2010 io.lockx.in.lock_cnt = 1; 2011 io.lockx.in.locks = &lock1; 2012 status = smb_raw_lock(cli->tree, &io); 2013 CHECK_STATUS(status, NT_STATUS_OK); 2014 2015 /* cleanup */ 2016 io.lockx.in.ulock_cnt = 2; 2017 io.lockx.in.lock_cnt = 0; 2018 io.lockx.in.locks = locks; 1730 2019 status = smb_raw_lock(cli->tree, &io); 1731 2020 CHECK_STATUS(status, NT_STATUS_OK); … … 1829 2118 } 1830 2119 1831 /* 2120 /** 2121 * Test how 0-byte read requests contend with byte range locks 2122 */ 2123 static bool test_zerobyteread(struct torture_context *tctx, 2124 struct smbcli_state *cli) 2125 { 2126 union smb_lock io; 2127 union smb_read rd; 2128 NTSTATUS status; 2129 bool ret = true; 2130 int fnum1, fnum2; 2131 const char *fname = BASEDIR "\\zerobyteread.txt"; 2132 struct smb_lock_entry lock1; 2133 uint8_t c = 1; 2134 2135 if (!torture_setup_dir(cli, BASEDIR)) { 2136 return false; 2137 } 2138 2139 io.generic.level = RAW_LOCK_LOCKX; 2140 2141 fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); 2142 torture_assert(tctx,(fnum1 != -1), talloc_asprintf(tctx, 2143 "Failed to create %s - %s\n", 2144 fname, smbcli_errstr(cli->tree))); 2145 2146 fnum2 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); 2147 torture_assert(tctx,(fnum2 != -1), talloc_asprintf(tctx, 2148 "Failed to create %s - %s\n", 2149 fname, smbcli_errstr(cli->tree))); 2150 2151 /* Setup initial parameters */ 2152 io.lockx.level = RAW_LOCK_LOCKX; 2153 io.lockx.in.timeout = 0; 2154 2155 lock1.pid = cli->session->pid; 2156 lock1.offset = 0; 2157 lock1.count = 10; 2158 2159 ZERO_STRUCT(rd); 2160 rd.readx.level = RAW_READ_READX; 2161 2162 torture_comment(tctx, "Testing zero byte read on lock range:\n"); 2163 2164 /* Take an exclusive lock */ 2165 torture_comment(tctx, " taking exclusive lock.\n"); 2166 io.lockx.in.ulock_cnt = 0; 2167 io.lockx.in.lock_cnt = 1; 2168 io.lockx.in.mode = LOCKING_ANDX_EXCLUSIVE_LOCK; 2169 io.lockx.in.file.fnum = fnum1; 2170 io.lockx.in.locks = &lock1; 2171 status = smb_raw_lock(cli->tree, &io); 2172 CHECK_STATUS(status, NT_STATUS_OK); 2173 2174 /* Try a zero byte read */ 2175 torture_comment(tctx, " reading 0 bytes.\n"); 2176 rd.readx.in.file.fnum = fnum2; 2177 rd.readx.in.offset = 5; 2178 rd.readx.in.mincnt = 0; 2179 rd.readx.in.maxcnt = 0; 2180 rd.readx.in.remaining = 0; 2181 rd.readx.in.read_for_execute = false; 2182 rd.readx.out.data = &c; 2183 status = smb_raw_read(cli->tree, &rd); 2184 torture_assert_int_equal_goto(tctx, rd.readx.out.nread, 0, ret, done, 2185 "zero byte read did not return 0 bytes"); 2186 CHECK_STATUS(status, NT_STATUS_OK); 2187 2188 /* Unlock lock */ 2189 io.lockx.in.ulock_cnt = 1; 2190 io.lockx.in.lock_cnt = 0; 2191 io.lockx.in.mode = LOCKING_ANDX_EXCLUSIVE_LOCK; 2192 io.lockx.in.file.fnum = fnum1; 2193 io.lockx.in.locks = &lock1; 2194 status = smb_raw_lock(cli->tree, &io); 2195 CHECK_STATUS(status, NT_STATUS_OK); 2196 2197 torture_comment(tctx, "Testing zero byte read on zero byte lock " 2198 "range:\n"); 2199 2200 /* Take an exclusive lock */ 2201 torture_comment(tctx, " taking exclusive 0-byte lock.\n"); 2202 io.lockx.in.ulock_cnt = 0; 2203 io.lockx.in.lock_cnt = 1; 2204 io.lockx.in.mode = LOCKING_ANDX_EXCLUSIVE_LOCK; 2205 io.lockx.in.file.fnum = fnum1; 2206 io.lockx.in.locks = &lock1; 2207 lock1.offset = 5; 2208 lock1.count = 0; 2209 status = smb_raw_lock(cli->tree, &io); 2210 CHECK_STATUS(status, NT_STATUS_OK); 2211 2212 /* Try a zero byte read before the lock */ 2213 torture_comment(tctx, " reading 0 bytes before the lock.\n"); 2214 rd.readx.in.file.fnum = fnum2; 2215 rd.readx.in.offset = 4; 2216 rd.readx.in.mincnt = 0; 2217 rd.readx.in.maxcnt = 0; 2218 rd.readx.in.remaining = 0; 2219 rd.readx.in.read_for_execute = false; 2220 rd.readx.out.data = &c; 2221 status = smb_raw_read(cli->tree, &rd); 2222 torture_assert_int_equal_goto(tctx, rd.readx.out.nread, 0, ret, done, 2223 "zero byte read did not return 0 bytes"); 2224 CHECK_STATUS(status, NT_STATUS_OK); 2225 2226 /* Try a zero byte read on the lock */ 2227 torture_comment(tctx, " reading 0 bytes on the lock.\n"); 2228 rd.readx.in.file.fnum = fnum2; 2229 rd.readx.in.offset = 5; 2230 rd.readx.in.mincnt = 0; 2231 rd.readx.in.maxcnt = 0; 2232 rd.readx.in.remaining = 0; 2233 rd.readx.in.read_for_execute = false; 2234 rd.readx.out.data = &c; 2235 status = smb_raw_read(cli->tree, &rd); 2236 torture_assert_int_equal_goto(tctx, rd.readx.out.nread, 0, ret, done, 2237 "zero byte read did not return 0 bytes"); 2238 CHECK_STATUS(status, NT_STATUS_OK); 2239 2240 /* Try a zero byte read after the lock */ 2241 torture_comment(tctx, " reading 0 bytes after the lock.\n"); 2242 rd.readx.in.file.fnum = fnum2; 2243 rd.readx.in.offset = 6; 2244 rd.readx.in.mincnt = 0; 2245 rd.readx.in.maxcnt = 0; 2246 rd.readx.in.remaining = 0; 2247 rd.readx.in.read_for_execute = false; 2248 rd.readx.out.data = &c; 2249 status = smb_raw_read(cli->tree, &rd); 2250 torture_assert_int_equal_goto(tctx, rd.readx.out.nread, 0, ret, done, 2251 "zero byte read did not return 0 bytes"); 2252 CHECK_STATUS(status, NT_STATUS_OK); 2253 2254 /* Unlock lock */ 2255 io.lockx.in.ulock_cnt = 1; 2256 io.lockx.in.lock_cnt = 0; 2257 io.lockx.in.mode = LOCKING_ANDX_EXCLUSIVE_LOCK; 2258 io.lockx.in.file.fnum = fnum1; 2259 io.lockx.in.locks = &lock1; 2260 status = smb_raw_lock(cli->tree, &io); 2261 CHECK_STATUS(status, NT_STATUS_OK); 2262 2263 done: 2264 smbcli_close(cli->tree, fnum1); 2265 smbcli_close(cli->tree, fnum2); 2266 smb_raw_exit(cli->session); 2267 smbcli_deltree(cli->tree, BASEDIR); 2268 return ret; 2269 } 2270 2271 /* 1832 2272 basic testing of lock calls 1833 2273 */ 1834 2274 struct torture_suite *torture_raw_lock(TALLOC_CTX *mem_ctx) 1835 2275 { 1836 struct torture_suite *suite = torture_suite_create(mem_ctx, " LOCK");2276 struct torture_suite *suite = torture_suite_create(mem_ctx, "lock"); 1837 2277 1838 2278 torture_suite_add_1smb_test(suite, "lockx", test_lockx); … … 1847 2287 torture_suite_add_1smb_test(suite, "multiple_unlock", 1848 2288 test_multiple_unlock); 1849 torture_suite_add_1smb_test(suite, "zerobytelocks", 1850 test_zerobytelocks);2289 torture_suite_add_1smb_test(suite, "zerobytelocks", test_zerobytelocks); 2290 torture_suite_add_1smb_test(suite, "zerobyteread", test_zerobyteread); 1851 2291 1852 2292 return suite; -
trunk/server/source4/torture/raw/lockbench.c
r414 r745 21 21 22 22 #include "includes.h" 23 #include "torture/torture.h"24 23 #include "libcli/raw/libcliraw.h" 25 24 #include "libcli/raw/raw_proto.h" … … 189 188 io->in.dest_host = state->dest_host; 190 189 io->in.dest_ports = state->dest_ports; 191 io->in.gensec_settings = lp _gensec_settings(state->mem_ctx, state->tctx->lp_ctx);192 io->in.socket_options = lp _socket_options(state->tctx->lp_ctx);190 io->in.gensec_settings = lpcfg_gensec_settings(state->mem_ctx, state->tctx->lp_ctx); 191 io->in.socket_options = lpcfg_socket_options(state->tctx->lp_ctx); 193 192 io->in.called_name = state->called_name; 194 193 io->in.service = share; … … 196 195 io->in.credentials = cmdline_credentials; 197 196 io->in.fallback_to_anonymous = false; 198 io->in.workgroup = lp_workgroup(state->tctx->lp_ctx); 199 io->in.iconv_convenience = lp_iconv_convenience(state->tctx->lp_ctx); 200 lp_smbcli_options(state->tctx->lp_ctx, &io->in.options); 201 lp_smbcli_session_options(state->tctx->lp_ctx, &io->in.session_options); 197 io->in.workgroup = lpcfg_workgroup(state->tctx->lp_ctx); 198 lpcfg_smbcli_options(state->tctx->lp_ctx, &io->in.options); 199 lpcfg_smbcli_session_options(state->tctx->lp_ctx, &io->in.session_options); 202 200 203 201 /* kill off the remnants of the old connection */ … … 206 204 207 205 ctx = smb_composite_connect_send(io, state->mem_ctx, 208 lp _resolve_context(state->tctx->lp_ctx),206 lpcfg_resolve_context(state->tctx->lp_ctx), 209 207 state->ev); 210 208 if (ctx == NULL) { … … 228 226 if (!NT_STATUS_IS_OK(status)) { 229 227 if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) || 230 NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT)) { 228 NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT) || 229 NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_RESET)) { 231 230 talloc_free(state->tree); 232 231 state->tree = NULL; … … 266 265 NTSTATUS status = smbcli_request_simple_recv(req); 267 266 if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) || 268 NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT)) { 267 NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT) || 268 NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_RESET)) { 269 269 talloc_free(state->tree); 270 270 state->tree = NULL; -
trunk/server/source4/torture/raw/lookuprate.c
r414 r745 21 21 #include "system/filesys.h" 22 22 #include "torture/smbtorture.h" 23 #include "torture/basic/proto.h"24 23 #include "libcli/libcli.h" 25 24 #include "torture/util.h" 26 #include "lib/cmdline/popt_common.h"27 #include "auth/credentials/credentials.h"28 25 29 26 #define BASEDIR "\\lookuprate" … … 97 94 98 95 fnum = smbcli_open(tree, fname, O_RDONLY|O_CREAT, 99 OPENX_MODE_DENY_NONE);96 DENY_NONE); 100 97 if (fnum < 0) { 101 98 talloc_free(fname); … … 248 245 249 246 for (i = 0; i < ARRAY_SIZE(records); ++i) { 250 printf(" testing lookup rate with %u directory entries\n",247 printf("Testing lookup rate with %u directory entries\n", 251 248 records[i].dirent_count); 252 249 -
trunk/server/source4/torture/raw/mkdir.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "torture/torture.h"22 21 #include "libcli/raw/libcliraw.h" 23 #include "libcli/raw/raw_proto.h"24 22 #include "libcli/libcli.h" 25 23 #include "torture/util.h" … … 59 57 CHECK_STATUS(status, NT_STATUS_OK); 60 58 61 printf(" testing mkdir collision\n");59 printf("Testing mkdir collision\n"); 62 60 63 61 /* 2nd create */ … … 73 71 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); 74 72 75 printf(" testing mkdir collision with file\n");73 printf("Testing mkdir collision with file\n"); 76 74 77 75 /* name collision with a file */ … … 80 78 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION); 81 79 82 printf(" testing rmdir with file\n");80 printf("Testing rmdir with file\n"); 83 81 84 82 /* delete a file with rmdir */ … … 88 86 smbcli_unlink(cli->tree, path); 89 87 90 printf(" testing invalid dir\n");88 printf("Testing invalid dir\n"); 91 89 92 90 /* create an invalid dir */ … … 95 93 CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD); 96 94 97 printf(" testing t2mkdir\n");95 printf("Testing t2mkdir\n"); 98 96 99 97 /* try a t2mkdir - need to work out why this fails! */ … … 107 105 CHECK_STATUS(status, NT_STATUS_OK); 108 106 109 printf(" testing t2mkdir bad path\n");107 printf("Testing t2mkdir bad path\n"); 110 108 md.t2mkdir.in.path = talloc_asprintf(tctx, "%s\\bad_path\\bad_path", 111 109 BASEDIR); … … 113 111 CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND); 114 112 115 printf(" testing t2mkdir with EAs\n");113 printf("Testing t2mkdir with EAs\n"); 116 114 117 115 /* with EAs */ -
trunk/server/source4/torture/raw/mux.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "torture/torture.h"22 21 #include "system/filesys.h" 23 22 #include "libcli/raw/libcliraw.h" … … 50 49 double d; 51 50 52 printf(" testing multiplexed open/open/close\n");51 printf("Testing multiplexed open/open/close\n"); 53 52 54 53 printf("send first open\n"); 55 54 io.generic.level = RAW_OPEN_NTCREATEX; 56 io.ntcreatex.in.root_fid = 0;55 io.ntcreatex.in.root_fid.fnum = 0; 57 56 io.ntcreatex.in.flags = 0; 58 57 io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA; … … 151 150 struct smbcli_request *req; 152 151 153 printf(" testing multiplexed lock/write/close\n");152 printf("Testing multiplexed lock/write/close\n"); 154 153 155 154 fnum = smbcli_open(cli->tree, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE); -
trunk/server/source4/torture/raw/notify.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "torture/torture.h"22 21 #include "libcli/raw/libcliraw.h" 23 22 #include "libcli/raw/raw_proto.h" … … 52 51 }} while (0) 53 52 53 #define CHECK_WSTR2(tctx, field, value, flags) \ 54 do { \ 55 if (!field.s || strcmp(field.s, value) || \ 56 wire_bad_flags(&field, flags, cli->transport)) { \ 57 torture_result(tctx, TORTURE_FAIL, \ 58 "(%d) %s [%s] != %s\n", __LINE__, #field, field.s, value); \ 59 } \ 60 } while (0) 54 61 55 62 /* … … 68 75 extern int torture_numops; 69 76 70 printf("TESTING CHANGE NOTIFY ON DIRECT RIES\n");77 printf("TESTING CHANGE NOTIFY ON DIRECTORIES\n"); 71 78 72 79 /* … … 74 81 */ 75 82 io.generic.level = RAW_OPEN_NTCREATEX; 76 io.ntcreatex.in.root_fid = 0;83 io.ntcreatex.in.root_fid.fnum = 0; 77 84 io.ntcreatex.in.flags = 0; 78 85 io.ntcreatex.in.access_mask = SEC_FILE_ALL; … … 102 109 notify.nttrans.in.recursive = true; 103 110 104 printf(" testing notify cancel\n");111 printf("Testing notify cancel\n"); 105 112 106 113 req = smb_raw_changenotify_send(cli->tree, ¬ify); … … 109 116 CHECK_STATUS(status, NT_STATUS_CANCELLED); 110 117 111 printf(" testing notify mkdir\n");118 printf("Testing notify mkdir\n"); 112 119 113 120 req = smb_raw_changenotify_send(cli->tree, ¬ify); … … 121 128 CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE); 122 129 123 printf(" testing notify rmdir\n");130 printf("Testing notify rmdir\n"); 124 131 125 132 req = smb_raw_changenotify_send(cli->tree, ¬ify); … … 132 139 CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE); 133 140 134 printf(" testing notify mkdir - rmdir - mkdir - rmdir\n");141 printf("Testing notify mkdir - rmdir - mkdir - rmdir\n"); 135 142 136 143 smbcli_mkdir(cli2->tree, BASEDIR "\\subdir-name"); … … 138 145 smbcli_mkdir(cli2->tree, BASEDIR "\\subdir-name"); 139 146 smbcli_rmdir(cli2->tree, BASEDIR "\\subdir-name"); 140 msleep(200);147 smb_msleep(200); 141 148 req = smb_raw_changenotify_send(cli->tree, ¬ify); 142 149 status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); … … 153 160 154 161 count = torture_numops; 155 printf(" testing buffered notify on create of %d files\n", count);162 printf("Testing buffered notify on create of %d files\n", count); 156 163 for (i=0;i<count;i++) { 157 164 char *fname = talloc_asprintf(cli, BASEDIR "\\test%d.txt", i); … … 183 190 this unlink is only seen by the 1st notify and 184 191 the 3rd notify (later) */ 185 printf(" testing notify on unlink for the first file\n");192 printf("Testing notify on unlink for the first file\n"); 186 193 status = smbcli_unlink(cli2->tree, BASEDIR "\\test0.txt"); 187 194 CHECK_STATUS(status, NT_STATUS_OK); … … 210 217 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); 211 218 212 printf(" testing notify on wildcard unlink for %d files\n", count-1);219 printf("Testing notify on wildcard unlink for %d files\n", count-1); 213 220 /* (2nd unlink) do a wildcard unlink */ 214 221 status = smbcli_unlink(cli2->tree, BASEDIR "\\test*.txt"); … … 241 248 } 242 249 243 printf(" testing if a close() on the dir handle triggers the notify reply\n");250 printf("Testing if a close() on the dir handle triggers the notify reply\n"); 244 251 245 252 notify.nttrans.in.file.fnum = fnum; … … 311 318 */ 312 319 io.generic.level = RAW_OPEN_NTCREATEX; 313 io.ntcreatex.in.root_fid = 0;320 io.ntcreatex.in.root_fid.fnum = 0; 314 321 io.ntcreatex.in.flags = 0; 315 322 io.ntcreatex.in.access_mask = SEC_FILE_ALL; … … 359 366 notify.nttrans.in.completion_filter = 0; 360 367 notify.nttrans.in.recursive = true; 361 msleep(200);368 smb_msleep(200); 362 369 req1 = smb_raw_changenotify_send(cli->tree, ¬ify); 363 370 … … 442 449 */ 443 450 io.generic.level = RAW_OPEN_NTCREATEX; 444 io.ntcreatex.in.root_fid = 0;451 io.ntcreatex.in.root_fid.fnum = 0; 445 452 io.ntcreatex.in.flags = 0; 446 453 io.ntcreatex.in.access_mask = SEC_FILE_ALL; … … 567 574 */ 568 575 io.generic.level = RAW_OPEN_NTCREATEX; 569 io.ntcreatex.in.root_fid = 0;576 io.ntcreatex.in.root_fid.fnum = 0; 570 577 io.ntcreatex.in.flags = 0; 571 578 io.ntcreatex.in.access_mask = SEC_FILE_ALL; … … 596 603 req = smb_raw_changenotify_send(cli->tree, ¬ify); \ 597 604 op \ 598 msleep(200); smb_raw_ntcancel(req); \605 smb_msleep(200); smb_raw_ntcancel(req); \ 599 606 status = smb_raw_changenotify_recv(req, tctx, ¬ify); \ 600 607 cleanup \ … … 645 652 } while (0); 646 653 647 printf(" testing mkdir\n");648 NOTIFY_MASK_TEST(" testing mkdir",;,654 printf("Testing mkdir\n"); 655 NOTIFY_MASK_TEST("Testing mkdir",;, 649 656 smbcli_mkdir(cli->tree, BASEDIR "\\tname1");, 650 657 smbcli_rmdir(cli->tree, BASEDIR "\\tname1");, … … 652 659 FILE_NOTIFY_CHANGE_DIR_NAME, 1); 653 660 654 printf(" testing create file\n");655 NOTIFY_MASK_TEST(" testing create file",;,661 printf("Testing create file\n"); 662 NOTIFY_MASK_TEST("Testing create file",;, 656 663 smbcli_close(cli->tree, smbcli_open(cli->tree, BASEDIR "\\tname1", O_CREAT, 0));, 657 664 smbcli_unlink(cli->tree, BASEDIR "\\tname1");, … … 659 666 FILE_NOTIFY_CHANGE_FILE_NAME, 1); 660 667 661 printf(" testing unlink\n");662 NOTIFY_MASK_TEST(" testing unlink",668 printf("Testing unlink\n"); 669 NOTIFY_MASK_TEST("Testing unlink", 663 670 smbcli_close(cli->tree, smbcli_open(cli->tree, BASEDIR "\\tname1", O_CREAT, 0));, 664 671 smbcli_unlink(cli->tree, BASEDIR "\\tname1");, … … 667 674 FILE_NOTIFY_CHANGE_FILE_NAME, 1); 668 675 669 printf(" testing rmdir\n");670 NOTIFY_MASK_TEST(" testing rmdir",676 printf("Testing rmdir\n"); 677 NOTIFY_MASK_TEST("Testing rmdir", 671 678 smbcli_mkdir(cli->tree, BASEDIR "\\tname1");, 672 679 smbcli_rmdir(cli->tree, BASEDIR "\\tname1");, … … 675 682 FILE_NOTIFY_CHANGE_DIR_NAME, 1); 676 683 677 printf(" testing rename file\n");678 NOTIFY_MASK_TEST(" testing rename file",684 printf("Testing rename file\n"); 685 NOTIFY_MASK_TEST("Testing rename file", 679 686 smbcli_close(cli->tree, smbcli_open(cli->tree, BASEDIR "\\tname1", O_CREAT, 0));, 680 687 smbcli_rename(cli->tree, BASEDIR "\\tname1", BASEDIR "\\tname2");, … … 683 690 FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_ATTRIBUTES|FILE_NOTIFY_CHANGE_CREATION, 2); 684 691 685 printf(" testing rename dir\n");686 NOTIFY_MASK_TEST(" testing rename dir",692 printf("Testing rename dir\n"); 693 NOTIFY_MASK_TEST("Testing rename dir", 687 694 smbcli_mkdir(cli->tree, BASEDIR "\\tname1");, 688 695 smbcli_rename(cli->tree, BASEDIR "\\tname1", BASEDIR "\\tname2");, … … 691 698 FILE_NOTIFY_CHANGE_DIR_NAME, 2); 692 699 693 printf(" testing set path attribute\n");694 NOTIFY_MASK_TEST(" testing set path attribute",700 printf("Testing set path attribute\n"); 701 NOTIFY_MASK_TEST("Testing set path attribute", 695 702 smbcli_close(cli->tree, smbcli_open(cli->tree, BASEDIR "\\tname1", O_CREAT, 0));, 696 703 smbcli_setatr(cli->tree, BASEDIR "\\tname1", FILE_ATTRIBUTE_HIDDEN, 0);, … … 699 706 FILE_NOTIFY_CHANGE_ATTRIBUTES, 1); 700 707 701 printf(" testing set path write time\n");702 NOTIFY_MASK_TEST(" testing set path write time",708 printf("Testing set path write time\n"); 709 NOTIFY_MASK_TEST("Testing set path write time", 703 710 smbcli_close(cli->tree, smbcli_open(cli->tree, BASEDIR "\\tname1", O_CREAT, 0));, 704 711 smbcli_setatr(cli->tree, BASEDIR "\\tname1", FILE_ATTRIBUTE_NORMAL, 1000);, … … 707 714 FILE_NOTIFY_CHANGE_LAST_WRITE, 1); 708 715 709 printf(" testing set file attribute\n");710 NOTIFY_MASK_TEST(" testing set file attribute",716 printf("Testing set file attribute\n"); 717 NOTIFY_MASK_TEST("Testing set file attribute", 711 718 fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");, 712 719 smbcli_fsetatr(cli->tree, fnum2, FILE_ATTRIBUTE_HIDDEN, 0, 0, 0, 0);, … … 720 727 } 721 728 else { 722 printf(" testing set file create time\n");723 NOTIFY_MASK_TEST(" testing set file create time",729 printf("Testing set file create time\n"); 730 NOTIFY_MASK_TEST("Testing set file create time", 724 731 fnum2 = create_complex_file(cli, tctx, 725 732 BASEDIR "\\tname1");, … … 731 738 } 732 739 733 printf(" testing set file access time\n");734 NOTIFY_MASK_TEST(" testing set file access time",740 printf("Testing set file access time\n"); 741 NOTIFY_MASK_TEST("Testing set file access time", 735 742 fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");, 736 743 smbcli_fsetatr(cli->tree, fnum2, 0, 0, t, 0, 0);, … … 739 746 FILE_NOTIFY_CHANGE_LAST_ACCESS, 1); 740 747 741 printf(" testing set file write time\n");742 NOTIFY_MASK_TEST(" testing set file write time",748 printf("Testing set file write time\n"); 749 NOTIFY_MASK_TEST("Testing set file write time", 743 750 fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");, 744 751 smbcli_fsetatr(cli->tree, fnum2, 0, 0, 0, t, 0);, … … 747 754 FILE_NOTIFY_CHANGE_LAST_WRITE, 1); 748 755 749 printf(" testing set file change time\n");750 NOTIFY_MASK_TEST(" testing set file change time",756 printf("Testing set file change time\n"); 757 NOTIFY_MASK_TEST("Testing set file change time", 751 758 fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");, 752 759 smbcli_fsetatr(cli->tree, fnum2, 0, 0, 0, 0, t);, … … 756 763 757 764 758 printf(" testing write\n");759 NOTIFY_MASK_TEST(" testing write",765 printf("Testing write\n"); 766 NOTIFY_MASK_TEST("Testing write", 760 767 fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");, 761 768 smbcli_write(cli->tree, fnum2, 1, &c, 10000, 1);, … … 764 771 0, 1); 765 772 766 printf(" testing truncate\n");767 NOTIFY_MASK_TEST(" testing truncate",773 printf("Testing truncate\n"); 774 NOTIFY_MASK_TEST("Testing truncate", 768 775 fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");, 769 776 smbcli_ftruncate(cli->tree, fnum2, 10000);, … … 794 801 795 802 io.generic.level = RAW_OPEN_NTCREATEX; 796 io.ntcreatex.in.root_fid = 0;803 io.ntcreatex.in.root_fid.fnum = 0; 797 804 io.ntcreatex.in.flags = 0; 798 805 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 817 824 notify.nttrans.in.recursive = false; 818 825 819 printf(" testing if notifies on file handles are invalid (should be)\n");826 printf("Testing if notifies on file handles are invalid (should be)\n"); 820 827 821 828 req = smb_raw_changenotify_send(cli->tree, ¬ify); … … 860 867 */ 861 868 io.generic.level = RAW_OPEN_NTCREATEX; 862 io.ntcreatex.in.root_fid = 0;869 io.ntcreatex.in.root_fid.fnum = 0; 863 870 io.ntcreatex.in.flags = 0; 864 871 io.ntcreatex.in.access_mask = SEC_FILE_ALL; … … 922 929 */ 923 930 io.generic.level = RAW_OPEN_NTCREATEX; 924 io.ntcreatex.in.root_fid = 0;931 io.ntcreatex.in.root_fid.fnum = 0; 925 932 io.ntcreatex.in.flags = 0; 926 933 io.ntcreatex.in.access_mask = SEC_FILE_ALL; … … 983 990 */ 984 991 io.generic.level = RAW_OPEN_NTCREATEX; 985 io.ntcreatex.in.root_fid = 0;992 io.ntcreatex.in.root_fid.fnum = 0; 986 993 io.ntcreatex.in.flags = 0; 987 994 io.ntcreatex.in.access_mask = SEC_FILE_ALL; … … 1051 1058 */ 1052 1059 io.generic.level = RAW_OPEN_NTCREATEX; 1053 io.ntcreatex.in.root_fid = 0;1060 io.ntcreatex.in.root_fid.fnum = 0; 1054 1061 io.ntcreatex.in.flags = 0; 1055 1062 io.ntcreatex.in.access_mask = SEC_FILE_ALL; … … 1105 1112 */ 1106 1113 io.generic.level = RAW_OPEN_NTCREATEX; 1107 io.ntcreatex.in.root_fid = 0;1114 io.ntcreatex.in.root_fid.fnum = 0; 1108 1115 io.ntcreatex.in.flags = 0; 1109 1116 io.ntcreatex.in.access_mask = SEC_FILE_ALL; … … 1198 1205 1199 1206 io.generic.level = RAW_OPEN_NTCREATEX; 1200 io.ntcreatex.in.root_fid = 0;1207 io.ntcreatex.in.root_fid.fnum = 0; 1201 1208 io.ntcreatex.in.flags = 0; 1202 1209 io.ntcreatex.in.access_mask = SEC_FILE_ALL; … … 1294 1301 union smb_notify notify; 1295 1302 union smb_open io; 1296 int fnum , fnum2;1303 int fnum; 1297 1304 int count = 100; 1298 1305 struct smbcli_request *req1; … … 1303 1310 /* get a handle on the directory */ 1304 1311 io.generic.level = RAW_OPEN_NTCREATEX; 1305 io.ntcreatex.in.root_fid = 0;1312 io.ntcreatex.in.root_fid.fnum = 0; 1306 1313 io.ntcreatex.in.flags = 0; 1307 1314 io.ntcreatex.in.access_mask = SEC_FILE_ALL; … … 1335 1342 1336 1343 /* open a lot of files, filling up the server side notify buffer */ 1337 printf(" testing overflowed buffer notify on create of %d files\n",1344 printf("Testing overflowed buffer notify on create of %d files\n", 1338 1345 count); 1339 1346 for (i=0;i<count;i++) { … … 1372 1379 union smb_notify notify; 1373 1380 union smb_open io; 1374 int fnum, fnum2; 1375 int count = 100; 1381 int fnum; 1376 1382 struct smbcli_request *req1; 1377 int i;1378 1383 1379 1384 printf("TESTING CHANGE NOTIFY BASEDIR EVENTS\n"); … … 1381 1386 /* get a handle on the directory */ 1382 1387 io.generic.level = RAW_OPEN_NTCREATEX; 1383 io.ntcreatex.in.root_fid = 0;1388 io.ntcreatex.in.root_fid.fnum = 0; 1384 1389 io.ntcreatex.in.flags = 0; 1385 1390 io.ntcreatex.in.access_mask = SEC_FILE_ALL; … … 1416 1421 /* set attribute on a file to assure we receive a notification */ 1417 1422 smbcli_setatr(cli->tree, BASEDIR "\\tname1", FILE_ATTRIBUTE_HIDDEN, 0); 1418 msleep(200);1423 smb_msleep(200); 1419 1424 1420 1425 /* check how many responses were given, expect only 1 for the file */ … … 1488 1493 */ 1489 1494 io.generic.level = RAW_OPEN_NTCREATEX; 1490 io.ntcreatex.in.root_fid = 0;1495 io.ntcreatex.in.root_fid.fnum = 0; 1491 1496 io.ntcreatex.in.flags = 0; 1492 1497 io.ntcreatex.in.access_mask = SEC_FILE_ALL; … … 1516 1521 notify.nttrans.in.recursive = true; 1517 1522 1518 printf(" testing notify mkdir\n");1523 printf("Testing notify mkdir\n"); 1519 1524 req = smb_raw_changenotify_send(cli->tree, ¬ify); 1520 1525 smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name"); … … 1527 1532 CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE); 1528 1533 1529 printf(" testing notify rmdir\n");1534 printf("Testing notify rmdir\n"); 1530 1535 req = smb_raw_changenotify_send(cli->tree, ¬ify); 1531 1536 smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name"); … … 1542 1547 tree = secondary_tcon(cli, torture); 1543 1548 1544 printf(" testing notify mkdir\n");1549 printf("Testing notify mkdir\n"); 1545 1550 req = smb_raw_changenotify_send(cli->tree, ¬ify); 1546 1551 smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name"); … … 1553 1558 CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE); 1554 1559 1555 printf(" testing notify rmdir\n");1560 printf("Testing notify rmdir\n"); 1556 1561 req = smb_raw_changenotify_send(cli->tree, ¬ify); 1557 1562 smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name"); … … 1570 1575 talloc_free(tree); 1571 1576 1572 printf(" testing notify mkdir\n");1577 printf("Testing notify mkdir\n"); 1573 1578 req = smb_raw_changenotify_send(cli->tree, ¬ify); 1574 1579 smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name"); … … 1581 1586 CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE); 1582 1587 1583 printf(" testing notify rmdir\n");1588 printf("Testing notify rmdir\n"); 1584 1589 req = smb_raw_changenotify_send(cli->tree, ¬ify); 1585 1590 smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name"); … … 1598 1603 1599 1604 1600 /* 1605 /* 1606 testing alignment of multiple change notify infos 1607 */ 1608 static bool test_notify_alignment(struct smbcli_state *cli, 1609 struct torture_context *tctx) 1610 { 1611 NTSTATUS status; 1612 union smb_notify notify; 1613 union smb_open io; 1614 int i, fnum, fnum2; 1615 struct smbcli_request *req; 1616 const char *fname = BASEDIR "\\starter"; 1617 const char *fnames[] = { "a", 1618 "ab", 1619 "abc", 1620 "abcd" }; 1621 int num_names = ARRAY_SIZE(fnames); 1622 char *fpath = NULL; 1623 1624 torture_comment(tctx, "TESTING CHANGE NOTIFY REPLY ALIGNMENT\n"); 1625 1626 /* get a handle on the directory */ 1627 io.generic.level = RAW_OPEN_NTCREATEX; 1628 io.ntcreatex.in.root_fid.fnum = 0; 1629 io.ntcreatex.in.flags = 0; 1630 io.ntcreatex.in.access_mask = SEC_FILE_ALL; 1631 io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; 1632 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 1633 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | 1634 NTCREATEX_SHARE_ACCESS_WRITE; 1635 io.ntcreatex.in.alloc_size = 0; 1636 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; 1637 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 1638 io.ntcreatex.in.security_flags = 0; 1639 io.ntcreatex.in.fname = BASEDIR; 1640 1641 status = smb_raw_open(cli->tree, tctx, &io); 1642 torture_assert_ntstatus_ok(tctx, status, ""); 1643 fnum = io.ntcreatex.out.file.fnum; 1644 1645 /* ask for a change notify, on file creation */ 1646 notify.nttrans.level = RAW_NOTIFY_NTTRANS; 1647 notify.nttrans.in.buffer_size = 1000; 1648 notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_FILE_NAME; 1649 notify.nttrans.in.file.fnum = fnum; 1650 notify.nttrans.in.recursive = false; 1651 1652 /* start change tracking */ 1653 req = smb_raw_changenotify_send(cli->tree, ¬ify); 1654 1655 fnum2 = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE); 1656 torture_assert(tctx, fnum2 != -1, smbcli_errstr(cli->tree)); 1657 smbcli_close(cli->tree, fnum2); 1658 1659 status = smb_raw_changenotify_recv(req, tctx, ¬ify); 1660 torture_assert_ntstatus_ok(tctx, status, ""); 1661 1662 /* create 4 files that will cause CHANGE_NOTIFY_INFO structures 1663 * to be returned in the same packet with all possible 4-byte padding 1664 * permutations. As per MS-CIFS 2.2.7.4.2 these structures should be 1665 * 4-byte aligned. */ 1666 1667 for (i = 0; i < num_names; i++) { 1668 fpath = talloc_asprintf(tctx, "%s\\%s", BASEDIR, fnames[i]); 1669 fnum2 = smbcli_open(cli->tree, fpath, 1670 O_CREAT|O_RDWR, DENY_NONE); 1671 torture_assert(tctx, fnum2 != -1, smbcli_errstr(cli->tree)); 1672 smbcli_close(cli->tree, fnum2); 1673 talloc_free(fpath); 1674 } 1675 1676 /* We send a notify packet, and let smb_raw_changenotify_recv() do 1677 * the alignment checking for us. */ 1678 req = smb_raw_changenotify_send(cli->tree, ¬ify); 1679 status = smb_raw_changenotify_recv(req, tctx, ¬ify); 1680 torture_assert_ntstatus_ok(tctx, status, ""); 1681 1682 /* Do basic checking for correctness. */ 1683 torture_assert(tctx, notify.nttrans.out.num_changes == num_names, ""); 1684 for (i = 0; i < num_names; i++) { 1685 torture_assert(tctx, notify.nttrans.out.changes[i].action == 1686 NOTIFY_ACTION_ADDED, ""); 1687 CHECK_WSTR2(tctx, notify.nttrans.out.changes[i].name, fnames[i], 1688 STR_UNICODE); 1689 } 1690 1691 return true; 1692 } 1693 1694 /* 1601 1695 basic testing of change notify 1602 1696 */ … … 1625 1719 ret &= test_notify_overflow(cli, torture); 1626 1720 ret &= test_notify_basedir(cli, torture); 1721 ret &= test_notify_alignment(cli, torture); 1627 1722 1628 1723 smb_raw_exit(cli->session); -
trunk/server/source4/torture/raw/offline.c
r414 r745 23 23 24 24 #include "includes.h" 25 #include "torture/torture.h"26 #include "libcli/raw/libcliraw.h"27 25 #include "system/time.h" 28 26 #include "system/filesys.h" … … 30 28 #include "torture/util.h" 31 29 #include "lib/events/events.h" 32 #include "lib/cmdline/popt_common.h"33 30 #include "libcli/composite/composite.h" 34 31 #include "libcli/smb_composite/smb_composite.h" 35 #include "libcli/resolve/resolve.h"36 32 37 33 #define BASEDIR "\\testoffline" … … 322 318 NTSTATUS status = smbcli_request_simple_recv(req); 323 319 if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) || 324 NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT)) { 320 NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT) || 321 NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_RESET)) { 325 322 talloc_free(state->tree); 326 323 state->tree = NULL; -
trunk/server/source4/torture/raw/open.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "torture/torture.h"22 21 #include "libcli/raw/libcliraw.h" 23 #include "libcli/raw/raw_proto.h"24 22 #include "system/time.h" 25 23 #include "system/filesys.h" 26 #include "librpc/gen_ndr/security.h"27 24 #include "lib/events/events.h" 28 25 #include "libcli/libcli.h" 29 26 #include "torture/util.h" 30 #include "auth/credentials/credentials.h"31 #include "lib/cmdline/popt_common.h"32 27 33 28 /* enum for whether reads/writes are possible on a file */ … … 66 61 #define CHECK_STATUS(status, correct) do { \ 67 62 if (!NT_STATUS_EQUAL(status, correct)) { \ 68 printf("(%s) Incorrect status %s - should be %s\n", \ 63 torture_result(tctx, TORTURE_FAIL, \ 64 "(%s) Incorrect status %s - should be %s\n", \ 69 65 __location__, nt_errstr(status), nt_errstr(correct)); \ 70 66 ret = false; \ … … 75 71 fnum = create_complex_file(cli, tctx, fname); \ 76 72 if (fnum == -1) { \ 77 printf("(%s) Failed to create %s - %s\n", __location__, fname, smbcli_errstr(cli->tree)); \ 73 torture_result(tctx, TORTURE_FAIL, \ 74 "(%s) Failed to create %s - %s\n", \ 75 __location__, fname, smbcli_errstr(cli->tree)); \ 78 76 ret = false; \ 79 77 goto done; \ … … 83 81 enum rdwr_mode m = check_rdwr(cli->tree, fnum); \ 84 82 if (m != correct) { \ 85 printf("(%s) Incorrect readwrite mode %s - expected %s\n", \ 83 torture_result(tctx, TORTURE_FAIL, \ 84 "(%s) Incorrect readwrite mode %s - expected %s\n", \ 86 85 __location__, rdwr_string(m), rdwr_string(correct)); \ 87 86 ret = false; \ … … 97 96 t2 = nt_time_to_unix(finfo.all_info.out.field) & ~1; \ 98 97 if (abs(t1-t2) > 2) { \ 99 printf("(%s) wrong time for field %s %s - %s\n", \ 98 torture_result(tctx, TORTURE_FAIL, \ 99 "(%s) wrong time for field %s %s - %s\n", \ 100 100 __location__, #field, \ 101 101 timestring(tctx, t1), \ … … 113 113 t2 = finfo.all_info.out.field; \ 114 114 if (t != t2) { \ 115 printf("(%s) wrong time for field %s %s - %s\n", \ 115 torture_result(tctx, TORTURE_FAIL, \ 116 "(%s) wrong time for field %s %s - %s\n", \ 116 117 __location__, #field, \ 117 118 nt_time_string(tctx, t), \ … … 127 128 CHECK_STATUS(status, NT_STATUS_OK); \ 128 129 if ((v) != (finfo.all_info.out.field)) { \ 129 printf("(%s) wrong value for field %s 0x%x - 0x%x\n", \ 130 torture_result(tctx, TORTURE_FAIL, \ 131 "(%s) wrong value for field %s 0x%x - 0x%x\n", \ 130 132 __location__, #field, (int)v, (int)(finfo.all_info.out.field)); \ 131 133 dump_all_info(tctx, &finfo); \ … … 135 137 #define CHECK_VAL(v, correct) do { \ 136 138 if ((v) != (correct)) { \ 137 printf("(%s) wrong value for %s 0x%x - should be 0x%x\n", \ 139 torture_result(tctx, TORTURE_FAIL, \ 140 "(%s) wrong value for %s 0x%x - should be 0x%x\n", \ 138 141 __location__, #v, (int)(v), (int)correct); \ 139 142 ret = false; \ … … 148 151 status = smb_raw_setpathinfo(cli->tree, &sfinfo); \ 149 152 if (!NT_STATUS_IS_OK(status)) { \ 150 printf("(%s) Failed to set attrib 0x%x on %s\n", \153 torture_warning(tctx, "(%s) Failed to set attrib 0x%x on %s\n", \ 151 154 __location__, sattrib, fname); \ 152 155 }} while (0) … … 155 158 test RAW_OPEN_OPEN 156 159 */ 157 static bool test_open(struct smbcli_state *cli, struct torture_context *tctx)160 static bool test_open(struct torture_context *tctx, struct smbcli_state *cli) 158 161 { 159 162 union smb_open io; … … 164 167 bool ret = true; 165 168 166 printf("Checking RAW_OPEN_OPEN\n"); 169 if (!torture_setup_dir(cli, BASEDIR)) { 170 return false; 171 } 167 172 168 173 io.openold.level = RAW_OPEN_OPEN; … … 224 229 225 230 if (io.openold.in.open_mode != io.openold.out.rmode) { 226 printf("(%s) rmode should equal open_mode - 0x%x 0x%x\n",231 torture_warning(tctx, "(%s) rmode should equal open_mode - 0x%x 0x%x\n", 227 232 __location__, io.openold.out.rmode, io.openold.in.open_mode); 228 233 } … … 257 262 done: 258 263 smbcli_close(cli->tree, fnum); 259 smbcli_ unlink(cli->tree, fname);264 smbcli_deltree(cli->tree, BASEDIR); 260 265 261 266 return ret; … … 266 271 test RAW_OPEN_OPENX 267 272 */ 268 static bool test_openx(struct smbcli_state *cli, struct torture_context *tctx)273 static bool test_openx(struct torture_context *tctx, struct smbcli_state *cli) 269 274 { 270 275 union smb_open io; … … 296 301 }; 297 302 298 printf("Checking RAW_OPEN_OPENX\n"); 299 smbcli_unlink(cli->tree, fname); 303 if (!torture_setup_dir(cli, BASEDIR)) { 304 return false; 305 } 300 306 301 307 io.openx.level = RAW_OPEN_OPENX; … … 314 320 fnum = create_complex_file(cli, tctx, fname); 315 321 if (fnum == -1) { 316 d_printf("Failed to create file %s - %s\n", fname, smbcli_errstr(cli->tree)); 322 torture_result(tctx, TORTURE_FAIL, 323 "Failed to create file %s - %s\n", 324 fname, smbcli_errstr(cli->tree)); 317 325 ret = false; 318 326 goto done; … … 323 331 status = smb_raw_open(cli->tree, tctx, &io); 324 332 if (!NT_STATUS_EQUAL(status, open_funcs[i].correct_status)) { 325 printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_func=0x%x)\n", 326 __location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status), 327 i, (int)open_funcs[i].with_file, (int)open_funcs[i].open_func); 333 torture_result(tctx, TORTURE_FAIL, 334 "(%s) incorrect status %s should be %s " 335 "(i=%d with_file=%d open_func=0x%x)\n", 336 __location__, nt_errstr(status), 337 nt_errstr(open_funcs[i].correct_status), 338 i, (int)open_funcs[i].with_file, 339 (int)open_funcs[i].open_func); 328 340 ret = false; 329 341 } … … 425 437 CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); 426 438 if (timeval_elapsed(&tv) > 3.0) { 427 printf("(%s) Incorrect timing in openx with timeout - waited %.2f seconds\n", 428 __location__, timeval_elapsed(&tv)); 439 torture_result(tctx, TORTURE_FAIL, 440 "(%s) Incorrect timing in openx with timeout " 441 "- waited %.2f seconds\n", 442 __location__, timeval_elapsed(&tv)); 429 443 ret = false; 430 444 } … … 484 498 done: 485 499 smbcli_close(cli->tree, fnum); 486 smbcli_unlink(cli->tree, fname_exe); 487 smbcli_unlink(cli->tree, fname); 500 smbcli_deltree(cli->tree, BASEDIR); 488 501 489 502 return ret; … … 496 509 many thanks to kukks for a sniff showing how this works with os2->w2k 497 510 */ 498 static bool test_t2open(struct smbcli_state *cli, struct torture_context *tctx)511 static bool test_t2open(struct torture_context *tctx, struct smbcli_state *cli) 499 512 { 500 513 union smb_open io; … … 526 539 }; 527 540 541 if (!torture_setup_dir(cli, BASEDIR)) { 542 return false; 543 } 544 528 545 fnum = create_complex_file(cli, tctx, fname1); 529 546 if (fnum == -1) { 530 d_printf("Failed to create file %s - %s\n", fname1, smbcli_errstr(cli->tree)); 547 torture_result(tctx, TORTURE_FAIL, 548 "(%s): Failed to create file %s - %s\n", 549 __location__, fname1, smbcli_errstr(cli->tree)); 531 550 ret = false; 532 551 goto done; 533 552 } 534 553 smbcli_close(cli->tree, fnum); 535 536 printf("Checking RAW_OPEN_T2OPEN\n");537 554 538 555 io.t2open.level = RAW_OPEN_T2OPEN; … … 571 588 && NT_STATUS_EQUAL(status, NT_STATUS_EAS_NOT_SUPPORTED) 572 589 && torture_setting_bool(tctx, "samba3", false)) { 573 printf("(%s) EAs not supported, not treating as fatal " 574 "in Samba3 test\n", __location__); 590 torture_warning(tctx, "(%s) EAs not supported, not " 591 "treating as fatal in Samba3 test\n", 592 __location__); 575 593 io.t2open.in.num_eas = 0; 576 594 goto again; … … 578 596 579 597 if (!NT_STATUS_EQUAL(status, open_funcs[i].correct_status)) { 580 printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_func=0x%x)\n", 581 __location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status), 582 i, (int)open_funcs[i].with_file, (int)open_funcs[i].open_func); 598 torture_result(tctx, TORTURE_FAIL, 599 "(%s) incorrect status %s should be %s " 600 "(i=%d with_file=%d open_func=0x%x)\n", 601 __location__, nt_errstr(status), 602 nt_errstr(open_funcs[i].correct_status), 603 i, (int)open_funcs[i].with_file, 604 (int)open_funcs[i].open_func); 583 605 ret = false; 584 606 } … … 652 674 done: 653 675 smbcli_close(cli->tree, fnum); 654 smbcli_ unlink(cli->tree, fname);676 smbcli_deltree(cli->tree, BASEDIR); 655 677 656 678 return ret; … … 661 683 test RAW_OPEN_NTCREATEX 662 684 */ 663 static bool test_ntcreatex(struct smbcli_state *cli, struct torture_context *tctx)685 static bool test_ntcreatex(struct torture_context *tctx, struct smbcli_state *cli) 664 686 { 665 687 union smb_open io; … … 692 714 }; 693 715 694 printf("Checking RAW_OPEN_NTCREATEX\n"); 716 if (!torture_setup_dir(cli, BASEDIR)) { 717 return false; 718 } 695 719 696 720 /* reasonable default parameters */ 697 721 io.generic.level = RAW_OPEN_NTCREATEX; 698 722 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; 699 io.ntcreatex.in.root_fid = 0;723 io.ntcreatex.in.root_fid.fnum = 0; 700 724 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 701 725 io.ntcreatex.in.alloc_size = 1024*1024; … … 713 737 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR|O_TRUNC, DENY_NONE); 714 738 if (fnum == -1) { 715 d_printf("Failed to create file %s - %s\n", fname, smbcli_errstr(cli->tree)); 739 torture_result(tctx, TORTURE_FAIL, 740 "Failed to create file %s - %s\n", 741 fname, smbcli_errstr(cli->tree)); 716 742 ret = false; 717 743 goto done; … … 722 748 status = smb_raw_open(cli->tree, tctx, &io); 723 749 if (!NT_STATUS_EQUAL(status, open_funcs[i].correct_status)) { 724 printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_disp=%d)\n", 725 __location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status), 726 i, (int)open_funcs[i].with_file, (int)open_funcs[i].open_disp); 750 torture_result(tctx, TORTURE_FAIL, 751 "(%s) incorrect status %s should be %s " 752 "(i=%d with_file=%d open_disp=%d)\n", 753 __location__, nt_errstr(status), 754 nt_errstr(open_funcs[i].correct_status), 755 i, (int)open_funcs[i].with_file, 756 (int)open_funcs[i].open_disp); 727 757 ret = false; 728 758 } … … 825 855 done: 826 856 smbcli_close(cli->tree, fnum); 827 smbcli_ unlink(cli->tree, fname);857 smbcli_deltree(cli->tree, BASEDIR); 828 858 829 859 return ret; … … 834 864 test RAW_OPEN_NTTRANS_CREATE 835 865 */ 836 static bool test_nttrans_create(struct smbcli_state *cli, struct torture_context *tctx)866 static bool test_nttrans_create(struct torture_context *tctx, struct smbcli_state *cli) 837 867 { 838 868 union smb_open io; … … 867 897 }; 868 898 869 printf("Checking RAW_OPEN_NTTRANS_CREATE\n"); 899 if (!torture_setup_dir(cli, BASEDIR)) { 900 return false; 901 } 870 902 871 903 /* reasonable default parameters */ 872 904 io.generic.level = RAW_OPEN_NTTRANS_CREATE; 873 905 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; 874 io.ntcreatex.in.root_fid = 0;906 io.ntcreatex.in.root_fid.fnum = 0; 875 907 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 876 908 io.ntcreatex.in.alloc_size = 1024*1024; … … 890 922 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR|O_TRUNC, DENY_NONE); 891 923 if (fnum == -1) { 892 d_printf("Failed to create file %s - %s\n", fname, smbcli_errstr(cli->tree)); 924 torture_result(tctx, TORTURE_FAIL, 925 "Failed to create file %s - %s\n", 926 fname, smbcli_errstr(cli->tree)); 893 927 ret = false; 894 928 goto done; … … 899 933 status = smb_raw_open(cli->tree, tctx, &io); 900 934 if (!NT_STATUS_EQUAL(status, open_funcs[i].correct_status)) { 901 printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_disp=%d)\n", 902 __location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status), 903 i, (int)open_funcs[i].with_file, (int)open_funcs[i].open_disp); 935 torture_result(tctx, TORTURE_FAIL, 936 "(%s) incorrect status %s should be %s " 937 "(i=%d with_file=%d open_disp=%d)\n", 938 __location__, nt_errstr(status), 939 nt_errstr(open_funcs[i].correct_status), 940 i, (int)open_funcs[i].with_file, 941 (int)open_funcs[i].open_disp); 904 942 ret = false; 905 943 } … … 985 1023 status = smb_raw_open(cli->tree, tctx, &io); 986 1024 if (!NT_STATUS_IS_OK(status)) { 987 printf("ntcreatex create option 0x%08x gave %s - should give NT_STATUS_OK\n", 988 create_option, nt_errstr(status)); 1025 torture_warning(tctx, "ntcreatex create option 0x%08x " 1026 "gave %s - should give NT_STATUS_OK\n", 1027 create_option, nt_errstr(status)); 989 1028 } 990 1029 CHECK_STATUS(status, NT_STATUS_OK); … … 1033 1072 } else { 1034 1073 unexpected_mask |= 1<<i; 1035 printf("create option 0x%08x returned %s\n", create_option, nt_errstr(status)); 1074 torture_comment(tctx, "create option 0x%08x returned %s\n", 1075 create_option, nt_errstr(status)); 1036 1076 } 1037 1077 } … … 1089 1129 done: 1090 1130 smbcli_close(cli->tree, fnum); 1091 smbcli_ unlink(cli->tree, fname);1131 smbcli_deltree(cli->tree, BASEDIR); 1092 1132 1093 1133 return ret; … … 1102 1142 second open. 1103 1143 */ 1104 static bool test_ntcreatex_brlocked(struct smbcli_state *cli, struct torture_context *tctx)1144 static bool test_ntcreatex_brlocked(struct torture_context *tctx, struct smbcli_state *cli) 1105 1145 { 1106 1146 union smb_open io, io1; … … 1111 1151 bool ret = true; 1112 1152 1113 printf("Testing ntcreatex with a byte range locked file\n"); 1153 if (!torture_setup_dir(cli, BASEDIR)) { 1154 return false; 1155 } 1156 1157 torture_comment(tctx, "Testing ntcreatex with a byte range locked file\n"); 1114 1158 1115 1159 io.generic.level = RAW_OPEN_NTCREATEX; 1116 1160 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; 1117 io.ntcreatex.in.root_fid = 0;1161 io.ntcreatex.in.root_fid.fnum = 0; 1118 1162 io.ntcreatex.in.access_mask = 0x2019f; 1119 1163 io.ntcreatex.in.alloc_size = 0; … … 1146 1190 io1.generic.level = RAW_OPEN_NTCREATEX; 1147 1191 io1.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; 1148 io1.ntcreatex.in.root_fid = 0;1192 io1.ntcreatex.in.root_fid.fnum = 0; 1149 1193 io1.ntcreatex.in.access_mask = 0x20196; 1150 1194 io1.ntcreatex.in.alloc_size = 0; … … 1165 1209 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 1166 1210 smbcli_close(cli->tree, io1.ntcreatex.out.file.fnum); 1167 smbcli_ unlink(cli->tree, fname);1211 smbcli_deltree(cli->tree, BASEDIR); 1168 1212 return ret; 1169 1213 } … … 1172 1216 test RAW_OPEN_MKNEW 1173 1217 */ 1174 static bool test_mknew(struct smbcli_state *cli, struct torture_context *tctx)1218 static bool test_mknew(struct torture_context *tctx, struct smbcli_state *cli) 1175 1219 { 1176 1220 union smb_open io; … … 1182 1226 union smb_fileinfo finfo; 1183 1227 1184 printf("Checking RAW_OPEN_MKNEW\n"); 1228 if (!torture_setup_dir(cli, BASEDIR)) { 1229 return false; 1230 } 1185 1231 1186 1232 io.mknew.level = RAW_OPEN_MKNEW; … … 1218 1264 done: 1219 1265 smbcli_close(cli->tree, fnum); 1220 smbcli_ unlink(cli->tree, fname);1266 smbcli_deltree(cli->tree, BASEDIR); 1221 1267 1222 1268 return ret; … … 1227 1273 test RAW_OPEN_CREATE 1228 1274 */ 1229 static bool test_create(struct smbcli_state *cli, struct torture_context *tctx)1275 static bool test_create(struct torture_context *tctx, struct smbcli_state *cli) 1230 1276 { 1231 1277 union smb_open io; … … 1237 1283 union smb_fileinfo finfo; 1238 1284 1239 printf("Checking RAW_OPEN_CREATE\n"); 1285 if (!torture_setup_dir(cli, BASEDIR)) { 1286 return false; 1287 } 1240 1288 1241 1289 io.create.level = RAW_OPEN_CREATE; … … 1274 1322 done: 1275 1323 smbcli_close(cli->tree, fnum); 1276 smbcli_ unlink(cli->tree, fname);1324 smbcli_deltree(cli->tree, BASEDIR); 1277 1325 1278 1326 return ret; … … 1283 1331 test RAW_OPEN_CTEMP 1284 1332 */ 1285 static bool test_ctemp(struct smbcli_state *cli, TALLOC_CTX *tctx)1333 static bool test_ctemp(struct torture_context *tctx, struct smbcli_state *cli) 1286 1334 { 1287 1335 union smb_open io; … … 1293 1341 const char *name, *fname = NULL; 1294 1342 1295 printf("Checking RAW_OPEN_CTEMP\n"); 1343 if (!torture_setup_dir(cli, BASEDIR)) { 1344 return false; 1345 } 1296 1346 1297 1347 io.ctemp.level = RAW_OPEN_CTEMP; … … 1311 1361 1312 1362 fname = finfo.name_info.out.fname.s; 1313 d_printf("ctemp name=%s real name=%s\n", name, fname);1363 torture_comment(tctx, "ctemp name=%s real name=%s\n", name, fname); 1314 1364 1315 1365 done: 1316 1366 smbcli_close(cli->tree, fnum); 1317 if (fname) { 1318 smbcli_unlink(cli->tree, fname); 1319 } 1367 smbcli_deltree(cli->tree, BASEDIR); 1320 1368 1321 1369 return ret; … … 1326 1374 test chained RAW_OPEN_OPENX_READX 1327 1375 */ 1328 static bool test_chained(struct smbcli_state *cli, TALLOC_CTX *tctx)1376 static bool test_chained(struct torture_context *tctx, struct smbcli_state *cli) 1329 1377 { 1330 1378 union smb_open io; … … 1336 1384 char buf2[4]; 1337 1385 1338 printf("Checking RAW_OPEN_OPENX chained with READX\n"); 1339 smbcli_unlink(cli->tree, fname); 1386 if (!torture_setup_dir(cli, BASEDIR)) { 1387 return false; 1388 } 1340 1389 1341 1390 fnum = create_complex_file(cli, tctx, fname); … … 1367 1416 1368 1417 if (memcmp(buf, buf2, sizeof(buf)) != 0) { 1369 d_printf("wrong data in reply buffer\n"); 1418 torture_result(tctx, TORTURE_FAIL, 1419 "wrong data in reply buffer\n"); 1370 1420 ret = false; 1371 1421 } … … 1373 1423 done: 1374 1424 smbcli_close(cli->tree, fnum); 1375 smbcli_ unlink(cli->tree, fname);1425 smbcli_deltree(cli->tree, BASEDIR); 1376 1426 1377 1427 return ret; … … 1383 1433 1384 1434 */ 1385 static bool test_no_leading_slash(struct smbcli_state *cli, TALLOC_CTX *tctx)1435 static bool test_no_leading_slash(struct torture_context *tctx, struct smbcli_state *cli) 1386 1436 { 1387 1437 union smb_open io; … … 1392 1442 const char *buf = "test"; 1393 1443 1394 printf("Checking RAW_OPEN_OPENX without leading slash on path\n"); 1395 smbcli_unlink(cli->tree, fname); 1396 1397 /* Create the file */ 1444 if (!torture_setup_dir(cli, BASEDIR)) { 1445 return false; 1446 } 1447 1448 smbcli_unlink(cli->tree, fname); 1449 1450 /* Create the file */ 1398 1451 fnum = create_complex_file(cli, tctx, fname); 1399 1452 smbcli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf)); 1400 1453 smbcli_close(cli->tree, fnum); 1401 1454 1402 1455 /* Prepare to open the file using path without leading slash */ 1403 1456 io.openx.level = RAW_OPEN_OPENX; 1404 1457 io.openx.in.fname = fname + 1; … … 1418 1471 done: 1419 1472 smbcli_close(cli->tree, fnum); 1420 smbcli_ unlink(cli->tree, fname);1473 smbcli_deltree(cli->tree, BASEDIR); 1421 1474 1422 1475 return ret; … … 1429 1482 1430 1483 */ 1431 static bool test_openx_over_dir(struct smbcli_state *cli, TALLOC_CTX *tctx)1484 static bool test_openx_over_dir(struct torture_context *tctx, struct smbcli_state *cli) 1432 1485 { 1433 1486 union smb_open io; … … 1438 1491 bool ret = true; 1439 1492 1440 printf("Checking RAW_OPEN_OPENX over an existing directory\n"); 1441 smbcli_unlink(cli->tree, fname); 1442 1443 /* Create the Directory */ 1493 if (!torture_setup_dir(cli, BASEDIR)) { 1494 return false; 1495 } 1496 1497 /* Create the Directory */ 1444 1498 status = create_directory_handle(cli->tree, fname, &d_fnum); 1445 1499 smbcli_close(cli->tree, d_fnum); 1446 1500 1447 1501 /* Prepare to open the file over the directory. */ 1448 1502 io.openx.level = RAW_OPEN_OPENX; 1449 1503 io.openx.in.fname = fname; … … 1463 1517 done: 1464 1518 smbcli_close(cli->tree, fnum); 1465 smbcli_ unlink(cli->tree, fname);1519 smbcli_deltree(cli->tree, BASEDIR); 1466 1520 1467 1521 return ret; … … 1471 1525 /* A little torture test to expose a race condition in Samba 3.0.20 ... :-) */ 1472 1526 1473 static bool test_raw_open_multi(struct torture_context *tctx )1527 static bool test_raw_open_multi(struct torture_context *tctx, struct smbcli_state *cli_ignored) 1474 1528 { 1475 1529 struct smbcli_state *cli; … … 1493 1547 if ((tctx->ev == NULL) || (clients == NULL) || (requests == NULL) || 1494 1548 (ios == NULL)) { 1495 DEBUG(0, ("talloc failed\n")); 1549 torture_result(tctx, TORTURE_FAIL, "(%s): talloc failed\n", 1550 __location__); 1496 1551 return false; 1497 1552 } … … 1506 1561 if (!torture_open_connection_share(mem_ctx, &(clients[i]), 1507 1562 tctx, host, share, tctx->ev)) { 1508 DEBUG(0, ("Could not open %d'th connection\n", i)); 1563 torture_result(tctx, TORTURE_FAIL, 1564 "(%s): Could not open %d'th connection\n", 1565 __location__, i); 1509 1566 return false; 1510 1567 } … … 1519 1576 */ 1520 1577 io.generic.level = RAW_OPEN_NTCREATEX; 1521 io.ntcreatex.in.root_fid = 0;1578 io.ntcreatex.in.root_fid.fnum = 0; 1522 1579 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1523 1580 io.ntcreatex.in.alloc_size = 0; … … 1537 1594 requests[i] = smb_raw_open_send(clients[i]->tree, &ios[i]); 1538 1595 if (requests[i] == NULL) { 1539 DEBUG(0, ("could not send %d'th request\n", i)); 1596 torture_result(tctx, TORTURE_FAIL, 1597 "(%s): could not send %d'th request\n", 1598 __location__, i); 1540 1599 return false; 1541 1600 } 1542 1601 } 1543 1602 1544 DEBUG(10, ("waiting for replies\n"));1603 torture_comment(tctx, "waiting for replies\n"); 1545 1604 while (1) { 1546 1605 bool unreplied = false; … … 1556 1615 &ios[i]); 1557 1616 1558 DEBUG(0, ("File %d returned status %s\n", i,1559 nt_errstr(status)) );1617 torture_comment(tctx, "File %d returned status %s\n", i, 1618 nt_errstr(status)); 1560 1619 1561 1620 if (NT_STATUS_IS_OK(status)) { … … 1575 1634 1576 1635 if (event_loop_once(tctx->ev) != 0) { 1577 DEBUG(0, ("event_loop_once failed\n")); 1636 torture_result(tctx, TORTURE_FAIL, 1637 "(%s): event_loop_once failed\n", __location__); 1578 1638 return false; 1579 1639 } … … 1594 1654 test opening for delete on a read-only attribute file. 1595 1655 */ 1596 static bool test_open_for_delete(struct smbcli_state *cli, struct torture_context *tctx)1656 static bool test_open_for_delete(struct torture_context *tctx, struct smbcli_state *cli) 1597 1657 { 1598 1658 union smb_open io; … … 1603 1663 bool ret = true; 1604 1664 1605 printf("Checking RAW_NTCREATEX for delete on a readonly file.\n"); 1665 if (!torture_setup_dir(cli, BASEDIR)) { 1666 return false; 1667 } 1606 1668 1607 1669 /* reasonable default parameters */ 1608 1670 io.generic.level = RAW_OPEN_NTCREATEX; 1609 1671 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; 1610 io.ntcreatex.in.root_fid = 0;1672 io.ntcreatex.in.root_fid.fnum = 0; 1611 1673 io.ntcreatex.in.alloc_size = 0; 1612 1674 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; … … 1643 1705 done: 1644 1706 smbcli_close(cli->tree, fnum); 1645 smbcli_ unlink(cli->tree, fname);1707 smbcli_deltree(cli->tree, BASEDIR); 1646 1708 1647 1709 return ret; 1648 1710 } 1649 1711 1650 1651 /* basic testing of all RAW_OPEN_* calls 1712 /* 1713 test chained RAW_OPEN_NTCREATEX_READX 1714 Send chained NTCREATEX_READX on a file that doesn't exist, then create 1715 the file and try again. 1652 1716 */ 1653 bool torture_raw_open(struct torture_context *torture, struct smbcli_state *cli)1717 static bool test_chained_ntcreatex_readx(struct torture_context *tctx, struct smbcli_state *cli) 1654 1718 { 1719 TALLOC_CTX *mem_ctx = talloc_new(tctx); 1720 union smb_open io; 1721 const char *fname = BASEDIR "\\torture_chained.txt"; 1722 NTSTATUS status; 1723 int fnum = -1; 1655 1724 bool ret = true; 1725 const char *buf = "test"; 1726 char buf2[4]; 1656 1727 1657 1728 if (!torture_setup_dir(cli, BASEDIR)) { … … 1659 1730 } 1660 1731 1661 ret &= test_ntcreatex_brlocked(cli, torture); 1662 ret &= test_open(cli, torture); 1663 ret &= test_raw_open_multi(torture); 1664 ret &= test_openx(cli, torture); 1665 ret &= test_ntcreatex(cli, torture); 1666 ret &= test_nttrans_create(cli, torture); 1667 ret &= test_t2open(cli, torture); 1668 ret &= test_mknew(cli, torture); 1669 ret &= test_create(cli, torture); 1670 ret &= test_ctemp(cli, torture); 1671 ret &= test_chained(cli, torture); 1672 ret &= test_no_leading_slash(cli, torture); 1673 ret &= test_openx_over_dir(cli, torture); 1674 ret &= test_open_for_delete(cli, torture); 1675 1676 smb_raw_exit(cli->session); 1732 torture_comment(tctx, "Checking RAW_NTCREATEX_READX chained on " 1733 "non-existant file \n"); 1734 1735 /* ntcreatex parameters */ 1736 io.generic.level = RAW_OPEN_NTCREATEX_READX; 1737 io.ntcreatexreadx.in.flags = 0; 1738 io.ntcreatexreadx.in.root_fid.fnum = 0; 1739 io.ntcreatexreadx.in.access_mask = SEC_FILE_READ_DATA; 1740 io.ntcreatexreadx.in.alloc_size = 0; 1741 io.ntcreatexreadx.in.file_attr = FILE_ATTRIBUTE_NORMAL; 1742 io.ntcreatexreadx.in.share_access = NTCREATEX_SHARE_ACCESS_READ | 1743 NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_DELETE; 1744 io.ntcreatexreadx.in.open_disposition = NTCREATEX_DISP_OPEN; 1745 io.ntcreatexreadx.in.create_options = 0; 1746 io.ntcreatexreadx.in.impersonation = NTCREATEX_IMPERSONATION_IMPERSONATION; 1747 io.ntcreatexreadx.in.security_flags = 0; 1748 io.ntcreatexreadx.in.fname = fname; 1749 1750 /* readx parameters */ 1751 io.ntcreatexreadx.in.offset = 0; 1752 io.ntcreatexreadx.in.mincnt = sizeof(buf); 1753 io.ntcreatexreadx.in.maxcnt = sizeof(buf); 1754 io.ntcreatexreadx.in.remaining = 0; 1755 io.ntcreatexreadx.out.data = (uint8_t *)buf2; 1756 1757 /* try to open the non-existant file */ 1758 status = smb_raw_open(cli->tree, mem_ctx, &io); 1759 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); 1760 fnum = io.ntcreatexreadx.out.file.fnum; 1761 1762 smbcli_close(cli->tree, fnum); 1763 smbcli_unlink(cli->tree, fname); 1764 1765 torture_comment(tctx, "Checking RAW_NTCREATEX_READX chained on " 1766 "existing file \n"); 1767 1768 fnum = create_complex_file(cli, mem_ctx, fname); 1769 smbcli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf)); 1770 smbcli_close(cli->tree, fnum); 1771 1772 status = smb_raw_open(cli->tree, mem_ctx, &io); 1773 CHECK_STATUS(status, NT_STATUS_OK); 1774 fnum = io.ntcreatexreadx.out.file.fnum; 1775 1776 if (memcmp(buf, buf2, sizeof(buf)) != 0) { 1777 torture_result(tctx, TORTURE_FAIL, 1778 "(%s): wrong data in reply buffer\n", __location__); 1779 ret = false; 1780 } 1781 1782 done: 1783 smbcli_close(cli->tree, fnum); 1677 1784 smbcli_deltree(cli->tree, BASEDIR); 1785 talloc_free(mem_ctx); 1678 1786 1679 1787 return ret; 1680 1788 } 1789 1790 static bool test_ntcreatex_opendisp_dir(struct torture_context *tctx, 1791 struct smbcli_state *cli) 1792 { 1793 const char *dname = BASEDIR "\\torture_ntcreatex_opendisp_dir"; 1794 NTSTATUS status; 1795 bool ret = true; 1796 int i; 1797 struct { 1798 uint32_t open_disp; 1799 bool dir_exists; 1800 NTSTATUS correct_status; 1801 } open_funcs_dir[] = { 1802 { NTCREATEX_DISP_SUPERSEDE, true, NT_STATUS_INVALID_PARAMETER }, 1803 { NTCREATEX_DISP_SUPERSEDE, false, NT_STATUS_INVALID_PARAMETER }, 1804 { NTCREATEX_DISP_OPEN, true, NT_STATUS_OK }, 1805 { NTCREATEX_DISP_OPEN, false, NT_STATUS_OBJECT_NAME_NOT_FOUND }, 1806 { NTCREATEX_DISP_CREATE, true, NT_STATUS_OBJECT_NAME_COLLISION }, 1807 { NTCREATEX_DISP_CREATE, false, NT_STATUS_OK }, 1808 { NTCREATEX_DISP_OPEN_IF, true, NT_STATUS_OK }, 1809 { NTCREATEX_DISP_OPEN_IF, false, NT_STATUS_OK }, 1810 { NTCREATEX_DISP_OVERWRITE, true, NT_STATUS_INVALID_PARAMETER }, 1811 { NTCREATEX_DISP_OVERWRITE, false, NT_STATUS_INVALID_PARAMETER }, 1812 { NTCREATEX_DISP_OVERWRITE_IF, true, NT_STATUS_INVALID_PARAMETER }, 1813 { NTCREATEX_DISP_OVERWRITE_IF, false, NT_STATUS_INVALID_PARAMETER }, 1814 { 6, true, NT_STATUS_INVALID_PARAMETER }, 1815 { 6, false, NT_STATUS_INVALID_PARAMETER }, 1816 }; 1817 union smb_open io; 1818 1819 ZERO_STRUCT(io); 1820 io.generic.level = RAW_OPEN_NTCREATEX; 1821 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; 1822 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; 1823 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY; 1824 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; 1825 io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; 1826 io.ntcreatex.in.fname = dname; 1827 1828 if (!torture_setup_dir(cli, BASEDIR)) { 1829 return false; 1830 } 1831 1832 smbcli_rmdir(cli->tree, dname); 1833 smbcli_unlink(cli->tree, dname); 1834 1835 /* test the open disposition for directories */ 1836 torture_comment(tctx, "Testing open dispositions for directories...\n"); 1837 1838 for (i=0; i<ARRAY_SIZE(open_funcs_dir); i++) { 1839 if (open_funcs_dir[i].dir_exists) { 1840 status = smbcli_mkdir(cli->tree, dname); 1841 if (!NT_STATUS_IS_OK(status)) { 1842 torture_result(tctx, TORTURE_FAIL, 1843 "(%s): Failed to make directory " 1844 "%s - %s\n", __location__, dname, 1845 smbcli_errstr(cli->tree)); 1846 ret = false; 1847 goto done; 1848 } 1849 } 1850 1851 io.ntcreatex.in.open_disposition = open_funcs_dir[i].open_disp; 1852 status = smb_raw_open(cli->tree, tctx, &io); 1853 if (!NT_STATUS_EQUAL(status, open_funcs_dir[i].correct_status)) { 1854 torture_result(tctx, TORTURE_FAIL, 1855 "(%s) incorrect status %s should be %s " 1856 "(i=%d dir_exists=%d open_disp=%d)\n", 1857 __location__, nt_errstr(status), 1858 nt_errstr(open_funcs_dir[i].correct_status), 1859 i, (int)open_funcs_dir[i].dir_exists, 1860 (int)open_funcs_dir[i].open_disp); 1861 ret = false; 1862 } 1863 if (NT_STATUS_IS_OK(status) || open_funcs_dir[i].dir_exists) { 1864 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 1865 smbcli_rmdir(cli->tree, dname); 1866 } 1867 } 1868 1869 done: 1870 smbcli_deltree(cli->tree, BASEDIR); 1871 1872 return ret; 1873 } 1874 1875 /** 1876 * Test what happens when trying to open a file with directory parameters and 1877 * vice-versa. Also test that NTCREATEX_OPTIONS_DIRECTORY is treated as 1878 * mandatory and FILE_ATTRIBUTE_DIRECTORY is advisory for directory 1879 * creation/opening. 1880 */ 1881 static bool test_ntcreatexdir(struct torture_context *tctx, 1882 struct smbcli_state *cli) 1883 { 1884 union smb_open io; 1885 const char *fname = BASEDIR "\\torture_ntcreatex.txt"; 1886 const char *dname = BASEDIR "\\torture_ntcreatex_dir"; 1887 NTSTATUS status; 1888 int i; 1889 1890 struct { 1891 uint32_t open_disp; 1892 uint32_t file_attr; 1893 uint32_t create_options; 1894 NTSTATUS correct_status; 1895 } open_funcs[] = { 1896 { NTCREATEX_DISP_SUPERSEDE, 0, NTCREATEX_OPTIONS_DIRECTORY, 1897 NT_STATUS_INVALID_PARAMETER }, 1898 { NTCREATEX_DISP_OPEN, 0, NTCREATEX_OPTIONS_DIRECTORY, 1899 NT_STATUS_OBJECT_NAME_NOT_FOUND }, 1900 { NTCREATEX_DISP_CREATE, 0, NTCREATEX_OPTIONS_DIRECTORY, 1901 NT_STATUS_OK }, 1902 { NTCREATEX_DISP_OPEN_IF, 0, NTCREATEX_OPTIONS_DIRECTORY, 1903 NT_STATUS_OK }, 1904 { NTCREATEX_DISP_OVERWRITE, 0, NTCREATEX_OPTIONS_DIRECTORY, 1905 NT_STATUS_INVALID_PARAMETER }, 1906 { NTCREATEX_DISP_OVERWRITE_IF, 0, NTCREATEX_OPTIONS_DIRECTORY, 1907 NT_STATUS_INVALID_PARAMETER }, 1908 { NTCREATEX_DISP_SUPERSEDE, FILE_ATTRIBUTE_DIRECTORY, 0, 1909 NT_STATUS_OK }, 1910 { NTCREATEX_DISP_OPEN, FILE_ATTRIBUTE_DIRECTORY, 0, 1911 NT_STATUS_OBJECT_NAME_NOT_FOUND }, 1912 { NTCREATEX_DISP_CREATE, FILE_ATTRIBUTE_DIRECTORY, 0, 1913 NT_STATUS_OK }, 1914 { NTCREATEX_DISP_OPEN_IF, FILE_ATTRIBUTE_DIRECTORY, 0, 1915 NT_STATUS_OK }, 1916 { NTCREATEX_DISP_OVERWRITE, FILE_ATTRIBUTE_DIRECTORY, 0, 1917 NT_STATUS_OBJECT_NAME_NOT_FOUND }, 1918 { NTCREATEX_DISP_OVERWRITE_IF, FILE_ATTRIBUTE_DIRECTORY, 0, 1919 NT_STATUS_OK }, 1920 1921 }; 1922 1923 if (!torture_setup_dir(cli, BASEDIR)) { 1924 return false; 1925 } 1926 1927 /* setup some base params. */ 1928 io.generic.level = RAW_OPEN_NTCREATEX; 1929 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; 1930 io.ntcreatex.in.root_fid.fnum = 0; 1931 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1932 io.ntcreatex.in.alloc_size = 0; 1933 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; 1934 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 1935 io.ntcreatex.in.security_flags = 0; 1936 io.ntcreatex.in.fname = fname; 1937 1938 /* 1939 * Test the validity checking for create dispositions, which is done 1940 * against the requested parameters rather than what's actually on 1941 * disk. 1942 */ 1943 for (i=0; i<ARRAY_SIZE(open_funcs); i++) { 1944 io.ntcreatex.in.open_disposition = open_funcs[i].open_disp; 1945 io.ntcreatex.in.file_attr = open_funcs[i].file_attr; 1946 io.ntcreatex.in.create_options = open_funcs[i].create_options; 1947 status = smb_raw_open(cli->tree, tctx, &io); 1948 if (!NT_STATUS_EQUAL(status, open_funcs[i].correct_status)) { 1949 torture_result(tctx, TORTURE_FAIL, 1950 "(%s) incorrect status %s should be %s " 1951 "(i=%d open_disp=%d)\n", 1952 __location__, nt_errstr(status), 1953 nt_errstr(open_funcs[i].correct_status), 1954 i, (int)open_funcs[i].open_disp); 1955 return false; 1956 } 1957 /* Close and delete the file. */ 1958 if (NT_STATUS_IS_OK(status)) { 1959 if (open_funcs[i].create_options != 0) { 1960 /* out attrib should be a directory. */ 1961 torture_assert_int_equal(tctx, 1962 io.ntcreatex.out.attrib, 1963 FILE_ATTRIBUTE_DIRECTORY, "should have " 1964 "created a directory"); 1965 1966 smbcli_close(cli->tree, 1967 io.ntcreatex.out.file.fnum); 1968 1969 /* Make sure unlink fails. */ 1970 status = smbcli_unlink(cli->tree, fname); 1971 torture_assert_ntstatus_equal(tctx, status, 1972 NT_STATUS_FILE_IS_A_DIRECTORY, 1973 "unlink should fail for a directory"); 1974 1975 status = smbcli_rmdir(cli->tree, fname); 1976 torture_assert_ntstatus_ok(tctx, status, 1977 "rmdir failed"); 1978 } else { 1979 torture_assert_int_equal(tctx, 1980 io.ntcreatex.out.attrib, 1981 FILE_ATTRIBUTE_ARCHIVE, "should not have " 1982 "created a directory"); 1983 1984 smbcli_close(cli->tree, 1985 io.ntcreatex.out.file.fnum); 1986 1987 /* Make sure rmdir fails. */ 1988 status = smbcli_rmdir(cli->tree, fname); 1989 torture_assert_ntstatus_equal(tctx, status, 1990 NT_STATUS_NOT_A_DIRECTORY, 1991 "rmdir should fail for a file"); 1992 1993 status = smbcli_unlink(cli->tree, fname); 1994 torture_assert_ntstatus_ok(tctx, status, 1995 "unlink failed"); 1996 } 1997 } 1998 } 1999 2000 /* Create a file. */ 2001 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 2002 io.ntcreatex.in.create_options = 0; 2003 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; 2004 status = smb_raw_open(cli->tree, tctx, &io); 2005 torture_assert_ntstatus_ok(tctx, status, "Failed to create file."); 2006 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 2007 2008 /* Try and open the file with file_attr_dir and check the error. */ 2009 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY; 2010 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; 2011 2012 status = smb_raw_open(cli->tree, tctx, &io); 2013 torture_assert_ntstatus_ok(tctx, status, "FILE_ATTRIBUTE_DIRECTORY " 2014 "doesn't produce a hard failure."); 2015 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 2016 2017 /* Try and open file with createx_option_dir and check the error. */ 2018 io.ntcreatex.in.file_attr = 0; 2019 io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; 2020 2021 status = smb_raw_open(cli->tree, tctx, &io); 2022 torture_assert_ntstatus_equal(tctx, status, NT_STATUS_NOT_A_DIRECTORY, 2023 "NTCREATEX_OPTIONS_DIRECTORY will a file from being opened."); 2024 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 2025 2026 /* Delete the file and move onto directory testing. */ 2027 smbcli_unlink(cli->tree, fname); 2028 2029 /* Now try some tests on a directory. */ 2030 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; 2031 io.ntcreatex.in.file_attr = 0; 2032 io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; 2033 io.ntcreatex.in.fname = dname; 2034 2035 status = smb_raw_open(cli->tree, tctx, &io); 2036 torture_assert_ntstatus_ok(tctx, status, "Failed to create dir."); 2037 2038 /* out attrib should be a directory. */ 2039 torture_assert_int_equal(tctx, io.ntcreatex.out.attrib, 2040 FILE_ATTRIBUTE_DIRECTORY, "should have created a directory"); 2041 2042 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 2043 2044 /* Try and open it with normal attr and check the error. */ 2045 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 2046 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; 2047 2048 status = smb_raw_open(cli->tree, tctx, &io); 2049 torture_assert_ntstatus_ok(tctx, status, "FILE_ATTRIBUTE_NORMAL " 2050 "doesn't produce a hard failure."); 2051 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 2052 2053 /* Try and open it with file create_options and check the error. */ 2054 io.ntcreatex.in.file_attr = 0; 2055 io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_NON_DIRECTORY_FILE; 2056 2057 status = smb_raw_open(cli->tree, tctx, &io); 2058 torture_assert_ntstatus_equal(tctx, status, 2059 NT_STATUS_FILE_IS_A_DIRECTORY, 2060 "NTCREATEX_OPTIONS_NON_DIRECTORY_FILE should be returned "); 2061 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 2062 2063 smbcli_deltree(cli->tree, BASEDIR); 2064 2065 return true; 2066 } 2067 2068 /* basic testing of all RAW_OPEN_* calls 2069 */ 2070 struct torture_suite *torture_raw_open(TALLOC_CTX *mem_ctx) 2071 { 2072 struct torture_suite *suite = torture_suite_create(mem_ctx, "open"); 2073 2074 torture_suite_add_1smb_test(suite, "brlocked", test_ntcreatex_brlocked); 2075 torture_suite_add_1smb_test(suite, "open", test_open); 2076 torture_suite_add_1smb_test(suite, "open-multi", test_raw_open_multi); 2077 torture_suite_add_1smb_test(suite, "openx", test_openx); 2078 torture_suite_add_1smb_test(suite, "ntcreatex", test_ntcreatex); 2079 torture_suite_add_1smb_test(suite, "nttrans-create", test_nttrans_create); 2080 torture_suite_add_1smb_test(suite, "t2open", test_t2open); 2081 torture_suite_add_1smb_test(suite, "mknew", test_mknew); 2082 torture_suite_add_1smb_test(suite, "create", test_create); 2083 torture_suite_add_1smb_test(suite, "ctemp", test_ctemp); 2084 torture_suite_add_1smb_test(suite, "chained-openx", test_chained); 2085 torture_suite_add_1smb_test(suite, "chained-ntcreatex", test_chained_ntcreatex_readx); 2086 torture_suite_add_1smb_test(suite, "no-leading-slash", test_no_leading_slash); 2087 torture_suite_add_1smb_test(suite, "openx-over-dir", test_openx_over_dir); 2088 torture_suite_add_1smb_test(suite, "open-for-delete", test_open_for_delete); 2089 torture_suite_add_1smb_test(suite, "opendisp-dir", test_ntcreatex_opendisp_dir); 2090 torture_suite_add_1smb_test(suite, "ntcreatedir", test_ntcreatexdir); 2091 2092 return suite; 2093 } -
trunk/server/source4/torture/raw/openbench.c
r414 r745 131 131 io->in.dest_host = state->dest_host; 132 132 io->in.dest_ports = state->dest_ports; 133 io->in.socket_options = lp _socket_options(state->tctx->lp_ctx);133 io->in.socket_options = lpcfg_socket_options(state->tctx->lp_ctx); 134 134 io->in.called_name = state->called_name; 135 135 io->in.service = share; … … 137 137 io->in.credentials = cmdline_credentials; 138 138 io->in.fallback_to_anonymous = false; 139 io->in.workgroup = lp _workgroup(state->tctx->lp_ctx);140 io->in.gensec_settings = lp _gensec_settings(state->mem_ctx, state->tctx->lp_ctx);141 lp _smbcli_options(state->tctx->lp_ctx, &io->in.options);142 lp _smbcli_session_options(state->tctx->lp_ctx, &io->in.session_options);139 io->in.workgroup = lpcfg_workgroup(state->tctx->lp_ctx); 140 io->in.gensec_settings = lpcfg_gensec_settings(state->mem_ctx, state->tctx->lp_ctx); 141 lpcfg_smbcli_options(state->tctx->lp_ctx, &io->in.options); 142 lpcfg_smbcli_session_options(state->tctx->lp_ctx, &io->in.session_options); 143 143 144 144 /* kill off the remnants of the old connection */ … … 149 149 150 150 ctx = smb_composite_connect_send(io, state->mem_ctx, 151 lp _resolve_context(state->tctx->lp_ctx),151 lpcfg_resolve_context(state->tctx->lp_ctx), 152 152 state->ev); 153 153 if (ctx == NULL) { … … 174 174 state->open_parms.ntcreatex.level = RAW_OPEN_NTCREATEX; 175 175 state->open_parms.ntcreatex.in.flags = 0; 176 state->open_parms.ntcreatex.in.root_fid = 0;176 state->open_parms.ntcreatex.in.root_fid.fnum = 0; 177 177 state->open_parms.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 178 178 state->open_parms.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; … … 223 223 224 224 if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) || 225 NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT)) { 225 NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT) || 226 NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_RESET)) { 226 227 talloc_free(state->tree); 227 228 talloc_free(state->cli); … … 282 283 283 284 if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) || 284 NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT)) { 285 NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT) || 286 NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_RESET)) { 285 287 talloc_free(state->tree); 286 288 talloc_free(state->cli); … … 316 318 NTSTATUS status = smbcli_request_simple_recv(req); 317 319 if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) || 318 NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT)) { 320 NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT) || 321 NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_RESET)) { 319 322 talloc_free(state->tree); 320 323 state->tree = NULL; -
trunk/server/source4/torture/raw/oplock.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "torture/torture.h"22 #include "torture/smbtorture.h"23 #include "librpc/gen_ndr/security.h"24 #include "librpc/gen_ndr/ndr_security.h"25 21 #include "libcli/raw/libcliraw.h" 26 22 #include "libcli/raw/raw_proto.h" 27 #include "libcli/security/security.h"28 23 #include "libcli/libcli.h" 29 24 #include "torture/util.h" … … 40 35 }} while (0) 41 36 42 #define CHECK_RANGE(v, min, max) do { 43 if ((v) < (min) || (v) > (max)) { 44 torture_ result(tctx, TORTURE_FAIL, "(%s): wrong value for %s got %d - should be between %d and %d\n",\45 __location__, #v, (int)v, (int)min, (int)max);\46 ret = false;\37 #define CHECK_RANGE(v, min, max) do { \ 38 if ((v) < (min) || (v) > (max)) { \ 39 torture_warning(tctx, "(%s): wrong value for %s got " \ 40 "%d - should be between %d and %d\n", \ 41 __location__, #v, (int)v, (int)min, (int)max); \ 47 42 }} while (0) 48 43 … … 182 177 struct smbcli_session_options session_options; 183 178 184 lp _smbcli_options(tctx->lp_ctx, &options);185 lp _smbcli_session_options(tctx->lp_ctx, &session_options);179 lpcfg_smbcli_options(tctx->lp_ctx, &options); 180 lpcfg_smbcli_session_options(tctx->lp_ctx, &session_options); 186 181 187 182 options.use_level2_oplocks = false; … … 189 184 status = smbcli_full_connection(tctx, c, 190 185 torture_setting_string(tctx, "host", NULL), 191 lp _smb_ports(tctx->lp_ctx),186 lpcfg_smb_ports(tctx->lp_ctx), 192 187 torture_setting_string(tctx, "share", NULL), 193 NULL, lp _socket_options(tctx->lp_ctx), cmdline_credentials,194 lp _resolve_context(tctx->lp_ctx),188 NULL, lpcfg_socket_options(tctx->lp_ctx), cmdline_credentials, 189 lpcfg_resolve_context(tctx->lp_ctx), 195 190 tctx->ev, &options, &session_options, 196 lp_iconv_convenience(tctx->lp_ctx), 197 lp_gensec_settings(tctx, tctx->lp_ctx)); 191 lpcfg_gensec_settings(tctx, tctx->lp_ctx)); 198 192 if (!NT_STATUS_IS_OK(status)) { 199 193 torture_comment(tctx, "Failed to open connection - %s\n", … … 259 253 } 260 254 255 static uint8_t get_break_level1_to_none_count(struct torture_context *tctx) 256 { 257 return torture_setting_bool(tctx, "2_step_break_to_none", false) ? 258 2 : 1; 259 } 260 261 261 static bool test_raw_oplock_exclusive1(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 262 262 { … … 281 281 */ 282 282 io.generic.level = RAW_OPEN_NTCREATEX; 283 io.ntcreatex.in.root_fid = 0;283 io.ntcreatex.in.root_fid.fnum = 0; 284 284 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 285 285 io.ntcreatex.in.alloc_size = 0; … … 348 348 */ 349 349 io.generic.level = RAW_OPEN_NTCREATEX; 350 io.ntcreatex.in.root_fid = 0;350 io.ntcreatex.in.root_fid.fnum = 0; 351 351 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 352 352 io.ntcreatex.in.alloc_size = 0; … … 446 446 */ 447 447 io.generic.level = RAW_OPEN_NTCREATEX; 448 io.ntcreatex.in.root_fid = 0; 448 io.ntcreatex.in.root_fid.fnum = 0; 449 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 450 io.ntcreatex.in.alloc_size = 0; 451 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 452 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; 453 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; 454 io.ntcreatex.in.create_options = 0; 455 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 456 io.ntcreatex.in.security_flags = 0; 457 io.ntcreatex.in.fname = fname; 458 459 torture_comment(tctx, "EXCLUSIVE3: open a file with an exclusive oplock (share mode: none)\n"); 460 461 ZERO_STRUCT(break_info); 462 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; 463 464 status = smb_raw_open(cli1->tree, tctx, &io); 465 CHECK_STATUS(tctx, status, NT_STATUS_OK); 466 fnum = io.ntcreatex.out.file.fnum; 467 CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN); 468 469 torture_comment(tctx, "setpathinfo EOF should trigger a break to none\n"); 470 ZERO_STRUCT(sfi); 471 sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; 472 sfi.generic.in.file.path = fname; 473 sfi.end_of_file_info.in.size = 100; 474 475 status = smb_raw_setpathinfo(cli2->tree, &sfi); 476 477 CHECK_STATUS(tctx, status, NT_STATUS_OK); 478 torture_wait_for_oplock_break(tctx); 479 CHECK_VAL(break_info.count, get_break_level1_to_none_count(tctx)); 480 CHECK_VAL(break_info.failures, 0); 481 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_NONE); 482 483 smbcli_close(cli1->tree, fnum); 484 485 done: 486 smb_raw_exit(cli1->session); 487 smb_raw_exit(cli2->session); 488 smbcli_deltree(cli1->tree, BASEDIR); 489 return ret; 490 } 491 492 static bool test_raw_oplock_exclusive4(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 493 { 494 const char *fname = BASEDIR "\\test_exclusive4.dat"; 495 NTSTATUS status; 496 bool ret = true; 497 union smb_open io; 498 uint16_t fnum=0, fnum2=0; 499 500 if (!torture_setup_dir(cli1, BASEDIR)) { 501 return false; 502 } 503 504 /* cleanup */ 505 smbcli_unlink(cli1->tree, fname); 506 507 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 508 509 /* 510 base ntcreatex parms 511 */ 512 io.generic.level = RAW_OPEN_NTCREATEX; 513 io.ntcreatex.in.root_fid.fnum = 0; 449 514 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 450 515 io.ntcreatex.in.alloc_size = 0; … … 457 522 io.ntcreatex.in.fname = fname; 458 523 459 torture_comment(tctx, "EXCLUSIVE3: open a file with an exclusive oplock (share mode: none)\n"); 460 461 ZERO_STRUCT(break_info); 524 torture_comment(tctx, "EXCLUSIVE4: open with exclusive oplock\n"); 525 ZERO_STRUCT(break_info); 526 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 527 462 528 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; 463 464 529 status = smb_raw_open(cli1->tree, tctx, &io); 465 530 CHECK_STATUS(tctx, status, NT_STATUS_OK); … … 467 532 CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN); 468 533 469 torture_comment(tctx, "setpathinfo EOF should trigger a break to none\n"); 470 ZERO_STRUCT(sfi); 471 sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; 472 sfi.generic.in.file.path = fname; 473 sfi.end_of_file_info.in.size = 100; 474 475 status = smb_raw_setpathinfo(cli2->tree, &sfi); 476 477 CHECK_STATUS(tctx, status, NT_STATUS_OK); 478 torture_wait_for_oplock_break(tctx); 479 CHECK_VAL(break_info.count, 1); 480 CHECK_VAL(break_info.failures, 0); 481 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_NONE); 534 ZERO_STRUCT(break_info); 535 torture_comment(tctx, "second open with attributes only shouldn't cause oplock break\n"); 536 537 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; 538 io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE; 539 status = smb_raw_open(cli2->tree, tctx, &io); 540 CHECK_STATUS(tctx, status, NT_STATUS_OK); 541 fnum2 = io.ntcreatex.out.file.fnum; 542 CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN); 543 torture_wait_for_oplock_break(tctx); 544 CHECK_VAL(break_info.count, 0); 545 CHECK_VAL(break_info.failures, 0); 482 546 483 547 smbcli_close(cli1->tree, fnum); 548 smbcli_close(cli2->tree, fnum2); 484 549 485 550 done: … … 490 555 } 491 556 492 static bool test_raw_oplock_exclusive 4(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)493 { 494 const char *fname = BASEDIR "\\test_exclusive 4.dat";557 static bool test_raw_oplock_exclusive5(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 558 { 559 const char *fname = BASEDIR "\\test_exclusive5.dat"; 495 560 NTSTATUS status; 496 561 bool ret = true; … … 506 571 507 572 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 573 smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli1->tree); 508 574 509 575 /* … … 511 577 */ 512 578 io.generic.level = RAW_OPEN_NTCREATEX; 513 io.ntcreatex.in.root_fid = 0;579 io.ntcreatex.in.root_fid.fnum = 0; 514 580 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 515 581 io.ntcreatex.in.alloc_size = 0; … … 522 588 io.ntcreatex.in.fname = fname; 523 589 524 torture_comment(tctx, "EXCLUSIVE 4: open with exclusive oplock\n");590 torture_comment(tctx, "EXCLUSIVE5: open with exclusive oplock\n"); 525 591 ZERO_STRUCT(break_info); 526 592 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 527 593 594 528 595 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; 596 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ| 597 NTCREATEX_SHARE_ACCESS_WRITE| 598 NTCREATEX_SHARE_ACCESS_DELETE; 529 599 status = smb_raw_open(cli1->tree, tctx, &io); 530 600 CHECK_STATUS(tctx, status, NT_STATUS_OK); … … 533 603 534 604 ZERO_STRUCT(break_info); 535 torture_comment(tctx, "second open with attributes only shouldn't cause oplock break\n"); 605 606 torture_comment(tctx, "second open with attributes only and NTCREATEX_DISP_OVERWRITE_IF dispostion causes oplock break\n"); 536 607 537 608 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; 538 609 io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE; 610 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; 539 611 status = smb_raw_open(cli2->tree, tctx, &io); 540 612 CHECK_STATUS(tctx, status, NT_STATUS_OK); 541 613 fnum2 = io.ntcreatex.out.file.fnum; 542 CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN);543 torture_wait_for_oplock_break(tctx); 544 CHECK_VAL(break_info.count, 0);614 CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN); 615 torture_wait_for_oplock_break(tctx); 616 CHECK_VAL(break_info.count, get_break_level1_to_none_count(tctx)); 545 617 CHECK_VAL(break_info.failures, 0); 546 618 … … 555 627 } 556 628 557 static bool test_raw_oplock_exclusive5(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 558 { 559 const char *fname = BASEDIR "\\test_exclusive5.dat"; 629 static bool test_raw_oplock_exclusive6(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 630 { 631 const char *fname1 = BASEDIR "\\test_exclusive6_1.dat"; 632 const char *fname2 = BASEDIR "\\test_exclusive6_2.dat"; 560 633 NTSTATUS status; 561 634 bool ret = true; 562 635 union smb_open io; 563 uint16_t fnum=0, fnum2=0; 636 union smb_rename rn; 637 uint16_t fnum=0; 638 639 if (!torture_setup_dir(cli1, BASEDIR)) { 640 return false; 641 } 642 643 /* cleanup */ 644 smbcli_unlink(cli1->tree, fname1); 645 smbcli_unlink(cli1->tree, fname2); 646 647 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 648 649 /* 650 base ntcreatex parms 651 */ 652 io.generic.level = RAW_OPEN_NTCREATEX; 653 io.ntcreatex.in.root_fid.fnum = 0; 654 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 655 io.ntcreatex.in.alloc_size = 0; 656 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 657 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; 658 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; 659 io.ntcreatex.in.create_options = 0; 660 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 661 io.ntcreatex.in.security_flags = 0; 662 io.ntcreatex.in.fname = fname1; 663 664 torture_comment(tctx, "EXCLUSIVE6: open a file with an exclusive " 665 "oplock (share mode: none)\n"); 666 ZERO_STRUCT(break_info); 667 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; 668 669 status = smb_raw_open(cli1->tree, tctx, &io); 670 CHECK_STATUS(tctx, status, NT_STATUS_OK); 671 fnum = io.ntcreatex.out.file.fnum; 672 CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN); 673 674 torture_comment(tctx, "rename should not generate a break but get a " 675 "sharing violation\n"); 676 ZERO_STRUCT(rn); 677 rn.generic.level = RAW_RENAME_RENAME; 678 rn.rename.in.pattern1 = fname1; 679 rn.rename.in.pattern2 = fname2; 680 rn.rename.in.attrib = 0; 681 682 torture_comment(tctx, "trying rename while first file open\n"); 683 status = smb_raw_rename(cli2->tree, &rn); 684 685 CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION); 686 torture_wait_for_oplock_break(tctx); 687 CHECK_VAL(break_info.count, 0); 688 CHECK_VAL(break_info.failures, 0); 689 690 smbcli_close(cli1->tree, fnum); 691 692 done: 693 smb_raw_exit(cli1->session); 694 smb_raw_exit(cli2->session); 695 smbcli_deltree(cli1->tree, BASEDIR); 696 return ret; 697 } 698 699 /** 700 * Exclusive version of batch19 701 */ 702 static bool test_raw_oplock_exclusive7(struct torture_context *tctx, 703 struct smbcli_state *cli1, struct smbcli_state *cli2) 704 { 705 const char *fname1 = BASEDIR "\\test_exclusiv6_1.dat"; 706 const char *fname2 = BASEDIR "\\test_exclusiv6_2.dat"; 707 const char *fname3 = BASEDIR "\\test_exclusiv6_3.dat"; 708 NTSTATUS status; 709 bool ret = true; 710 union smb_open io; 711 union smb_fileinfo qfi; 712 union smb_setfileinfo sfi; 713 uint16_t fnum=0; 714 uint16_t fnum2 = 0; 715 716 if (!torture_setup_dir(cli1, BASEDIR)) { 717 return false; 718 } 719 720 /* cleanup */ 721 smbcli_unlink(cli1->tree, fname1); 722 smbcli_unlink(cli1->tree, fname2); 723 smbcli_unlink(cli1->tree, fname3); 724 725 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, 726 cli1->tree); 727 728 /* 729 base ntcreatex parms 730 */ 731 io.generic.level = RAW_OPEN_NTCREATEX; 732 io.ntcreatex.in.root_fid.fnum = 0; 733 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 734 io.ntcreatex.in.alloc_size = 0; 735 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 736 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | 737 NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_DELETE; 738 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; 739 io.ntcreatex.in.create_options = 0; 740 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 741 io.ntcreatex.in.security_flags = 0; 742 io.ntcreatex.in.fname = fname1; 743 744 torture_comment(tctx, "open a file with an exclusive oplock (share " 745 "mode: none)\n"); 746 ZERO_STRUCT(break_info); 747 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | 748 NTCREATEX_FLAGS_REQUEST_OPLOCK; 749 status = smb_raw_open(cli1->tree, tctx, &io); 750 CHECK_STATUS(tctx, status, NT_STATUS_OK); 751 fnum = io.ntcreatex.out.file.fnum; 752 CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN); 753 754 torture_comment(tctx, "setpathinfo rename info should trigger a break " 755 "to none\n"); 756 ZERO_STRUCT(sfi); 757 sfi.generic.level = RAW_SFILEINFO_RENAME_INFORMATION; 758 sfi.generic.in.file.path = fname1; 759 sfi.rename_information.in.overwrite = 0; 760 sfi.rename_information.in.root_fid = 0; 761 sfi.rename_information.in.new_name = fname2+strlen(BASEDIR)+1; 762 763 status = smb_raw_setpathinfo(cli2->tree, &sfi); 764 CHECK_STATUS(tctx, status, NT_STATUS_OK); 765 766 torture_wait_for_oplock_break(tctx); 767 CHECK_VAL(break_info.failures, 0); 768 769 if (TARGET_IS_WINXP(tctx)) { 770 /* XP incorrectly breaks to level2. */ 771 CHECK_VAL(break_info.count, 1); 772 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); 773 } else { 774 /* Exclusive oplocks should not be broken on rename. */ 775 CHECK_VAL(break_info.failures, 0); 776 CHECK_VAL(break_info.count, 0); 777 } 778 779 ZERO_STRUCT(qfi); 780 qfi.generic.level = RAW_FILEINFO_ALL_INFORMATION; 781 qfi.generic.in.file.fnum = fnum; 782 783 status = smb_raw_fileinfo(cli1->tree, tctx, &qfi); 784 CHECK_STATUS(tctx, status, NT_STATUS_OK); 785 CHECK_STRMATCH(qfi.all_info.out.fname.s, fname2); 786 787 /* Try breaking to level2 and then see if rename breaks the level2.*/ 788 ZERO_STRUCT(break_info); 789 io.ntcreatex.in.fname = fname2; 790 status = smb_raw_open(cli2->tree, tctx, &io); 791 CHECK_STATUS(tctx, status, NT_STATUS_OK); 792 fnum2 = io.ntcreatex.out.file.fnum; 793 CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN); 794 795 torture_wait_for_oplock_break(tctx); 796 CHECK_VAL(break_info.failures, 0); 797 798 if (TARGET_IS_WINXP(tctx)) { 799 /* XP already broke to level2. */ 800 CHECK_VAL(break_info.failures, 0); 801 CHECK_VAL(break_info.count, 0); 802 } else { 803 /* Break to level 2 expected. */ 804 CHECK_VAL(break_info.count, 1); 805 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); 806 } 807 808 ZERO_STRUCT(break_info); 809 sfi.generic.in.file.path = fname2; 810 sfi.rename_information.in.overwrite = 0; 811 sfi.rename_information.in.root_fid = 0; 812 sfi.rename_information.in.new_name = fname1+strlen(BASEDIR)+1; 813 814 status = smb_raw_setpathinfo(cli2->tree, &sfi); 815 CHECK_STATUS(tctx, status, NT_STATUS_OK); 816 817 /* Level2 oplocks are not broken on rename. */ 818 torture_wait_for_oplock_break(tctx); 819 CHECK_VAL(break_info.failures, 0); 820 CHECK_VAL(break_info.count, 0); 821 822 /* Close and re-open file with oplock. */ 823 smbcli_close(cli1->tree, fnum); 824 status = smb_raw_open(cli1->tree, tctx, &io); 825 CHECK_STATUS(tctx, status, NT_STATUS_OK); 826 fnum = io.ntcreatex.out.file.fnum; 827 CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN); 828 829 torture_comment(tctx, "setfileinfo rename info on a client's own fid " 830 "should not trigger a break nor a violation\n"); 831 ZERO_STRUCT(break_info); 832 ZERO_STRUCT(sfi); 833 sfi.generic.level = RAW_SFILEINFO_RENAME_INFORMATION; 834 sfi.generic.in.file.fnum = fnum; 835 sfi.rename_information.in.overwrite = 0; 836 sfi.rename_information.in.root_fid = 0; 837 sfi.rename_information.in.new_name = fname3+strlen(BASEDIR)+1; 838 839 status = smb_raw_setfileinfo(cli1->tree, &sfi); 840 CHECK_STATUS(tctx, status, NT_STATUS_OK); 841 842 torture_wait_for_oplock_break(tctx); 843 if (TARGET_IS_WINXP(tctx)) { 844 /* XP incorrectly breaks to level2. */ 845 CHECK_VAL(break_info.count, 1); 846 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); 847 } else { 848 CHECK_VAL(break_info.count, 0); 849 } 850 851 ZERO_STRUCT(qfi); 852 qfi.generic.level = RAW_FILEINFO_ALL_INFORMATION; 853 qfi.generic.in.file.fnum = fnum; 854 855 status = smb_raw_fileinfo(cli1->tree, tctx, &qfi); 856 CHECK_STATUS(tctx, status, NT_STATUS_OK); 857 CHECK_STRMATCH(qfi.all_info.out.fname.s, fname3); 858 859 done: 860 smbcli_close(cli1->tree, fnum); 861 smbcli_close(cli2->tree, fnum2); 862 863 smb_raw_exit(cli1->session); 864 smb_raw_exit(cli2->session); 865 smbcli_deltree(cli1->tree, BASEDIR); 866 return ret; 867 } 868 869 static bool test_raw_oplock_batch1(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 870 { 871 const char *fname = BASEDIR "\\test_batch1.dat"; 872 NTSTATUS status; 873 bool ret = true; 874 union smb_open io; 875 union smb_unlink unl; 876 uint16_t fnum=0; 877 char c = 0; 564 878 565 879 if (!torture_setup_dir(cli1, BASEDIR)) { … … 571 885 572 886 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 573 smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli1->tree);574 887 575 888 /* … … 577 890 */ 578 891 io.generic.level = RAW_OPEN_NTCREATEX; 579 io.ntcreatex.in.root_fid = 0;892 io.ntcreatex.in.root_fid.fnum = 0; 580 893 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 581 894 io.ntcreatex.in.alloc_size = 0; … … 588 901 io.ntcreatex.in.fname = fname; 589 902 590 torture_comment(tctx, "EXCLUSIVE5: open with exclusive oplock\n"); 591 ZERO_STRUCT(break_info); 592 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 593 594 595 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; 596 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ| 597 NTCREATEX_SHARE_ACCESS_WRITE| 598 NTCREATEX_SHARE_ACCESS_DELETE; 903 /* 904 with a batch oplock we get a break 905 */ 906 torture_comment(tctx, "BATCH1: open with batch oplock\n"); 907 ZERO_STRUCT(break_info); 908 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | 909 NTCREATEX_FLAGS_REQUEST_OPLOCK | 910 NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; 599 911 status = smb_raw_open(cli1->tree, tctx, &io); 600 912 CHECK_STATUS(tctx, status, NT_STATUS_OK); 601 913 fnum = io.ntcreatex.out.file.fnum; 602 CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN); 603 604 ZERO_STRUCT(break_info); 605 606 torture_comment(tctx, "second open with attributes only and NTCREATEX_DISP_OVERWRITE_IF dispostion causes oplock break\n"); 607 608 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; 609 io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE; 610 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; 611 status = smb_raw_open(cli2->tree, tctx, &io); 612 CHECK_STATUS(tctx, status, NT_STATUS_OK); 613 fnum2 = io.ntcreatex.out.file.fnum; 614 CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN); 914 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 915 916 torture_comment(tctx, "unlink should generate a break\n"); 917 unl.unlink.in.pattern = fname; 918 unl.unlink.in.attrib = 0; 919 status = smb_raw_unlink(cli2->tree, &unl); 920 CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION); 921 615 922 torture_wait_for_oplock_break(tctx); 616 923 CHECK_VAL(break_info.count, 1); 924 CHECK_VAL(break_info.fnum, fnum); 925 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); 926 CHECK_VAL(break_info.failures, 0); 927 928 torture_comment(tctx, "2nd unlink should not generate a break\n"); 929 ZERO_STRUCT(break_info); 930 status = smb_raw_unlink(cli2->tree, &unl); 931 CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION); 932 933 torture_wait_for_oplock_break(tctx); 934 CHECK_VAL(break_info.count, 0); 935 936 torture_comment(tctx, "writing should generate a self break to none\n"); 937 smbcli_write(cli1->tree, fnum, 0, &c, 0, 1); 938 939 torture_wait_for_oplock_break(tctx); 940 torture_wait_for_oplock_break(tctx); 941 CHECK_VAL(break_info.count, 1); 942 CHECK_VAL(break_info.fnum, fnum); 943 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_NONE); 617 944 CHECK_VAL(break_info.failures, 0); 618 945 619 946 smbcli_close(cli1->tree, fnum); 620 smbcli_close(cli2->tree, fnum2);621 947 622 948 done: … … 627 953 } 628 954 629 static bool test_raw_oplock_exclusive6(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 630 { 631 const char *fname1 = BASEDIR "\\test_exclusive6_1.dat"; 632 const char *fname2 = BASEDIR "\\test_exclusive6_2.dat"; 633 NTSTATUS status; 634 bool ret = true; 635 union smb_open io; 636 union smb_rename rn; 637 uint16_t fnum=0; 638 639 if (!torture_setup_dir(cli1, BASEDIR)) { 640 return false; 641 } 642 643 /* cleanup */ 644 smbcli_unlink(cli1->tree, fname1); 645 smbcli_unlink(cli1->tree, fname2); 646 647 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 648 649 /* 650 base ntcreatex parms 651 */ 652 io.generic.level = RAW_OPEN_NTCREATEX; 653 io.ntcreatex.in.root_fid = 0; 654 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 655 io.ntcreatex.in.alloc_size = 0; 656 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 657 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; 658 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; 659 io.ntcreatex.in.create_options = 0; 660 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 661 io.ntcreatex.in.security_flags = 0; 662 io.ntcreatex.in.fname = fname1; 663 664 torture_comment(tctx, "EXCLUSIVE6: open a file with an exclusive " 665 "oplock (share mode: none)\n"); 666 ZERO_STRUCT(break_info); 667 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; 668 669 status = smb_raw_open(cli1->tree, tctx, &io); 670 CHECK_STATUS(tctx, status, NT_STATUS_OK); 671 fnum = io.ntcreatex.out.file.fnum; 672 CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN); 673 674 torture_comment(tctx, "rename should not generate a break but get a " 675 "sharing violation\n"); 676 ZERO_STRUCT(rn); 677 rn.generic.level = RAW_RENAME_RENAME; 678 rn.rename.in.pattern1 = fname1; 679 rn.rename.in.pattern2 = fname2; 680 rn.rename.in.attrib = 0; 681 682 torture_comment(tctx, "trying rename while first file open\n"); 683 status = smb_raw_rename(cli2->tree, &rn); 684 685 CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION); 686 torture_wait_for_oplock_break(tctx); 687 CHECK_VAL(break_info.count, 0); 688 CHECK_VAL(break_info.failures, 0); 689 690 smbcli_close(cli1->tree, fnum); 691 692 done: 693 smb_raw_exit(cli1->session); 694 smb_raw_exit(cli2->session); 695 smbcli_deltree(cli1->tree, BASEDIR); 696 return ret; 697 } 698 699 static bool test_raw_oplock_batch1(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 700 { 701 const char *fname = BASEDIR "\\test_batch1.dat"; 955 static bool test_raw_oplock_batch2(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 956 { 957 const char *fname = BASEDIR "\\test_batch2.dat"; 702 958 NTSTATUS status; 703 959 bool ret = true; … … 720 976 */ 721 977 io.generic.level = RAW_OPEN_NTCREATEX; 722 io.ntcreatex.in.root_fid = 0;978 io.ntcreatex.in.root_fid.fnum = 0; 723 979 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 724 980 io.ntcreatex.in.alloc_size = 0; … … 731 987 io.ntcreatex.in.fname = fname; 732 988 733 /* 734 with a batch oplock we get a break 735 */ 736 torture_comment(tctx, "BATCH1: open with batch oplock\n"); 989 torture_comment(tctx, "BATCH2: open with batch oplock\n"); 737 990 ZERO_STRUCT(break_info); 738 991 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | … … 744 997 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 745 998 746 torture_comment(tctx, "unlink should generate a break\n"); 999 torture_comment(tctx, "unlink should generate a break, which we ack as break to none\n"); 1000 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_none, cli1->tree); 747 1001 unl.unlink.in.pattern = fname; 748 1002 unl.unlink.in.attrib = 0; … … 764 1018 CHECK_VAL(break_info.count, 0); 765 1019 766 torture_comment(tctx, "writing should generate a self break to none\n");1020 torture_comment(tctx, "writing should not generate a break\n"); 767 1021 smbcli_write(cli1->tree, fnum, 0, &c, 0, 1); 768 1022 769 1023 torture_wait_for_oplock_break(tctx); 770 torture_wait_for_oplock_break(tctx); 771 CHECK_VAL(break_info.count, 1); 772 CHECK_VAL(break_info.fnum, fnum); 773 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_NONE); 774 CHECK_VAL(break_info.failures, 0); 1024 CHECK_VAL(break_info.count, 0); 775 1025 776 1026 smbcli_close(cli1->tree, fnum); … … 783 1033 } 784 1034 785 static bool test_raw_oplock_batch 2(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)786 { 787 const char *fname = BASEDIR "\\test_batch 2.dat";1035 static bool test_raw_oplock_batch3(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 1036 { 1037 const char *fname = BASEDIR "\\test_batch3.dat"; 788 1038 NTSTATUS status; 789 1039 bool ret = true; … … 791 1041 union smb_unlink unl; 792 1042 uint16_t fnum=0; 793 char c = 0;794 1043 795 1044 if (!torture_setup_dir(cli1, BASEDIR)) { … … 806 1055 */ 807 1056 io.generic.level = RAW_OPEN_NTCREATEX; 808 io.ntcreatex.in.root_fid = 0;1057 io.ntcreatex.in.root_fid.fnum = 0; 809 1058 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 810 1059 io.ntcreatex.in.alloc_size = 0; … … 817 1066 io.ntcreatex.in.fname = fname; 818 1067 819 torture_comment(tctx, "BATCH2: open with batch oplock\n"); 820 ZERO_STRUCT(break_info); 1068 torture_comment(tctx, "BATCH3: if we close on break then the unlink can succeed\n"); 1069 ZERO_STRUCT(break_info); 1070 smbcli_oplock_handler(cli1->transport, oplock_handler_close, cli1->tree); 821 1071 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | 822 1072 NTCREATEX_FLAGS_REQUEST_OPLOCK | … … 827 1077 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 828 1078 829 torture_comment(tctx, "unlink should generate a break, which we ack as break to none\n");830 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_none, cli1->tree);831 1079 unl.unlink.in.pattern = fname; 832 1080 unl.unlink.in.attrib = 0; 1081 ZERO_STRUCT(break_info); 833 1082 status = smb_raw_unlink(cli2->tree, &unl); 834 CHECK_STATUS(tctx, status, NT_STATUS_ SHARING_VIOLATION);1083 CHECK_STATUS(tctx, status, NT_STATUS_OK); 835 1084 836 1085 torture_wait_for_oplock_break(tctx); 837 1086 CHECK_VAL(break_info.count, 1); 838 1087 CHECK_VAL(break_info.fnum, fnum); 839 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); 840 CHECK_VAL(break_info.failures, 0); 841 842 torture_comment(tctx, "2nd unlink should not generate a break\n"); 843 ZERO_STRUCT(break_info); 844 status = smb_raw_unlink(cli2->tree, &unl); 845 CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION); 846 847 torture_wait_for_oplock_break(tctx); 848 CHECK_VAL(break_info.count, 0); 849 850 torture_comment(tctx, "writing should not generate a break\n"); 851 smbcli_write(cli1->tree, fnum, 0, &c, 0, 1); 852 853 torture_wait_for_oplock_break(tctx); 854 CHECK_VAL(break_info.count, 0); 1088 CHECK_VAL(break_info.level, 1); 1089 CHECK_VAL(break_info.failures, 0); 855 1090 856 1091 smbcli_close(cli1->tree, fnum); … … 863 1098 } 864 1099 865 static bool test_raw_oplock_batch 3(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)866 { 867 const char *fname = BASEDIR "\\test_batch 3.dat";1100 static bool test_raw_oplock_batch4(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 1101 { 1102 const char *fname = BASEDIR "\\test_batch4.dat"; 868 1103 NTSTATUS status; 869 1104 bool ret = true; 870 1105 union smb_open io; 871 union smb_ unlink unl;1106 union smb_read rd; 872 1107 uint16_t fnum=0; 873 1108 … … 885 1120 */ 886 1121 io.generic.level = RAW_OPEN_NTCREATEX; 887 io.ntcreatex.in.root_fid = 0;1122 io.ntcreatex.in.root_fid.fnum = 0; 888 1123 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 889 1124 io.ntcreatex.in.alloc_size = 0; … … 896 1131 io.ntcreatex.in.fname = fname; 897 1132 898 torture_comment(tctx, "BATCH3: if we close on break then the unlink can succeed\n"); 899 ZERO_STRUCT(break_info); 900 smbcli_oplock_handler(cli1->transport, oplock_handler_close, cli1->tree); 1133 torture_comment(tctx, "BATCH4: a self read should not cause a break\n"); 1134 ZERO_STRUCT(break_info); 1135 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 1136 901 1137 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | 902 1138 NTCREATEX_FLAGS_REQUEST_OPLOCK | … … 907 1143 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 908 1144 909 unl.unlink.in.pattern = fname; 910 unl.unlink.in.attrib = 0; 911 ZERO_STRUCT(break_info); 912 status = smb_raw_unlink(cli2->tree, &unl); 913 CHECK_STATUS(tctx, status, NT_STATUS_OK); 914 915 torture_wait_for_oplock_break(tctx); 916 CHECK_VAL(break_info.count, 1); 917 CHECK_VAL(break_info.fnum, fnum); 918 CHECK_VAL(break_info.level, 1); 1145 rd.readx.level = RAW_READ_READX; 1146 rd.readx.in.file.fnum = fnum; 1147 rd.readx.in.mincnt = 1; 1148 rd.readx.in.maxcnt = 1; 1149 rd.readx.in.offset = 0; 1150 rd.readx.in.remaining = 0; 1151 rd.readx.in.read_for_execute = false; 1152 status = smb_raw_read(cli1->tree, &rd); 1153 CHECK_STATUS(tctx, status, NT_STATUS_OK); 1154 torture_wait_for_oplock_break(tctx); 1155 CHECK_VAL(break_info.count, 0); 919 1156 CHECK_VAL(break_info.failures, 0); 920 1157 … … 928 1165 } 929 1166 930 static bool test_raw_oplock_batch 4(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)931 { 932 const char *fname = BASEDIR "\\test_batch 4.dat";1167 static bool test_raw_oplock_batch5(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 1168 { 1169 const char *fname = BASEDIR "\\test_batch5.dat"; 933 1170 NTSTATUS status; 934 1171 bool ret = true; 935 1172 union smb_open io; 936 union smb_read rd;937 1173 uint16_t fnum=0; 938 1174 … … 950 1186 */ 951 1187 io.generic.level = RAW_OPEN_NTCREATEX; 952 io.ntcreatex.in.root_fid = 0;1188 io.ntcreatex.in.root_fid.fnum = 0; 953 1189 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 954 1190 io.ntcreatex.in.alloc_size = 0; … … 961 1197 io.ntcreatex.in.fname = fname; 962 1198 963 torture_comment(tctx, "BATCH 4: a self read should not cause a break\n");1199 torture_comment(tctx, "BATCH5: a 2nd open should give a break\n"); 964 1200 ZERO_STRUCT(break_info); 965 1201 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); … … 973 1209 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 974 1210 975 rd.read.level = RAW_READ_READ; 976 rd.read.in.file.fnum = fnum; 977 rd.read.in.count = 1; 978 rd.read.in.offset = 0; 979 rd.read.in.remaining = 0; 980 status = smb_raw_read(cli1->tree, &rd); 981 CHECK_STATUS(tctx, status, NT_STATUS_OK); 982 torture_wait_for_oplock_break(tctx); 983 CHECK_VAL(break_info.count, 0); 1211 ZERO_STRUCT(break_info); 1212 1213 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; 1214 status = smb_raw_open(cli2->tree, tctx, &io); 1215 CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION); 1216 1217 torture_wait_for_oplock_break(tctx); 1218 CHECK_VAL(break_info.count, 1); 1219 CHECK_VAL(break_info.fnum, fnum); 1220 CHECK_VAL(break_info.level, 1); 984 1221 CHECK_VAL(break_info.failures, 0); 985 1222 … … 993 1230 } 994 1231 995 static bool test_raw_oplock_batch 5(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)996 { 997 const char *fname = BASEDIR "\\test_batch 5.dat";1232 static bool test_raw_oplock_batch6(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 1233 { 1234 const char *fname = BASEDIR "\\test_batch6.dat"; 998 1235 NTSTATUS status; 999 1236 bool ret = true; 1000 1237 union smb_open io; 1001 uint16_t fnum=0; 1238 uint16_t fnum=0, fnum2=0; 1239 char c = 0; 1002 1240 1003 1241 if (!torture_setup_dir(cli1, BASEDIR)) { … … 1009 1247 1010 1248 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 1249 smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli2->tree); 1011 1250 1012 1251 /* … … 1014 1253 */ 1015 1254 io.generic.level = RAW_OPEN_NTCREATEX; 1016 io.ntcreatex.in.root_fid = 0;1255 io.ntcreatex.in.root_fid.fnum = 0; 1017 1256 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1018 1257 io.ntcreatex.in.alloc_size = 0; … … 1025 1264 io.ntcreatex.in.fname = fname; 1026 1265 1027 torture_comment(tctx, "BATCH5: a 2nd open should give a break\n"); 1028 ZERO_STRUCT(break_info); 1029 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 1030 1266 torture_comment(tctx, "BATCH6: a 2nd open should give a break to level II if the first open allowed shared read\n"); 1267 ZERO_STRUCT(break_info); 1268 1269 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_READ | SEC_RIGHTS_FILE_WRITE; 1270 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; 1031 1271 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | 1032 1272 NTCREATEX_FLAGS_REQUEST_OPLOCK | … … 1039 1279 ZERO_STRUCT(break_info); 1040 1280 1041 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;1042 1281 status = smb_raw_open(cli2->tree, tctx, &io); 1043 CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION); 1044 1045 torture_wait_for_oplock_break(tctx); 1282 CHECK_STATUS(tctx, status, NT_STATUS_OK); 1283 fnum2 = io.ntcreatex.out.file.fnum; 1284 CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN); 1285 1286 //torture_wait_for_oplock_break(tctx); 1046 1287 CHECK_VAL(break_info.count, 1); 1047 1288 CHECK_VAL(break_info.fnum, fnum); 1048 1289 CHECK_VAL(break_info.level, 1); 1049 1290 CHECK_VAL(break_info.failures, 0); 1291 ZERO_STRUCT(break_info); 1292 1293 torture_comment(tctx, "write should trigger a break to none on both\n"); 1294 smbcli_write(cli1->tree, fnum, 0, &c, 0, 1); 1295 1296 /* We expect two breaks */ 1297 torture_wait_for_oplock_break(tctx); 1298 torture_wait_for_oplock_break(tctx); 1299 1300 CHECK_VAL(break_info.count, 2); 1301 CHECK_VAL(break_info.level, 0); 1302 CHECK_VAL(break_info.failures, 0); 1050 1303 1051 1304 smbcli_close(cli1->tree, fnum); 1305 smbcli_close(cli2->tree, fnum2); 1052 1306 1053 1307 done: … … 1058 1312 } 1059 1313 1060 static bool test_raw_oplock_batch 6(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)1061 { 1062 const char *fname = BASEDIR "\\test_batch 6.dat";1314 static bool test_raw_oplock_batch7(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 1315 { 1316 const char *fname = BASEDIR "\\test_batch7.dat"; 1063 1317 NTSTATUS status; 1064 1318 bool ret = true; 1065 1319 union smb_open io; 1066 1320 uint16_t fnum=0, fnum2=0; 1067 char c = 0;1068 1321 1069 1322 if (!torture_setup_dir(cli1, BASEDIR)) { … … 1075 1328 1076 1329 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 1077 smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli2->tree);1078 1330 1079 1331 /* … … 1081 1333 */ 1082 1334 io.generic.level = RAW_OPEN_NTCREATEX; 1083 io.ntcreatex.in.root_fid = 0;1335 io.ntcreatex.in.root_fid.fnum = 0; 1084 1336 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1085 1337 io.ntcreatex.in.alloc_size = 0; … … 1092 1344 io.ntcreatex.in.fname = fname; 1093 1345 1094 torture_comment(tctx, "BATCH6: a 2nd open should give a break to level II if the first open allowed shared read\n"); 1095 ZERO_STRUCT(break_info); 1096 1097 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_READ | SEC_RIGHTS_FILE_WRITE; 1098 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; 1346 torture_comment(tctx, "BATCH7: a 2nd open should get an oplock when we close instead of ack\n"); 1347 ZERO_STRUCT(break_info); 1348 smbcli_oplock_handler(cli1->transport, oplock_handler_close, cli1->tree); 1349 1350 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1351 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; 1099 1352 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | 1100 1353 NTCREATEX_FLAGS_REQUEST_OPLOCK | … … 1102 1355 status = smb_raw_open(cli1->tree, tctx, &io); 1103 1356 CHECK_STATUS(tctx, status, NT_STATUS_OK); 1357 fnum2 = io.ntcreatex.out.file.fnum; 1358 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 1359 1360 ZERO_STRUCT(break_info); 1361 1362 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | 1363 NTCREATEX_FLAGS_REQUEST_OPLOCK | 1364 NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; 1365 status = smb_raw_open(cli2->tree, tctx, &io); 1366 CHECK_STATUS(tctx, status, NT_STATUS_OK); 1104 1367 fnum = io.ntcreatex.out.file.fnum; 1105 1368 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 1106 1369 1107 ZERO_STRUCT(break_info); 1108 1109 status = smb_raw_open(cli2->tree, tctx, &io); 1110 CHECK_STATUS(tctx, status, NT_STATUS_OK); 1111 fnum2 = io.ntcreatex.out.file.fnum; 1112 CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN); 1113 1114 //torture_wait_for_oplock_break(tctx); 1370 torture_wait_for_oplock_break(tctx); 1115 1371 CHECK_VAL(break_info.count, 1); 1116 CHECK_VAL(break_info.fnum, fnum );1372 CHECK_VAL(break_info.fnum, fnum2); 1117 1373 CHECK_VAL(break_info.level, 1); 1118 1374 CHECK_VAL(break_info.failures, 0); 1119 ZERO_STRUCT(break_info); 1120 1121 torture_comment(tctx, "write should trigger a break to none on both\n"); 1122 smbcli_write(cli1->tree, fnum, 0, &c, 0, 1); 1123 1124 /* We expect two breaks */ 1125 torture_wait_for_oplock_break(tctx); 1126 torture_wait_for_oplock_break(tctx); 1127 1128 CHECK_VAL(break_info.count, 2); 1129 CHECK_VAL(break_info.level, 0); 1130 CHECK_VAL(break_info.failures, 0); 1131 1132 smbcli_close(cli1->tree, fnum); 1133 smbcli_close(cli2->tree, fnum2); 1375 1376 smbcli_close(cli2->tree, fnum); 1134 1377 1135 1378 done: … … 1140 1383 } 1141 1384 1142 static bool test_raw_oplock_batch 7(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)1143 { 1144 const char *fname = BASEDIR "\\test_batch 7.dat";1385 static bool test_raw_oplock_batch8(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 1386 { 1387 const char *fname = BASEDIR "\\test_batch8.dat"; 1145 1388 NTSTATUS status; 1146 1389 bool ret = true; … … 1161 1404 */ 1162 1405 io.generic.level = RAW_OPEN_NTCREATEX; 1163 io.ntcreatex.in.root_fid = 0;1406 io.ntcreatex.in.root_fid.fnum = 0; 1164 1407 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1165 1408 io.ntcreatex.in.alloc_size = 0; … … 1172 1415 io.ntcreatex.in.fname = fname; 1173 1416 1174 torture_comment(tctx, "BATCH7: a 2nd open should get an oplock when we close instead of ack\n"); 1175 ZERO_STRUCT(break_info); 1176 smbcli_oplock_handler(cli1->transport, oplock_handler_close, cli1->tree); 1177 1178 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1179 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; 1417 torture_comment(tctx, "BATCH8: open with batch oplock\n"); 1418 ZERO_STRUCT(break_info); 1419 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 1420 1180 1421 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | 1181 1422 NTCREATEX_FLAGS_REQUEST_OPLOCK | … … 1183 1424 status = smb_raw_open(cli1->tree, tctx, &io); 1184 1425 CHECK_STATUS(tctx, status, NT_STATUS_OK); 1185 fnum 2= io.ntcreatex.out.file.fnum;1426 fnum = io.ntcreatex.out.file.fnum; 1186 1427 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 1187 1428 1188 1429 ZERO_STRUCT(break_info); 1430 torture_comment(tctx, "second open with attributes only shouldn't cause oplock break\n"); 1189 1431 1190 1432 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | 1191 1433 NTCREATEX_FLAGS_REQUEST_OPLOCK | 1192 1434 NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; 1435 io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE; 1193 1436 status = smb_raw_open(cli2->tree, tctx, &io); 1194 1437 CHECK_STATUS(tctx, status, NT_STATUS_OK); 1195 fnum = io.ntcreatex.out.file.fnum; 1196 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 1197 1198 torture_wait_for_oplock_break(tctx); 1199 CHECK_VAL(break_info.count, 1); 1200 CHECK_VAL(break_info.fnum, fnum2); 1201 CHECK_VAL(break_info.level, 1); 1202 CHECK_VAL(break_info.failures, 0); 1203 1204 smbcli_close(cli2->tree, fnum); 1438 fnum2 = io.ntcreatex.out.file.fnum; 1439 CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN); 1440 torture_wait_for_oplock_break(tctx); 1441 CHECK_VAL(break_info.count, 0); 1442 CHECK_VAL(break_info.failures, 0); 1443 1444 smbcli_close(cli1->tree, fnum); 1445 smbcli_close(cli2->tree, fnum2); 1205 1446 1206 1447 done: … … 1211 1452 } 1212 1453 1213 static bool test_raw_oplock_batch 8(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)1214 { 1215 const char *fname = BASEDIR "\\test_batch 8.dat";1454 static bool test_raw_oplock_batch9(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 1455 { 1456 const char *fname = BASEDIR "\\test_batch9.dat"; 1216 1457 NTSTATUS status; 1217 1458 bool ret = true; 1218 1459 union smb_open io; 1219 1460 uint16_t fnum=0, fnum2=0; 1461 char c = 0; 1220 1462 1221 1463 if (!torture_setup_dir(cli1, BASEDIR)) { … … 1232 1474 */ 1233 1475 io.generic.level = RAW_OPEN_NTCREATEX; 1234 io.ntcreatex.in.root_fid = 0;1476 io.ntcreatex.in.root_fid.fnum = 0; 1235 1477 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1236 1478 io.ntcreatex.in.alloc_size = 0; … … 1243 1485 io.ntcreatex.in.fname = fname; 1244 1486 1245 torture_comment(tctx, "BATCH8: open with batch oplock\n"); 1246 ZERO_STRUCT(break_info); 1247 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 1248 1249 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | 1250 NTCREATEX_FLAGS_REQUEST_OPLOCK | 1251 NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; 1252 status = smb_raw_open(cli1->tree, tctx, &io); 1253 CHECK_STATUS(tctx, status, NT_STATUS_OK); 1254 fnum = io.ntcreatex.out.file.fnum; 1255 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 1256 1257 ZERO_STRUCT(break_info); 1258 torture_comment(tctx, "second open with attributes only shouldn't cause oplock break\n"); 1487 torture_comment(tctx, "BATCH9: open with attributes only can create file\n"); 1259 1488 1260 1489 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | … … 1262 1491 NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; 1263 1492 io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE; 1493 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; 1494 status = smb_raw_open(cli1->tree, tctx, &io); 1495 CHECK_STATUS(tctx, status, NT_STATUS_OK); 1496 fnum = io.ntcreatex.out.file.fnum; 1497 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 1498 1499 torture_comment(tctx, "Subsequent normal open should break oplock on attribute only open to level II\n"); 1500 1501 ZERO_STRUCT(break_info); 1502 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 1503 1504 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | 1505 NTCREATEX_FLAGS_REQUEST_OPLOCK | 1506 NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; 1507 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1508 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; 1264 1509 status = smb_raw_open(cli2->tree, tctx, &io); 1265 1510 CHECK_STATUS(tctx, status, NT_STATUS_OK); 1266 1511 fnum2 = io.ntcreatex.out.file.fnum; 1267 CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN); 1512 torture_wait_for_oplock_break(tctx); 1513 CHECK_VAL(break_info.count, 1); 1514 CHECK_VAL(break_info.fnum, fnum); 1515 CHECK_VAL(break_info.failures, 0); 1516 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); 1517 CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN); 1518 smbcli_close(cli2->tree, fnum2); 1519 1520 torture_comment(tctx, "third oplocked open should grant level2 without break\n"); 1521 ZERO_STRUCT(break_info); 1522 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 1523 smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli2->tree); 1524 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | 1525 NTCREATEX_FLAGS_REQUEST_OPLOCK | 1526 NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; 1527 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1528 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; 1529 status = smb_raw_open(cli2->tree, tctx, &io); 1530 CHECK_STATUS(tctx, status, NT_STATUS_OK); 1531 fnum2 = io.ntcreatex.out.file.fnum; 1268 1532 torture_wait_for_oplock_break(tctx); 1269 1533 CHECK_VAL(break_info.count, 0); 1534 CHECK_VAL(break_info.failures, 0); 1535 CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN); 1536 1537 ZERO_STRUCT(break_info); 1538 1539 torture_comment(tctx, "write should trigger a break to none on both\n"); 1540 smbcli_write(cli2->tree, fnum2, 0, &c, 0, 1); 1541 1542 /* We expect two breaks */ 1543 torture_wait_for_oplock_break(tctx); 1544 torture_wait_for_oplock_break(tctx); 1545 1546 CHECK_VAL(break_info.count, 2); 1547 CHECK_VAL(break_info.level, 0); 1270 1548 CHECK_VAL(break_info.failures, 0); 1271 1549 … … 1280 1558 } 1281 1559 1282 static bool test_raw_oplock_batch9(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)1283 {1284 const char *fname = BASEDIR "\\test_batch9.dat";1285 NTSTATUS status;1286 bool ret = true;1287 union smb_open io;1288 uint16_t fnum=0, fnum2=0;1289 char c = 0;1290 1291 if (!torture_setup_dir(cli1, BASEDIR)) {1292 return false;1293 }1294 1295 /* cleanup */1296 smbcli_unlink(cli1->tree, fname);1297 1298 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);1299 1300 /*1301 base ntcreatex parms1302 */1303 io.generic.level = RAW_OPEN_NTCREATEX;1304 io.ntcreatex.in.root_fid = 0;1305 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;1306 io.ntcreatex.in.alloc_size = 0;1307 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;1308 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;1309 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;1310 io.ntcreatex.in.create_options = 0;1311 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;1312 io.ntcreatex.in.security_flags = 0;1313 io.ntcreatex.in.fname = fname;1314 1315 torture_comment(tctx, "BATCH9: open with attributes only can create file\n");1316 1317 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |1318 NTCREATEX_FLAGS_REQUEST_OPLOCK |1319 NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;1320 io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;1321 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;1322 status = smb_raw_open(cli1->tree, tctx, &io);1323 CHECK_STATUS(tctx, status, NT_STATUS_OK);1324 fnum = io.ntcreatex.out.file.fnum;1325 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);1326 1327 torture_comment(tctx, "Subsequent normal open should break oplock on attribute only open to level II\n");1328 1329 ZERO_STRUCT(break_info);1330 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);1331 1332 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |1333 NTCREATEX_FLAGS_REQUEST_OPLOCK |1334 NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;1335 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;1336 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;1337 status = smb_raw_open(cli2->tree, tctx, &io);1338 CHECK_STATUS(tctx, status, NT_STATUS_OK);1339 fnum2 = io.ntcreatex.out.file.fnum;1340 torture_wait_for_oplock_break(tctx);1341 CHECK_VAL(break_info.count, 1);1342 CHECK_VAL(break_info.fnum, fnum);1343 CHECK_VAL(break_info.failures, 0);1344 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);1345 CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);1346 smbcli_close(cli2->tree, fnum2);1347 1348 torture_comment(tctx, "third oplocked open should grant level2 without break\n");1349 ZERO_STRUCT(break_info);1350 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);1351 smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli2->tree);1352 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |1353 NTCREATEX_FLAGS_REQUEST_OPLOCK |1354 NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;1355 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;1356 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;1357 status = smb_raw_open(cli2->tree, tctx, &io);1358 CHECK_STATUS(tctx, status, NT_STATUS_OK);1359 fnum2 = io.ntcreatex.out.file.fnum;1360 torture_wait_for_oplock_break(tctx);1361 CHECK_VAL(break_info.count, 0);1362 CHECK_VAL(break_info.failures, 0);1363 CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);1364 1365 ZERO_STRUCT(break_info);1366 1367 torture_comment(tctx, "write should trigger a break to none on both\n");1368 smbcli_write(cli2->tree, fnum2, 0, &c, 0, 1);1369 1370 /* We expect two breaks */1371 torture_wait_for_oplock_break(tctx);1372 torture_wait_for_oplock_break(tctx);1373 1374 CHECK_VAL(break_info.count, 2);1375 CHECK_VAL(break_info.level, 0);1376 CHECK_VAL(break_info.failures, 0);1377 1378 smbcli_close(cli1->tree, fnum);1379 smbcli_close(cli2->tree, fnum2);1380 1381 done:1382 smb_raw_exit(cli1->session);1383 smb_raw_exit(cli2->session);1384 smbcli_deltree(cli1->tree, BASEDIR);1385 return ret;1386 }1387 1388 1560 static bool test_raw_oplock_batch10(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 1389 1561 { … … 1407 1579 */ 1408 1580 io.generic.level = RAW_OPEN_NTCREATEX; 1409 io.ntcreatex.in.root_fid = 0;1581 io.ntcreatex.in.root_fid.fnum = 0; 1410 1582 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1411 1583 io.ntcreatex.in.alloc_size = 0; … … 1503 1675 */ 1504 1676 io.generic.level = RAW_OPEN_NTCREATEX; 1505 io.ntcreatex.in.root_fid = 0; 1677 io.ntcreatex.in.root_fid.fnum = 0; 1678 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1679 io.ntcreatex.in.alloc_size = 0; 1680 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 1681 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; 1682 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; 1683 io.ntcreatex.in.create_options = 0; 1684 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 1685 io.ntcreatex.in.security_flags = 0; 1686 io.ntcreatex.in.fname = fname; 1687 1688 /* Test if a set-eof on pathname breaks an exclusive oplock. */ 1689 torture_comment(tctx, "BATCH11: Test if setpathinfo set EOF breaks oplocks.\n"); 1690 1691 ZERO_STRUCT(break_info); 1692 1693 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | 1694 NTCREATEX_FLAGS_REQUEST_OPLOCK | 1695 NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; 1696 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1697 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ| 1698 NTCREATEX_SHARE_ACCESS_WRITE| 1699 NTCREATEX_SHARE_ACCESS_DELETE; 1700 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; 1701 status = smb_raw_open(cli1->tree, tctx, &io); 1702 CHECK_STATUS(tctx, status, NT_STATUS_OK); 1703 fnum = io.ntcreatex.out.file.fnum; 1704 torture_wait_for_oplock_break(tctx); 1705 CHECK_VAL(break_info.count, 0); 1706 CHECK_VAL(break_info.failures, 0); 1707 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 1708 1709 ZERO_STRUCT(sfi); 1710 sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; 1711 sfi.generic.in.file.path = fname; 1712 sfi.end_of_file_info.in.size = 100; 1713 1714 status = smb_raw_setpathinfo(cli2->tree, &sfi); 1715 CHECK_STATUS(tctx, status, NT_STATUS_OK); 1716 1717 torture_wait_for_oplock_break(tctx); 1718 CHECK_VAL(break_info.count, get_break_level1_to_none_count(tctx)); 1719 CHECK_VAL(break_info.failures, 0); 1720 CHECK_VAL(break_info.level, 0); 1721 1722 smbcli_close(cli1->tree, fnum); 1723 1724 done: 1725 smb_raw_exit(cli1->session); 1726 smb_raw_exit(cli2->session); 1727 smbcli_deltree(cli1->tree, BASEDIR); 1728 return ret; 1729 } 1730 1731 static bool test_raw_oplock_batch12(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 1732 { 1733 const char *fname = BASEDIR "\\test_batch12.dat"; 1734 NTSTATUS status; 1735 bool ret = true; 1736 union smb_open io; 1737 union smb_setfileinfo sfi; 1738 uint16_t fnum=0; 1739 1740 if (!torture_setup_dir(cli1, BASEDIR)) { 1741 return false; 1742 } 1743 1744 /* cleanup */ 1745 smbcli_unlink(cli1->tree, fname); 1746 1747 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 1748 1749 /* 1750 base ntcreatex parms 1751 */ 1752 io.generic.level = RAW_OPEN_NTCREATEX; 1753 io.ntcreatex.in.root_fid.fnum = 0; 1506 1754 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1507 1755 io.ntcreatex.in.alloc_size = 0; … … 1514 1762 io.ntcreatex.in.fname = fname; 1515 1763 1516 /* Test if a set-eof on pathname breaks an exclusive oplock. */ 1517 torture_comment(tctx, "BATCH11: Test if setpathinfo set EOF breaks oplocks.\n"); 1518 1519 ZERO_STRUCT(break_info); 1764 /* Test if a set-allocation size on pathname breaks an exclusive oplock. */ 1765 torture_comment(tctx, "BATCH12: Test if setpathinfo allocation size breaks oplocks.\n"); 1766 1767 ZERO_STRUCT(break_info); 1768 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 1520 1769 1521 1770 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | … … 1536 1785 1537 1786 ZERO_STRUCT(sfi); 1538 sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION;1787 sfi.generic.level = SMB_SFILEINFO_ALLOCATION_INFORMATION; 1539 1788 sfi.generic.in.file.path = fname; 1540 sfi. end_of_file_info.in.size = 100;1789 sfi.allocation_info.in.alloc_size = 65536 * 8; 1541 1790 1542 1791 status = smb_raw_setpathinfo(cli2->tree, &sfi); … … 1544 1793 1545 1794 torture_wait_for_oplock_break(tctx); 1546 CHECK_VAL(break_info.count, 1);1795 CHECK_VAL(break_info.count, get_break_level1_to_none_count(tctx)); 1547 1796 CHECK_VAL(break_info.failures, 0); 1548 1797 CHECK_VAL(break_info.level, 0); … … 1557 1806 } 1558 1807 1559 static bool test_raw_oplock_batch12(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)1560 {1561 const char *fname = BASEDIR "\\test_batch12.dat";1562 NTSTATUS status;1563 bool ret = true;1564 union smb_open io;1565 union smb_setfileinfo sfi;1566 uint16_t fnum=0;1567 1568 if (!torture_setup_dir(cli1, BASEDIR)) {1569 return false;1570 }1571 1572 /* cleanup */1573 smbcli_unlink(cli1->tree, fname);1574 1575 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);1576 1577 /*1578 base ntcreatex parms1579 */1580 io.generic.level = RAW_OPEN_NTCREATEX;1581 io.ntcreatex.in.root_fid = 0;1582 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;1583 io.ntcreatex.in.alloc_size = 0;1584 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;1585 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;1586 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;1587 io.ntcreatex.in.create_options = 0;1588 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;1589 io.ntcreatex.in.security_flags = 0;1590 io.ntcreatex.in.fname = fname;1591 1592 /* Test if a set-allocation size on pathname breaks an exclusive oplock. */1593 torture_comment(tctx, "BATCH12: Test if setpathinfo allocation size breaks oplocks.\n");1594 1595 ZERO_STRUCT(break_info);1596 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);1597 1598 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |1599 NTCREATEX_FLAGS_REQUEST_OPLOCK |1600 NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;1601 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;1602 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ|1603 NTCREATEX_SHARE_ACCESS_WRITE|1604 NTCREATEX_SHARE_ACCESS_DELETE;1605 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;1606 status = smb_raw_open(cli1->tree, tctx, &io);1607 CHECK_STATUS(tctx, status, NT_STATUS_OK);1608 fnum = io.ntcreatex.out.file.fnum;1609 torture_wait_for_oplock_break(tctx);1610 CHECK_VAL(break_info.count, 0);1611 CHECK_VAL(break_info.failures, 0);1612 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);1613 1614 ZERO_STRUCT(sfi);1615 sfi.generic.level = SMB_SFILEINFO_ALLOCATION_INFORMATION;1616 sfi.generic.in.file.path = fname;1617 sfi.allocation_info.in.alloc_size = 65536 * 8;1618 1619 status = smb_raw_setpathinfo(cli2->tree, &sfi);1620 CHECK_STATUS(tctx, status, NT_STATUS_OK);1621 1622 torture_wait_for_oplock_break(tctx);1623 CHECK_VAL(break_info.count, 1);1624 CHECK_VAL(break_info.failures, 0);1625 CHECK_VAL(break_info.level, 0);1626 1627 smbcli_close(cli1->tree, fnum);1628 1629 done:1630 smb_raw_exit(cli1->session);1631 smb_raw_exit(cli2->session);1632 smbcli_deltree(cli1->tree, BASEDIR);1633 return ret;1634 }1635 1636 1808 static bool test_raw_oplock_batch13(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) 1637 1809 { … … 1656 1828 */ 1657 1829 io.generic.level = RAW_OPEN_NTCREATEX; 1658 io.ntcreatex.in.root_fid = 0;1830 io.ntcreatex.in.root_fid.fnum = 0; 1659 1831 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1660 1832 io.ntcreatex.in.alloc_size = 0; … … 1698 1870 torture_wait_for_oplock_break(tctx); 1699 1871 CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN); 1700 CHECK_VAL(break_info.count, 1);1872 CHECK_VAL(break_info.count, get_break_level1_to_none_count(tctx)); 1701 1873 CHECK_VAL(break_info.failures, 0); 1702 1874 … … 1732 1904 */ 1733 1905 io.generic.level = RAW_OPEN_NTCREATEX; 1734 io.ntcreatex.in.root_fid = 0;1906 io.ntcreatex.in.root_fid.fnum = 0; 1735 1907 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1736 1908 io.ntcreatex.in.alloc_size = 0; … … 1775 1947 1776 1948 torture_wait_for_oplock_break(tctx); 1777 CHECK_VAL(break_info.count, 1);1949 CHECK_VAL(break_info.count, get_break_level1_to_none_count(tctx)); 1778 1950 CHECK_VAL(break_info.failures, 0); 1779 1951 … … 1809 1981 */ 1810 1982 io.generic.level = RAW_OPEN_NTCREATEX; 1811 io.ntcreatex.in.root_fid = 0;1983 io.ntcreatex.in.root_fid.fnum = 0; 1812 1984 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1813 1985 io.ntcreatex.in.alloc_size = 0; … … 1884 2056 */ 1885 2057 io.generic.level = RAW_OPEN_NTCREATEX; 1886 io.ntcreatex.in.root_fid = 0;2058 io.ntcreatex.in.root_fid.fnum = 0; 1887 2059 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1888 2060 io.ntcreatex.in.alloc_size = 0; … … 1927 2099 1928 2100 torture_wait_for_oplock_break(tctx); 1929 CHECK_VAL(break_info.count, 1);2101 CHECK_VAL(break_info.count, get_break_level1_to_none_count(tctx)); 1930 2102 CHECK_VAL(break_info.failures, 0); 1931 2103 … … 1964 2136 */ 1965 2137 io.generic.level = RAW_OPEN_NTCREATEX; 1966 io.ntcreatex.in.root_fid = 0;2138 io.ntcreatex.in.root_fid.fnum = 0; 1967 2139 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1968 2140 io.ntcreatex.in.alloc_size = 0; … … 2036 2208 */ 2037 2209 io.generic.level = RAW_OPEN_NTCREATEX; 2038 io.ntcreatex.in.root_fid = 0;2210 io.ntcreatex.in.root_fid.fnum = 0; 2039 2211 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 2040 2212 io.ntcreatex.in.alloc_size = 0; … … 2111 2283 */ 2112 2284 io.generic.level = RAW_OPEN_NTCREATEX; 2113 io.ntcreatex.in.root_fid = 0;2285 io.ntcreatex.in.root_fid.fnum = 0; 2114 2286 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 2115 2287 io.ntcreatex.in.alloc_size = 0; 2116 2288 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 2117 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; 2289 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | 2290 NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_DELETE; 2118 2291 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; 2119 2292 io.ntcreatex.in.create_options = 0; … … 2132 2305 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 2133 2306 2134 torture_comment(tctx, "setpathinfo rename info should not trigger a break nor a violation\n"); 2307 torture_comment(tctx, "setpathinfo rename info should trigger a break " 2308 "to none\n"); 2135 2309 ZERO_STRUCT(sfi); 2136 2310 sfi.generic.level = RAW_SFILEINFO_RENAME_INFORMATION; … … 2144 2318 2145 2319 torture_wait_for_oplock_break(tctx); 2146 CHECK_VAL(break_info.count, 0); 2320 2321 CHECK_VAL(break_info.failures, 0); 2322 2323 if (TARGET_IS_WINXP(tctx)) { 2324 /* Win XP breaks to level2. */ 2325 CHECK_VAL(break_info.count, 1); 2326 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); 2327 } else if (TARGET_IS_W2K3(tctx) || TARGET_IS_W2K8(tctx) || 2328 TARGET_IS_SAMBA3(tctx) || TARGET_IS_SAMBA4(tctx)) { 2329 /* Win2K3/2k8 incorrectly doesn't break at all. */ 2330 CHECK_VAL(break_info.count, 0); 2331 } else { 2332 /* win7/2k8r2 break to none. */ 2333 CHECK_VAL(break_info.count, 1); 2334 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_NONE); 2335 } 2147 2336 2148 2337 ZERO_STRUCT(qfi); … … 2154 2343 CHECK_STRMATCH(qfi.all_info.out.fname.s, fname2); 2155 2344 2156 torture_comment(tctx, "setfileinfo rename info should not trigger a break nor a violation\n"); 2345 /* Close and re-open file with oplock. */ 2346 smbcli_close(cli1->tree, fnum); 2347 status = smb_raw_open(cli1->tree, tctx, &io); 2348 CHECK_STATUS(tctx, status, NT_STATUS_OK); 2349 fnum = io.ntcreatex.out.file.fnum; 2350 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 2351 2352 torture_comment(tctx, "setfileinfo rename info on a client's own fid " 2353 "should not trigger a break nor a violation\n"); 2354 ZERO_STRUCT(break_info); 2157 2355 ZERO_STRUCT(sfi); 2158 2356 sfi.generic.level = RAW_SFILEINFO_RENAME_INFORMATION; … … 2166 2364 2167 2365 torture_wait_for_oplock_break(tctx); 2168 CHECK_VAL(break_info.count, 0); 2366 if (TARGET_IS_WINXP(tctx)) { 2367 /* XP incorrectly breaks to level2. */ 2368 CHECK_VAL(break_info.count, 1); 2369 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); 2370 } else { 2371 CHECK_VAL(break_info.count, 0); 2372 } 2169 2373 2170 2374 ZERO_STRUCT(qfi); … … 2176 2380 CHECK_STRMATCH(qfi.all_info.out.fname.s, fname3); 2177 2381 2382 done: 2178 2383 smbcli_close(cli1->tree, fnum); 2179 2180 done:2181 2384 smb_raw_exit(cli1->session); 2182 2385 smb_raw_exit(cli2->session); … … 2217 2420 */ 2218 2421 io.generic.level = RAW_OPEN_NTCREATEX; 2219 io.ntcreatex.in.root_fid = 0;2422 io.ntcreatex.in.root_fid.fnum = 0; 2220 2423 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 2221 2424 io.ntcreatex.in.alloc_size = 0; 2222 2425 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 2223 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; 2426 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | 2427 NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_DELETE; 2224 2428 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; 2225 2429 io.ntcreatex.in.create_options = 0; … … 2282 2486 CHECK_STRMATCH(qfi.all_info.out.fname.s, fname3); 2283 2487 2488 done: 2284 2489 smbcli_close(cli1->tree, fnum); 2285 2286 done:2287 2490 smb_raw_exit(cli1->session); 2288 2491 smb_raw_exit(cli2->session); … … 2321 2524 */ 2322 2525 io.generic.level = RAW_OPEN_NTCREATEX; 2323 io.ntcreatex.in.root_fid = 0;2526 io.ntcreatex.in.root_fid.fnum = 0; 2324 2527 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 2325 2528 io.ntcreatex.in.alloc_size = 0; … … 2443 2646 */ 2444 2647 io.generic.level = RAW_OPEN_NTCREATEX; 2445 io.ntcreatex.in.root_fid = 0;2648 io.ntcreatex.in.root_fid.fnum = 0; 2446 2649 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 2447 2650 io.ntcreatex.in.alloc_size = 0; … … 2467 2670 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 2468 2671 2469 torture_comment(tctx, "setpathinfo rename info should not trigger a break nor a violation\n");2470 2672 ZERO_STRUCT(sfi); 2471 2673 sfi.generic.level = RAW_SFILEINFO_RENAME_INFORMATION; … … 2479 2681 2480 2682 torture_wait_for_oplock_break(tctx); 2481 CHECK_VAL(break_info.count, 0); 2683 CHECK_VAL(break_info.failures, 0); 2684 2685 if (TARGET_IS_WINXP(tctx)) { 2686 /* Win XP breaks to level2. */ 2687 CHECK_VAL(break_info.count, 1); 2688 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); 2689 } else if (TARGET_IS_W2K3(tctx) || TARGET_IS_W2K8(tctx) || 2690 TARGET_IS_SAMBA3(tctx) || TARGET_IS_SAMBA4(tctx)) { 2691 /* Win2K3/2k8 incorrectly doesn't break at all. */ 2692 CHECK_VAL(break_info.count, 0); 2693 } else { 2694 /* win7/2k8r2 break to none. */ 2695 CHECK_VAL(break_info.count, 1); 2696 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_NONE); 2697 } 2482 2698 2483 2699 ZERO_STRUCT(qfi); … … 2504 2720 2505 2721 torture_wait_for_oplock_break(tctx); 2506 CHECK_VAL(break_info.count, 1); 2507 CHECK_VAL(break_info.failures, 0); 2508 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); 2509 2510 torture_comment(tctx, "setfileinfo rename info should not trigger a break nor a violation\n"); 2722 2723 if (TARGET_IS_WINXP(tctx)) { 2724 /* XP broke to level2, and doesn't break again. */ 2725 CHECK_VAL(break_info.count, 0); 2726 } else if (TARGET_IS_W2K3(tctx) || TARGET_IS_W2K8(tctx) || 2727 TARGET_IS_SAMBA3(tctx) || TARGET_IS_SAMBA4(tctx)) { 2728 /* Win2K3 incorrectly didn't break before so break now. */ 2729 CHECK_VAL(break_info.count, 1); 2730 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); 2731 } else { 2732 /* win7/2k8r2 broke to none, and doesn't break again. */ 2733 CHECK_VAL(break_info.count, 0); 2734 } 2735 2736 ZERO_STRUCT(break_info); 2737 2511 2738 ZERO_STRUCT(sfi); 2512 2739 sfi.generic.level = RAW_SFILEINFO_RENAME_INFORMATION; … … 2520 2747 2521 2748 torture_wait_for_oplock_break(tctx); 2522 CHECK_VAL(break_info.count, 1); 2523 CHECK_VAL(break_info.failures, 0); 2524 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); 2749 CHECK_VAL(break_info.count, 0); 2525 2750 2526 2751 ZERO_STRUCT(qfi); … … 2540 2765 CHECK_STRMATCH(qfi.all_info.out.fname.s, fname3); 2541 2766 2767 2768 done: 2542 2769 smbcli_close(cli1->tree, fnum); 2543 2544 done: 2770 smbcli_close(cli2->tree, fnum2); 2545 2771 smb_raw_exit(cli1->session); 2546 2772 smb_raw_exit(cli2->session); … … 2573 2799 */ 2574 2800 io.generic.level = RAW_OPEN_NTCREATEX; 2575 io.ntcreatex.in.root_fid = 0;2801 io.ntcreatex.in.root_fid.fnum = 0; 2576 2802 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 2577 2803 io.ntcreatex.in.alloc_size = 0; … … 2625 2851 bool ret = true; 2626 2852 union smb_open io; 2627 uint16_t fnum =0, fnum2=0;2853 uint16_t fnum = 0, fnum2 = 0, fnum3 = 0; 2628 2854 struct timeval tv; 2629 2855 int timeout = torture_setting_int(tctx, "oplocktimeout", 30); 2630 2856 int te; 2631 2857 2632 if (torture_setting_bool(tctx, "samba3", false)) {2633 torture_skip(tctx, "BATCH22 disabled against samba3\n");2634 }2635 2636 2858 if (!torture_setup_dir(cli1, BASEDIR)) { 2637 2859 return false; … … 2642 2864 2643 2865 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); 2644 2645 2866 /* 2646 2867 base ntcreatex parms 2647 2868 */ 2648 2869 io.generic.level = RAW_OPEN_NTCREATEX; 2649 io.ntcreatex.in.root_fid = 0;2870 io.ntcreatex.in.root_fid.fnum = 0; 2650 2871 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 2651 2872 io.ntcreatex.in.alloc_size = 0; … … 2679 2900 smbcli_oplock_handler(cli1->transport, oplock_handler_timeout, cli1->tree); 2680 2901 status = smb_raw_open(cli1->tree, tctx, &io); 2681 CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION); 2902 2903 if (TARGET_IS_W2K3(tctx)) { 2904 /* 2k3 has an issue here. xp/win7 are ok. */ 2905 CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION); 2906 } else { 2907 CHECK_STATUS(tctx, status, NT_STATUS_OK); 2908 } 2909 2910 fnum2 = io.ntcreatex.out.file.fnum; 2911 2682 2912 torture_wait_for_oplock_break(tctx); 2683 2913 te = (int)timeval_elapsed(&tv); 2914 2915 /* 2916 * Some servers detect clients that let oplocks timeout, so this check 2917 * only shows a warning message instead failing the test to eliminate 2918 * failures from repeated runs of the test. This isn't ideal, but 2919 * it's better than not running the test at all. 2920 */ 2684 2921 CHECK_RANGE(te, timeout - 1, timeout + 15); 2685 2922 … … 2696 2933 status = smb_raw_open(cli1->tree, tctx, &io); 2697 2934 CHECK_STATUS(tctx, status, NT_STATUS_OK); 2698 CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN); 2935 #if 0 2936 /* Samba 3.6.0 and above behave as Windows. */ 2937 if (TARGET_IS_SAMBA3(tctx)) { 2938 /* samba3 doesn't grant additional oplocks to bad clients. */ 2939 CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN); 2940 } else { 2941 CHECK_VAL(io.ntcreatex.out.oplock_level, 2942 LEVEL_II_OPLOCK_RETURN); 2943 } 2944 #else 2945 CHECK_VAL(io.ntcreatex.out.oplock_level, 2946 LEVEL_II_OPLOCK_RETURN); 2947 #endif 2699 2948 torture_wait_for_oplock_break(tctx); 2700 2949 te = (int)timeval_elapsed(&tv); 2701 2950 /* it should come in without delay */ 2702 2951 CHECK_RANGE(te+1, 0, timeout); 2703 fnum 2= io.ntcreatex.out.file.fnum;2952 fnum3 = io.ntcreatex.out.file.fnum; 2704 2953 2705 2954 CHECK_VAL(break_info.count, 0); … … 2707 2956 smbcli_close(cli1->tree, fnum); 2708 2957 smbcli_close(cli1->tree, fnum2); 2958 smbcli_close(cli1->tree, fnum3); 2709 2959 2710 2960 done: … … 2742 2992 */ 2743 2993 io.generic.level = RAW_OPEN_NTCREATEX; 2744 io.ntcreatex.in.root_fid = 0;2994 io.ntcreatex.in.root_fid.fnum = 0; 2745 2995 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 2746 2996 io.ntcreatex.in.alloc_size = 0; … … 2830 3080 */ 2831 3081 io.generic.level = RAW_OPEN_NTCREATEX; 2832 io.ntcreatex.in.root_fid = 0;3082 io.ntcreatex.in.root_fid.fnum = 0; 2833 3083 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 2834 3084 io.ntcreatex.in.alloc_size = 0; … … 2903 3153 */ 2904 3154 io.generic.level = RAW_OPEN_NTCREATEX; 2905 io.ntcreatex.in.root_fid = 0;3155 io.ntcreatex.in.root_fid.fnum = 0; 2906 3156 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 2907 3157 io.ntcreatex.in.alloc_size = 0; … … 2939 3189 torture_wait_for_oplock_break(tctx); 2940 3190 CHECK_VAL(break_info.count, 0); 3191 3192 smbcli_close(cli1->tree, fnum); 3193 3194 done: 3195 smb_raw_exit(cli1->session); 3196 smb_raw_exit(cli2->session); 3197 smbcli_deltree(cli1->tree, BASEDIR); 3198 return ret; 3199 } 3200 3201 /** 3202 * Similar to batch17/18, but test with open share mode rather than 3203 * share_none. 3204 */ 3205 static bool test_raw_oplock_batch26(struct torture_context *tctx, 3206 struct smbcli_state *cli1, struct smbcli_state *cli2) 3207 { 3208 const char *fname1 = BASEDIR "\\test_batch26_1.dat"; 3209 const char *fname2 = BASEDIR "\\test_batch26_2.dat"; 3210 NTSTATUS status; 3211 bool ret = true; 3212 union smb_open io; 3213 union smb_rename rn; 3214 uint16_t fnum=0; 3215 3216 if (!torture_setup_dir(cli1, BASEDIR)) { 3217 return false; 3218 } 3219 3220 /* cleanup */ 3221 smbcli_unlink(cli1->tree, fname1); 3222 smbcli_unlink(cli1->tree, fname2); 3223 3224 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, 3225 cli1->tree); 3226 3227 /* 3228 base ntcreatex parms 3229 */ 3230 io.generic.level = RAW_OPEN_NTCREATEX; 3231 io.ntcreatex.in.root_fid.fnum = 0; 3232 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 3233 io.ntcreatex.in.alloc_size = 0; 3234 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 3235 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | 3236 NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_DELETE; 3237 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; 3238 io.ntcreatex.in.create_options = 0; 3239 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 3240 io.ntcreatex.in.security_flags = 0; 3241 io.ntcreatex.in.fname = fname1; 3242 3243 torture_comment(tctx, "BATCH26: open a file with an batch oplock " 3244 "(share mode: none)\n"); 3245 3246 ZERO_STRUCT(break_info); 3247 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | 3248 NTCREATEX_FLAGS_REQUEST_OPLOCK | 3249 NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; 3250 3251 3252 status = smb_raw_open(cli1->tree, tctx, &io); 3253 CHECK_STATUS(tctx, status, NT_STATUS_OK); 3254 fnum = io.ntcreatex.out.file.fnum; 3255 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 3256 3257 torture_comment(tctx, "rename should trigger a break\n"); 3258 ZERO_STRUCT(rn); 3259 rn.generic.level = RAW_RENAME_RENAME; 3260 rn.rename.in.pattern1 = fname1; 3261 rn.rename.in.pattern2 = fname2; 3262 rn.rename.in.attrib = 0; 3263 3264 torture_comment(tctx, "trying rename while first file open\n"); 3265 status = smb_raw_rename(cli2->tree, &rn); 3266 CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION); 3267 3268 torture_wait_for_oplock_break(tctx); 3269 CHECK_VAL(break_info.count, 1); 3270 CHECK_VAL(break_info.failures, 0); 3271 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); 3272 3273 /* Close and reopen with batch again. */ 3274 smbcli_close(cli1->tree, fnum); 3275 ZERO_STRUCT(break_info); 3276 3277 status = smb_raw_open(cli1->tree, tctx, &io); 3278 CHECK_STATUS(tctx, status, NT_STATUS_OK); 3279 fnum = io.ntcreatex.out.file.fnum; 3280 CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 3281 3282 /* Now try ntrename. */ 3283 torture_comment(tctx, "ntrename should trigger a break\n"); 3284 ZERO_STRUCT(rn); 3285 rn.generic.level = RAW_RENAME_NTRENAME; 3286 rn.ntrename.in.attrib = 0; 3287 rn.ntrename.in.flags = RENAME_FLAG_RENAME; 3288 rn.ntrename.in.old_name = fname1; 3289 rn.ntrename.in.new_name = fname2; 3290 torture_comment(tctx, "trying rename while first file open\n"); 3291 status = smb_raw_rename(cli2->tree, &rn); 3292 CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION); 3293 3294 torture_wait_for_oplock_break(tctx); 3295 CHECK_VAL(break_info.count, 1); 3296 CHECK_VAL(break_info.failures, 0); 3297 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); 2941 3298 2942 3299 smbcli_close(cli1->tree, fnum); … … 3011 3368 /* Setup generic open parameters. */ 3012 3369 io.generic.level = RAW_OPEN_NTCREATEX; 3013 io.ntcreatex.in.root_fid = 0;3370 io.ntcreatex.in.root_fid.fnum = 0; 3014 3371 io.ntcreatex.in.access_mask = (SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA| 3015 3372 SEC_FILE_APPEND_DATA|SEC_STD_READ_CONTROL); … … 3044 3401 if (open_base_file) { 3045 3402 torture_comment(tctx, "Opening base file: %s with " 3046 "%d\n", fname_base, oplock_req);3403 "%d\n", fname_base, batch_req); 3047 3404 io.ntcreatex.in.fname = fname_base; 3048 3405 io.ntcreatex.in.flags = batch_req; … … 3150 3507 */ 3151 3508 io.generic.level = RAW_OPEN_NTCREATEX; 3152 io.ntcreatex.in.root_fid = 0;3509 io.ntcreatex.in.root_fid.fnum = 0; 3153 3510 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 3154 3511 io.ntcreatex.in.alloc_size = 0; … … 3213 3570 */ 3214 3571 io.generic.level = RAW_OPEN_NTCREATEX; 3215 io.ntcreatex.in.root_fid = 0;3572 io.ntcreatex.in.root_fid.fnum = 0; 3216 3573 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_READ | 3217 3574 SEC_RIGHTS_FILE_WRITE; … … 3324 3681 */ 3325 3682 io.generic.level = RAW_OPEN_NTCREATEX; 3326 io.ntcreatex.in.root_fid = 0;3683 io.ntcreatex.in.root_fid.fnum = 0; 3327 3684 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_READ | 3328 3685 SEC_RIGHTS_FILE_WRITE; … … 3417 3774 */ 3418 3775 io.generic.level = RAW_OPEN_NTCREATEX; 3419 io.ntcreatex.in.root_fid = 0;3776 io.ntcreatex.in.root_fid.fnum = 0; 3420 3777 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_READ | 3421 3778 SEC_RIGHTS_FILE_WRITE; … … 3500 3857 3501 3858 /* 3859 * Open a file with an exclusive oplock from the 1st client and acquire a 3860 * brl. Then open the same file from the 2nd client that should give oplock 3861 * break with level2 to the 1st and return no oplock to the 2nd. 3862 */ 3863 static bool test_raw_oplock_brl4(struct torture_context *tctx, 3864 struct smbcli_state *cli1, 3865 struct smbcli_state *cli2) 3866 { 3867 const char *fname = BASEDIR "\\test_batch_brl.dat"; 3868 bool ret = true; 3869 uint8_t buf[1000]; 3870 bool correct = true; 3871 union smb_open io; 3872 NTSTATUS status; 3873 uint16_t fnum = 0; 3874 uint16_t fnum2 = 0; 3875 3876 if (!torture_setup_dir(cli1, BASEDIR)) { 3877 return false; 3878 } 3879 3880 /* cleanup */ 3881 smbcli_unlink(cli1->tree, fname); 3882 3883 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, 3884 cli1->tree); 3885 3886 /* 3887 base ntcreatex parms 3888 */ 3889 io.generic.level = RAW_OPEN_NTCREATEX; 3890 io.ntcreatex.in.root_fid.fnum = 0; 3891 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_READ | 3892 SEC_RIGHTS_FILE_WRITE; 3893 io.ntcreatex.in.alloc_size = 0; 3894 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 3895 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | 3896 NTCREATEX_SHARE_ACCESS_WRITE; 3897 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; 3898 io.ntcreatex.in.create_options = 0; 3899 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 3900 io.ntcreatex.in.security_flags = 0; 3901 io.ntcreatex.in.fname = fname; 3902 3903 torture_comment(tctx, "open with exclusive oplock\n"); 3904 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | 3905 NTCREATEX_FLAGS_REQUEST_OPLOCK; 3906 3907 status = smb_raw_open(cli1->tree, tctx, &io); 3908 3909 CHECK_STATUS(tctx, status, NT_STATUS_OK); 3910 fnum = io.ntcreatex.out.file.fnum; 3911 CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN); 3912 3913 /* create a file with bogus data */ 3914 memset(buf, 0, sizeof(buf)); 3915 3916 if (smbcli_write(cli1->tree, fnum, 0, buf, 0, sizeof(buf)) != 3917 sizeof(buf)) 3918 { 3919 torture_comment(tctx, "Failed to create file\n"); 3920 correct = false; 3921 goto done; 3922 } 3923 3924 status = smbcli_lock(cli1->tree, fnum, 0, 1, 0, WRITE_LOCK); 3925 CHECK_STATUS(tctx, status, NT_STATUS_OK); 3926 3927 torture_comment(tctx, "a 2nd open should give a break to the 1st\n"); 3928 ZERO_STRUCT(break_info); 3929 3930 status = smb_raw_open(cli2->tree, tctx, &io); 3931 3932 CHECK_STATUS(tctx, status, NT_STATUS_OK); 3933 CHECK_VAL(break_info.count, 1); 3934 CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); 3935 CHECK_VAL(break_info.failures, 0); 3936 CHECK_VAL(break_info.fnum, fnum); 3937 3938 torture_comment(tctx, "and return no oplock to the 2nd\n"); 3939 fnum2 = io.ntcreatex.out.file.fnum; 3940 CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN); 3941 3942 smbcli_close(cli1->tree, fnum); 3943 smbcli_close(cli2->tree, fnum2); 3944 3945 done: 3946 smb_raw_exit(cli1->session); 3947 smb_raw_exit(cli2->session); 3948 smbcli_deltree(cli1->tree, BASEDIR); 3949 return ret; 3950 } 3951 3952 /* 3502 3953 basic testing of oplocks 3503 3954 */ 3504 3955 struct torture_suite *torture_raw_oplock(TALLOC_CTX *mem_ctx) 3505 3956 { 3506 struct torture_suite *suite = torture_suite_create(mem_ctx, "OPLOCK"); 3507 3508 torture_suite_add_2smb_test(suite, "EXCLUSIVE1", test_raw_oplock_exclusive1); 3509 torture_suite_add_2smb_test(suite, "EXCLUSIVE2", test_raw_oplock_exclusive2); 3510 torture_suite_add_2smb_test(suite, "EXCLUSIVE3", test_raw_oplock_exclusive3); 3511 torture_suite_add_2smb_test(suite, "EXCLUSIVE4", test_raw_oplock_exclusive4); 3512 torture_suite_add_2smb_test(suite, "EXCLUSIVE5", test_raw_oplock_exclusive5); 3513 torture_suite_add_2smb_test(suite, "EXCLUSIVE6", test_raw_oplock_exclusive6); 3514 torture_suite_add_2smb_test(suite, "BATCH1", test_raw_oplock_batch1); 3515 torture_suite_add_2smb_test(suite, "BATCH2", test_raw_oplock_batch2); 3516 torture_suite_add_2smb_test(suite, "BATCH3", test_raw_oplock_batch3); 3517 torture_suite_add_2smb_test(suite, "BATCH4", test_raw_oplock_batch4); 3518 torture_suite_add_2smb_test(suite, "BATCH5", test_raw_oplock_batch5); 3519 torture_suite_add_2smb_test(suite, "BATCH6", test_raw_oplock_batch6); 3520 torture_suite_add_2smb_test(suite, "BATCH7", test_raw_oplock_batch7); 3521 torture_suite_add_2smb_test(suite, "BATCH8", test_raw_oplock_batch8); 3522 torture_suite_add_2smb_test(suite, "BATCH9", test_raw_oplock_batch9); 3523 torture_suite_add_2smb_test(suite, "BATCH10", test_raw_oplock_batch10); 3524 torture_suite_add_2smb_test(suite, "BATCH11", test_raw_oplock_batch11); 3525 torture_suite_add_2smb_test(suite, "BATCH12", test_raw_oplock_batch12); 3526 torture_suite_add_2smb_test(suite, "BATCH13", test_raw_oplock_batch13); 3527 torture_suite_add_2smb_test(suite, "BATCH14", test_raw_oplock_batch14); 3528 torture_suite_add_2smb_test(suite, "BATCH15", test_raw_oplock_batch15); 3529 torture_suite_add_2smb_test(suite, "BATCH16", test_raw_oplock_batch16); 3530 torture_suite_add_2smb_test(suite, "BATCH17", test_raw_oplock_batch17); 3531 torture_suite_add_2smb_test(suite, "BATCH18", test_raw_oplock_batch18); 3532 torture_suite_add_2smb_test(suite, "BATCH19", test_raw_oplock_batch19); 3533 torture_suite_add_2smb_test(suite, "BATCH20", test_raw_oplock_batch20); 3534 torture_suite_add_2smb_test(suite, "BATCH21", test_raw_oplock_batch21); 3535 torture_suite_add_2smb_test(suite, "BATCH22", test_raw_oplock_batch22); 3536 torture_suite_add_2smb_test(suite, "BATCH23", test_raw_oplock_batch23); 3537 torture_suite_add_2smb_test(suite, "BATCH24", test_raw_oplock_batch24); 3538 torture_suite_add_2smb_test(suite, "BATCH25", test_raw_oplock_batch25); 3539 torture_suite_add_2smb_test(suite, "STREAM1", test_raw_oplock_stream1); 3540 torture_suite_add_1smb_test(suite, "DOC1", test_raw_oplock_doc); 3541 torture_suite_add_2smb_test(suite, "BRL1", test_raw_oplock_brl1); 3542 torture_suite_add_1smb_test(suite, "BRL2", test_raw_oplock_brl2); 3543 torture_suite_add_1smb_test(suite, "BRL3", test_raw_oplock_brl3); 3957 struct torture_suite *suite = torture_suite_create(mem_ctx, "oplock"); 3958 3959 torture_suite_add_2smb_test(suite, "exclusive1", test_raw_oplock_exclusive1); 3960 torture_suite_add_2smb_test(suite, "exclusive2", test_raw_oplock_exclusive2); 3961 torture_suite_add_2smb_test(suite, "exclusive3", test_raw_oplock_exclusive3); 3962 torture_suite_add_2smb_test(suite, "exclusive4", test_raw_oplock_exclusive4); 3963 torture_suite_add_2smb_test(suite, "exclusive5", test_raw_oplock_exclusive5); 3964 torture_suite_add_2smb_test(suite, "exclusive6", test_raw_oplock_exclusive6); 3965 torture_suite_add_2smb_test(suite, "exclusive7", test_raw_oplock_exclusive7); 3966 torture_suite_add_2smb_test(suite, "batch1", test_raw_oplock_batch1); 3967 torture_suite_add_2smb_test(suite, "batch2", test_raw_oplock_batch2); 3968 torture_suite_add_2smb_test(suite, "batch3", test_raw_oplock_batch3); 3969 torture_suite_add_2smb_test(suite, "batch4", test_raw_oplock_batch4); 3970 torture_suite_add_2smb_test(suite, "batch5", test_raw_oplock_batch5); 3971 torture_suite_add_2smb_test(suite, "batch6", test_raw_oplock_batch6); 3972 torture_suite_add_2smb_test(suite, "batch7", test_raw_oplock_batch7); 3973 torture_suite_add_2smb_test(suite, "batch8", test_raw_oplock_batch8); 3974 torture_suite_add_2smb_test(suite, "batch9", test_raw_oplock_batch9); 3975 torture_suite_add_2smb_test(suite, "batch10", test_raw_oplock_batch10); 3976 torture_suite_add_2smb_test(suite, "batch11", test_raw_oplock_batch11); 3977 torture_suite_add_2smb_test(suite, "batch12", test_raw_oplock_batch12); 3978 torture_suite_add_2smb_test(suite, "batch13", test_raw_oplock_batch13); 3979 torture_suite_add_2smb_test(suite, "batch14", test_raw_oplock_batch14); 3980 torture_suite_add_2smb_test(suite, "batch15", test_raw_oplock_batch15); 3981 torture_suite_add_2smb_test(suite, "batch16", test_raw_oplock_batch16); 3982 torture_suite_add_2smb_test(suite, "batch17", test_raw_oplock_batch17); 3983 torture_suite_add_2smb_test(suite, "batch18", test_raw_oplock_batch18); 3984 torture_suite_add_2smb_test(suite, "batch19", test_raw_oplock_batch19); 3985 torture_suite_add_2smb_test(suite, "batch20", test_raw_oplock_batch20); 3986 torture_suite_add_2smb_test(suite, "batch21", test_raw_oplock_batch21); 3987 torture_suite_add_2smb_test(suite, "batch22", test_raw_oplock_batch22); 3988 torture_suite_add_2smb_test(suite, "batch23", test_raw_oplock_batch23); 3989 torture_suite_add_2smb_test(suite, "batch24", test_raw_oplock_batch24); 3990 torture_suite_add_2smb_test(suite, "batch25", test_raw_oplock_batch25); 3991 torture_suite_add_2smb_test(suite, "batch26", test_raw_oplock_batch26); 3992 torture_suite_add_2smb_test(suite, "stream1", test_raw_oplock_stream1); 3993 torture_suite_add_1smb_test(suite, "doc1", test_raw_oplock_doc); 3994 torture_suite_add_2smb_test(suite, "brl1", test_raw_oplock_brl1); 3995 torture_suite_add_1smb_test(suite, "brl2", test_raw_oplock_brl2); 3996 torture_suite_add_1smb_test(suite, "brl3", test_raw_oplock_brl3); 3997 torture_suite_add_2smb_test(suite, "brl4", test_raw_oplock_brl4); 3544 3998 3545 3999 return suite; … … 3578 4032 3579 4033 io.ntcreatex.level = RAW_OPEN_NTCREATEX; 3580 io.ntcreatex.in.root_fid = 0;4034 io.ntcreatex.in.root_fid.fnum = 0; 3581 4035 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 3582 4036 io.ntcreatex.in.alloc_size = 0; … … 3704 4158 3705 4159 io.generic.level = RAW_OPEN_NTCREATEX; 3706 io.ntcreatex.in.root_fid = 0;4160 io.ntcreatex.in.root_fid.fnum = 0; 3707 4161 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 3708 4162 io.ntcreatex.in.alloc_size = 0; -
trunk/server/source4/torture/raw/pingpong.c
r414 r745 45 45 */ 46 46 #include "includes.h" 47 #include "torture/torture.h"48 #include "libcli/raw/libcliraw.h"49 47 #include "system/time.h" 50 48 #include "system/filesys.h" … … 157 155 } 158 156 } 159 160 161 static struct timeval tp1, tp2;162 163 static void start_timer(void)164 {165 gettimeofday(&tp1, NULL);166 }167 168 static double end_timer(void)169 {170 gettimeofday(&tp2, NULL);171 return (tp2.tv_sec + (tp2.tv_usec*1.0e-6)) -172 (tp1.tv_sec + (tp1.tv_usec*1.0e-6));173 }174 157 175 158 /* … … 190 173 uint8_t *val; 191 174 int count, loops; 175 struct timeval start; 192 176 193 177 fn = torture_setting_string(torture, "filename", NULL); … … 222 206 223 207 224 start _timer();208 start = timeval_current(); 225 209 val = talloc_zero_array(mem_ctx, uint8_t, num_locks); 226 210 i = 0; … … 251 235 fflush(stdout); 252 236 } 253 if ( end_timer() > 1.0) {237 if (timeval_elapsed(&start) > 1.0) { 254 238 printf("%8u locks/sec\r", 255 (unsigned)(2*count/ end_timer()));239 (unsigned)(2*count/timeval_elapsed(&start))); 256 240 fflush(stdout); 257 start _timer();241 start = timeval_current(); 258 242 count=0; 259 243 } 260 244 loops++; 261 245 } 262 263 talloc_free(mem_ctx);264 return true;265 246 } 266 247 -
trunk/server/source4/torture/raw/qfileinfo.c
r414 r745 20 20 21 21 #include "includes.h" 22 #include "torture/torture.h"23 22 #include "libcli/raw/libcliraw.h" 24 23 #include "libcli/raw/raw_proto.h" 25 24 #include "libcli/libcli.h" 26 25 #include "torture/util.h" 27 #include "librpc/rpc/dcerpc.h" 28 #include "torture/rpc/rpc.h" 29 #include "torture/raw/proto.h" 26 #include "torture/rpc/torture_rpc.h" 30 27 #include "param/param.h" 31 28 … … 33 30 const char *name; 34 31 enum smb_fileinfo_level level; 35 u int_t only_paths:1;36 u int_t only_handles:1;32 unsigned int only_paths:1; 33 unsigned int only_handles:1; 37 34 uint32_t capability_mask; 38 u int_t expected_ipc_access_denied:1;35 unsigned int expected_ipc_access_denied:1; 39 36 NTSTATUS expected_ipc_fnum_status; 40 37 NTSTATUS fnum_status, fname_status; … … 144 141 time_t t2 = nt_time_to_unix(nt); 145 142 if (abs(t2 - t) <= 2) return 0; 146 return t2 - t;143 return t2 > t ? 1 : -1; 147 144 } 148 145 … … 186 183 #define VAL_EQUAL(n1, v1, n2, v2) do {if (s1->n1.out.v1 != s2->n2.out.v2) { \ 187 184 printf("%s/%s [%u] != %s/%s [%u] at %s(%d)\n", \ 188 #n1, #v1, (u int_t)s1->n1.out.v1, \189 #n2, #v2, (u int_t)s2->n2.out.v2, \185 #n1, #v1, (unsigned int)s1->n1.out.v1, \ 186 #n2, #v2, (unsigned int)s2->n2.out.v2, \ 190 187 __FILE__, __LINE__); \ 191 188 ret = false; \ … … 215 212 printf("%s/%s non-zero unknown - %u (0x%x) at %s(%d)\n", \ 216 213 #n1, #v1, \ 217 (u int_t)s1->n1.out.v1, \218 (u int_t)s1->n1.out.v1, \214 (unsigned int)s1->n1.out.v1, \ 215 (unsigned int)s1->n1.out.v1, \ 219 216 __FILE__, __LINE__); \ 220 217 ret = false; \ … … 269 266 if (is_ipc) { 270 267 if (levels[i].expected_ipc_access_denied && NT_STATUS_EQUAL(NT_STATUS_ACCESS_DENIED, levels[i].fname_status)) { 268 } else if (!levels[i].only_handles && 269 NT_STATUS_EQUAL(levels[i].fname_status, 270 NT_STATUS_NOT_SUPPORTED)) { 271 torture_warning(torture, "fname level %s %s", 272 levels[i].name, 273 nt_errstr(levels[i].fname_status)); 274 continue; 271 275 } else if (!levels[i].only_handles && !NT_STATUS_EQUAL(NT_STATUS_INVALID_DEVICE_REQUEST, levels[i].fname_status)) { 272 276 printf("ERROR: fname level %s failed, expected NT_STATUS_INVALID_DEVICE_REQUEST - %s\n", 273 277 levels[i].name, nt_errstr(levels[i].fname_status)); 274 278 count++; 279 } 280 if (!levels[i].only_paths && 281 (NT_STATUS_EQUAL(levels[i].fnum_status, 282 NT_STATUS_NOT_SUPPORTED) || 283 NT_STATUS_EQUAL(levels[i].fnum_status, 284 NT_STATUS_NOT_IMPLEMENTED))) { 285 torture_warning(torture, "fnum level %s %s", 286 levels[i].name, 287 nt_errstr(levels[i].fnum_status)); 288 continue; 275 289 } 276 290 if (!levels[i].only_paths && !NT_STATUS_EQUAL(levels[i].expected_ipc_fnum_status, levels[i].fnum_status)) { … … 281 295 } 282 296 } else { 297 if (!levels[i].only_paths && 298 (NT_STATUS_EQUAL(levels[i].fnum_status, 299 NT_STATUS_NOT_SUPPORTED) || 300 NT_STATUS_EQUAL(levels[i].fnum_status, 301 NT_STATUS_NOT_IMPLEMENTED))) { 302 torture_warning(torture, "fnum level %s %s", 303 levels[i].name, 304 nt_errstr(levels[i].fnum_status)); 305 continue; 306 } 307 308 if (!levels[i].only_handles && 309 (NT_STATUS_EQUAL(levels[i].fname_status, 310 NT_STATUS_NOT_SUPPORTED) || 311 NT_STATUS_EQUAL(levels[i].fname_status, 312 NT_STATUS_NOT_IMPLEMENTED))) { 313 torture_warning(torture, "fname level %s %s", 314 levels[i].name, 315 nt_errstr(levels[i].fname_status)); 316 continue; 317 } 318 283 319 if (!levels[i].only_paths && !NT_STATUS_IS_OK(levels[i].fnum_status)) { 284 320 printf("ERROR: fnum level %s failed - %s\n", … … 500 536 if (s1 && s1->stype.out.tfield != correct_size) { \ 501 537 printf("(%d) handle %s/%s incorrect - %u should be %u\n", __LINE__, #stype, #tfield, \ 502 (u int_t)s1->stype.out.tfield, \503 (u int_t)correct_size); \538 (unsigned int)s1->stype.out.tfield, \ 539 (unsigned int)correct_size); \ 504 540 ret = false; \ 505 541 } \ … … 507 543 if (s1 && s1->stype.out.tfield != correct_size) { \ 508 544 printf("(%d) path %s/%s incorrect - %u should be %u\n", __LINE__, #stype, #tfield, \ 509 (u int_t)s1->stype.out.tfield, \510 (u int_t)correct_size); \545 (unsigned int)s1->stype.out.tfield, \ 546 (unsigned int)correct_size); \ 511 547 ret = false; \ 512 548 }} while (0) … … 514 550 s1 = fnum_find("STANDARD_INFO"); 515 551 correct_size = s1->standard_info.out.size; 516 torture_comment(torture, "size: %u\n", (u int_t)correct_size);552 torture_comment(torture, "size: %u\n", (unsigned int)correct_size); 517 553 518 554 SIZE_CHECK("GETATTR", getattr, size); … … 535 571 s1 = fnum_find("STANDARD_INFO"); 536 572 correct_size = s1->standard_info.out.alloc_size; 537 torture_comment(torture, "alloc_size: %u\n", (u int_t)correct_size);573 torture_comment(torture, "alloc_size: %u\n", (unsigned int)correct_size); 538 574 539 575 SIZE_CHECK("GETATTRE", getattre, alloc_size); … … 554 590 if (s1 && s1->stype.out.tfield != correct_attrib) { \ 555 591 printf("(%d) handle %s/%s incorrect - 0x%x should be 0x%x\n", __LINE__, #stype, #tfield, \ 556 (u int_t)s1->stype.out.tfield, \557 (u int_t)correct_attrib); \592 (unsigned int)s1->stype.out.tfield, \ 593 (unsigned int)correct_attrib); \ 558 594 ret = false; \ 559 595 } \ … … 561 597 if (s1 && s1->stype.out.tfield != correct_attrib) { \ 562 598 printf("(%d) path %s/%s incorrect - 0x%x should be 0x%x\n", __LINE__, #stype, #tfield, \ 563 (u int_t)s1->stype.out.tfield, \564 (u int_t)correct_attrib); \599 (unsigned int)s1->stype.out.tfield, \ 600 (unsigned int)correct_attrib); \ 565 601 ret = false; \ 566 602 }} while (0) … … 568 604 s1 = fnum_find("BASIC_INFO"); 569 605 correct_attrib = s1->basic_info.out.attrib; 570 torture_comment(torture, "attrib: 0x%x\n", (u int_t)correct_attrib);606 torture_comment(torture, "attrib: 0x%x\n", (unsigned int)correct_attrib); 571 607 572 608 ATTRIB_CHECK("GETATTR", getattr, attrib); … … 632 668 if (s1) { 633 669 correct_name = s1->alt_name_info.out.fname.s; 670 } 671 672 if (!correct_name) { 673 torture_comment(torture, "no alternate name information\n"); 674 } else { 634 675 torture_comment(torture, "alt_name: %s\n", correct_name); 635 676 … … 796 837 printf("(%d) handle %s/%s unknown != 0 (0x%x)\n", __LINE__, \ 797 838 #stype, #tfield, \ 798 (u int_t)s1->stype.out.tfield); \839 (unsigned int)s1->stype.out.tfield); \ 799 840 } \ 800 841 s1 = fname_find(is_ipc, sname); \ … … 802 843 printf("(%d) path %s/%s unknown != 0 (0x%x)\n", __LINE__, \ 803 844 #stype, #tfield, \ 804 (u int_t)s1->stype.out.tfield); \845 (unsigned int)s1->stype.out.tfield); \ 805 846 }} while (0) 806 847 #endif … … 848 889 NTSTATUS status; 849 890 850 if (!(p = dcerpc_pipe_init(torture, cli->tree->session->transport->socket->event.ctx, 851 lp_iconv_convenience(torture->lp_ctx)))) { 891 if (!(p = dcerpc_pipe_init(torture, cli->tree->session->transport->socket->event.ctx))) { 852 892 return false; 853 893 } -
trunk/server/source4/torture/raw/qfsinfo.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "torture/torture.h"22 #include "libcli/raw/libcliraw.h"23 21 #include "libcli/libcli.h" 24 22 #include "torture/util.h" … … 72 70 #define VAL_EQUAL(n1, v1, n2, v2) do {if (s1->n1.out.v1 != s2->n2.out.v2) { \ 73 71 printf("%s/%s [%u] != %s/%s [%u] at %s(%d)\n", \ 74 #n1, #v1, (u int_t)s1->n1.out.v1, \75 #n2, #v2, (u int_t)s2->n2.out.v2, \72 #n1, #v1, (unsigned int)s1->n1.out.v1, \ 73 #n2, #v2, (unsigned int)s2->n2.out.v2, \ 76 74 __FILE__, __LINE__); \ 77 75 ret = false; \ … … 80 78 #define VAL_APPROX_EQUAL(n1, v1, n2, v2) do {if (abs((int)(s1->n1.out.v1) - (int)(s2->n2.out.v2)) > 0.1*s1->n1.out.v1) { \ 81 79 printf("%s/%s [%u] != %s/%s [%u] at %s(%d)\n", \ 82 #n1, #v1, (u int_t)s1->n1.out.v1, \83 #n2, #v2, (u int_t)s2->n2.out.v2, \80 #n1, #v1, (unsigned int)s1->n1.out.v1, \ 81 #n2, #v2, (unsigned int)s2->n2.out.v2, \ 84 82 __FILE__, __LINE__); \ 85 83 ret = false; \ … … 108 106 printf("%s/%s non-zero unknown - %u (0x%x) at %s(%d)\n", \ 109 107 #n1, #v1, \ 110 (u int_t)s1->n1.out.v1, \111 (u int_t)s1->n1.out.v1, \108 (unsigned int)s1->n1.out.v1, \ 109 (unsigned int)s1->n1.out.v1, \ 112 110 __FILE__, __LINE__); \ 113 111 ret = false; \ -
trunk/server/source4/torture/raw/raw.c
r414 r745 27 27 { 28 28 struct torture_suite *suite = torture_suite_create( 29 talloc_autofree_context(), 30 "RAW"); 29 talloc_autofree_context(), "raw"); 31 30 /* RAW smb tests */ 32 torture_suite_add_simple_test(suite, " BENCH-OPLOCK", torture_bench_oplock);33 torture_suite_add_simple_test(suite, " PING-PONG", torture_ping_pong);34 torture_suite_add_simple_test(suite, " BENCH-LOCK", torture_bench_lock);35 torture_suite_add_simple_test(suite, " BENCH-OPEN", torture_bench_open);36 torture_suite_add_simple_test(suite, " BENCH-LOOKUP",31 torture_suite_add_simple_test(suite, "bench-oplock", torture_bench_oplock); 32 torture_suite_add_simple_test(suite, "ping-pong", torture_ping_pong); 33 torture_suite_add_simple_test(suite, "bench-lock", torture_bench_lock); 34 torture_suite_add_simple_test(suite, "bench-open", torture_bench_open); 35 torture_suite_add_simple_test(suite, "bench-lookup", 37 36 torture_bench_lookup); 38 torture_suite_add_simple_test(suite, " BENCH-TCON",37 torture_suite_add_simple_test(suite, "bench-tcon", 39 38 torture_bench_treeconnect); 40 torture_suite_add_simple_test(suite, "OFFLINE", torture_test_offline); 41 torture_suite_add_1smb_test(suite, "QFSINFO", torture_raw_qfsinfo); 42 torture_suite_add_1smb_test(suite, "QFILEINFO", torture_raw_qfileinfo); 43 torture_suite_add_1smb_test(suite, "QFILEINFO-IPC", torture_raw_qfileinfo_pipe); 44 torture_suite_add_1smb_test(suite, "SFILEINFO", torture_raw_sfileinfo); 45 torture_suite_add_1smb_test(suite, "SFILEINFO-BUG", torture_raw_sfileinfo_bug); 46 torture_suite_add_1smb_test(suite, "SFILEINFO-RENAME", 47 torture_raw_sfileinfo_rename); 39 torture_suite_add_simple_test(suite, "offline", torture_test_offline); 40 torture_suite_add_1smb_test(suite, "qfsinfo", torture_raw_qfsinfo); 41 torture_suite_add_1smb_test(suite, "qfileinfo", torture_raw_qfileinfo); 42 torture_suite_add_1smb_test(suite, "qfileinfo.ipc", torture_raw_qfileinfo_pipe); 43 torture_suite_add_suite(suite, torture_raw_sfileinfo(suite)); 48 44 torture_suite_add_suite(suite, torture_raw_search(suite)); 49 torture_suite_add_1smb_test(suite, " CLOSE", torture_raw_close);50 torture_suite_add_ 1smb_test(suite, "OPEN", torture_raw_open);51 torture_suite_add_1smb_test(suite, " MKDIR", torture_raw_mkdir);45 torture_suite_add_1smb_test(suite, "close", torture_raw_close); 46 torture_suite_add_suite(suite, torture_raw_open(suite)); 47 torture_suite_add_1smb_test(suite, "mkdir", torture_raw_mkdir); 52 48 torture_suite_add_suite(suite, torture_raw_oplock(suite)); 53 torture_suite_add_1smb_test(suite, " HOLD-OPLOCK", torture_hold_oplock);54 torture_suite_add_2smb_test(suite, " NOTIFY", torture_raw_notify);55 torture_suite_add_1smb_test(suite, " MUX", torture_raw_mux);56 torture_suite_add_1smb_test(suite, " IOCTL", torture_raw_ioctl);57 torture_suite_add_1smb_test(suite, " CHKPATH", torture_raw_chkpath);49 torture_suite_add_1smb_test(suite, "hold-oplock", torture_hold_oplock); 50 torture_suite_add_2smb_test(suite, "notify", torture_raw_notify); 51 torture_suite_add_1smb_test(suite, "mux", torture_raw_mux); 52 torture_suite_add_1smb_test(suite, "ioctl", torture_raw_ioctl); 53 torture_suite_add_1smb_test(suite, "chkpath", torture_raw_chkpath); 58 54 torture_suite_add_suite(suite, torture_raw_unlink(suite)); 59 55 torture_suite_add_suite(suite, torture_raw_read(suite)); 60 56 torture_suite_add_suite(suite, torture_raw_write(suite)); 61 57 torture_suite_add_suite(suite, torture_raw_lock(suite)); 62 torture_suite_add_1smb_test(suite, " CONTEXT", torture_raw_context);58 torture_suite_add_1smb_test(suite, "context", torture_raw_context); 63 59 torture_suite_add_suite(suite, torture_raw_rename(suite)); 64 torture_suite_add_1smb_test(suite, " SEEK", torture_raw_seek);65 torture_suite_add_1smb_test(suite, " EAS", torture_raw_eas);66 torture_suite_add_ 1smb_test(suite, "STREAMS", torture_raw_streams);67 torture_suite_add_ 1smb_test(suite, "ACLS", torture_raw_acls);68 torture_suite_add_1smb_test(suite, " COMPOSITE", torture_raw_composite);69 torture_suite_add_simple_test(suite, " SAMBA3HIDE", torture_samba3_hide);70 torture_suite_add_simple_test(suite, " SAMBA3CLOSEERR", torture_samba3_closeerr);71 torture_suite_add_simple_test(suite, " SAMBA3ROOTDIRFID",60 torture_suite_add_1smb_test(suite, "seek", torture_raw_seek); 61 torture_suite_add_1smb_test(suite, "eas", torture_raw_eas); 62 torture_suite_add_suite(suite, torture_raw_streams(suite)); 63 torture_suite_add_suite(suite, torture_raw_acls(suite)); 64 torture_suite_add_1smb_test(suite, "composite", torture_raw_composite); 65 torture_suite_add_simple_test(suite, "samba3hide", torture_samba3_hide); 66 torture_suite_add_simple_test(suite, "samba3closeerr", torture_samba3_closeerr); 67 torture_suite_add_simple_test(suite, "samba3rootdirfid", 72 68 torture_samba3_rootdirfid); 73 torture_suite_add_simple_test(suite, " SAMBA3CHECKFSP", torture_samba3_checkfsp);74 torture_suite_add_simple_test(suite, " SAMBA3OPLOCKLOGOFF", torture_samba3_oplock_logoff);75 torture_suite_add_simple_test(suite, " SAMBA3BADPATH", torture_samba3_badpath);76 torture_suite_add_simple_test(suite, " SAMBA3CASEINSENSITIVE",69 torture_suite_add_simple_test(suite, "samba3checkfsp", torture_samba3_checkfsp); 70 torture_suite_add_simple_test(suite, "samba3oplocklogoff", torture_samba3_oplock_logoff); 71 torture_suite_add_simple_test(suite, "samba3badpath", torture_samba3_badpath); 72 torture_suite_add_simple_test(suite, "samba3caseinsensitive", 77 73 torture_samba3_caseinsensitive); 78 torture_suite_add_simple_test(suite, " SAMBA3POSIXTIMEDLOCK",74 torture_suite_add_simple_test(suite, "samba3posixtimedlock", 79 75 torture_samba3_posixtimedlock); 80 torture_suite_add_simple_test(suite, " SCAN-EAMAX", torture_max_eas);76 torture_suite_add_simple_test(suite, "scan-eamax", torture_max_eas); 81 77 82 78 suite->description = talloc_strdup(suite, "Tests for the raw SMB interface"); -
trunk/server/source4/torture/raw/read.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "torture/torture.h"22 21 #include "libcli/raw/libcliraw.h" 23 #include "libcli/raw/raw_proto.h"24 22 #include "system/time.h" 25 23 #include "system/filesys.h" … … 55 53 setup a random buffer based on a seed 56 54 */ 57 static void setup_buffer(uint8_t *buf, u int_t seed, int len)55 static void setup_buffer(uint8_t *buf, unsigned int seed, int len) 58 56 { 59 57 int i; … … 65 63 check a random buffer based on a seed 66 64 */ 67 static bool check_buffer(uint8_t *buf, u int_t seed, int len, int line)65 static bool check_buffer(uint8_t *buf, unsigned int seed, int len, int line) 68 66 { 69 67 int i; … … 93 91 const char *fname = BASEDIR "\\test.txt"; 94 92 const char *test_data = "TEST DATA"; 95 u int_t seed = time(NULL);93 unsigned int seed = time(NULL); 96 94 97 95 buf = talloc_zero_array(tctx, uint8_t, maxsize); 96 97 if (!torture_setting_bool(tctx, "read_support", true)) { 98 printf("server refuses to support READ\n"); 99 return true; 100 } 98 101 99 102 if (!torture_setup_dir(cli, BASEDIR)) { … … 103 106 printf("Testing RAW_READ_READ\n"); 104 107 io.generic.level = RAW_READ_READ; 105 108 106 109 fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); 107 110 if (fnum == -1) { … … 220 223 const char *fname = BASEDIR "\\test.txt"; 221 224 const char *test_data = "TEST DATA"; 222 uint_t seed = time(NULL); 225 unsigned int seed = time(NULL); 226 227 if (!cli->transport->negotiate.lockread_supported) { 228 printf("Server does not support lockread - skipping\n"); 229 return true; 230 } 223 231 224 232 buf = talloc_zero_array(tctx, uint8_t, maxsize); … … 365 373 const char *fname = BASEDIR "\\test.txt"; 366 374 const char *test_data = "TEST DATA"; 367 u int_t seed = time(NULL);375 unsigned int seed = time(NULL); 368 376 369 377 buf = talloc_zero_array(tctx, uint8_t, maxsize); … … 481 489 memset(buf, 0, maxsize); 482 490 483 printf("Trying large read\n"); 491 printf("Trying page sized read\n"); 492 io.readx.in.offset = 0; 493 io.readx.in.mincnt = 0x1000; 494 io.readx.in.maxcnt = 0x1000; 495 status = smb_raw_read(cli->tree, &io); 496 CHECK_STATUS(status, NT_STATUS_OK); 497 CHECK_VALUE(io.readx.out.remaining, 0xFFFF); 498 CHECK_VALUE(io.readx.out.compaction_mode, 0); 499 CHECK_VALUE(io.readx.out.nread, io.readx.in.maxcnt); 500 CHECK_BUFFER(buf, seed, io.readx.out.nread); 501 502 printf("Trying page + 1 sized read (check alignment)\n"); 503 io.readx.in.offset = 0; 504 io.readx.in.mincnt = 0x1001; 505 io.readx.in.maxcnt = 0x1001; 506 status = smb_raw_read(cli->tree, &io); 507 CHECK_STATUS(status, NT_STATUS_OK); 508 CHECK_VALUE(io.readx.out.remaining, 0xFFFF); 509 CHECK_VALUE(io.readx.out.compaction_mode, 0); 510 CHECK_VALUE(io.readx.out.nread, io.readx.in.maxcnt); 511 CHECK_BUFFER(buf, seed, io.readx.out.nread); 512 513 printf("Trying large read (UINT16_MAX)\n"); 484 514 io.readx.in.offset = 0; 485 515 io.readx.in.mincnt = 0xFFFF; … … 626 656 const char *fname = BASEDIR "\\test.txt"; 627 657 const char *test_data = "TEST DATA"; 628 u int_t seed = time(NULL);658 unsigned int seed = time(NULL); 629 659 630 660 if (!cli->transport->negotiate.readbraw_supported) { … … 816 846 817 847 op.generic.level = RAW_OPEN_NTCREATEX; 818 op.ntcreatex.in.root_fid = 0;848 op.ntcreatex.in.root_fid.fnum = 0; 819 849 op.ntcreatex.in.flags = 0; 820 850 op.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 847 877 printf("open file with SEC_FILE_EXECUTE\n"); 848 878 op.generic.level = RAW_OPEN_NTCREATEX; 849 op.ntcreatex.in.root_fid = 0;879 op.ntcreatex.in.root_fid.fnum = 0; 850 880 op.ntcreatex.in.flags = 0; 851 881 op.ntcreatex.in.access_mask = SEC_FILE_EXECUTE; … … 894 924 printf("open file with SEC_FILE_READ_DATA\n"); 895 925 op.generic.level = RAW_OPEN_NTCREATEX; 896 op.ntcreatex.in.root_fid = 0;926 op.ntcreatex.in.root_fid.fnum = 0; 897 927 op.ntcreatex.in.flags = 0; 898 928 op.ntcreatex.in.access_mask = SEC_FILE_READ_DATA; … … 951 981 struct torture_suite *torture_raw_read(TALLOC_CTX *mem_ctx) 952 982 { 953 struct torture_suite *suite = torture_suite_create(mem_ctx, " READ");983 struct torture_suite *suite = torture_suite_create(mem_ctx, "read"); 954 984 955 985 torture_suite_add_1smb_test(suite, "read", test_read); … … 958 988 torture_suite_add_1smb_test(suite, "readbraw", test_readbraw); 959 989 torture_suite_add_1smb_test(suite, "read for execute", 960 990 test_read_for_execute); 961 991 962 992 return suite; -
trunk/server/source4/torture/raw/rename.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "torture/torture.h"22 #include "libcli/raw/libcliraw.h"23 21 #include "libcli/libcli.h" 24 22 #include "torture/util.h" … … 68 66 69 67 op.generic.level = RAW_OPEN_NTCREATEX; 70 op.ntcreatex.in.root_fid = 0;68 op.ntcreatex.in.root_fid.fnum = 0; 71 69 op.ntcreatex.in.flags = 0; 72 70 op.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 209 207 } 210 208 op.generic.level = RAW_OPEN_NTCREATEX; 211 op.ntcreatex.in.root_fid = 0;209 op.ntcreatex.in.root_fid.fnum = 0; 212 210 op.ntcreatex.in.flags = 0; 213 211 op.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; … … 308 306 CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); 309 307 310 smb _raw_exit(cli->session);308 smbcli_close(cli->tree, fnum); 311 309 status = smb_raw_rename(cli->tree, &io); 312 310 CHECK_STATUS(status, NT_STATUS_OK); … … 429 427 io.ntrename.in.flags = 0; 430 428 status = smb_raw_rename(cli->tree, &io); 431 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 429 if (TARGET_IS_WIN7(tctx)) { 430 CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); 431 } else { 432 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 433 } 432 434 433 435 io.ntrename.in.flags = 300; 434 436 status = smb_raw_rename(cli->tree, &io); 435 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 437 if (TARGET_IS_WIN7(tctx)) { 438 CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); 439 } else { 440 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 441 } 436 442 437 443 io.ntrename.in.flags = 0x106; 438 444 status = smb_raw_rename(cli->tree, &io); 439 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 445 if (TARGET_IS_WIN7(tctx)) { 446 CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); 447 } else { 448 CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); 449 } 440 450 441 451 torture_comment(tctx, "Checking unknown field\n"); … … 508 518 io.ntrename.in.cluster_size = 0; 509 519 status = smb_raw_rename(cli->tree, &io); 510 if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { 511 torture_warning(tctx, "flags=0x%x status=%s\n", i, nt_errstr(status)); 520 if (TARGET_IS_WIN7(tctx)){ 521 if (!NT_STATUS_EQUAL(status, 522 NT_STATUS_INVALID_PARAMETER)) { 523 torture_warning(tctx, "flags=0x%x status=%s\n", 524 i, nt_errstr(status)); 525 } 526 } else { 527 if (!NT_STATUS_EQUAL(status, 528 NT_STATUS_ACCESS_DENIED)) { 529 torture_warning(tctx, "flags=0x%x status=%s\n", 530 i, nt_errstr(status)); 531 } 512 532 } 513 533 } … … 578 598 io.generic.level = RAW_OPEN_NTCREATEX; 579 599 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; 580 io.ntcreatex.in.root_fid = 0;600 io.ntcreatex.in.root_fid.fnum = 0; 581 601 io.ntcreatex.in.alloc_size = 0; 582 602 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; … … 698 718 struct torture_suite *torture_raw_rename(TALLOC_CTX *mem_ctx) 699 719 { 700 struct torture_suite *suite = torture_suite_create(mem_ctx, " RENAME");720 struct torture_suite *suite = torture_suite_create(mem_ctx, "rename"); 701 721 702 722 torture_suite_add_1smb_test(suite, "mv", test_mv); -
trunk/server/source4/torture/raw/samba3hide.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "torture/torture.h"22 #include "libcli/raw/libcliraw.h"23 21 #include "system/time.h" 24 22 #include "system/filesys.h" … … 138 136 torture, &cli, torture, torture_setting_string(torture, "host", NULL), 139 137 torture_setting_string(torture, "share", NULL), torture->ev)) { 140 d_printf("torture_open_connection_share failed\n"); 141 return false; 138 torture_fail(torture, "torture_open_connection_share failed\n"); 142 139 } 143 140 144 141 status = torture_second_tcon(torture, cli->session, "hideunread", 145 142 &hideunread); 146 if (!NT_STATUS_IS_OK(status)) { 147 d_printf("second_tcon(hideunread) failed: %s\n", 148 nt_errstr(status)); 149 return false; 150 } 143 torture_assert_ntstatus_ok(torture, status, "second_tcon(hideunread) failed\n"); 151 144 152 145 status = torture_second_tcon(torture, cli->session, "hideunwrite", 153 146 &hideunwrite); 154 if (!NT_STATUS_IS_OK(status)) { 155 d_printf("second_tcon(hideunwrite) failed: %s\n", 156 nt_errstr(status)); 157 return false; 158 } 147 torture_assert_ntstatus_ok(torture, status, "second_tcon(hideunwrite) failed\n"); 159 148 160 149 status = smbcli_unlink(cli->tree, fname); … … 166 155 fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); 167 156 if (fnum == -1) { 168 d_printf("Failed to create %s - %s\n", fname, 169 smbcli_errstr(cli->tree)); 170 return false; 157 torture_fail(torture, 158 talloc_asprintf(torture, "Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree))); 171 159 } 172 160 … … 174 162 175 163 if (!smbcli_file_exists(cli->tree, fname)) { 176 d_printf("%s does not exist\n", fname); 177 return false; 164 torture_fail(torture, talloc_asprintf(torture, "%s does not exist\n", fname)); 178 165 } 179 166 … … 181 168 182 169 status = smbcli_chmod(cli->tree, fname, UNIX_R_USR|UNIX_W_USR); 183 if (!NT_STATUS_IS_OK(status)) { 184 d_printf("smbcli_chmod failed: %s\n", nt_errstr(status)); 185 return false; 186 } 170 torture_assert_ntstatus_ok(torture, status, "smbcli_chmod failed\n"); 171 187 172 if (!is_writeable(torture, cli->tree, fname)) { 188 d_printf("File not writable\n"); 189 return false; 173 torture_fail(torture, "File not writable\n"); 190 174 } 191 175 if (!is_readable(cli->tree, fname)) { 192 d_printf("File not readable\n"); 193 return false; 176 torture_fail(torture, "File not readable\n"); 194 177 } 195 178 if (!is_visible(cli->tree, fname)) { 196 d_printf("r/w file not visible via normal share\n"); 197 return false; 179 torture_fail(torture, "r/w file not visible via normal share\n"); 198 180 } 199 181 if (!is_visible(hideunread, fname)) { 200 d_printf("r/w file not visible via hide unreadable\n"); 201 return false; 182 torture_fail(torture, "r/w file not visible via hide unreadable\n"); 202 183 } 203 184 if (!is_visible(hideunwrite, fname)) { 204 d_printf("r/w file not visible via hide unwriteable\n"); 205 return false; 185 torture_fail(torture, "r/w file not visible via hide unwriteable\n"); 206 186 } 207 187 … … 209 189 210 190 status = smbcli_chmod(cli->tree, fname, UNIX_R_USR); 211 212 if (!NT_STATUS_IS_OK(status)) { 213 d_printf("smbcli_chmod failed: %s\n", nt_errstr(status)); 214 return false; 215 } 191 torture_assert_ntstatus_ok(torture, status, "smbcli_chmod failed\n"); 192 216 193 if (is_writeable(torture, cli->tree, fname)) { 217 d_printf("r/o is writable\n"); 218 return false; 194 torture_fail(torture, "r/o is writable\n"); 219 195 } 220 196 if (!is_readable(cli->tree, fname)) { 221 d_printf("r/o not readable\n"); 222 return false; 197 torture_fail(torture, "r/o not readable\n"); 223 198 } 224 199 if (!is_visible(cli->tree, fname)) { 225 d_printf("r/o file not visible via normal share\n"); 226 return false; 200 torture_fail(torture, "r/o file not visible via normal share\n"); 227 201 } 228 202 if (!is_visible(hideunread, fname)) { 229 d_printf("r/o file not visible via hide unreadable\n"); 230 return false; 203 torture_fail(torture, "r/o file not visible via hide unreadable\n"); 231 204 } 232 205 if (is_visible(hideunwrite, fname)) { 233 d_printf("r/o file visible via hide unwriteable\n"); 234 return false; 206 torture_fail(torture, "r/o file visible via hide unwriteable\n"); 235 207 } 236 208 … … 238 210 239 211 status = smbcli_chmod(cli->tree, fname, 0); 240 if (!NT_STATUS_IS_OK(status)) { 241 d_printf("smbcli_chmod failed: %s\n", nt_errstr(status)); 242 return false; 243 } 212 torture_assert_ntstatus_ok(torture, status, "smbcli_chmod failed\n"); 213 244 214 if (is_writeable(torture, cli->tree, fname)) { 245 d_printf("inaccessible file is writable\n"); 246 return false; 215 torture_fail(torture, "inaccessible file is writable\n"); 247 216 } 248 217 if (is_readable(cli->tree, fname)) { 249 d_printf("inaccessible file is readable\n"); 250 return false; 218 torture_fail(torture, "inaccessible file is readable\n"); 251 219 } 252 220 if (!is_visible(cli->tree, fname)) { 253 d_printf("inaccessible file not visible via normal share\n"); 254 return false; 221 torture_fail(torture, "inaccessible file not visible via normal share\n"); 255 222 } 256 223 if (is_visible(hideunread, fname)) { 257 d_printf("inaccessible file visible via hide unreadable\n"); 258 return false; 224 torture_fail(torture, "inaccessible file visible via hide unreadable\n"); 259 225 } 260 226 if (is_visible(hideunwrite, fname)) { 261 d_printf("inaccessible file visible via hide unwriteable\n"); 262 return false; 227 torture_fail(torture, "inaccessible file visible via hide unwriteable\n"); 263 228 } 264 229 -
trunk/server/source4/torture/raw/samba3misc.c
r414 r745 91 91 io.generic.level = RAW_OPEN_NTCREATEX; 92 92 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; 93 io.ntcreatex.in.root_fid = 0;93 io.ntcreatex.in.root_fid.fnum = 0; 94 94 io.ntcreatex.in.security_flags = 0; 95 95 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; … … 163 163 { 164 164 union smb_open open_parms; 165 u int_t openfn=0;166 u int_t accessmode=0;165 unsigned int openfn=0; 166 unsigned int accessmode=0; 167 167 TALLOC_CTX *mem_ctx; 168 168 NTSTATUS status; … … 226 226 { 227 227 union smb_open io; 228 u int_t openfn=0;229 u int_t accessmode=0;228 unsigned int openfn=0; 229 unsigned int accessmode=0; 230 230 TALLOC_CTX *mem_ctx; 231 231 NTSTATUS status; … … 305 305 io.generic.level = RAW_OPEN_NTCREATEX; 306 306 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; 307 io.ntcreatex.in.root_fid = 0;307 io.ntcreatex.in.root_fid.fnum = 0; 308 308 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 309 309 io.ntcreatex.in.alloc_size = 0; … … 347 347 } 348 348 349 nt_status_support = lp _nt_status_support(torture->lp_ctx);350 351 if (!lp _set_cmdline(torture->lp_ctx, "nt status support", "yes")) {349 nt_status_support = lpcfg_nt_status_support(torture->lp_ctx); 350 351 if (!lpcfg_set_cmdline(torture->lp_ctx, "nt status support", "yes")) { 352 352 printf("Could not set 'nt status support = yes'\n"); 353 353 goto fail; … … 358 358 } 359 359 360 if (!lp _set_cmdline(torture->lp_ctx, "nt status support", "no")) {360 if (!lpcfg_set_cmdline(torture->lp_ctx, "nt status support", "no")) { 361 361 printf("Could not set 'nt status support = yes'\n"); 362 362 goto fail; … … 367 367 } 368 368 369 if (!lp _set_cmdline(torture->lp_ctx, "nt status support",369 if (!lpcfg_set_cmdline(torture->lp_ctx, "nt status support", 370 370 nt_status_support ? "yes":"no")) { 371 371 printf("Could not reset 'nt status support = yes'"); … … 622 622 int fnum; 623 623 int counter = 0; 624 bool ret = true;624 bool ret = false; 625 625 626 626 if (!(mem_ctx = talloc_init("torture_samba3_caseinsensitive"))) { … … 636 636 637 637 status = smbcli_mkdir(cli->tree, dirname); 638 torture_assert_ntstatus_ok(torture, status, "smbcli_mkdir failed"); 638 639 if (!NT_STATUS_IS_OK(status)) { 639 d_printf("smbcli_mkdir failed: %s\n", nt_errstr(status));640 640 goto done; 641 641 } … … 646 646 fnum = smbcli_open(cli->tree, fpath, O_RDWR | O_CREAT, DENY_NONE); 647 647 if (fnum == -1) { 648 d_printf("Could not create file %s: %s\n", fpath, 648 torture_result(torture, TORTURE_FAIL, 649 "Could not create file %s: %s", fpath, 649 650 smbcli_errstr(cli->tree)); 650 651 goto done; … … 662 663 } 663 664 else { 664 d_fprintf(stderr, "expected 3 entries, got %d\n", counter); 665 torture_result(torture, TORTURE_FAIL, 666 "expected 3 entries, got %d", counter); 665 667 ret = false; 666 668 } … … 888 890 io.generic.level = RAW_OPEN_NTCREATEX; 889 891 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; 890 io.ntcreatex.in.root_fid = 0;892 io.ntcreatex.in.root_fid.fnum = 0; 891 893 io.ntcreatex.in.security_flags = 0; 892 894 io.ntcreatex.in.access_mask = … … 913 915 NTCREATEX_FLAGS_REQUEST_OPLOCK 914 916 | NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; 915 io.ntcreatex.in.root_fid = dnum;917 io.ntcreatex.in.root_fid.fnum = dnum; 916 918 io.ntcreatex.in.security_flags = 0; 917 919 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; … … 962 964 io.generic.level = RAW_OPEN_NTCREATEX; 963 965 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; 964 io.ntcreatex.in.root_fid = 0;966 io.ntcreatex.in.root_fid.fnum = 0; 965 967 io.ntcreatex.in.security_flags = 0; 966 968 io.ntcreatex.in.access_mask = … … 1008 1010 echo_req.in.repeat_count = 1; 1009 1011 echo_req.in.size = 1; 1010 echo_req.in.data = (uint8_t *)"";1012 echo_req.in.data = discard_const_p(uint8_t, ""); 1011 1013 1012 1014 status = smb_raw_echo(cli->session->transport, &echo_req); -
trunk/server/source4/torture/raw/search.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "torture/torture.h"22 21 #include "system/filesys.h" 23 22 #include "libcli/raw/libcliraw.h" … … 25 24 #include "libcli/libcli.h" 26 25 #include "torture/util.h" 26 #include "lib/util/tsort.h" 27 27 28 28 29 29 #define BASEDIR "\\testsearch" 30 31 #define CHECK_STATUS_LEVEL(__tctx, __status, __level, __supp) \ 32 do { \ 33 if (NT_STATUS_EQUAL(__status, \ 34 NT_STATUS_NOT_SUPPORTED) || \ 35 NT_STATUS_EQUAL(__status, \ 36 NT_STATUS_NOT_IMPLEMENTED)) { \ 37 torture_warning(__tctx, "(%s) Info " \ 38 "level "#__level" is %s", \ 39 __location__, nt_errstr(__status)); \ 40 __supp = false; \ 41 } else { \ 42 torture_assert_ntstatus_ok_goto(__tctx, \ 43 __status, ret, done, #__level" failed"); \ 44 __supp = true; \ 45 } \ 46 } while (0) 30 47 31 48 /* … … 243 260 int i; 244 261 union smb_fileinfo all_info, alt_info, name_info, internal_info; 262 bool all_info_supported, alt_info_supported, name_info_supported, 263 internal_info_supported; 245 264 union smb_search_data *s; 246 265 … … 257 276 uint32_t cap = cli->transport->negotiate.capabilities; 258 277 259 torture_comment(tctx, " testing %s\n", levels[i].name);278 torture_comment(tctx, "Testing %s\n", levels[i].name); 260 279 261 280 levels[i].status = torture_single_search(cli, tctx, fname, … … 266 285 267 286 /* see if this server claims to support this level */ 268 if ((cap & levels[i].capability_mask) != levels[i].capability_mask) { 287 if (((cap & levels[i].capability_mask) != levels[i].capability_mask) 288 || NT_STATUS_EQUAL(levels[i].status, NT_STATUS_NOT_SUPPORTED)) { 269 289 printf("search level %s(%d) not supported by server\n", 270 290 levels[i].name, (int)levels[i].level); … … 305 325 all_info.generic.in.file.path = fname; 306 326 status = smb_raw_pathinfo(cli->tree, tctx, &all_info); 307 torture_assert_ntstatus_ok(tctx, status, "RAW_FILEINFO_ALL_INFO failed"); 327 CHECK_STATUS_LEVEL(tctx, status, "RAW_FILEINFO_ALL_INFO", 328 all_info_supported); 308 329 309 330 alt_info.generic.level = RAW_FILEINFO_ALT_NAME_INFO; 310 331 alt_info.generic.in.file.path = fname; 311 332 status = smb_raw_pathinfo(cli->tree, tctx, &alt_info); 312 torture_assert_ntstatus_ok(tctx, status, "RAW_FILEINFO_ALT_NAME_INFO failed"); 333 CHECK_STATUS_LEVEL(tctx, status, "RAW_FILEINFO_ALT_NAME_INFO", 334 alt_info_supported); 313 335 314 336 internal_info.generic.level = RAW_FILEINFO_INTERNAL_INFORMATION; 315 337 internal_info.generic.in.file.path = fname; 316 338 status = smb_raw_pathinfo(cli->tree, tctx, &internal_info); 317 torture_assert_ntstatus_ok(tctx, status, "RAW_FILEINFO_INTERNAL_INFORMATION failed"); 339 CHECK_STATUS_LEVEL(tctx, status, "RAW_FILEINFO_INTERNAL_INFORMATION", 340 internal_info_supported); 318 341 319 342 name_info.generic.level = RAW_FILEINFO_NAME_INFO; 320 343 name_info.generic.in.file.path = fname; 321 344 status = smb_raw_pathinfo(cli->tree, tctx, &name_info); 322 torture_assert_ntstatus_ok(tctx, status, "RAW_FILEINFO_NAME_INFO failed"); 345 CHECK_STATUS_LEVEL(tctx, status, "RAW_FILEINFO_NAME_INFO", 346 name_info_supported); 323 347 324 348 #define CHECK_VAL(name, sname1, field1, v, sname2, field2) do { \ … … 478 502 CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, ea_size, all_info, all_info, ea_size); 479 503 480 CHECK_STR("SEARCH", search, name, alt_info, alt_name_info, fname); 481 CHECK_WSTR("BOTH_DIRECTORY_INFO", both_directory_info, short_name, alt_info, alt_name_info, fname, STR_UNICODE); 504 if (alt_info_supported) { 505 CHECK_STR("SEARCH", search, name, alt_info, alt_name_info, 506 fname); 507 CHECK_WSTR("BOTH_DIRECTORY_INFO", both_directory_info, 508 short_name, alt_info, alt_name_info, fname, STR_UNICODE); 509 } 482 510 483 511 CHECK_NAME("STANDARD", standard, name, fname+1, 0); … … 485 513 CHECK_NAME("DIRECTORY_INFO", directory_info, name, fname+1, STR_TERMINATE_ASCII); 486 514 CHECK_NAME("FULL_DIRECTORY_INFO", full_directory_info, name, fname+1, STR_TERMINATE_ASCII); 487 CHECK_NAME("NAME_INFO", name_info, name, fname+1, STR_TERMINATE_ASCII); 515 516 if (name_info_supported) { 517 CHECK_NAME("NAME_INFO", name_info, name, fname+1, 518 STR_TERMINATE_ASCII); 519 } 520 488 521 CHECK_NAME("BOTH_DIRECTORY_INFO", both_directory_info, name, fname+1, STR_TERMINATE_ASCII); 489 522 CHECK_NAME("ID_FULL_DIRECTORY_INFO", id_full_directory_info, name, fname+1, STR_TERMINATE_ASCII); … … 491 524 CHECK_UNIX_NAME("UNIX_INFO", unix_info, name, fname+1, STR_TERMINATE_ASCII); 492 525 493 CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info, file_id, internal_info, internal_information, file_id); 494 CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, file_id, internal_info, internal_information, file_id); 526 if (internal_info_supported) { 527 CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info, 528 file_id, internal_info, internal_information, file_id); 529 CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, 530 file_id, internal_info, internal_information, file_id); 531 } 495 532 496 533 done: … … 713 750 if ((search_types[t].cont_type == CONT_RESUME_KEY) && 714 751 (search_types[t].data_level != RAW_SEARCH_DATA_SEARCH) && 715 torture_setting_bool(tctx, "samba3", false)) {752 !torture_setting_bool(tctx, "resume_key_support", true)) { 716 753 torture_comment(tctx, 717 754 "SKIP: Continue %s via %s\n", … … 729 766 search_types[t].cont_type, 730 767 &result); 731 768 if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { 769 torture_warning(tctx, "search level %s not supported " 770 "by server", 771 search_types[t].name); 772 continue; 773 } 732 774 torture_assert_ntstatus_ok(tctx, status, "search failed"); 733 775 CHECK_VALUE(result.count, num_files); … … 735 777 compare_data_level = search_types[t].data_level; 736 778 737 qsort(result.list, result.count, sizeof(result.list[0]), 738 QSORT_CAST search_compare); 779 TYPESAFE_QSORT(result.list, result.count, search_compare); 739 780 740 781 for (i=0;i<result.count;i++) { … … 992 1033 union smb_search_data *file, *file2, *file3; 993 1034 1035 if (!torture_setting_bool(tctx, "raw_search_search", true)) { 1036 torture_comment(tctx, "Skipping these tests as the server " 1037 "doesn't support old style search calls\n"); 1038 return true; 1039 } 994 1040 if (!torture_setup_dir(cli, BASEDIR)) { 995 1041 return false; … … 1124 1170 } 1125 1171 1126 if (strcmp(file3[i].search.name, file2[i].search.name) != 0) { 1172 if (torture_setting_bool(tctx, "rewind_support", true) && 1173 strcmp(file3[i].search.name, file2[i].search.name) != 0) { 1127 1174 printf("(%s) server did not rewind - got '%s' expected '%s'\n", 1128 1175 __location__, file3[i].search.name, file2[i].search.name); … … 1160 1207 struct multiple_result result; 1161 1208 1209 if (!torture_setting_bool(tctx, "search_ea_size", true)){ 1210 torture_comment(tctx, 1211 "Server does not support RAW_SEARCH_EA_SIZE " 1212 "level. Skipping this test\n"); 1213 return true; 1214 } 1215 1162 1216 if (!torture_setup_dir(cli, BASEDIR)) { 1163 1217 return false; … … 1274 1328 1275 1329 printf("Testing RAW_SEARCH_EA_LIST level\n"); 1330 1331 if (!torture_setting_bool(tctx, "search_ea_support", true) || 1332 !torture_setting_bool(tctx, "ea_support", true)) { 1333 printf("..skipped per target configuration.\n"); 1334 return true; 1335 } 1276 1336 1277 1337 fnum = smbcli_open(cli->tree, BASEDIR "\\file1.txt", O_CREAT|O_RDWR, DENY_NONE); … … 1340 1400 /* we have to sort the result as different servers can return directories 1341 1401 in different orders */ 1342 qsort(result.list, result.count, sizeof(result.list[0]), 1343 (comparison_fn_t)ealist_cmp); 1402 TYPESAFE_QSORT(result.list, result.count, ealist_cmp); 1344 1403 1345 1404 CHECK_VALUE(result.count, 3); … … 1371 1430 } 1372 1431 1373 1432 /* 1433 Test the behavior of max count parameter in TRANS2_FIND_FIRST2 and 1434 TRANS2_FIND_NEXT2 queries 1435 */ 1436 static bool test_max_count(struct torture_context *tctx, 1437 struct smbcli_state *cli) 1438 { 1439 const int num_files = 2; 1440 int i, fnum; 1441 char *fname; 1442 bool ret = true; 1443 NTSTATUS status; 1444 struct multiple_result result; 1445 union smb_search_first io; 1446 union smb_search_next io2; 1447 1448 if (!torture_setup_dir(cli, BASEDIR)) { 1449 return false; 1450 } 1451 1452 torture_comment(tctx, "Creating %d files\n", num_files); 1453 1454 for (i=num_files-1;i>=0;i--) { 1455 fname = talloc_asprintf(cli, BASEDIR "\\t%03d-%d.txt", i, i); 1456 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE); 1457 if (fnum == -1) { 1458 torture_comment(tctx, 1459 "Failed to create %s - %s\n", 1460 fname, smbcli_errstr(cli->tree)); 1461 ret = false; 1462 goto done; 1463 } 1464 talloc_free(fname); 1465 smbcli_close(cli->tree, fnum); 1466 } 1467 1468 torture_comment(tctx, "Set max_count parameter to 0. " 1469 "This should return 1 entry\n"); 1470 ZERO_STRUCT(result); 1471 result.tctx = talloc_new(tctx); 1472 1473 io.t2ffirst.level = RAW_SEARCH_TRANS2; 1474 io.t2ffirst.data_level = RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO; 1475 io.t2ffirst.in.search_attrib = 0; 1476 io.t2ffirst.in.max_count = 0; 1477 io.t2ffirst.in.flags = 0; 1478 io.t2ffirst.in.storage_type = 0; 1479 io.t2ffirst.in.pattern = BASEDIR "\\*.*"; 1480 1481 status = smb_raw_search_first(cli->tree, tctx, 1482 &io, &result, multiple_search_callback); 1483 CHECK_STATUS(status, NT_STATUS_OK); 1484 CHECK_VALUE(result.count, 1); 1485 1486 torture_comment(tctx, "Set max_count to 1. This should also " 1487 "return 1 entry\n"); 1488 io2.t2fnext.level = RAW_SEARCH_TRANS2; 1489 io2.t2fnext.data_level = RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO; 1490 io2.t2fnext.in.handle = io.t2ffirst.out.handle; 1491 io2.t2fnext.in.max_count = 1; 1492 io2.t2fnext.in.resume_key = 0; 1493 io2.t2fnext.in.flags = 0; 1494 io2.t2fnext.in.last_name = 1495 result.list[result.count-1].both_directory_info.name.s; 1496 1497 status = smb_raw_search_next(cli->tree, tctx, 1498 &io2, &result, multiple_search_callback); 1499 CHECK_STATUS(status, NT_STATUS_OK); 1500 CHECK_VALUE(result.count, 2); 1501 done: 1502 smb_raw_exit(cli->session); 1503 smbcli_deltree(cli->tree, BASEDIR); 1504 1505 return ret; 1506 } 1374 1507 1375 1508 /* … … 1378 1511 struct torture_suite *torture_raw_search(TALLOC_CTX *mem_ctx) 1379 1512 { 1380 struct torture_suite *suite = torture_suite_create(mem_ctx, " SEARCH");1513 struct torture_suite *suite = torture_suite_create(mem_ctx, "search"); 1381 1514 1382 1515 torture_suite_add_1smb_test(suite, "one file search", test_one_file); … … 1387 1520 torture_suite_add_1smb_test(suite, "os2 delete", test_os2_delete); 1388 1521 torture_suite_add_1smb_test(suite, "ea list", test_ea_list); 1522 torture_suite_add_1smb_test(suite, "max count", test_max_count); 1389 1523 1390 1524 return suite; -
trunk/server/source4/torture/raw/seek.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "torture/torture.h"22 21 #include "system/filesys.h" 23 #include "libcli/raw/libcliraw.h"24 22 #include "libcli/libcli.h" 25 23 #include "torture/util.h" -
trunk/server/source4/torture/raw/setfileinfo.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "torture/torture.h"22 21 #include "system/time.h" 23 22 #include "libcli/raw/libcliraw.h" 24 #include "libcli/raw/raw_proto.h"25 23 #include "libcli/libcli.h" 26 24 #include "torture/util.h" 27 #include "torture/raw/proto.h"28 25 29 26 #define BASEDIR "\\testsfileinfo" … … 33 30 for consistency between the calls. 34 31 */ 35 bool torture_raw_sfileinfo(struct torture_context *torture, 36 32 static bool 33 torture_raw_sfileinfo_base(struct torture_context *torture, struct smbcli_state *cli) 37 34 { 38 35 bool ret = true; … … 83 80 sfinfo.generic.in.file.fnum = fnum; \ 84 81 status = smb_raw_setfileinfo(cli->tree, &sfinfo); \ 85 if (!NT_STATUS_EQUAL(status, rightstatus)) { \ 82 if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { \ 83 torture_warning(torture, \ 84 "(%s) %s - %s", __location__, #call, \ 85 nt_errstr(status)); \ 86 } else if (!NT_STATUS_EQUAL(status, rightstatus)) { \ 86 87 printf("(%s) %s - %s (should be %s)\n", __location__, #call, \ 87 88 nt_errstr(status), nt_errstr(rightstatus)); \ … … 91 92 finfo1.generic.in.file.fnum = fnum; \ 92 93 status2 = smb_raw_fileinfo(cli->tree, torture, &finfo1); \ 93 if (!NT_STATUS_IS_OK(status2)) { \ 94 if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { \ 95 torture_warning(torture, \ 96 "(%s) %s - %s", __location__, #call, \ 97 nt_errstr(status)); \ 98 } else if (!NT_STATUS_IS_OK(status2)) { \ 94 99 printf("(%s) %s pathinfo - %s\n", __location__, #call, nt_errstr(status)); \ 95 100 ret = false; \ … … 106 111 status = smb_raw_setpathinfo(cli->tree, &sfinfo); \ 107 112 } \ 108 if (!NT_STATUS_EQUAL(status, rightstatus)) { \ 113 if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { \ 114 torture_warning(torture, \ 115 "(%s) %s - %s", __location__, #call, \ 116 nt_errstr(status)); \ 117 } else if (!NT_STATUS_EQUAL(status, rightstatus)) { \ 109 118 printf("(%s) %s - %s (should be %s)\n", __location__, #call, \ 110 119 nt_errstr(status), nt_errstr(rightstatus)); \ … … 118 127 status2 = smb_raw_pathinfo(cli->tree, torture, &finfo1); \ 119 128 } \ 120 if (!NT_STATUS_IS_OK(status2)) { \ 129 if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { \ 130 torture_warning(torture, \ 131 "(%s) %s - %s", __location__, #call, \ 132 nt_errstr(status)); \ 133 } else if (!NT_STATUS_IS_OK(status2)) { \ 121 134 printf("(%s) %s pathinfo - %s\n", __location__, #call, nt_errstr(status2)); \ 122 135 ret = false; \ … … 148 161 printf("(%s) %s - %s/%s should be 0x%x - 0x%x\n", __location__, \ 149 162 call_name, #stype, #field, \ 150 (u int_t)value, (uint_t)finfo2.stype.out.field); \163 (unsigned int)value, (unsigned int)finfo2.stype.out.field); \ 151 164 dump_all_info(torture, &finfo1); \ 152 165 ret = false; \ … … 158 171 printf("(%s) %s - %s/%s should be 0x%x - 0x%x\n", __location__, \ 159 172 call_name, #stype, #field, \ 160 (u int_t)value, \161 (u int_t)nt_time_to_unix(finfo2.stype.out.field)); \173 (unsigned int)value, \ 174 (unsigned int)nt_time_to_unix(finfo2.stype.out.field)); \ 162 175 printf("\t%s", timestring(torture, value)); \ 163 176 printf("\t%s\n", nt_time_string(torture, finfo2.stype.out.field)); \ … … 186 199 187 200 188 printf(" test setattr\n");201 printf("Test setattr\n"); 189 202 sfinfo.setattr.in.attrib = FILE_ATTRIBUTE_READONLY; 190 203 sfinfo.setattr.in.write_time = basetime; … … 207 220 CHECK_TIME (ALL_INFO, all_info, write_time, basetime); 208 221 209 printf(" test setattre\n");222 printf("Test setattre\n"); 210 223 sfinfo.setattre.in.create_time = basetime + 20; 211 224 sfinfo.setattre.in.access_time = basetime + 30; … … 224 237 CHECK_TIME(ALL_INFO, all_info, write_time, basetime + 40); 225 238 226 printf(" test standard level\n");239 printf("Test standard level\n"); 227 240 sfinfo.standard.in.create_time = basetime + 100; 228 241 sfinfo.standard.in.access_time = basetime + 200; … … 233 246 CHECK_TIME(ALL_INFO, all_info, write_time, basetime + 300); 234 247 235 printf(" test basic_info level\n");248 printf("Test basic_info level\n"); 236 249 basetime += 86400; 237 250 unix_to_nt_time(&sfinfo.basic_info.in.create_time, basetime + 100); … … 260 273 CHECK_VALUE(ALL_INFO, all_info, attrib, FILE_ATTRIBUTE_READONLY); 261 274 262 printf(" test basic_information level\n");275 printf("Test basic_information level\n"); 263 276 basetime += 86400; 264 277 unix_to_nt_time(&sfinfo.basic_info.in.create_time, basetime + 100); … … 281 294 CHECK_VALUE(ALL_INFO, all_info, attrib, FILE_ATTRIBUTE_NORMAL); 282 295 296 torture_comment(torture, "try to change a file to a directory\n"); 297 sfinfo.basic_info.in.attrib = FILE_ATTRIBUTE_DIRECTORY; 298 CHECK_CALL_FNUM(BASIC_INFO, NT_STATUS_INVALID_PARAMETER); 299 283 300 printf("a zero time means don't change\n"); 284 301 unix_to_nt_time(&sfinfo.basic_info.in.create_time, 0); … … 305 322 CHECK_VALUE(ALL_INFO, all_info, attrib, FILE_ATTRIBUTE_NORMAL); 306 323 307 printf(" test disposition_info level\n");324 printf("Test disposition_info level\n"); 308 325 sfinfo.disposition_info.in.delete_on_close = 1; 309 326 CHECK_CALL_FNUM(DISPOSITION_INFO, NT_STATUS_OK); … … 316 333 CHECK_VALUE(ALL_INFO, all_info, nlink, 1); 317 334 318 printf(" test disposition_information level\n");335 printf("Test disposition_information level\n"); 319 336 sfinfo.disposition_info.in.delete_on_close = 1; 320 337 CHECK_CALL_FNUM(DISPOSITION_INFORMATION, NT_STATUS_OK); … … 338 355 CHECK_VALUE(ALL_INFO, all_info, nlink, 1); 339 356 340 printf(" test allocation_info level\n");357 printf("Test allocation_info level\n"); 341 358 sfinfo.allocation_info.in.alloc_size = 0; 342 359 CHECK_CALL_FNUM(ALLOCATION_INFO, NT_STATUS_OK); … … 370 387 CHECK_VALUE(ALL_INFO, all_info, size, 0); 371 388 372 printf(" test end_of_file_info level\n");389 printf("Test end_of_file_info level\n"); 373 390 sfinfo.end_of_file_info.in.size = 37; 374 391 CHECK_CALL_FNUM(END_OF_FILE_INFO, NT_STATUS_OK); … … 393 410 CHECK_VALUE(ALL_INFO, all_info, size, 7); 394 411 395 printf(" test position_information level\n");412 printf("Test position_information level\n"); 396 413 sfinfo.position_information.in.position = 123456; 397 414 CHECK_CALL_FNUM(POSITION_INFORMATION, NT_STATUS_OK); … … 401 418 CHECK_VALUE(POSITION_INFORMATION, position_information, position, 0); 402 419 403 printf(" test mode_information level\n");420 printf("Test mode_information level\n"); 404 421 sfinfo.mode_information.in.mode = 2; 405 422 CHECK_CALL_FNUM(MODE_INFORMATION, NT_STATUS_OK); … … 421 438 422 439 #if 0 423 printf(" test unix_basic level\n");440 printf("Test unix_basic level\n"); 424 441 CHECK_CALL_FNUM(UNIX_BASIC, NT_STATUS_OK); 425 442 CHECK_CALL_PATH(UNIX_BASIC, NT_STATUS_OK); 426 443 427 printf(" test unix_link level\n");444 printf("Test unix_link level\n"); 428 445 CHECK_CALL_FNUM(UNIX_LINK, NT_STATUS_OK); 429 446 CHECK_CALL_PATH(UNIX_LINK, NT_STATUS_OK); … … 446 463 * basic testing of all RAW_SFILEINFO_RENAME call 447 464 */ 448 bool torture_raw_sfileinfo_rename(struct torture_context *torture, 449 struct smbcli_state *cli) 465 static bool 466 torture_raw_sfileinfo_rename(struct torture_context *torture, 467 struct smbcli_state *cli) 450 468 { 451 469 bool ret = true; … … 673 691 look for the w2k3 setpathinfo STANDARD bug 674 692 */ 675 bool torture_raw_sfileinfo_bug(struct torture_context *torture,676 693 static bool torture_raw_sfileinfo_bug(struct torture_context *torture, 694 struct smbcli_state *cli) 677 695 { 678 696 const char *fname = "\\bug3.txt"; … … 702 720 return true; 703 721 } 722 723 /** 724 * Test both the snia cifs RAW_SFILEINFO_END_OF_FILE_INFO and the undocumented 725 * pass-through RAW_SFILEINFO_END_OF_FILE_INFORMATION in the context of 726 * trans2setpathinfo. 727 */ 728 static bool 729 torture_raw_sfileinfo_eof(struct torture_context *tctx, 730 struct smbcli_state *cli1, struct smbcli_state *cli2) 731 { 732 const char *fname = BASEDIR "\\test_sfileinfo_end_of_file.dat"; 733 NTSTATUS status; 734 bool ret = true; 735 union smb_open io; 736 union smb_setfileinfo sfi; 737 union smb_fileinfo qfi; 738 uint16_t fnum = 0; 739 740 if (!torture_setup_dir(cli1, BASEDIR)) { 741 return false; 742 } 743 744 /* cleanup */ 745 smbcli_unlink(cli1->tree, fname); 746 747 io.generic.level = RAW_OPEN_NTCREATEX; 748 io.ntcreatex.in.root_fid.fnum = 0; 749 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 750 io.ntcreatex.in.alloc_size = 0; 751 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 752 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; 753 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; 754 io.ntcreatex.in.create_options = 0; 755 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 756 io.ntcreatex.in.security_flags = 0; 757 io.ntcreatex.in.fname = fname; 758 io.ntcreatex.in.flags = 0; 759 760 /* Open the file sharing none. */ 761 status = smb_raw_open(cli1->tree, tctx, &io); 762 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, 763 done, "Status should be OK"); 764 fnum = io.ntcreatex.out.file.fnum; 765 766 /* Try to sfileinfo to extend the file. */ 767 ZERO_STRUCT(sfi); 768 sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFO; 769 sfi.generic.in.file.path = fname; 770 sfi.end_of_file_info.in.size = 100; 771 status = smb_raw_setpathinfo(cli2->tree, &sfi); 772 773 /* There should be share mode contention in this case. */ 774 torture_assert_ntstatus_equal_goto(tctx, status, 775 NT_STATUS_SHARING_VIOLATION, ret, done, "Status should be " 776 "SHARING_VIOLATION"); 777 778 /* Make sure the size is still 0. */ 779 ZERO_STRUCT(qfi); 780 qfi.generic.level = RAW_FILEINFO_STANDARD_INFO; 781 qfi.generic.in.file.path = fname; 782 status = smb_raw_pathinfo(cli2->tree, tctx, &qfi); 783 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, 784 done, "Status should be OK"); 785 786 torture_assert_u64_equal(tctx, qfi.standard_info.out.size, 0, 787 "alloc_size should be 0 since the setpathinfo failed."); 788 789 /* Try again with the pass through instead of documented version. */ 790 ZERO_STRUCT(sfi); 791 sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; 792 sfi.generic.in.file.path = fname; 793 sfi.end_of_file_info.in.size = 100; 794 status = smb_raw_setpathinfo(cli2->tree, &sfi); 795 796 /* 797 * Looks like a windows bug: 798 * http://lists.samba.org/archive/cifs-protocol/2009-November/001130.html 799 */ 800 if (TARGET_IS_W2K8(tctx) || TARGET_IS_WIN7(tctx)) { 801 /* It succeeds! This is just weird! */ 802 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, 803 ret, done, "Status should be OK"); 804 805 /* Verify that the file was actually extended to 100. */ 806 ZERO_STRUCT(qfi); 807 qfi.generic.level = RAW_FILEINFO_STANDARD_INFO; 808 qfi.generic.in.file.path = fname; 809 status = smb_raw_pathinfo(cli2->tree, tctx, &qfi); 810 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, 811 ret, done, "Status should be OK"); 812 813 torture_assert_u64_equal(tctx, qfi.standard_info.out.size, 100, 814 "alloc_size should be 100 since the setpathinfo " 815 "succeeded."); 816 } else { 817 torture_assert_ntstatus_equal_goto(tctx, status, 818 NT_STATUS_SHARING_VIOLATION, ret, done, "Status should be " 819 "SHARING_VIOLATION"); 820 } 821 822 /* close the first file. */ 823 smbcli_close(cli1->tree, fnum); 824 fnum = 0; 825 826 /* Try to sfileinfo to extend the file again (non-pass-through). */ 827 ZERO_STRUCT(sfi); 828 sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFO; 829 sfi.generic.in.file.path = fname; 830 sfi.end_of_file_info.in.size = 200; 831 status = smb_raw_setpathinfo(cli2->tree, &sfi); 832 833 /* This should cause the client to retun invalid level. */ 834 if (TARGET_IS_W2K8(tctx) || TARGET_IS_WIN7(tctx)) { 835 /* 836 * Windows sends back an invalid packet that smbclient sees 837 * and returns INTERNAL_ERROR. 838 */ 839 torture_assert_ntstatus_equal_goto(tctx, status, 840 NT_STATUS_INTERNAL_ERROR, ret, done, "Status should be " 841 "INTERNAL_ERROR"); 842 } else { 843 torture_assert_ntstatus_equal_goto(tctx, status, 844 NT_STATUS_INVALID_LEVEL, ret, done, "Status should be " 845 "INVALID_LEVEL"); 846 } 847 848 /* Try to extend the file now with the passthrough level. */ 849 sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; 850 status = smb_raw_setpathinfo(cli2->tree, &sfi); 851 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, 852 done, "Status should be OK"); 853 854 /* Verify that the file was actually extended to 200. */ 855 ZERO_STRUCT(qfi); 856 qfi.generic.level = RAW_FILEINFO_STANDARD_INFO; 857 qfi.generic.in.file.path = fname; 858 status = smb_raw_pathinfo(cli2->tree, tctx, &qfi); 859 860 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, 861 done, "Status should be OK"); 862 torture_assert_u64_equal(tctx, qfi.standard_info.out.size, 200, 863 "alloc_size should be 200 since the setpathinfo succeeded."); 864 865 /* Open the file so end of file can be set by handle. */ 866 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_WRITE; 867 status = smb_raw_open(cli1->tree, tctx, &io); 868 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, 869 done, "Status should be OK"); 870 fnum = io.ntcreatex.out.file.fnum; 871 872 /* Try sfileinfo to extend the file by handle (non-pass-through). */ 873 ZERO_STRUCT(sfi); 874 sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFO; 875 sfi.generic.in.file.fnum = fnum; 876 sfi.end_of_file_info.in.size = 300; 877 status = smb_raw_setfileinfo(cli1->tree, &sfi); 878 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, 879 done, "Status should be OK"); 880 881 /* Verify that the file was actually extended to 300. */ 882 ZERO_STRUCT(qfi); 883 qfi.generic.level = RAW_FILEINFO_STANDARD_INFO; 884 qfi.generic.in.file.path = fname; 885 status = smb_raw_pathinfo(cli1->tree, tctx, &qfi); 886 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, 887 done, "Status should be OK"); 888 torture_assert_u64_equal(tctx, qfi.standard_info.out.size, 300, 889 "alloc_size should be 300 since the setpathinfo succeeded."); 890 891 /* Try sfileinfo to extend the file by handle (pass-through). */ 892 ZERO_STRUCT(sfi); 893 sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; 894 sfi.generic.in.file.fnum = fnum; 895 sfi.end_of_file_info.in.size = 400; 896 status = smb_raw_setfileinfo(cli1->tree, &sfi); 897 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, 898 done, "Status should be OK"); 899 900 /* Verify that the file was actually extended to 300. */ 901 ZERO_STRUCT(qfi); 902 qfi.generic.level = RAW_FILEINFO_STANDARD_INFO; 903 qfi.generic.in.file.path = fname; 904 status = smb_raw_pathinfo(cli1->tree, tctx, &qfi); 905 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, 906 done, "Status should be OK"); 907 torture_assert_u64_equal(tctx, qfi.standard_info.out.size, 400, 908 "alloc_size should be 400 since the setpathinfo succeeded."); 909 done: 910 if (fnum > 0) { 911 smbcli_close(cli1->tree, fnum); 912 fnum = 0; 913 } 914 915 smb_raw_exit(cli1->session); 916 smb_raw_exit(cli2->session); 917 smbcli_deltree(cli1->tree, BASEDIR); 918 return ret; 919 } 920 921 static bool 922 torture_raw_sfileinfo_eof_access(struct torture_context *tctx, 923 struct smbcli_state *cli1, struct smbcli_state *cli2) 924 { 925 const char *fname = BASEDIR "\\test_exclusive3.dat"; 926 NTSTATUS status, expected_status; 927 bool ret = true; 928 union smb_open io; 929 union smb_setfileinfo sfi; 930 uint16_t fnum=0; 931 uint32_t access_mask = 0; 932 933 if (!torture_setup_dir(cli1, BASEDIR)) { 934 return false; 935 } 936 937 /* cleanup */ 938 smbcli_unlink(cli1->tree, fname); 939 940 /* 941 * base ntcreatex parms 942 */ 943 io.generic.level = RAW_OPEN_NTCREATEX; 944 io.ntcreatex.in.root_fid.fnum = 0; 945 io.ntcreatex.in.alloc_size = 0; 946 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 947 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; 948 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; 949 io.ntcreatex.in.create_options = 0; 950 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 951 io.ntcreatex.in.security_flags = 0; 952 io.ntcreatex.in.fname = fname; 953 io.ntcreatex.in.flags = 0; 954 955 956 for (access_mask = 1; access_mask <= 0x00001FF; access_mask++) { 957 io.ntcreatex.in.access_mask = access_mask; 958 959 status = smb_raw_open(cli1->tree, tctx, &io); 960 if (!NT_STATUS_IS_OK(status)) { 961 continue; 962 } 963 964 fnum = io.ntcreatex.out.file.fnum; 965 966 ZERO_STRUCT(sfi); 967 sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFO; 968 sfi.generic.in.file.fnum = fnum; 969 sfi.end_of_file_info.in.size = 100; 970 971 status = smb_raw_setfileinfo(cli1->tree, &sfi); 972 973 expected_status = (access_mask & SEC_FILE_WRITE_DATA) ? 974 NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; 975 976 if (!NT_STATUS_EQUAL(expected_status, status)) { 977 torture_comment(tctx, "0x%x wrong\n", access_mask); 978 } 979 980 torture_assert_ntstatus_equal_goto(tctx, status, 981 expected_status, ret, done, "Status Wrong"); 982 983 smbcli_close(cli1->tree, fnum); 984 } 985 986 done: 987 smb_raw_exit(cli1->session); 988 smb_raw_exit(cli2->session); 989 smbcli_deltree(cli1->tree, BASEDIR); 990 return ret; 991 } 992 993 static bool 994 torture_raw_sfileinfo_archive(struct torture_context *tctx, 995 struct smbcli_state *cli) 996 { 997 const char *fname = BASEDIR "\\test_archive.dat"; 998 NTSTATUS status; 999 bool ret = true; 1000 union smb_open io; 1001 union smb_setfileinfo sfinfo; 1002 union smb_fileinfo finfo; 1003 uint16_t fnum=0; 1004 1005 if (!torture_setup_dir(cli, BASEDIR)) { 1006 return false; 1007 } 1008 1009 /* cleanup */ 1010 smbcli_unlink(cli->tree, fname); 1011 1012 /* 1013 * create a normal file, verify archive bit 1014 */ 1015 io.generic.level = RAW_OPEN_NTCREATEX; 1016 io.ntcreatex.in.root_fid.fnum = 0; 1017 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 1018 io.ntcreatex.in.alloc_size = 0; 1019 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 1020 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; 1021 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; 1022 io.ntcreatex.in.create_options = 0; 1023 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 1024 io.ntcreatex.in.security_flags = 0; 1025 io.ntcreatex.in.fname = fname; 1026 io.ntcreatex.in.flags = 0; 1027 status = smb_raw_open(cli->tree, tctx, &io); 1028 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, 1029 ret, done, "open failed"); 1030 fnum = io.ntcreatex.out.file.fnum; 1031 1032 torture_assert_int_equal(tctx, 1033 io.ntcreatex.out.attrib & ~FILE_ATTRIBUTE_NONINDEXED, 1034 FILE_ATTRIBUTE_ARCHIVE, 1035 "archive bit not set"); 1036 1037 /* 1038 * try to turn off archive bit 1039 */ 1040 ZERO_STRUCT(sfinfo); 1041 sfinfo.generic.level = RAW_SFILEINFO_BASIC_INFO; 1042 sfinfo.generic.in.file.fnum = fnum; 1043 sfinfo.basic_info.in.attrib = FILE_ATTRIBUTE_NORMAL; 1044 status = smb_raw_setfileinfo(cli->tree, &sfinfo); 1045 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, 1046 ret, done, "setfileinfo failed"); 1047 1048 finfo.generic.level = RAW_FILEINFO_ALL_INFO; 1049 finfo.generic.in.file.fnum = fnum; 1050 status = smb_raw_fileinfo(cli->tree, tctx, &finfo); 1051 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, 1052 ret, done, "fileinfo failed"); 1053 1054 torture_assert_int_equal(tctx, 1055 finfo.all_info.out.attrib & ~FILE_ATTRIBUTE_NONINDEXED, 1056 FILE_ATTRIBUTE_NORMAL, 1057 "archive bit set"); 1058 1059 status = smbcli_close(cli->tree, fnum); 1060 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, 1061 ret, done, "close failed"); 1062 1063 status = smbcli_unlink(cli->tree, fname); 1064 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, 1065 ret, done, "unlink failed"); 1066 1067 /* 1068 * create a directory, verify no archive bit 1069 */ 1070 io.generic.level = RAW_OPEN_NTCREATEX; 1071 io.ntcreatex.in.root_fid.fnum = 0; 1072 io.ntcreatex.in.access_mask = SEC_RIGHTS_DIR_ALL; 1073 io.ntcreatex.in.alloc_size = 0; 1074 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY; 1075 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; 1076 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; 1077 io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; 1078 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 1079 io.ntcreatex.in.security_flags = 0; 1080 io.ntcreatex.in.fname = fname; 1081 io.ntcreatex.in.flags = 0; 1082 status = smb_raw_open(cli->tree, tctx, &io); 1083 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, 1084 ret, done, "directory open failed"); 1085 fnum = io.ntcreatex.out.file.fnum; 1086 1087 torture_assert_int_equal(tctx, 1088 io.ntcreatex.out.attrib & ~FILE_ATTRIBUTE_NONINDEXED, 1089 FILE_ATTRIBUTE_DIRECTORY, 1090 "archive bit set"); 1091 1092 /* 1093 * verify you can turn on archive bit 1094 */ 1095 sfinfo.generic.level = RAW_SFILEINFO_BASIC_INFO; 1096 sfinfo.generic.in.file.fnum = fnum; 1097 sfinfo.basic_info.in.attrib = FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_ARCHIVE; 1098 status = smb_raw_setfileinfo(cli->tree, &sfinfo); 1099 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, 1100 ret, done, "setfileinfo failed"); 1101 1102 finfo.generic.level = RAW_FILEINFO_ALL_INFO; 1103 finfo.generic.in.file.fnum = fnum; 1104 status = smb_raw_fileinfo(cli->tree, tctx, &finfo); 1105 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, 1106 ret, done, "fileinfo failed"); 1107 1108 torture_assert_int_equal(tctx, 1109 finfo.all_info.out.attrib & ~FILE_ATTRIBUTE_NONINDEXED, 1110 FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_ARCHIVE, 1111 "archive bit not set"); 1112 1113 /* 1114 * and try to turn it back off 1115 */ 1116 sfinfo.generic.level = RAW_SFILEINFO_BASIC_INFO; 1117 sfinfo.generic.in.file.fnum = fnum; 1118 sfinfo.basic_info.in.attrib = FILE_ATTRIBUTE_DIRECTORY; 1119 status = smb_raw_setfileinfo(cli->tree, &sfinfo); 1120 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, 1121 ret, done, "setfileinfo failed"); 1122 1123 finfo.generic.level = RAW_FILEINFO_ALL_INFO; 1124 finfo.generic.in.file.fnum = fnum; 1125 status = smb_raw_fileinfo(cli->tree, tctx, &finfo); 1126 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, 1127 ret, done, "fileinfo failed"); 1128 1129 torture_assert_int_equal(tctx, 1130 finfo.all_info.out.attrib & ~FILE_ATTRIBUTE_NONINDEXED, 1131 FILE_ATTRIBUTE_DIRECTORY, 1132 "archive bit set"); 1133 1134 status = smbcli_close(cli->tree, fnum); 1135 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, 1136 ret, done, "close failed"); 1137 1138 done: 1139 smbcli_close(cli->tree, fnum); 1140 smbcli_deltree(cli->tree, BASEDIR); 1141 return ret; 1142 } 1143 1144 struct torture_suite *torture_raw_sfileinfo(TALLOC_CTX *mem_ctx) 1145 { 1146 struct torture_suite *suite = torture_suite_create(mem_ctx, "sfileinfo"); 1147 1148 torture_suite_add_1smb_test(suite, "base", torture_raw_sfileinfo_base); 1149 torture_suite_add_1smb_test(suite, "rename", torture_raw_sfileinfo_rename); 1150 torture_suite_add_1smb_test(suite, "bug", torture_raw_sfileinfo_bug); 1151 torture_suite_add_2smb_test(suite, "end-of-file", 1152 torture_raw_sfileinfo_eof); 1153 torture_suite_add_2smb_test(suite, "end-of-file-access", 1154 torture_raw_sfileinfo_eof_access); 1155 torture_suite_add_1smb_test(suite, "archive", 1156 torture_raw_sfileinfo_archive); 1157 1158 return suite; 1159 } -
trunk/server/source4/torture/raw/streams.c
r414 r745 27 27 #include "libcli/libcli.h" 28 28 #include "torture/util.h" 29 #include "lib/util/tsort.h" 29 30 30 31 #define BASEDIR "\\teststreams" 31 32 32 #define CHECK_STATUS(status, correct) do { \ 33 if (!NT_STATUS_EQUAL(status, correct)) { \ 34 printf("(%s) Incorrect status %s - should be %s\n", \ 35 __location__, nt_errstr(status), nt_errstr(correct)); \ 36 ret = false; \ 37 goto done; \ 38 }} while (0) 39 40 #define CHECK_VALUE(v, correct) do { \ 41 if ((v) != (correct)) { \ 42 printf("(%s) Incorrect value %s=%d - should be %d\n", \ 43 __location__, #v, (int)v, (int)correct); \ 44 ret = false; \ 45 }} while (0) 46 47 #define CHECK_NTTIME(v, correct) do { \ 48 if ((v) != (correct)) { \ 49 printf("(%s) Incorrect value %s=%llu - should be %llu\n", \ 50 __location__, #v, (unsigned long long)v, \ 51 (unsigned long long)correct); \ 52 ret = false; \ 53 }} while (0) 33 #define CHECK_STATUS(status, correct) \ 34 torture_assert_ntstatus_equal_goto(tctx,status,correct,ret,done,"CHECK_STATUS") 35 36 #define CHECK_VALUE(v, correct) \ 37 torture_assert_int_equal(tctx,v,correct,"CHECK_VALUE") 38 39 #define CHECK_NTTIME(v, correct) \ 40 torture_assert_u64_equal(tctx,v,correct,"CHECK_NTTIME") 54 41 55 42 #define CHECK_STR(v, correct) do { \ … … 66 53 ok = false; \ 67 54 } \ 68 if (!ok) { \ 69 printf("(%s) Incorrect value %s='%s' - should be '%s'\n", \ 70 __location__, #v, (v)?(v):"NULL", \ 71 (correct)?(correct):"NULL"); \ 72 ret = false; \ 73 }} while (0) 55 torture_assert(tctx,ok,\ 56 talloc_asprintf(tctx, "got '%s', expected '%s'",\ 57 (v)?(v):"NULL", (correct)?(correct):"NULL")); \ 58 } while (0) 74 59 75 60 /* … … 123 108 } 124 109 125 static int qsort_string(c onst void *v1, const void *v2)110 static int qsort_string(char * const *s1, char * const *s2) 126 111 { 127 char * const *s1 = v1;128 char * const *s2 = v2;129 112 return strcmp(*s1, *s2); 130 113 } 131 114 132 static int qsort_stream(const void *v1, const void *v2)115 static int qsort_stream(const struct stream_struct *s1, const struct stream_struct *s2) 133 116 { 134 const struct stream_struct * s1 = v1;135 const struct stream_struct * s2 = v2;136 117 return strcmp(s1->stream_name.s, s2->stream_name.s); 137 118 } 138 119 139 static bool check_stream_list(struct smbcli_state *cli, const char *fname, 120 static bool check_stream_list(struct torture_context *tctx, 121 struct smbcli_state *cli, const char *fname, 140 122 int num_exp, const char **exp) 141 123 { … … 147 129 struct stream_struct *stream_sort; 148 130 bool ret = false; 131 int fail = -1; 149 132 150 133 finfo.generic.level = RAW_FILEINFO_STREAM_INFO; … … 152 135 153 136 status = smb_raw_pathinfo(cli->tree, tmp_ctx, &finfo); 154 if (!NT_STATUS_IS_OK(status)) { 155 d_fprintf(stderr, "(%s) smb_raw_pathinfo failed: %s\n", 156 __location__, nt_errstr(status)); 157 goto fail; 158 } 159 160 if (finfo.stream_info.out.num_streams != num_exp) { 161 d_fprintf(stderr, "(%s) expected %d streams, got %d\n", 162 __location__, num_exp, 163 finfo.stream_info.out.num_streams); 164 goto fail; 165 } 137 CHECK_STATUS(status, NT_STATUS_OK); 138 139 CHECK_VALUE(finfo.stream_info.out.num_streams, num_exp); 166 140 167 141 if (num_exp == 0) { 168 142 ret = true; 169 goto fail;170 } 171 172 exp_sort = talloc_memdup(tmp_ctx, exp, num_exp * sizeof(*exp));143 goto done; 144 } 145 146 exp_sort = (char **)talloc_memdup(tmp_ctx, exp, num_exp * sizeof(*exp)); 173 147 174 148 if (exp_sort == NULL) { 175 goto fail; 176 } 177 178 qsort(exp_sort, num_exp, sizeof(*exp_sort), qsort_string); 179 180 stream_sort = talloc_memdup(tmp_ctx, finfo.stream_info.out.streams, 181 finfo.stream_info.out.num_streams * 182 sizeof(*stream_sort)); 149 goto done; 150 } 151 152 TYPESAFE_QSORT(exp_sort, num_exp, qsort_string); 153 154 stream_sort = (struct stream_struct *)talloc_memdup(tmp_ctx, 155 finfo.stream_info.out.streams, 156 finfo.stream_info.out.num_streams * 157 sizeof(*stream_sort)); 183 158 184 159 if (stream_sort == NULL) { 185 goto fail; 186 } 187 188 qsort(stream_sort, finfo.stream_info.out.num_streams, 189 sizeof(*stream_sort), qsort_stream); 160 goto done; 161 } 162 163 TYPESAFE_QSORT(stream_sort, finfo.stream_info.out.num_streams, qsort_stream); 190 164 191 165 for (i=0; i<num_exp; i++) { 192 166 if (strcmp(exp_sort[i], stream_sort[i].stream_name.s) != 0) { 193 d_fprintf(stderr, "(%s) expected stream name %s, got " 194 "%s\n", __location__, exp_sort[i], 195 stream_sort[i].stream_name.s); 196 goto fail; 167 fail = i; 168 goto show_streams; 197 169 } 198 170 } 199 171 200 172 ret = true; 201 fail: 173 done: 174 talloc_free(tmp_ctx); 175 return ret; 176 177 show_streams: 178 for (i=0; i<num_exp; i++) { 179 torture_comment(tctx, "stream names '%s' '%s'\n", 180 exp_sort[i], stream_sort[i].stream_name.s); 181 } 182 CHECK_STR(stream_sort[fail].stream_name.s, exp_sort[fail]); 202 183 talloc_free(tmp_ctx); 203 184 return ret; … … 208 189 */ 209 190 static bool test_stream_dir(struct torture_context *tctx, 210 struct smbcli_state *cli , TALLOC_CTX *mem_ctx)191 struct smbcli_state *cli) 211 192 { 212 193 NTSTATUS status; … … 217 198 const char *basedir_data; 218 199 219 basedir_data = talloc_asprintf(mem_ctx, "%s::$DATA", BASEDIR); 220 sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One"); 200 if (!torture_setup_dir(cli, BASEDIR)) { 201 return false; 202 } 203 204 basedir_data = talloc_asprintf(tctx, "%s::$DATA", BASEDIR); 205 sname1 = talloc_asprintf(tctx, "%s:%s", fname, "Stream One"); 221 206 222 207 printf("(%s) opening non-existant directory stream\n", __location__); 223 208 io.generic.level = RAW_OPEN_NTCREATEX; 224 io.ntcreatex.in.root_fid = 0;209 io.ntcreatex.in.root_fid.fnum = 0; 225 210 io.ntcreatex.in.flags = 0; 226 211 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; … … 233 218 io.ntcreatex.in.security_flags = 0; 234 219 io.ntcreatex.in.fname = sname1; 235 status = smb_raw_open(cli->tree, mem_ctx, &io);220 status = smb_raw_open(cli->tree, tctx, &io); 236 221 CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY); 237 222 238 223 printf("(%s) opening basedir stream\n", __location__); 239 224 io.generic.level = RAW_OPEN_NTCREATEX; 240 io.ntcreatex.in.root_fid = 0;225 io.ntcreatex.in.root_fid.fnum = 0; 241 226 io.ntcreatex.in.flags = 0; 242 227 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; … … 249 234 io.ntcreatex.in.security_flags = 0; 250 235 io.ntcreatex.in.fname = basedir_data; 251 status = smb_raw_open(cli->tree, mem_ctx, &io);236 status = smb_raw_open(cli->tree, tctx, &io); 252 237 CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY); 253 238 254 239 printf("(%s) opening basedir ::$DATA stream\n", __location__); 255 240 io.generic.level = RAW_OPEN_NTCREATEX; 256 io.ntcreatex.in.root_fid = 0;241 io.ntcreatex.in.root_fid.fnum = 0; 257 242 io.ntcreatex.in.flags = 0x10; 258 243 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; … … 265 250 io.ntcreatex.in.security_flags = 0; 266 251 io.ntcreatex.in.fname = basedir_data; 267 status = smb_raw_open(cli->tree, mem_ctx, &io);252 status = smb_raw_open(cli->tree, tctx, &io); 268 253 CHECK_STATUS(status, NT_STATUS_FILE_IS_A_DIRECTORY); 269 254 270 255 printf("(%s) list the streams on the basedir\n", __location__); 271 ret &= check_stream_list( cli, BASEDIR, 0, NULL);256 ret &= check_stream_list(tctx, cli, BASEDIR, 0, NULL); 272 257 done: 258 smbcli_deltree(cli->tree, BASEDIR); 273 259 return ret; 274 260 } … … 278 264 */ 279 265 static bool test_stream_io(struct torture_context *tctx, 280 struct smbcli_state *cli , TALLOC_CTX *mem_ctx)266 struct smbcli_state *cli) 281 267 { 282 268 NTSTATUS status; … … 293 279 ":Second Stream:$DATA" }; 294 280 295 sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One"); 296 sname2 = talloc_asprintf(mem_ctx, "%s:%s:$DaTa", fname, "Second Stream"); 281 if (!torture_setup_dir(cli, BASEDIR)) { 282 return false; 283 } 284 285 sname1 = talloc_asprintf(tctx, "%s:%s", fname, "Stream One"); 286 sname2 = talloc_asprintf(tctx, "%s:%s:$DaTa", fname, "Second Stream"); 297 287 298 288 printf("(%s) creating a stream on a non-existant file\n", __location__); 299 289 io.generic.level = RAW_OPEN_NTCREATEX; 300 io.ntcreatex.in.root_fid = 0;290 io.ntcreatex.in.root_fid.fnum = 0; 301 291 io.ntcreatex.in.flags = 0; 302 292 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; … … 309 299 io.ntcreatex.in.security_flags = 0; 310 300 io.ntcreatex.in.fname = sname1; 311 status = smb_raw_open(cli->tree, mem_ctx, &io);301 status = smb_raw_open(cli->tree, tctx, &io); 312 302 CHECK_STATUS(status, NT_STATUS_OK); 313 303 fnum = io.ntcreatex.out.file.fnum; 314 304 315 ret &= check_stream(cli, __location__, mem_ctx, fname, "Stream One", NULL);305 ret &= check_stream(cli, __location__, tctx, fname, "Stream One", NULL); 316 306 317 307 printf("(%s) check that open of base file is allowed\n", __location__); 318 308 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; 319 309 io.ntcreatex.in.fname = fname; 320 status = smb_raw_open(cli->tree, mem_ctx, &io);310 status = smb_raw_open(cli->tree, tctx, &io); 321 311 CHECK_STATUS(status, NT_STATUS_OK); 322 312 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); … … 328 318 smbcli_close(cli->tree, fnum); 329 319 330 ret &= check_stream(cli, __location__, mem_ctx, fname, "Stream One", "test data");320 ret &= check_stream(cli, __location__, tctx, fname, "Stream One", "test data"); 331 321 332 322 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; 333 323 io.ntcreatex.in.fname = sname1; 334 status = smb_raw_open(cli->tree, mem_ctx, &io);324 status = smb_raw_open(cli->tree, tctx, &io); 335 325 CHECK_STATUS(status, NT_STATUS_OK); 336 326 fnum = io.ntcreatex.out.file.fnum; … … 342 332 smbcli_close(cli->tree, fnum); 343 333 344 ret &= check_stream(cli, __location__, mem_ctx, fname, "Stream One:$FOO", NULL);334 ret &= check_stream(cli, __location__, tctx, fname, "Stream One:$FOO", NULL); 345 335 346 336 printf("(%s) creating a stream2 on a existing file\n", __location__); 347 337 io.ntcreatex.in.fname = sname2; 348 338 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; 349 status = smb_raw_open(cli->tree, mem_ctx, &io);339 status = smb_raw_open(cli->tree, tctx, &io); 350 340 CHECK_STATUS(status, NT_STATUS_OK); 351 341 fnum = io.ntcreatex.out.file.fnum; … … 357 347 smbcli_close(cli->tree, fnum); 358 348 359 ret &= check_stream(cli, __location__, mem_ctx, fname, "Stream One", "test MORE DATA "); 360 ret &= check_stream(cli, __location__, mem_ctx, fname, "Stream One:$DATA", "test MORE DATA "); 361 ret &= check_stream(cli, __location__, mem_ctx, fname, "Stream One:", NULL); 362 ret &= check_stream(cli, __location__, mem_ctx, fname, "Second Stream", "SECOND STREAM"); 363 if (!torture_setting_bool(tctx, "samba4", false)) { 364 ret &= check_stream(cli, __location__, mem_ctx, fname, 365 "SECOND STREAM:$DATA", "SECOND STREAM"); 366 } 367 ret &= check_stream(cli, __location__, mem_ctx, fname, "Second Stream:$DATA", "SECOND STREAM"); 368 ret &= check_stream(cli, __location__, mem_ctx, fname, "Second Stream:", NULL); 369 ret &= check_stream(cli, __location__, mem_ctx, fname, "Second Stream:$FOO", NULL); 370 371 check_stream_list(cli, fname, 3, three); 349 ret &= check_stream(cli, __location__, tctx, fname, "Stream One", "test MORE DATA "); 350 ret &= check_stream(cli, __location__, tctx, fname, "Stream One:$DATA", "test MORE DATA "); 351 ret &= check_stream(cli, __location__, tctx, fname, "Stream One:", NULL); 352 ret &= check_stream(cli, __location__, tctx, fname, "Second Stream", "SECOND STREAM"); 353 ret &= check_stream(cli, __location__, tctx, fname, 354 "SECOND STREAM:$DATA", "SECOND STREAM"); 355 ret &= check_stream(cli, __location__, tctx, fname, "Second Stream:$DATA", "SECOND STREAM"); 356 ret &= check_stream(cli, __location__, tctx, fname, "Second Stream:", NULL); 357 ret &= check_stream(cli, __location__, tctx, fname, "Second Stream:$FOO", NULL); 358 359 check_stream_list(tctx, cli, fname, 3, three); 372 360 373 361 printf("(%s) deleting stream\n", __location__); … … 375 363 CHECK_STATUS(status, NT_STATUS_OK); 376 364 377 check_stream_list( cli, fname, 2, two);365 check_stream_list(tctx, cli, fname, 2, two); 378 366 379 367 printf("(%s) delete a stream via delete-on-close\n", __location__); … … 384 372 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; 385 373 386 status = smb_raw_open(cli->tree, mem_ctx, &io);374 status = smb_raw_open(cli->tree, tctx, &io); 387 375 CHECK_STATUS(status, NT_STATUS_OK); 388 376 fnum = io.ntcreatex.out.file.fnum; … … 392 380 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); 393 381 394 check_stream_list(cli, fname, 1, one); 395 396 if (!torture_setting_bool(tctx, "samba4", false)) { 397 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; 398 io.ntcreatex.in.fname = sname1; 399 status = smb_raw_open(cli->tree, mem_ctx, &io); 400 CHECK_STATUS(status, NT_STATUS_OK); 401 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 402 io.ntcreatex.in.fname = sname2; 403 status = smb_raw_open(cli->tree, mem_ctx, &io); 404 CHECK_STATUS(status, NT_STATUS_OK); 405 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 406 } 382 check_stream_list(tctx, cli, fname, 1, one); 383 384 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; 385 io.ntcreatex.in.fname = sname1; 386 status = smb_raw_open(cli->tree, tctx, &io); 387 CHECK_STATUS(status, NT_STATUS_OK); 388 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 389 io.ntcreatex.in.fname = sname2; 390 status = smb_raw_open(cli->tree, tctx, &io); 391 CHECK_STATUS(status, NT_STATUS_OK); 392 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 407 393 408 394 printf("(%s) deleting file\n", __location__); … … 412 398 done: 413 399 smbcli_close(cli->tree, fnum); 400 smbcli_deltree(cli->tree, BASEDIR); 414 401 return ret; 415 402 } … … 419 406 */ 420 407 static bool test_stream_sharemodes(struct torture_context *tctx, 421 struct smbcli_state *cli, 422 TALLOC_CTX *mem_ctx) 408 struct smbcli_state *cli) 423 409 { 424 410 NTSTATUS status; … … 430 416 int fnum2 = -1; 431 417 432 sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One"); 433 sname2 = talloc_asprintf(mem_ctx, "%s:%s:$DaTa", fname, "Second Stream"); 418 if (!torture_setup_dir(cli, BASEDIR)) { 419 return false; 420 } 421 422 sname1 = talloc_asprintf(tctx, "%s:%s", fname, "Stream One"); 423 sname2 = talloc_asprintf(tctx, "%s:%s:$DaTa", fname, "Second Stream"); 434 424 435 425 printf("(%s) testing stream share mode conflicts\n", __location__); 436 426 io.generic.level = RAW_OPEN_NTCREATEX; 437 io.ntcreatex.in.root_fid = 0;427 io.ntcreatex.in.root_fid.fnum = 0; 438 428 io.ntcreatex.in.flags = 0; 439 429 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; … … 447 437 io.ntcreatex.in.fname = sname1; 448 438 449 status = smb_raw_open(cli->tree, mem_ctx, &io);439 status = smb_raw_open(cli->tree, tctx, &io); 450 440 CHECK_STATUS(status, NT_STATUS_OK); 451 441 fnum1 = io.ntcreatex.out.file.fnum; … … 456 446 457 447 io.ntcreatex.in.fname = sname2; 458 status = smb_raw_open(cli->tree, mem_ctx, &io);448 status = smb_raw_open(cli->tree, tctx, &io); 459 449 CHECK_STATUS(status, NT_STATUS_OK); 460 450 fnum2 = io.ntcreatex.out.file.fnum; … … 467 457 io.ntcreatex.in.fname = sname1; 468 458 io.ntcreatex.in.open_disposition = 0; 469 status = smb_raw_open(cli->tree, mem_ctx, &io);459 status = smb_raw_open(cli->tree, tctx, &io); 470 460 CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); 471 461 472 462 io.ntcreatex.in.fname = sname2; 473 status = smb_raw_open(cli->tree, mem_ctx, &io);463 status = smb_raw_open(cli->tree, tctx, &io); 474 464 CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); 475 465 … … 478 468 if (fnum2 != -1) smbcli_close(cli->tree, fnum2); 479 469 status = smbcli_unlink(cli->tree, fname); 470 smbcli_deltree(cli->tree, BASEDIR); 480 471 return ret; 481 472 } … … 508 499 509 500 static bool test_stream_delete(struct torture_context *tctx, 510 struct smbcli_state *cli , TALLOC_CTX *mem_ctx)501 struct smbcli_state *cli) 511 502 { 512 503 NTSTATUS status; … … 520 511 union smb_fileinfo finfo; 521 512 522 sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One"); 513 if (!torture_setup_dir(cli, BASEDIR)) { 514 return false; 515 } 516 517 sname1 = talloc_asprintf(tctx, "%s:%s", fname, "Stream One"); 523 518 524 519 printf("(%s) opening non-existant file stream\n", __location__); 525 520 io.generic.level = RAW_OPEN_NTCREATEX; 526 io.ntcreatex.in.root_fid = 0;521 io.ntcreatex.in.root_fid.fnum = 0; 527 522 io.ntcreatex.in.flags = 0; 528 523 io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA; … … 536 531 io.ntcreatex.in.fname = sname1; 537 532 538 status = smb_raw_open(cli->tree, mem_ctx, &io);533 status = smb_raw_open(cli->tree, tctx, &io); 539 534 CHECK_STATUS(status, NT_STATUS_OK); 540 535 fnum = io.ntcreatex.out.file.fnum; … … 554 549 io.ntcreatex.in.fname = fname; 555 550 io.ntcreatex.in.access_mask = SEC_STD_DELETE; 556 status = smb_raw_open(cli->tree, mem_ctx, &io);551 status = smb_raw_open(cli->tree, tctx, &io); 557 552 CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); 558 553 … … 566 561 io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA; 567 562 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE; 568 status = smb_raw_open(cli->tree, mem_ctx, &io);563 status = smb_raw_open(cli->tree, tctx, &io); 569 564 CHECK_STATUS(status, NT_STATUS_OK); 570 565 fnum = io.ntcreatex.out.file.fnum; … … 588 583 */ 589 584 590 status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);585 status = smb_raw_pathinfo(cli->tree, tctx, &finfo); 591 586 CHECK_STATUS(status, NT_STATUS_DELETE_PENDING); 592 587 … … 595 590 */ 596 591 finfo.generic.in.file.path = sname1; 597 status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);592 status = smb_raw_pathinfo(cli->tree, tctx, &finfo); 598 593 CHECK_STATUS(status, NT_STATUS_DELETE_PENDING); 599 594 … … 607 602 finfo.all_info.in.file.fnum = fnum; 608 603 609 status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo); 610 CHECK_STATUS(status, NT_STATUS_OK); 611 /* w2k and w2k3 return 0 and w2k8 returns 1 612 CHECK_VALUE(finfo.all_info.out.delete_pending, 0); 613 */ 604 status = smb_raw_fileinfo(cli->tree, tctx, &finfo); 605 CHECK_STATUS(status, NT_STATUS_OK); 606 607 /* w2k and w2k3 return 0 and w2k8 returns 1 */ 608 if (TARGET_IS_WINXP(tctx) || TARGET_IS_W2K3(tctx) || 609 TARGET_IS_SAMBA3(tctx)) { 610 CHECK_VALUE(finfo.all_info.out.delete_pending, 0); 611 } else { 612 CHECK_VALUE(finfo.all_info.out.delete_pending, 1); 613 } 614 614 615 615 smbcli_close(cli->tree, fnum); … … 620 620 621 621 finfo.generic.in.file.path = fname; 622 status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);622 status = smb_raw_pathinfo(cli->tree, tctx, &finfo); 623 623 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); 624 624 … … 627 627 io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DELETE_ON_CLOSE; 628 628 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; 629 status = smb_raw_open(cli->tree, mem_ctx, &io);629 status = smb_raw_open(cli->tree, tctx, &io); 630 630 CHECK_STATUS(status, NT_STATUS_OK); 631 631 fnum = io.ntcreatex.out.file.fnum; 632 632 633 633 finfo.generic.in.file.path = fname; 634 status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);634 status = smb_raw_pathinfo(cli->tree, tctx, &finfo); 635 635 CHECK_STATUS(status, NT_STATUS_OK); 636 636 637 637 smbcli_close(cli->tree, fnum); 638 638 639 status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);639 status = smb_raw_pathinfo(cli->tree, tctx, &finfo); 640 640 CHECK_STATUS(status, NT_STATUS_OK); 641 641 done: 642 642 smbcli_close(cli->tree, fnum); 643 643 smbcli_unlink(cli->tree, fname); 644 smbcli_deltree(cli->tree, BASEDIR); 644 645 return ret; 645 646 } … … 649 650 */ 650 651 static bool test_stream_names(struct torture_context *tctx, 651 struct smbcli_state *cli, 652 TALLOC_CTX *mem_ctx) 652 struct smbcli_state *cli) 653 653 { 654 654 NTSTATUS status; … … 687 687 }; 688 688 689 sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "\x05Stream\n One"); 690 sname1b = talloc_asprintf(mem_ctx, "%s:", sname1); 691 sname1c = talloc_asprintf(mem_ctx, "%s:$FOO", sname1); 692 sname1d = talloc_asprintf(mem_ctx, "%s:?D*a", sname1); 693 sname2 = talloc_asprintf(mem_ctx, "%s:%s:$DaTa", fname, "MStream Two"); 694 snamew = talloc_asprintf(mem_ctx, "%s:%s:$DATA", fname, "?Stream*"); 695 snamew2 = talloc_asprintf(mem_ctx, "%s\\stream*:%s:$DATA", BASEDIR, "?Stream*"); 696 snamer1 = talloc_asprintf(mem_ctx, "%s:%s:$DATA", fname, "BeforeRename"); 697 snamer2 = talloc_asprintf(mem_ctx, "%s:%s:$DATA", fname, "AfterRename"); 689 if (!torture_setup_dir(cli, BASEDIR)) { 690 return false; 691 } 692 693 sname1 = talloc_asprintf(tctx, "%s:%s", fname, "\x05Stream\n One"); 694 sname1b = talloc_asprintf(tctx, "%s:", sname1); 695 sname1c = talloc_asprintf(tctx, "%s:$FOO", sname1); 696 sname1d = talloc_asprintf(tctx, "%s:?D*a", sname1); 697 sname2 = talloc_asprintf(tctx, "%s:%s:$DaTa", fname, "MStream Two"); 698 snamew = talloc_asprintf(tctx, "%s:%s:$DATA", fname, "?Stream*"); 699 snamew2 = talloc_asprintf(tctx, "%s\\stream*:%s:$DATA", BASEDIR, "?Stream*"); 700 snamer1 = talloc_asprintf(tctx, "%s:%s:$DATA", fname, "BeforeRename"); 701 snamer2 = talloc_asprintf(tctx, "%s:%s:$DATA", fname, "AfterRename"); 698 702 699 703 printf("(%s) testing stream names\n", __location__); 700 704 io.generic.level = RAW_OPEN_NTCREATEX; 701 io.ntcreatex.in.root_fid = 0; 705 io.ntcreatex.in.root_fid.fnum = 0; 706 io.ntcreatex.in.flags = 0; 707 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; 708 io.ntcreatex.in.create_options = 0; 709 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 710 io.ntcreatex.in.share_access = 0; 711 io.ntcreatex.in.alloc_size = 0; 712 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; 713 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 714 io.ntcreatex.in.security_flags = 0; 715 io.ntcreatex.in.fname = fname; 716 717 status = smb_raw_open(cli->tree, tctx, &io); 718 CHECK_STATUS(status, NT_STATUS_OK); 719 fnum1 = io.ntcreatex.out.file.fnum; 720 721 /* 722 * Make sure the create time of the streams are different from the 723 * base file. 724 */ 725 sleep(2); 726 smbcli_close(cli->tree, fnum1); 727 728 io.generic.level = RAW_OPEN_NTCREATEX; 729 io.ntcreatex.in.root_fid.fnum = 0; 702 730 io.ntcreatex.in.flags = 0; 703 731 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; … … 711 739 io.ntcreatex.in.fname = sname1; 712 740 713 status = smb_raw_open(cli->tree, mem_ctx, &io);741 status = smb_raw_open(cli->tree, tctx, &io); 714 742 CHECK_STATUS(status, NT_STATUS_OK); 715 743 fnum1 = io.ntcreatex.out.file.fnum; … … 720 748 721 749 io.ntcreatex.in.fname = sname2; 722 status = smb_raw_open(cli->tree, mem_ctx, &io);750 status = smb_raw_open(cli->tree, tctx, &io); 723 751 CHECK_STATUS(status, NT_STATUS_OK); 724 752 fnum2 = io.ntcreatex.out.file.fnum; … … 731 759 io.ntcreatex.in.fname = sname1; 732 760 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_SUPERSEDE; 733 status = smb_raw_open(cli->tree, mem_ctx, &io);761 status = smb_raw_open(cli->tree, tctx, &io); 734 762 CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); 735 763 736 764 io.ntcreatex.in.fname = sname1b; 737 status = smb_raw_open(cli->tree, mem_ctx, &io);765 status = smb_raw_open(cli->tree, tctx, &io); 738 766 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); 739 767 740 768 io.ntcreatex.in.fname = sname1c; 741 status = smb_raw_open(cli->tree, mem_ctx, &io);769 status = smb_raw_open(cli->tree, tctx, &io); 742 770 if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { 743 771 /* w2k returns INVALID_PARAMETER */ … … 748 776 749 777 io.ntcreatex.in.fname = sname1d; 750 status = smb_raw_open(cli->tree, mem_ctx, &io);778 status = smb_raw_open(cli->tree, tctx, &io); 751 779 if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { 752 780 /* w2k returns INVALID_PARAMETER */ … … 757 785 758 786 io.ntcreatex.in.fname = sname2; 759 status = smb_raw_open(cli->tree, mem_ctx, &io);787 status = smb_raw_open(cli->tree, tctx, &io); 760 788 CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); 761 789 762 790 io.ntcreatex.in.fname = snamew; 763 status = smb_raw_open(cli->tree, mem_ctx, &io);791 status = smb_raw_open(cli->tree, tctx, &io); 764 792 CHECK_STATUS(status, NT_STATUS_OK); 765 793 fnum3 = io.ntcreatex.out.file.fnum; 766 794 767 795 io.ntcreatex.in.fname = snamew2; 768 status = smb_raw_open(cli->tree, mem_ctx, &io);796 status = smb_raw_open(cli->tree, tctx, &io); 769 797 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); 770 798 771 ret &= check_stream_list( cli, fname, 4, four);799 ret &= check_stream_list(tctx, cli, fname, 4, four); 772 800 773 801 smbcli_close(cli->tree, fnum1); … … 775 803 smbcli_close(cli->tree, fnum3); 776 804 777 if (torture_setting_bool(tctx, "samba4", true)) {778 goto done;779 }780 781 805 finfo.generic.level = RAW_FILEINFO_ALL_INFO; 782 806 finfo.generic.in.file.path = fname; 783 status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);784 CHECK_STATUS(status, NT_STATUS_OK); 785 786 ret &= check_stream_list( cli, fname, 4, four);807 status = smb_raw_pathinfo(cli->tree, tctx, &finfo); 808 CHECK_STATUS(status, NT_STATUS_OK); 809 810 ret &= check_stream_list(tctx, cli, fname, 4, four); 787 811 788 812 for (i=0; i < 4; i++) { … … 807 831 SEC_RIGHTS_FILE_ALL; 808 832 io.ntcreatex.in.fname = path; 809 status = smb_raw_open(cli->tree, mem_ctx, &io);833 status = smb_raw_open(cli->tree, tctx, &io); 810 834 CHECK_STATUS(status, NT_STATUS_OK); 811 835 fnum1 = io.ntcreatex.out.file.fnum; … … 813 837 finfo.generic.level = RAW_FILEINFO_ALL_INFO; 814 838 finfo.generic.in.file.path = fname; 815 status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);839 status = smb_raw_pathinfo(cli->tree, tctx, &finfo); 816 840 CHECK_STATUS(status, NT_STATUS_OK); 817 841 818 842 stinfo.generic.level = RAW_FILEINFO_ALL_INFO; 819 843 stinfo.generic.in.file.fnum = fnum1; 820 status = smb_raw_fileinfo(cli->tree, mem_ctx, &stinfo);844 status = smb_raw_fileinfo(cli->tree, tctx, &stinfo); 821 845 CHECK_STATUS(status, NT_STATUS_OK); 822 846 if (!torture_setting_bool(tctx, "samba3", false)) { … … 843 867 stinfo.generic.level = RAW_FILEINFO_NAME_INFO; 844 868 stinfo.generic.in.file.fnum = fnum1; 845 status = smb_raw_fileinfo(cli->tree, mem_ctx, &stinfo);869 status = smb_raw_fileinfo(cli->tree, tctx, &stinfo); 846 870 CHECK_STATUS(status, NT_STATUS_OK); 847 871 if (!torture_setting_bool(tctx, "samba3", false)) { 848 CHECK_STR( rpath, stinfo.name_info.out.fname.s);872 CHECK_STR(stinfo.name_info.out.fname.s, rpath); 849 873 } 850 874 … … 873 897 stinfo.generic.level = RAW_FILEINFO_ALL_INFO; 874 898 stinfo.generic.in.file.fnum = fnum1; 875 status = smb_raw_fileinfo(cli->tree, mem_ctx, &stinfo);899 status = smb_raw_fileinfo(cli->tree, tctx, &stinfo); 876 900 CHECK_STATUS(status, NT_STATUS_OK); 877 901 if (!torture_setting_bool(tctx, "samba3", false)) { … … 890 914 finfo.all_info.out.ea_size); 891 915 892 ret &= check_stream_list( cli, fname, 4, four);916 ret &= check_stream_list(tctx, cli, fname, 4, four); 893 917 894 918 smbcli_close(cli->tree, fnum1); … … 902 926 SEC_RIGHTS_FILE_ALL; 903 927 io.ntcreatex.in.fname = snamer1; 904 status = smb_raw_open(cli->tree, mem_ctx, &io);928 status = smb_raw_open(cli->tree, tctx, &io); 905 929 CHECK_STATUS(status, NT_STATUS_OK); 906 930 fnum1 = io.ntcreatex.out.file.fnum; 907 931 908 ret &= check_stream_list( cli, fname, 5, five1);932 ret &= check_stream_list(tctx, cli, fname, 5, five1); 909 933 910 934 ZERO_STRUCT(sinfo); … … 917 941 CHECK_STATUS(status, NT_STATUS_OK); 918 942 919 ret &= check_stream_list( cli, fname, 5, five2);943 ret &= check_stream_list(tctx, cli, fname, 5, five2); 920 944 921 945 ZERO_STRUCT(sinfo); … … 928 952 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION); 929 953 930 ret &= check_stream_list( cli, fname, 5, five2);954 ret &= check_stream_list(tctx, cli, fname, 5, five2); 931 955 932 956 ZERO_STRUCT(sinfo); … … 937 961 sinfo.rename_information.in.new_name = ":MStream Two:$DATA"; 938 962 status = smb_raw_setfileinfo(cli->tree, &sinfo); 939 CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); 940 941 ret &= check_stream_list(cli, fname, 5, five2); 963 if (torture_setting_bool(tctx, "samba4", false) || 964 torture_setting_bool(tctx, "samba3", false)) { 965 /* why should this rename be considered invalid?? */ 966 CHECK_STATUS(status, NT_STATUS_OK); 967 ret &= check_stream_list(tctx, cli, fname, 4, four); 968 } else { 969 CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); 970 ret &= check_stream_list(tctx, cli, fname, 5, five2); 971 } 972 942 973 943 974 /* TODO: we need to test more rename combinations */ … … 948 979 if (fnum3 != -1) smbcli_close(cli->tree, fnum3); 949 980 status = smbcli_unlink(cli->tree, fname); 981 smbcli_deltree(cli->tree, BASEDIR); 950 982 return ret; 951 983 } … … 955 987 */ 956 988 static bool test_stream_names2(struct torture_context *tctx, 957 struct smbcli_state *cli, 958 TALLOC_CTX *mem_ctx) 989 struct smbcli_state *cli) 959 990 { 960 991 NTSTATUS status; … … 965 996 uint8_t i; 966 997 998 if (!torture_setup_dir(cli, BASEDIR)) { 999 return false; 1000 } 1001 967 1002 printf("(%s) testing stream names\n", __location__); 968 1003 io.generic.level = RAW_OPEN_NTCREATEX; 969 io.ntcreatex.in.root_fid = 0;1004 io.ntcreatex.in.root_fid.fnum = 0; 970 1005 io.ntcreatex.in.flags = 0; 971 1006 io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; … … 978 1013 io.ntcreatex.in.security_flags = 0; 979 1014 io.ntcreatex.in.fname = fname; 980 status = smb_raw_open(cli->tree, mem_ctx, &io);1015 status = smb_raw_open(cli->tree, tctx, &io); 981 1016 CHECK_STATUS(status, NT_STATUS_OK); 982 1017 fnum1 = io.ntcreatex.out.file.fnum; … … 1001 1036 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; 1002 1037 io.ntcreatex.in.fname = path; 1003 status = smb_raw_open(cli->tree, mem_ctx, &io);1038 status = smb_raw_open(cli->tree, tctx, &io); 1004 1039 if (!NT_STATUS_EQUAL(status, expected)) { 1005 1040 printf("(%s) %s:Stream%c0x%02X:$DATA%s => expected[%s]\n", … … 1016 1051 if (fnum1 != -1) smbcli_close(cli->tree, fnum1); 1017 1052 status = smbcli_unlink(cli->tree, fname); 1053 smbcli_deltree(cli->tree, BASEDIR); 1018 1054 return ret; 1019 1055 } … … 1042 1078 */ 1043 1079 static bool test_stream_rename(struct torture_context *tctx, 1044 struct smbcli_state *cli, 1045 TALLOC_CTX *mem_ctx) 1080 struct smbcli_state *cli) 1046 1081 { 1047 1082 NTSTATUS status, status2; … … 1056 1091 const char *call_name; 1057 1092 1058 sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One"); 1059 sname2 = talloc_asprintf(mem_ctx, "%s:%s:$DaTa", fname, "Second Stream"); 1093 if (!torture_setup_dir(cli, BASEDIR)) { 1094 return false; 1095 } 1096 1097 sname1 = talloc_asprintf(tctx, "%s:%s", fname, "Stream One"); 1098 sname2 = talloc_asprintf(tctx, "%s:%s:$DaTa", fname, "Second Stream"); 1060 1099 1061 1100 printf("(%s) testing stream renames\n", __location__); 1062 1101 io.generic.level = RAW_OPEN_NTCREATEX; 1063 io.ntcreatex.in.root_fid = 0;1102 io.ntcreatex.in.root_fid.fnum = 0; 1064 1103 io.ntcreatex.in.flags = 0; 1065 1104 io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE | … … 1076 1115 1077 1116 /* Create two streams. */ 1078 status = smb_raw_open(cli->tree, mem_ctx, &io);1117 status = smb_raw_open(cli->tree, tctx, &io); 1079 1118 CHECK_STATUS(status, NT_STATUS_OK); 1080 1119 fnum = io.ntcreatex.out.file.fnum; … … 1082 1121 1083 1122 io.ntcreatex.in.fname = sname2; 1084 status = smb_raw_open(cli->tree, mem_ctx, &io);1123 status = smb_raw_open(cli->tree, tctx, &io); 1085 1124 CHECK_STATUS(status, NT_STATUS_OK); 1086 1125 fnum = io.ntcreatex.out.file.fnum; … … 1094 1133 io.ntcreatex.in.access_mask = SEC_STD_DELETE; 1095 1134 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; 1096 status = smb_raw_open(cli->tree, mem_ctx, &io);1135 status = smb_raw_open(cli->tree, tctx, &io); 1097 1136 CHECK_STATUS(status, NT_STATUS_OK); 1098 1137 fnum = io.ntcreatex.out.file.fnum; … … 1112 1151 if (fnum != -1) smbcli_close(cli->tree, fnum); 1113 1152 status = smbcli_unlink(cli->tree, fname); 1153 smbcli_deltree(cli->tree, BASEDIR); 1114 1154 return ret; 1115 1155 } 1116 1156 1117 1157 static bool test_stream_rename2(struct torture_context *tctx, 1118 struct smbcli_state *cli , TALLOC_CTX *mem_ctx)1158 struct smbcli_state *cli) 1119 1159 { 1120 1160 NTSTATUS status; … … 1132 1172 union smb_rename rio; 1133 1173 1134 sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname1, "Stream One"); 1135 sname2 = talloc_asprintf(mem_ctx, "%s:%s", fname1, "Stream Two"); 1174 if (!torture_setup_dir(cli, BASEDIR)) { 1175 return false; 1176 } 1177 1178 sname1 = talloc_asprintf(tctx, "%s:%s", fname1, "Stream One"); 1179 sname2 = talloc_asprintf(tctx, "%s:%s", fname1, "Stream Two"); 1136 1180 1137 1181 io.generic.level = RAW_OPEN_NTCREATEX; 1138 io.ntcreatex.in.root_fid = 0;1182 io.ntcreatex.in.root_fid.fnum = 0; 1139 1183 io.ntcreatex.in.flags = 0; 1140 1184 io.ntcreatex.in.access_mask = (SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA| … … 1152 1196 1153 1197 /* Open/create new stream. */ 1154 status = smb_raw_open(cli->tree, mem_ctx, &io);1198 status = smb_raw_open(cli->tree, tctx, &io); 1155 1199 CHECK_STATUS(status, NT_STATUS_OK); 1156 1200 … … 1207 1251 /* Create the file. */ 1208 1252 io.ntcreatex.in.fname = fname2; 1209 status = smb_raw_open(cli->tree, mem_ctx, &io);1253 status = smb_raw_open(cli->tree, tctx, &io); 1210 1254 CHECK_STATUS(status, NT_STATUS_OK); 1211 1255 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); … … 1222 1266 io.ntcreatex.in.fname = sname2; 1223 1267 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; 1224 status = smb_raw_open(cli->tree, mem_ctx, &io);1268 status = smb_raw_open(cli->tree, tctx, &io); 1225 1269 CHECK_STATUS(status, NT_STATUS_OK); 1226 1270 fnum = io.ntcreatex.out.file.fnum; … … 1249 1293 io.ntcreatex.in.fname = sname2; 1250 1294 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; 1251 status = smb_raw_open(cli->tree, mem_ctx, &io);1295 status = smb_raw_open(cli->tree, tctx, &io); 1252 1296 CHECK_STATUS(status, NT_STATUS_OK); 1253 1297 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); … … 1266 1310 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; 1267 1311 io.ntcreatex.in.fname = sname2; 1268 status = smb_raw_open(cli->tree, mem_ctx, &io);1312 status = smb_raw_open(cli->tree, tctx, &io); 1269 1313 CHECK_STATUS(status, NT_STATUS_OK); 1270 1314 fnum = io.ntcreatex.out.file.fnum; … … 1305 1349 status = smbcli_unlink(cli->tree, fname1); 1306 1350 status = smbcli_unlink(cli->tree, fname2); 1351 smbcli_deltree(cli->tree, BASEDIR); 1307 1352 return ret; 1308 1353 } 1309 1354 1355 /* 1356 test stream renames 1357 */ 1358 static bool test_stream_rename3(struct torture_context *tctx, 1359 struct smbcli_state *cli) 1360 { 1361 NTSTATUS status, status2; 1362 union smb_open io; 1363 const char *fname = BASEDIR "\\stream_rename.txt"; 1364 const char *sname1, *sname2; 1365 union smb_fileinfo finfo1; 1366 union smb_setfileinfo sfinfo; 1367 bool ret = true; 1368 int fnum = -1; 1369 int fnum2 = -1; 1370 bool check_fnum; 1371 const char *call_name; 1372 1373 if (!torture_setup_dir(cli, BASEDIR)) { 1374 return false; 1375 } 1376 1377 sname1 = talloc_asprintf(tctx, "%s:%s", fname, "MStream Two:$DATA"); 1378 sname2 = talloc_asprintf(tctx, "%s:%s:$DaTa", fname, "Second Stream"); 1379 1380 printf("(%s) testing stream renames\n", __location__); 1381 io.generic.level = RAW_OPEN_NTCREATEX; 1382 io.ntcreatex.in.root_fid.fnum = 0; 1383 io.ntcreatex.in.flags = 0; 1384 io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE | 1385 SEC_FILE_WRITE_ATTRIBUTE | 1386 SEC_RIGHTS_FILE_ALL; 1387 io.ntcreatex.in.create_options = 0; 1388 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 1389 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | 1390 NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_DELETE; 1391 io.ntcreatex.in.alloc_size = 0; 1392 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; 1393 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 1394 io.ntcreatex.in.security_flags = 0; 1395 io.ntcreatex.in.fname = sname1; 1396 1397 /* Create two streams. */ 1398 status = smb_raw_open(cli->tree, tctx, &io); 1399 CHECK_STATUS(status, NT_STATUS_OK); 1400 fnum = io.ntcreatex.out.file.fnum; 1401 if (fnum != -1) smbcli_close(cli->tree, fnum); 1402 1403 io.ntcreatex.in.fname = sname2; 1404 status = smb_raw_open(cli->tree, tctx, &io); 1405 CHECK_STATUS(status, NT_STATUS_OK); 1406 fnum = io.ntcreatex.out.file.fnum; 1407 1408 if (fnum != -1) smbcli_close(cli->tree, fnum); 1409 1410 /* open the second stream. */ 1411 io.ntcreatex.in.access_mask = SEC_STD_DELETE; 1412 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; 1413 status = smb_raw_open(cli->tree, tctx, &io); 1414 CHECK_STATUS(status, NT_STATUS_OK); 1415 fnum = io.ntcreatex.out.file.fnum; 1416 1417 /* Keep a handle to the first stream open. */ 1418 io.ntcreatex.in.fname = sname1; 1419 io.ntcreatex.in.access_mask = SEC_STD_DELETE; 1420 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; 1421 status = smb_raw_open(cli->tree, tctx, &io); 1422 CHECK_STATUS(status, NT_STATUS_OK); 1423 fnum2 = io.ntcreatex.out.file.fnum; 1424 1425 ZERO_STRUCT(sfinfo); 1426 sfinfo.rename_information.in.overwrite = 1; 1427 sfinfo.rename_information.in.root_fid = 0; 1428 sfinfo.rename_information.in.new_name = ":MStream Two:$DATA"; 1429 if (torture_setting_bool(tctx, "samba4", false) || 1430 torture_setting_bool(tctx, "samba3", false)) { 1431 CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK); 1432 } else { 1433 CHECK_CALL_FNUM(RENAME_INFORMATION, 1434 NT_STATUS_INVALID_PARAMETER); 1435 } 1436 1437 1438 done: 1439 if (fnum != -1) smbcli_close(cli->tree, fnum); 1440 if (fnum2 != -1) smbcli_close(cli->tree, fnum2); 1441 status = smbcli_unlink(cli->tree, fname); 1442 smbcli_deltree(cli->tree, BASEDIR); 1443 return ret; 1444 } 1445 1310 1446 static bool create_file_with_stream(struct torture_context *tctx, 1311 1447 struct smbcli_state *cli, 1312 TALLOC_CTX *mem_ctx,1313 1448 const char *stream) 1314 1449 { … … 1319 1454 /* Create a file with a stream */ 1320 1455 io.generic.level = RAW_OPEN_NTCREATEX; 1321 io.ntcreatex.in.root_fid = 0;1456 io.ntcreatex.in.root_fid.fnum = 0; 1322 1457 io.ntcreatex.in.flags = 0; 1323 1458 io.ntcreatex.in.access_mask = (SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA| … … 1332 1467 io.ntcreatex.in.fname = stream; 1333 1468 1334 status = smb_raw_open(cli->tree, mem_ctx, &io);1469 status = smb_raw_open(cli->tree, tctx, &io); 1335 1470 CHECK_STATUS(status, NT_STATUS_OK); 1336 1471 … … 1342 1477 /* Test how streams interact with create dispositions */ 1343 1478 static bool test_stream_create_disposition(struct torture_context *tctx, 1344 struct smbcli_state *cli, 1345 TALLOC_CTX *mem_ctx) 1479 struct smbcli_state *cli) 1346 1480 { 1347 1481 NTSTATUS status; … … 1352 1486 const char *default_stream_name = "::$DATA"; 1353 1487 const char *stream_list[2]; 1354 bool ret = true;1488 bool ret = false; 1355 1489 int fnum = -1; 1356 1490 1357 fname_stream = talloc_asprintf(mem_ctx, "%s:%s", fname, stream); 1358 1359 stream_list[0] = talloc_asprintf(mem_ctx, ":%s", stream); 1491 if (!torture_setup_dir(cli, BASEDIR)) { 1492 return false; 1493 } 1494 1495 fname_stream = talloc_asprintf(tctx, "%s:%s", fname, stream); 1496 1497 stream_list[0] = talloc_asprintf(tctx, ":%s", stream); 1360 1498 stream_list[1] = default_stream_name; 1361 1499 1362 if (!create_file_with_stream(tctx, cli, mem_ctx,fname_stream)) {1500 if (!create_file_with_stream(tctx, cli, fname_stream)) { 1363 1501 goto done; 1364 1502 } … … 1366 1504 /* Open the base file with OPEN */ 1367 1505 io.generic.level = RAW_OPEN_NTCREATEX; 1368 io.ntcreatex.in.root_fid = 0;1506 io.ntcreatex.in.root_fid.fnum = 0; 1369 1507 io.ntcreatex.in.flags = 0; 1370 1508 io.ntcreatex.in.access_mask = (SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA| … … 1383 1521 printf("(%s) Checking ntcreatex disp: open\n", __location__); 1384 1522 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; 1385 status = smb_raw_open(cli->tree, mem_ctx, &io);1523 status = smb_raw_open(cli->tree, tctx, &io); 1386 1524 CHECK_STATUS(status, NT_STATUS_OK); 1387 1525 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 1388 if (!check_stream_list( cli, fname, 2, stream_list)) {1526 if (!check_stream_list(tctx, cli, fname, 2, stream_list)) { 1389 1527 goto done; 1390 1528 } … … 1395 1533 printf("(%s) Checking ntcreatex disp: overwrite\n", __location__); 1396 1534 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE; 1397 status = smb_raw_open(cli->tree, mem_ctx, &io);1535 status = smb_raw_open(cli->tree, tctx, &io); 1398 1536 CHECK_STATUS(status, NT_STATUS_OK); 1399 1537 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 1400 if (!check_stream_list( cli, fname, 1, &default_stream_name)) {1538 if (!check_stream_list(tctx, cli, fname, 1, &default_stream_name)) { 1401 1539 goto done; 1402 1540 } … … 1407 1545 printf("(%s) Checking ntcreatex disp: overwrite_if\n", __location__); 1408 1546 smbcli_unlink(cli->tree, fname); 1409 if (!create_file_with_stream(tctx, cli, mem_ctx,fname_stream)) {1547 if (!create_file_with_stream(tctx, cli, fname_stream)) { 1410 1548 goto done; 1411 1549 } 1412 1550 1413 1551 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; 1414 status = smb_raw_open(cli->tree, mem_ctx, &io);1552 status = smb_raw_open(cli->tree, tctx, &io); 1415 1553 CHECK_STATUS(status, NT_STATUS_OK); 1416 1554 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 1417 if (!check_stream_list( cli, fname, 1, &default_stream_name)) {1555 if (!check_stream_list(tctx, cli, fname, 1, &default_stream_name)) { 1418 1556 goto done; 1419 1557 } … … 1424 1562 printf("(%s) Checking ntcreatex disp: supersede\n", __location__); 1425 1563 smbcli_unlink(cli->tree, fname); 1426 if (!create_file_with_stream(tctx, cli, mem_ctx,fname_stream)) {1564 if (!create_file_with_stream(tctx, cli, fname_stream)) { 1427 1565 goto done; 1428 1566 } 1429 1567 1430 1568 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_SUPERSEDE; 1431 status = smb_raw_open(cli->tree, mem_ctx, &io);1569 status = smb_raw_open(cli->tree, tctx, &io); 1432 1570 CHECK_STATUS(status, NT_STATUS_OK); 1433 1571 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 1434 if (!check_stream_list( cli, fname, 1, &default_stream_name)) {1572 if (!check_stream_list(tctx, cli, fname, 1, &default_stream_name)) { 1435 1573 goto done; 1436 1574 } … … 1442 1580 __location__); 1443 1581 smbcli_unlink(cli->tree, fname); 1444 if (!create_file_with_stream(tctx, cli, mem_ctx,fname_stream)) {1582 if (!create_file_with_stream(tctx, cli, fname_stream)) { 1445 1583 goto done; 1446 1584 } … … 1448 1586 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; 1449 1587 io.ntcreatex.in.fname = fname_stream; 1450 status = smb_raw_open(cli->tree, mem_ctx, &io);1588 status = smb_raw_open(cli->tree, tctx, &io); 1451 1589 CHECK_STATUS(status, NT_STATUS_OK); 1452 1590 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); 1453 if (!check_stream_list( cli, fname, 1, &default_stream_name)) {1591 if (!check_stream_list(tctx, cli, fname, 2, stream_list)) { 1454 1592 goto done; 1455 1593 } … … 1460 1598 printf("(%s) Checking openx disp: overwrite_if\n", __location__); 1461 1599 smbcli_unlink(cli->tree, fname); 1462 if (!create_file_with_stream(tctx, cli, mem_ctx,fname_stream)) {1600 if (!create_file_with_stream(tctx, cli, fname_stream)) { 1463 1601 goto done; 1464 1602 } … … 1466 1604 io.openx.level = RAW_OPEN_OPENX; 1467 1605 io.openx.in.flags = OPENX_FLAGS_ADDITIONAL_INFO; 1468 io.openx.in.open_mode = OPENX_MODE_ACCESS_RDWR ;1606 io.openx.in.open_mode = OPENX_MODE_ACCESS_RDWR | OPEN_FLAGS_DENY_NONE; 1469 1607 io.openx.in.search_attrs = 0; 1470 1608 io.openx.in.file_attrs = 0; … … 1475 1613 1476 1614 io.openx.in.open_func = OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE; 1477 status = smb_raw_open(cli->tree, mem_ctx, &io);1615 status = smb_raw_open(cli->tree, tctx, &io); 1478 1616 CHECK_STATUS(status, NT_STATUS_OK); 1479 1617 smbcli_close(cli->tree, io.openx.out.file.fnum); 1480 if (!check_stream_list(cli, fname, 1, &default_stream_name)) { 1481 goto done; 1482 } 1618 if (!check_stream_list(tctx, cli, fname, 1, &default_stream_name)) { 1619 goto done; 1620 } 1621 1622 ret = true; 1483 1623 1484 1624 done: 1485 1625 smbcli_close(cli->tree, fnum); 1486 1626 smbcli_unlink(cli->tree, fname); 1627 smbcli_deltree(cli->tree, BASEDIR); 1487 1628 return ret; 1488 1629 } … … 1490 1631 /* Test streaminfo with enough streams on a file to fill up the buffer. */ 1491 1632 static bool test_stream_large_streaminfo(struct torture_context *tctx, 1492 struct smbcli_state *cli, 1493 TALLOC_CTX *mem_ctx) 1633 struct smbcli_state *cli) 1494 1634 { 1495 1635 #define LONG_STREAM_SIZE 2 … … 1502 1642 union smb_fileinfo finfo; 1503 1643 1504 lstream_name = talloc_array(mem_ctx, char, LONG_STREAM_SIZE); 1644 if (!torture_setup_dir(cli, BASEDIR)) { 1645 return false; 1646 } 1647 1648 lstream_name = talloc_array(tctx, char, LONG_STREAM_SIZE); 1505 1649 1506 1650 for (i = 0; i < LONG_STREAM_SIZE - 1; i++) { … … 1509 1653 lstream_name[LONG_STREAM_SIZE - 1] = '\0'; 1510 1654 1511 printf("(%s) Creating a file with a lot of streams\n", __location__);1655 torture_comment(tctx, "(%s) Creating a file with a lot of streams\n", __location__); 1512 1656 for (i = 0; i < 10000; i++) { 1513 fname_stream = talloc_asprintf( mem_ctx, "%s:%s%d", fname,1657 fname_stream = talloc_asprintf(tctx, "%s:%s%d", fname, 1514 1658 lstream_name, i); 1515 ret = create_file_with_stream(tctx, cli, mem_ctx, 1516 fname_stream); 1659 ret = create_file_with_stream(tctx, cli, fname_stream); 1517 1660 if (!ret) { 1518 1661 goto done; … … 1523 1666 finfo.generic.in.file.path = fname; 1524 1667 1525 status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);1668 status = smb_raw_pathinfo(cli->tree, tctx, &finfo); 1526 1669 CHECK_STATUS(status, STATUS_BUFFER_OVERFLOW); 1527 1670 1528 1671 done: 1529 1672 smbcli_unlink(cli->tree, fname); 1673 smbcli_deltree(cli->tree, BASEDIR); 1530 1674 return ret; 1531 1675 } … … 1533 1677 /* Test the effect of setting attributes on a stream. */ 1534 1678 static bool test_stream_attributes(struct torture_context *tctx, 1535 struct smbcli_state *cli, 1536 TALLOC_CTX *mem_ctx) 1679 struct smbcli_state *cli) 1537 1680 { 1538 1681 bool ret = true; … … 1547 1690 time_t basetime = (time(NULL) - 86400) & ~1; 1548 1691 1549 printf ("(%s) testing attribute setting on stream\n", __location__); 1550 1551 fname_stream = talloc_asprintf(mem_ctx, "%s:%s", fname, stream); 1692 if (!torture_setup_dir(cli, BASEDIR)) { 1693 return false; 1694 } 1695 1696 torture_comment(tctx, "(%s) testing attribute setting on stream\n", __location__); 1697 1698 fname_stream = talloc_asprintf(tctx, "%s:%s", fname, stream); 1552 1699 1553 1700 /* Create a file with a stream with attribute FILE_ATTRIBUTE_ARCHIVE. */ 1554 ret = create_file_with_stream(tctx, cli, mem_ctx,fname_stream);1701 ret = create_file_with_stream(tctx, cli, fname_stream); 1555 1702 if (!ret) { 1556 1703 goto done; … … 1560 1707 finfo.generic.level = RAW_FILEINFO_BASIC_INFO; 1561 1708 finfo.generic.in.file.path = fname; 1562 status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);1709 status = smb_raw_pathinfo(cli->tree, tctx, &finfo); 1563 1710 CHECK_STATUS(status, NT_STATUS_OK); 1564 1711 … … 1574 1721 1575 1722 io.generic.level = RAW_OPEN_NTCREATEX; 1576 io.ntcreatex.in.root_fid = 0;1723 io.ntcreatex.in.root_fid.fnum = 0; 1577 1724 io.ntcreatex.in.flags = 0; 1578 1725 io.ntcreatex.in.access_mask = (SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA| … … 1587 1734 io.ntcreatex.in.fname = fname_stream; 1588 1735 1589 status = smb_raw_open(cli->tree, mem_ctx, &io);1736 status = smb_raw_open(cli->tree, tctx, &io); 1590 1737 CHECK_STATUS(status, NT_STATUS_OK); 1591 1738 … … 1613 1760 finfo.generic.level = RAW_FILEINFO_ALL_INFO; 1614 1761 finfo.generic.in.file.path = fname; 1615 status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);1762 status = smb_raw_pathinfo(cli->tree, tctx, &finfo); 1616 1763 if (!NT_STATUS_IS_OK(status)) { 1617 1764 printf("(%s) %s pathinfo - %s\n", __location__, "SETATTRE", nt_errstr(status)); … … 1642 1789 } 1643 1790 smbcli_unlink(cli->tree, fname); 1791 smbcli_deltree(cli->tree, BASEDIR); 1792 return ret; 1793 } 1794 1795 /** 1796 * A rough approximation of how a windows client creates the streams for use 1797 * in the summary tab. 1798 */ 1799 static bool test_stream_summary_tab(struct torture_context *tctx, 1800 struct smbcli_state *cli) 1801 { 1802 bool ret = true; 1803 NTSTATUS status; 1804 union smb_open io; 1805 const char *fname = BASEDIR "\\stream_summary.txt"; 1806 const char *stream = ":\005SummaryInformation:$DATA"; 1807 const char *fname_stream = NULL; 1808 const char *tmp_stream = ":Updt_\005SummaryInformation:$DATA"; 1809 const char *fname_tmp_stream = NULL; 1810 int fnum = -1; 1811 union smb_fileinfo finfo; 1812 union smb_rename rio; 1813 ssize_t retsize; 1814 1815 if (!torture_setup_dir(cli, BASEDIR)) { 1816 return false; 1817 } 1818 1819 fname_stream = talloc_asprintf(tctx, "%s%s", fname, stream); 1820 fname_tmp_stream = talloc_asprintf(tctx, "%s%s", fname, 1821 tmp_stream); 1822 1823 /* Create summary info stream */ 1824 ret = create_file_with_stream(tctx, cli, fname_stream); 1825 if (!ret) { 1826 goto done; 1827 } 1828 1829 /* Create summary info tmp update stream */ 1830 ret = create_file_with_stream(tctx, cli, fname_tmp_stream); 1831 if (!ret) { 1832 goto done; 1833 } 1834 1835 /* Open tmp stream and write to it */ 1836 io.generic.level = RAW_OPEN_NTCREATEX; 1837 io.ntcreatex.in.root_fid.fnum = 0; 1838 io.ntcreatex.in.flags = 0; 1839 io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA; 1840 io.ntcreatex.in.create_options = 0; 1841 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 1842 io.ntcreatex.in.share_access = 0; 1843 io.ntcreatex.in.alloc_size = 0; 1844 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; 1845 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 1846 io.ntcreatex.in.security_flags = 0; 1847 io.ntcreatex.in.fname = fname_tmp_stream; 1848 1849 status = smb_raw_open(cli->tree, tctx, &io); 1850 CHECK_STATUS(status, NT_STATUS_OK); 1851 fnum = io.ntcreatex.out.file.fnum; 1852 1853 retsize = smbcli_write(cli->tree, fnum, 0, "test data", 0, 9); 1854 CHECK_VALUE(retsize, 9); 1855 1856 /* close the tmp stream. */ 1857 smbcli_close(cli->tree, fnum); 1858 fnum = -1; 1859 1860 /* Delete the current stream */ 1861 smbcli_unlink(cli->tree, fname_stream); 1862 1863 /* Do the rename. */ 1864 rio.generic.level = RAW_RENAME_RENAME; 1865 rio.rename.in.pattern1 = fname_tmp_stream; 1866 rio.rename.in.pattern2 = stream; 1867 rio.rename.in.attrib = FILE_ATTRIBUTE_SYSTEM | 1868 FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY; 1869 status = smb_raw_rename(cli->tree, &rio); 1870 CHECK_STATUS(status, NT_STATUS_OK); 1871 1872 /* Try to open the tmp stream that we just renamed away. */ 1873 status = smb_raw_open(cli->tree, tctx, &io); 1874 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); 1875 1876 /* Query the base file to make sure it's still there. */ 1877 finfo.generic.level = RAW_FILEINFO_BASIC_INFO; 1878 finfo.generic.in.file.path = fname; 1879 1880 status = smb_raw_pathinfo(cli->tree, tctx, &finfo); 1881 CHECK_STATUS(status, NT_STATUS_OK); 1882 1883 done: 1884 1885 if (fnum != -1) { 1886 smbcli_close(cli->tree, fnum); 1887 } 1888 smbcli_unlink(cli->tree, fname); 1889 1890 smbcli_deltree(cli->tree, BASEDIR); 1644 1891 return ret; 1645 1892 } … … 1648 1895 basic testing of streams calls 1649 1896 */ 1650 bool torture_raw_streams(struct torture_context *torture, 1651 struct smbcli_state *cli) 1897 struct torture_suite *torture_raw_streams(TALLOC_CTX *tctx) 1652 1898 { 1653 bool ret = true; 1654 1655 if (!torture_setup_dir(cli, BASEDIR)) { 1656 return false; 1657 } 1658 1659 ret &= test_stream_dir(torture, cli, torture); 1660 smb_raw_exit(cli->session); 1661 ret &= test_stream_io(torture, cli, torture); 1662 smb_raw_exit(cli->session); 1663 ret &= test_stream_sharemodes(torture, cli, torture); 1664 smb_raw_exit(cli->session); 1665 if (!torture_setting_bool(torture, "samba4", false)) { 1666 ret &= test_stream_delete(torture, cli, torture); 1667 } 1668 ret &= test_stream_names(torture, cli, torture); 1669 smb_raw_exit(cli->session); 1670 ret &= test_stream_names2(torture, cli, torture); 1671 smb_raw_exit(cli->session); 1672 ret &= test_stream_rename(torture, cli, torture); 1673 smb_raw_exit(cli->session); 1674 ret &= test_stream_rename2(torture, cli, torture); 1675 smb_raw_exit(cli->session); 1676 ret &= test_stream_create_disposition(torture, cli, torture); 1677 smb_raw_exit(cli->session); 1678 1679 ret &= test_stream_attributes(torture, cli, torture); 1680 smb_raw_exit(cli->session); 1681 1682 /* ret &= test_stream_large_streaminfo(torture, cli, torture); */ 1683 /* smb_raw_exit(cli->session); */ 1684 1685 smbcli_deltree(cli->tree, BASEDIR); 1686 1687 return ret; 1899 struct torture_suite *suite = torture_suite_create(tctx, "streams"); 1900 1901 torture_suite_add_1smb_test(suite, "dir", test_stream_dir); 1902 torture_suite_add_1smb_test(suite, "io", test_stream_io); 1903 torture_suite_add_1smb_test(suite, "sharemodes", test_stream_sharemodes); 1904 torture_suite_add_1smb_test(suite, "delete", test_stream_delete); 1905 torture_suite_add_1smb_test(suite, "names", test_stream_names); 1906 torture_suite_add_1smb_test(suite, "names2", test_stream_names2); 1907 torture_suite_add_1smb_test(suite, "rename", test_stream_rename); 1908 torture_suite_add_1smb_test(suite, "rename2", test_stream_rename2); 1909 torture_suite_add_1smb_test(suite, "rename3", test_stream_rename3); 1910 torture_suite_add_1smb_test(suite, "createdisp", 1911 test_stream_create_disposition); 1912 torture_suite_add_1smb_test(suite, "attr", test_stream_attributes); 1913 torture_suite_add_1smb_test(suite, "sumtab", test_stream_summary_tab); 1914 1915 /* torture_suite_add_1smb_test(suite, "LARGESTREAMINFO", */ 1916 /* test_stream_large_streaminfo); */ 1917 1918 return suite; 1688 1919 } -
trunk/server/source4/torture/raw/tconrate.c
r414 r745 71 71 struct smbcli_session_options session_options; 72 72 73 lp _smbcli_options(tctx->lp_ctx, &options);74 lp _smbcli_session_options(tctx->lp_ctx, &session_options);73 lpcfg_smbcli_options(tctx->lp_ctx, &options); 74 lpcfg_smbcli_session_options(tctx->lp_ctx, &session_options); 75 75 76 76 child = fork(); … … 99 99 100 100 status = smbcli_full_connection(NULL, &cli, 101 host, lp _smb_ports(tctx->lp_ctx), share,102 NULL, lp _socket_options(tctx->lp_ctx), cmdline_credentials,103 lp _resolve_context(tctx->lp_ctx),101 host, lpcfg_smb_ports(tctx->lp_ctx), share, 102 NULL, lpcfg_socket_options(tctx->lp_ctx), cmdline_credentials, 103 lpcfg_resolve_context(tctx->lp_ctx), 104 104 tctx->ev, &options, &session_options, 105 lp_iconv_convenience(tctx->lp_ctx), 106 lp_gensec_settings(tctx, tctx->lp_ctx)); 105 lpcfg_gensec_settings(tctx, tctx->lp_ctx)); 107 106 108 107 if (!NT_STATUS_IS_OK(status)) { … … 125 124 static bool children_remain(void) 126 125 { 126 bool res; 127 127 128 /* Reap as many children as possible. */ 128 129 for (;;) { … … 130 131 if (ret == 0) { 131 132 /* no children ready */ 132 return true; 133 res = true; 134 break; 133 135 } 134 136 if (ret == -1) { 135 137 /* no children left. maybe */ 136 return errno == ECHILD ? false : true; 137 } 138 } 139 140 /* notreached */ 141 return false; 138 res = errno != ECHILD; 139 break; 140 } 141 } 142 return res; 142 143 } 143 144 -
trunk/server/source4/torture/raw/unlink.c
r414 r745 328 328 329 329 op.generic.level = RAW_OPEN_NTCREATEX; 330 op.ntcreatex.in.root_fid = 0;330 op.ntcreatex.in.root_fid.fnum = 0; 331 331 op.ntcreatex.in.flags = 0; 332 332 op.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; … … 360 360 361 361 op.generic.level = RAW_OPEN_NTCREATEX; 362 op.ntcreatex.in.root_fid = 0;362 op.ntcreatex.in.root_fid.fnum = 0; 363 363 op.ntcreatex.in.flags = 0; 364 364 op.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; … … 395 395 396 396 op.generic.level = RAW_OPEN_NTCREATEX; 397 op.ntcreatex.in.root_fid = 0;397 op.ntcreatex.in.root_fid.fnum = 0; 398 398 op.ntcreatex.in.flags = 0; 399 399 op.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; … … 436 436 437 437 438 struct unlink_defer_cli_state { 439 struct torture_context *tctx; 440 struct smbcli_state *cli1; 441 }; 442 443 /* 444 * A handler function for oplock break requests. Ack it as a break to none 445 */ 446 static bool oplock_handler_ack_to_none(struct smbcli_transport *transport, 447 uint16_t tid, uint16_t fnum, 448 uint8_t level, void *private_data) 449 { 450 struct unlink_defer_cli_state *ud_cli_state = 451 (struct unlink_defer_cli_state *)private_data; 452 union smb_setfileinfo sfinfo; 453 bool ret; 454 struct smbcli_request *req = NULL; 455 456 torture_comment(ud_cli_state->tctx, "delete the file before sending " 457 "the ack."); 458 459 /* cli1: set delete on close */ 460 sfinfo.disposition_info.level = RAW_SFILEINFO_DISPOSITION_INFO; 461 sfinfo.disposition_info.in.file.fnum = fnum; 462 sfinfo.disposition_info.in.delete_on_close = 1; 463 req = smb_raw_setfileinfo_send(ud_cli_state->cli1->tree, &sfinfo); 464 465 smbcli_close(ud_cli_state->cli1->tree, fnum); 466 467 torture_comment(ud_cli_state->tctx, "Acking the oplock to NONE\n"); 468 469 ret = smbcli_oplock_ack(ud_cli_state->cli1->tree, fnum, 470 OPLOCK_BREAK_TO_NONE); 471 472 return ret; 473 } 474 475 static bool test_unlink_defer(struct torture_context *tctx, 476 struct smbcli_state *cli1, 477 struct smbcli_state *cli2) 478 { 479 const char *fname = BASEDIR "\\test_unlink_defer.dat"; 480 NTSTATUS status; 481 bool ret = true; 482 union smb_open io; 483 union smb_unlink unl; 484 uint16_t fnum=0; 485 struct unlink_defer_cli_state ud_cli_state = {}; 486 487 if (!torture_setup_dir(cli1, BASEDIR)) { 488 return false; 489 } 490 491 /* cleanup */ 492 smbcli_unlink(cli1->tree, fname); 493 494 ud_cli_state.tctx = tctx; 495 ud_cli_state.cli1 = cli1; 496 497 smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_none, 498 &ud_cli_state); 499 500 io.generic.level = RAW_OPEN_NTCREATEX; 501 io.ntcreatex.in.root_fid.fnum = 0; 502 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; 503 io.ntcreatex.in.alloc_size = 0; 504 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; 505 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | 506 NTCREATEX_SHARE_ACCESS_WRITE | 507 NTCREATEX_SHARE_ACCESS_DELETE; 508 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; 509 io.ntcreatex.in.create_options = 0; 510 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; 511 io.ntcreatex.in.security_flags = 0; 512 io.ntcreatex.in.fname = fname; 513 514 /* cli1: open file with a batch oplock. */ 515 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | 516 NTCREATEX_FLAGS_REQUEST_OPLOCK | 517 NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; 518 519 status = smb_raw_open(cli1->tree, tctx, &io); 520 CHECK_STATUS(status, NT_STATUS_OK); 521 fnum = io.ntcreatex.out.file.fnum; 522 523 /* cli2: Try to unlink it, but block on the oplock */ 524 torture_comment(tctx, "Try an unlink (should defer the open\n"); 525 unl.unlink.in.pattern = fname; 526 unl.unlink.in.attrib = 0; 527 status = smb_raw_unlink(cli2->tree, &unl); 528 529 done: 530 smb_raw_exit(cli1->session); 531 smb_raw_exit(cli2->session); 532 smbcli_deltree(cli1->tree, BASEDIR); 533 return ret; 534 } 535 438 536 /* 439 537 basic testing of unlink calls … … 441 539 struct torture_suite *torture_raw_unlink(TALLOC_CTX *mem_ctx) 442 540 { 443 struct torture_suite *suite = torture_suite_create(mem_ctx, " UNLINK");541 struct torture_suite *suite = torture_suite_create(mem_ctx, "unlink"); 444 542 445 543 torture_suite_add_1smb_test(suite, "unlink", test_unlink); 446 544 torture_suite_add_1smb_test(suite, "delete_on_close", test_delete_on_close); 545 torture_suite_add_2smb_test(suite, "unlink-defer", test_unlink_defer); 447 546 448 547 return suite; -
trunk/server/source4/torture/raw/write.c
r414 r745 1 /* 1 /* 2 2 Unix SMB/CIFS implementation. 3 3 test suite for various write operations 4 4 5 5 Copyright (C) Andrew Tridgell 2003 6 6 7 7 This program is free software; you can redistribute it and/or modify 8 8 it under the terms of the GNU General Public License as published by 9 9 the Free Software Foundation; either version 3 of the License, or 10 10 (at your option) any later version. 11 11 12 12 This program is distributed in the hope that it will be useful, 13 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 15 GNU General Public License for more details. 16 16 17 17 You should have received a copy of the GNU General Public License 18 18 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 20 20 21 21 #include "includes.h" 22 #include "torture/torture.h"23 22 #include "libcli/raw/libcliraw.h" 24 #include "libcli/raw/raw_proto.h"25 23 #include "system/time.h" 26 24 #include "system/filesys.h" … … 30 28 #define CHECK_STATUS(status, correct) do { \ 31 29 if (!NT_STATUS_EQUAL(status, correct)) { \ 32 printf("(%s) Incorrect status %s - should be %s\n", \33 __location__, nt_errstr(status), nt_errstr(correct)) ; \30 torture_fail(tctx, talloc_asprintf(tctx, "(%s) Incorrect status %s - should be %s\n", \ 31 __location__, nt_errstr(status), nt_errstr(correct))); \ 34 32 ret = false; \ 35 33 goto done; \ … … 38 36 #define CHECK_VALUE(v, correct) do { \ 39 37 if ((v) != (correct)) { \ 40 printf("(%s) Incorrect value %s=%d - should be %d\n", \41 __location__, #v, v, correct) ; \38 torture_fail(tctx, talloc_asprintf(tctx, "(%s) Incorrect value %s=%d - should be %d\n", \ 39 __location__, #v, v, correct)); \ 42 40 ret = false; \ 43 41 goto done; \ … … 45 43 46 44 #define CHECK_BUFFER(buf, seed, len) do { \ 47 if (!check_buffer( buf, seed, len, __location__)) { \45 if (!check_buffer(tctx, buf, seed, len, __location__)) { \ 48 46 ret = false; \ 49 47 goto done; \ … … 56 54 CHECK_STATUS(status, NT_STATUS_OK); \ 57 55 if ((v) != finfo.all_info.out.field) { \ 58 printf("(%s) wrong value for field %s %.0f - %.0f\n", \56 torture_comment(tctx, "(%s) wrong value for field %s %.0f - %.0f\n", \ 59 57 __location__, #field, (double)v, (double)finfo.all_info.out.field); \ 60 58 dump_all_info(tctx, &finfo); \ … … 69 67 setup a random buffer based on a seed 70 68 */ 71 static void setup_buffer(uint8_t *buf, u int_t seed, int len)69 static void setup_buffer(uint8_t *buf, unsigned int seed, int len) 72 70 { 73 71 int i; … … 79 77 check a random buffer based on a seed 80 78 */ 81 static bool check_buffer(uint8_t *buf, uint_t seed, int len, const char *location) 79 static bool check_buffer(struct torture_context *tctx, 80 uint8_t *buf, unsigned int seed, int len, const char *location) 82 81 { 83 82 int i; … … 86 85 uint8_t v = random(); 87 86 if (buf[i] != v) { 88 printf("Buffer incorrect at %s! ofs=%d buf=0x%x correct=0x%x\n",89 location, i, buf[i], v) ;87 torture_fail(tctx, talloc_asprintf(tctx, "Buffer incorrect at %s! ofs=%d buf=0x%x correct=0x%x\n", 88 location, i, buf[i], v)); 90 89 return false; 91 90 } … … 97 96 test write ops 98 97 */ 99 static bool test_write(struct torture_context *tctx, 100 98 static bool test_write(struct torture_context *tctx, 99 struct smbcli_state *cli) 101 100 { 102 101 union smb_write io; … … 107 106 const int maxsize = 90000; 108 107 const char *fname = BASEDIR "\\test.txt"; 109 u int_t seed = time(NULL);108 unsigned int seed = time(NULL); 110 109 union smb_fileinfo finfo; 111 110 … … 113 112 114 113 if (!torture_setup_dir(cli, BASEDIR)) { 115 return false;116 } 117 118 printf("Testing RAW_WRITE_WRITE\n");114 torture_fail(tctx, "failed to setup basedir"); 115 } 116 117 torture_comment(tctx, "Testing RAW_WRITE_WRITE\n"); 119 118 io.generic.level = RAW_WRITE_WRITE; 120 119 121 120 fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); 122 121 if (fnum == -1) { 123 printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));124 ret = false;125 goto done;126 } 127 128 printf("Trying zero write\n");122 ret = false; 123 torture_fail_goto(tctx, done, 124 talloc_asprintf(tctx, "Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree))); 125 } 126 127 torture_comment(tctx, "Trying zero write\n"); 129 128 io.write.in.file.fnum = fnum; 130 129 io.write.in.count = 0; … … 138 137 setup_buffer(buf, seed, maxsize); 139 138 140 printf("Trying small write\n");139 torture_comment(tctx, "Trying small write\n"); 141 140 io.write.in.count = 9; 142 141 io.write.in.offset = 4; … … 148 147 memset(buf, 0, maxsize); 149 148 if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) { 150 printf("read failed at %s\n", __location__); 151 ret = false; 152 goto done; 149 ret = false; 150 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__)); 153 151 } 154 152 CHECK_BUFFER(buf+4, seed, 9); … … 157 155 setup_buffer(buf, seed, maxsize); 158 156 159 printf("Trying large write\n");157 torture_comment(tctx, "Trying large write\n"); 160 158 io.write.in.count = 4000; 161 159 io.write.in.offset = 0; … … 167 165 memset(buf, 0, maxsize); 168 166 if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) { 169 printf("read failed at %s\n", __location__); 170 ret = false; 171 goto done; 167 ret = false; 168 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__)); 172 169 } 173 170 CHECK_BUFFER(buf, seed, 4000); 174 171 175 printf("Trying bad fnum\n");172 torture_comment(tctx, "Trying bad fnum\n"); 176 173 io.write.in.file.fnum = fnum+1; 177 174 io.write.in.count = 4000; … … 181 178 CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE); 182 179 183 printf("Setting file as sparse\n");180 torture_comment(tctx, "Setting file as sparse\n"); 184 181 status = torture_set_sparse(cli->tree, fnum); 185 182 CHECK_STATUS(status, NT_STATUS_OK); 186 183 187 184 if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) { 188 printf("skipping large file tests - CAP_LARGE_FILES not set\n");185 torture_comment(tctx, "skipping large file tests - CAP_LARGE_FILES not set\n"); 189 186 goto done; 190 187 } 191 192 if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) { 193 printf("skipping large file tests - CAP_LARGE_FILES not set\n"); 194 goto done; 195 } 196 197 printf("Trying 2^32 offset\n"); 188 189 torture_comment(tctx, "Trying 2^32 offset\n"); 198 190 setup_buffer(buf, seed, maxsize); 199 191 io.write.in.file.fnum = fnum; … … 205 197 CHECK_VALUE(io.write.out.nwritten, 4000); 206 198 CHECK_ALL_INFO(io.write.in.count + (uint64_t)io.write.in.offset, size); 207 199 208 200 memset(buf, 0, maxsize); 209 201 if (smbcli_read(cli->tree, fnum, buf, io.write.in.offset, 4000) != 4000) { 210 printf("read failed at %s\n", __location__); 211 ret = false; 212 goto done; 202 ret = false; 203 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__)); 213 204 } 214 205 CHECK_BUFFER(buf, seed, 4000); … … 225 216 test writex ops 226 217 */ 227 static bool test_writex(struct torture_context *tctx, 228 218 static bool test_writex(struct torture_context *tctx, 219 struct smbcli_state *cli) 229 220 { 230 221 union smb_write io; … … 235 226 const int maxsize = 90000; 236 227 const char *fname = BASEDIR "\\test.txt"; 237 u int_t seed = time(NULL);228 unsigned int seed = time(NULL); 238 229 union smb_fileinfo finfo; 239 230 int max_bits=63; … … 246 237 buf = talloc_zero_array(tctx, uint8_t, maxsize); 247 238 239 if (!cli->transport->negotiate.lockread_supported) { 240 torture_comment(tctx, "Server does not support writeunlock - skipping\n"); 241 return true; 242 } 243 248 244 if (!torture_setup_dir(cli, BASEDIR)) { 249 return false;250 } 251 252 printf("Testing RAW_WRITE_WRITEX\n");245 torture_fail(tctx, "failed to setup basedir"); 246 } 247 248 torture_comment(tctx, "Testing RAW_WRITE_WRITEX\n"); 253 249 io.generic.level = RAW_WRITE_WRITEX; 254 250 255 251 fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); 256 252 if (fnum == -1) { 257 printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); 258 ret = false; 259 goto done; 260 } 261 262 printf("Trying zero write\n"); 253 ret = false; 254 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree))); 255 } 256 257 torture_comment(tctx, "Trying zero write\n"); 263 258 io.writex.in.file.fnum = fnum; 264 259 io.writex.in.offset = 0; … … 273 268 setup_buffer(buf, seed, maxsize); 274 269 275 printf("Trying small write\n");270 torture_comment(tctx, "Trying small write\n"); 276 271 io.writex.in.count = 9; 277 272 io.writex.in.offset = 4; … … 283 278 memset(buf, 0, maxsize); 284 279 if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) { 285 printf("read failed at %s\n", __location__); 286 ret = false; 287 goto done; 280 ret = false; 281 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__)); 288 282 } 289 283 CHECK_BUFFER(buf+4, seed, 9); … … 292 286 setup_buffer(buf, seed, maxsize); 293 287 294 printf("Trying large write\n");288 torture_comment(tctx, "Trying large write\n"); 295 289 io.writex.in.count = 4000; 296 290 io.writex.in.offset = 0; … … 302 296 memset(buf, 0, maxsize); 303 297 if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) { 304 printf("read failed at %s\n", __location__); 305 ret = false; 306 goto done; 298 ret = false; 299 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__)); 307 300 } 308 301 CHECK_BUFFER(buf, seed, 4000); 309 302 310 printf("Trying bad fnum\n");303 torture_comment(tctx, "Trying bad fnum\n"); 311 304 io.writex.in.file.fnum = fnum+1; 312 305 io.writex.in.count = 4000; … … 316 309 CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE); 317 310 318 printf("Testing wmode\n");311 torture_comment(tctx, "Testing wmode\n"); 319 312 io.writex.in.file.fnum = fnum; 320 313 io.writex.in.count = 1; … … 332 325 333 326 334 printf("Trying locked region\n");327 torture_comment(tctx, "Trying locked region\n"); 335 328 cli->session->pid++; 336 329 if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 3, 1, 0, WRITE_LOCK))) { 337 printf("Failed to lock file at %s\n", __location__); 338 ret = false; 339 goto done; 330 ret = false; 331 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "Failed to lock file at %s\n", __location__)); 340 332 } 341 333 cli->session->pid--; … … 346 338 CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT); 347 339 348 printf("Setting file as sparse\n");340 torture_comment(tctx, "Setting file as sparse\n"); 349 341 status = torture_set_sparse(cli->tree, fnum); 350 342 CHECK_STATUS(status, NT_STATUS_OK); 351 343 352 344 if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) { 353 printf("skipping large file tests - CAP_LARGE_FILES not set\n"); 354 goto done; 355 } 356 357 printf("Trying 2^32 offset\n"); 345 torture_skip(tctx, "skipping large file tests - CAP_LARGE_FILES not set\n"); 346 } 347 348 torture_comment(tctx, "Trying 2^32 offset\n"); 358 349 setup_buffer(buf, seed, maxsize); 359 350 io.writex.in.file.fnum = fnum; … … 368 359 memset(buf, 0, maxsize); 369 360 if (smbcli_read(cli->tree, fnum, buf, io.writex.in.offset, 4000) != 4000) { 370 printf("read failed at %s\n", __location__); 371 ret = false; 372 goto done; 361 ret = false; 362 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__)); 373 363 } 374 364 CHECK_BUFFER(buf, seed, 4000); 375 365 376 366 for (i=33;i<max_bits;i++) { 377 printf("Trying 2^%d offset\n", i);367 torture_comment(tctx, "Trying 2^%d offset\n", i); 378 368 setup_buffer(buf, seed+1, maxsize); 379 369 io.writex.in.file.fnum = fnum; … … 392 382 memset(buf, 0, maxsize); 393 383 if (smbcli_read(cli->tree, fnum, buf, io.writex.in.offset, 4000) != 4000) { 394 printf("read failed at %s\n", __location__);395 384 ret = false; 396 goto done;385 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__)); 397 386 } 398 387 CHECK_BUFFER(buf, seed+1, 4000); 399 388 } 400 printf("limit is 2^%d\n", i);389 torture_comment(tctx, "limit is 2^%d\n", i); 401 390 402 391 setup_buffer(buf, seed, maxsize); … … 413 402 test write unlock ops 414 403 */ 415 static bool test_writeunlock(struct torture_context *tctx, 416 404 static bool test_writeunlock(struct torture_context *tctx, 405 struct smbcli_state *cli) 417 406 { 418 407 union smb_write io; … … 423 412 const int maxsize = 90000; 424 413 const char *fname = BASEDIR "\\test.txt"; 425 u int_t seed = time(NULL);414 unsigned int seed = time(NULL); 426 415 union smb_fileinfo finfo; 427 416 428 417 buf = talloc_zero_array(tctx, uint8_t, maxsize); 429 418 419 if (!cli->transport->negotiate.lockread_supported) { 420 torture_skip(tctx, "Server does not support writeunlock - skipping\n"); 421 } 422 430 423 if (!torture_setup_dir(cli, BASEDIR)) { 431 return false;432 } 433 434 printf("Testing RAW_WRITE_WRITEUNLOCK\n");424 torture_fail(tctx, "failed to setup basedir"); 425 } 426 427 torture_comment(tctx, "Testing RAW_WRITE_WRITEUNLOCK\n"); 435 428 io.generic.level = RAW_WRITE_WRITEUNLOCK; 436 429 437 430 fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); 438 431 if (fnum == -1) { 439 printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); 440 ret = false; 441 goto done; 442 } 443 444 printf("Trying zero write\n"); 432 ret = false; 433 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree))); 434 } 435 436 torture_comment(tctx, "Trying zero write\n"); 445 437 io.writeunlock.in.file.fnum = fnum; 446 438 io.writeunlock.in.count = 0; … … 454 446 setup_buffer(buf, seed, maxsize); 455 447 456 printf("Trying small write\n");448 torture_comment(tctx, "Trying small write\n"); 457 449 io.writeunlock.in.count = 9; 458 450 io.writeunlock.in.offset = 4; … … 461 453 CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED); 462 454 if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) { 463 printf("read failed at %s\n", __location__); 464 ret = false; 465 goto done; 455 ret = false; 456 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__)); 466 457 } 467 458 CHECK_BUFFER(buf+4, seed, 9); … … 469 460 470 461 setup_buffer(buf, seed, maxsize); 471 smbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count, 462 smbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count, 472 463 0, WRITE_LOCK); 473 464 status = smb_raw_write(cli->tree, &io); … … 477 468 memset(buf, 0, maxsize); 478 469 if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) { 479 printf("read failed at %s\n", __location__); 480 ret = false; 481 goto done; 470 ret = false; 471 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__)); 482 472 } 483 473 CHECK_BUFFER(buf+4, seed, 9); … … 486 476 setup_buffer(buf, seed, maxsize); 487 477 488 printf("Trying large write\n");478 torture_comment(tctx, "Trying large write\n"); 489 479 io.writeunlock.in.count = 4000; 490 480 io.writeunlock.in.offset = 0; 491 481 io.writeunlock.in.data = buf; 492 smbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count, 482 smbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count, 493 483 0, WRITE_LOCK); 494 484 status = smb_raw_write(cli->tree, &io); … … 501 491 memset(buf, 0, maxsize); 502 492 if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) { 503 printf("read failed at %s\n", __location__); 504 ret = false; 505 goto done; 493 ret = false; 494 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__)); 506 495 } 507 496 CHECK_BUFFER(buf, seed, 4000); 508 497 509 printf("Trying bad fnum\n");498 torture_comment(tctx, "Trying bad fnum\n"); 510 499 io.writeunlock.in.file.fnum = fnum+1; 511 500 io.writeunlock.in.count = 4000; … … 515 504 CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE); 516 505 517 printf("Setting file as sparse\n");506 torture_comment(tctx, "Setting file as sparse\n"); 518 507 status = torture_set_sparse(cli->tree, fnum); 519 508 CHECK_STATUS(status, NT_STATUS_OK); 520 509 521 510 if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) { 522 printf("skipping large file tests - CAP_LARGE_FILES not set\n"); 523 goto done; 524 } 525 526 printf("Trying 2^32 offset\n"); 511 torture_skip(tctx, "skipping large file tests - CAP_LARGE_FILES not set\n"); 512 } 513 514 torture_comment(tctx, "Trying 2^32 offset\n"); 527 515 setup_buffer(buf, seed, maxsize); 528 516 io.writeunlock.in.file.fnum = fnum; … … 530 518 io.writeunlock.in.offset = 0xFFFFFFFF - 2000; 531 519 io.writeunlock.in.data = buf; 532 smbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count, 520 smbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count, 533 521 0, WRITE_LOCK); 534 522 status = smb_raw_write(cli->tree, &io); … … 539 527 memset(buf, 0, maxsize); 540 528 if (smbcli_read(cli->tree, fnum, buf, io.writeunlock.in.offset, 4000) != 4000) { 541 printf("read failed at %s\n", __location__); 542 ret = false; 543 goto done; 529 ret = false; 530 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__)); 544 531 } 545 532 CHECK_BUFFER(buf, seed, 4000); … … 556 543 test write close ops 557 544 */ 558 static bool test_writeclose(struct torture_context *tctx, 559 545 static bool test_writeclose(struct torture_context *tctx, 546 struct smbcli_state *cli) 560 547 { 561 548 union smb_write io; … … 566 553 const int maxsize = 90000; 567 554 const char *fname = BASEDIR "\\test.txt"; 568 u int_t seed = time(NULL);555 unsigned int seed = time(NULL); 569 556 union smb_fileinfo finfo; 570 557 571 558 buf = talloc_zero_array(tctx, uint8_t, maxsize); 572 559 560 if (!torture_setting_bool(tctx, "writeclose_support", true)) { 561 torture_skip(tctx, "Server does not support writeclose - skipping\n"); 562 } 563 573 564 if (!torture_setup_dir(cli, BASEDIR)) { 574 return false;575 } 576 577 printf("Testing RAW_WRITE_WRITECLOSE\n");565 torture_fail(tctx, "failed to setup basedir"); 566 } 567 568 torture_comment(tctx, "Testing RAW_WRITE_WRITECLOSE\n"); 578 569 io.generic.level = RAW_WRITE_WRITECLOSE; 579 570 580 571 fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); 581 572 if (fnum == -1) { 582 printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); 583 ret = false; 584 goto done; 585 } 586 587 printf("Trying zero write\n"); 573 ret = false; 574 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree))); 575 } 576 577 torture_comment(tctx, "Trying zero write\n"); 588 578 io.writeclose.in.file.fnum = fnum; 589 579 io.writeclose.in.count = 0; … … 601 591 setup_buffer(buf, seed, maxsize); 602 592 603 printf("Trying small write\n");593 torture_comment(tctx, "Trying small write\n"); 604 594 io.writeclose.in.count = 9; 605 595 io.writeclose.in.offset = 4; … … 615 605 616 606 if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) { 617 printf("read failed at %s\n", __location__); 618 ret = false; 619 goto done; 607 ret = false; 608 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__)); 620 609 } 621 610 CHECK_BUFFER(buf+4, seed, 9); … … 632 621 memset(buf, 0, maxsize); 633 622 if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) { 634 printf("read failed at %s\n", __location__); 635 ret = false; 636 goto done; 623 ret = false; 624 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__)); 637 625 } 638 626 CHECK_BUFFER(buf+4, seed, 9); … … 641 629 setup_buffer(buf, seed, maxsize); 642 630 643 printf("Trying large write\n");631 torture_comment(tctx, "Trying large write\n"); 644 632 io.writeclose.in.count = 4000; 645 633 io.writeclose.in.offset = 0; … … 657 645 memset(buf, 0, maxsize); 658 646 if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) { 659 printf("read failed at %s\n", __location__); 660 ret = false; 661 goto done; 647 ret = false; 648 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__)); 662 649 } 663 650 CHECK_BUFFER(buf, seed, 4000); 664 651 665 printf("Trying bad fnum\n");652 torture_comment(tctx, "Trying bad fnum\n"); 666 653 io.writeclose.in.file.fnum = fnum+1; 667 654 io.writeclose.in.count = 4000; … … 671 658 CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE); 672 659 673 printf("Setting file as sparse\n");660 torture_comment(tctx, "Setting file as sparse\n"); 674 661 status = torture_set_sparse(cli->tree, fnum); 675 662 CHECK_STATUS(status, NT_STATUS_OK); 676 663 677 664 if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) { 678 printf("skipping large file tests - CAP_LARGE_FILES not set\n"); 679 goto done; 680 } 681 682 printf("Trying 2^32 offset\n"); 665 torture_skip(tctx, "skipping large file tests - CAP_LARGE_FILES not set\n"); 666 } 667 668 torture_comment(tctx, "Trying 2^32 offset\n"); 683 669 setup_buffer(buf, seed, maxsize); 684 670 io.writeclose.in.file.fnum = fnum; … … 696 682 memset(buf, 0, maxsize); 697 683 if (smbcli_read(cli->tree, fnum, buf, io.writeclose.in.offset, 4000) != 4000) { 698 printf("read failed at %s\n", __location__); 699 ret = false; 700 goto done; 684 ret = false; 685 torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__)); 701 686 } 702 687 CHECK_BUFFER(buf, seed, 4000); … … 709 694 } 710 695 711 /* 696 /* 712 697 basic testing of write calls 713 698 */ 714 699 struct torture_suite *torture_raw_write(TALLOC_CTX *mem_ctx) 715 700 { 716 struct torture_suite *suite = torture_suite_create(mem_ctx, " WRITE");701 struct torture_suite *suite = torture_suite_create(mem_ctx, "write"); 717 702 718 703 torture_suite_add_1smb_test(suite, "write", test_write);
Note:
See TracChangeset
for help on using the changeset viewer.