diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index b0910433940..3a739d6e4a6 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -2075,12 +2075,9 @@ sub provision($$) my $badnames_shrdir="$shrdir/badnames"; push(@dirs,$badnames_shrdir); - my $lease1_shrdir="$shrdir/SMB2_10"; + my $lease1_shrdir="$shrdir/dynamic"; push(@dirs,$lease1_shrdir); - my $lease2_shrdir="$shrdir/SMB3_00"; - push(@dirs,$lease2_shrdir); - my $manglenames_shrdir="$shrdir/manglenames"; push(@dirs,$manglenames_shrdir); @@ -2652,8 +2649,9 @@ sub provision($$) guest ok = yes [dynamic_share] - path = $shrdir/%R + path = $shrdir/dynamic/%t guest ok = yes + root preexec = mkdir %P [widelinks_share] path = $widelinks_shrdir diff --git a/source4/torture/smb2/lease.c b/source4/torture/smb2/lease.c index d3b8daea310..6b7f10b5eb7 100644 --- a/source4/torture/smb2/lease.c +++ b/source4/torture/smb2/lease.c @@ -3869,10 +3869,9 @@ static bool test_lease_dynamic_share(struct torture_context *tctx, const char *fname = "dynamic_path.dat"; bool ret = true; uint32_t caps; - struct smb2_tree *tree_2_1 = NULL; - struct smb2_tree *tree_3_0 = NULL; - struct smbcli_options options2_1; - struct smbcli_options options3_0; + struct smb2_tree *tree_2 = NULL; + struct smb2_tree *tree_3 = NULL; + struct smbcli_options options; const char *orig_share = NULL; if (!TARGET_IS_SAMBA3(tctx)) { @@ -3880,8 +3879,8 @@ static bool test_lease_dynamic_share(struct torture_context *tctx, return true; } - options2_1 = tree1a->session->transport->options; - options3_0 = tree1a->session->transport->options; + options = tree1a->session->transport->options; + options.client_guid = GUID_random(); caps = smb2cli_conn_server_capabilities(tree1a->session->transport->conn); if (!(caps & SMB2_CAP_LEASING)) { @@ -3891,7 +3890,8 @@ static bool test_lease_dynamic_share(struct torture_context *tctx, /* * Save off original share name and change it to dynamic_share. * This must have been pre-created with a dynamic path containing - * %R. + * %t. It means we'll sleep between the connects in order to + * get a different timestamp for the share path. */ orig_share = lpcfg_parm_string(tctx->lp_ctx, NULL, "torture", "share"); @@ -3903,10 +3903,9 @@ static bool test_lease_dynamic_share(struct torture_context *tctx, } lpcfg_set_cmdline(tctx->lp_ctx, "torture:share", "dynamic_share"); - /* Set max protocol to SMB2.1 */ - options2_1.max_protocol = PROTOCOL_SMB2_10; /* create a new connection (same client_guid) */ - if (!torture_smb2_connection_ext(tctx, 0, &options2_1, &tree_2_1)) { + sleep(2); + if (!torture_smb2_connection_ext(tctx, 0, &options, &tree_2)) { torture_result(tctx, TORTURE_FAIL, __location__ "couldn't reconnect " "max protocol 2.1, bailing\n"); @@ -3914,17 +3913,16 @@ static bool test_lease_dynamic_share(struct torture_context *tctx, goto done; } - tree_2_1->session->transport->lease.handler = torture_lease_handler; - tree_2_1->session->transport->lease.private_data = tree_2_1; - tree_2_1->session->transport->oplock.handler = torture_oplock_handler; - tree_2_1->session->transport->oplock.private_data = tree_2_1; + tree_2->session->transport->lease.handler = torture_lease_handler; + tree_2->session->transport->lease.private_data = tree_2; + tree_2->session->transport->oplock.handler = torture_oplock_handler; + tree_2->session->transport->oplock.private_data = tree_2; - smb2_util_unlink(tree_2_1, fname); + smb2_util_unlink(tree_2, fname); - /* Set max protocol to SMB3.0 */ - options3_0.max_protocol = PROTOCOL_SMB3_00; /* create a new connection (same client_guid) */ - if (!torture_smb2_connection_ext(tctx, 0, &options3_0, &tree_3_0)) { + sleep(2); + if (!torture_smb2_connection_ext(tctx, 0, &options, &tree_3)) { torture_result(tctx, TORTURE_FAIL, __location__ "couldn't reconnect " "max protocol 3.0, bailing\n"); @@ -3932,18 +3930,18 @@ static bool test_lease_dynamic_share(struct torture_context *tctx, goto done; } - tree_3_0->session->transport->lease.handler = torture_lease_handler; - tree_3_0->session->transport->lease.private_data = tree_3_0; - tree_3_0->session->transport->oplock.handler = torture_oplock_handler; - tree_3_0->session->transport->oplock.private_data = tree_3_0; + tree_3->session->transport->lease.handler = torture_lease_handler; + tree_3->session->transport->lease.private_data = tree_3; + tree_3->session->transport->oplock.handler = torture_oplock_handler; + tree_3->session->transport->oplock.private_data = tree_3; - smb2_util_unlink(tree_3_0, fname); + smb2_util_unlink(tree_3, fname); ZERO_STRUCT(lease_break_info); - /* Get RWH lease over connection 2_1 */ + /* Get RWH lease over connection 2 */ smb2_lease_create(&io, &ls1, false, fname, LEASE1, smb2_util_lease_state("RWH")); - status = smb2_create(tree_2_1, mem_ctx, &io); + status = smb2_create(tree_2, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); CHECK_LEASE(&io, "RWH", true, LEASE1, 0); @@ -3954,12 +3952,12 @@ static bool test_lease_dynamic_share(struct torture_context *tctx, w.in.offset = 0; w.in.data = data_blob_talloc(mem_ctx, NULL, 4096); memset(w.in.data.data, '1', w.in.data.length); - status = smb2_write(tree_2_1, &w); + status = smb2_write(tree_2, &w); CHECK_STATUS(status, NT_STATUS_OK); - /* Open the same name over connection 3_0. */ + /* Open the same name over connection 3. */ smb2_lease_create(&io, &ls1, false, fname, LEASE1, smb2_util_lease_state("RWH")); - status = smb2_create(tree_3_0, mem_ctx, &io); + status = smb2_create(tree_3, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); h1 = io.out.file.handle; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -3970,9 +3968,9 @@ static bool test_lease_dynamic_share(struct torture_context *tctx, /* We should have broken h to NONE. */ CHECK_BREAK_INFO("RWH", "", LEASE1); - /* Try to upgrade to RWH over connection 2_1 */ + /* Try to upgrade to RWH over connection 2 */ smb2_lease_create(&io, &ls1, false, fname, LEASE1, smb2_util_lease_state("RWH")); - status = smb2_create(tree_2_1, mem_ctx, &io); + status = smb2_create(tree_2, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); h2 = io.out.file.handle; CHECK_VAL(io.out.create_action, NTCREATEX_ACTION_EXISTED); @@ -3980,11 +3978,11 @@ static bool test_lease_dynamic_share(struct torture_context *tctx, CHECK_VAL(io.out.file_attr, FILE_ATTRIBUTE_ARCHIVE); /* Should have been denied. */ CHECK_LEASE(&io, "", true, LEASE1, 0); - smb2_util_close(tree_2_1, h2); + smb2_util_close(tree_2, h2); - /* Try to upgrade to RWH over connection 3_0 */ + /* Try to upgrade to RWH over connection 3 */ smb2_lease_create(&io, &ls1, false, fname, LEASE1, smb2_util_lease_state("RWH")); - status = smb2_create(tree_3_0, mem_ctx, &io); + status = smb2_create(tree_3, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); h2 = io.out.file.handle; CHECK_VAL(io.out.create_action, NTCREATEX_ACTION_EXISTED); @@ -3992,23 +3990,23 @@ static bool test_lease_dynamic_share(struct torture_context *tctx, CHECK_VAL(io.out.file_attr, FILE_ATTRIBUTE_ARCHIVE); /* Should have been denied. */ CHECK_LEASE(&io, "", true, LEASE1, 0); - smb2_util_close(tree_3_0, h2); + smb2_util_close(tree_3, h2); /* Write some data into it. */ w.in.file.handle = h1; w.in.offset = 0; w.in.data = data_blob_talloc(mem_ctx, NULL, 1024); memset(w.in.data.data, '2', w.in.data.length); - status = smb2_write(tree_3_0, &w); + status = smb2_write(tree_3, &w); CHECK_STATUS(status, NT_STATUS_OK); /* Close everything.. */ - smb2_util_close(tree_2_1, h); - smb2_util_close(tree_3_0, h1); + smb2_util_close(tree_2, h); + smb2_util_close(tree_3, h1); /* And ensure we can get a lease ! */ smb2_lease_create(&io, &ls1, false, fname, LEASE1, smb2_util_lease_state("RWH")); - status = smb2_create(tree_2_1, mem_ctx, &io); + status = smb2_create(tree_2, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VAL(io.out.create_action, NTCREATEX_ACTION_EXISTED); CHECK_VAL(io.out.file_attr, FILE_ATTRIBUTE_ARCHIVE); @@ -4017,11 +4015,11 @@ static bool test_lease_dynamic_share(struct torture_context *tctx, /* And the file is the right size. */ CHECK_VAL(io.out.size, 4096); \ /* Close it. */ - smb2_util_close(tree_2_1, h); + smb2_util_close(tree_2, h); /* And ensure we can get a lease ! */ smb2_lease_create(&io, &ls1, false, fname, LEASE1, smb2_util_lease_state("RWH")); - status = smb2_create(tree_3_0, mem_ctx, &io); + status = smb2_create(tree_3, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VAL(io.out.create_action, NTCREATEX_ACTION_EXISTED); CHECK_VAL(io.out.file_attr, FILE_ATTRIBUTE_ARCHIVE); @@ -4030,19 +4028,19 @@ static bool test_lease_dynamic_share(struct torture_context *tctx, /* And the file is the right size. */ CHECK_VAL(io.out.size, 1024); \ /* Close it. */ - smb2_util_close(tree_3_0, h); + smb2_util_close(tree_3, h); done: - if (tree_2_1 != NULL) { - smb2_util_close(tree_2_1, h); - smb2_util_unlink(tree_2_1, fname); + if (tree_2 != NULL) { + smb2_util_close(tree_2, h); + smb2_util_unlink(tree_2, fname); } - if (tree_3_0 != NULL) { - smb2_util_close(tree_3_0, h1); - smb2_util_close(tree_3_0, h2); + if (tree_3 != NULL) { + smb2_util_close(tree_3, h1); + smb2_util_close(tree_3, h2); - smb2_util_unlink(tree_3_0, fname); + smb2_util_unlink(tree_3, fname); } /* Set sharename back. */