diff options
-rw-r--r-- | source3/include/client.h | 1 | ||||
-rw-r--r-- | source3/libsmb/smb2cli_tcon.c | 13 | ||||
-rw-r--r-- | source3/torture/test_smb2.c | 45 |
3 files changed, 27 insertions, 32 deletions
diff --git a/source3/include/client.h b/source3/include/client.h index 00a7e1b40c..b2b589a82e 100644 --- a/source3/include/client.h +++ b/source3/include/client.h @@ -109,7 +109,6 @@ struct cli_state { struct { uint32_t pid; - uint32_t tid; struct smbXcli_session *session; struct smbXcli_tcon *tcon; diff --git a/source3/libsmb/smb2cli_tcon.c b/source3/libsmb/smb2cli_tcon.c index 615dcfa2d9..ed5b00b329 100644 --- a/source3/libsmb/smb2cli_tcon.c +++ b/source3/libsmb/smb2cli_tcon.c @@ -106,6 +106,7 @@ static void smb2cli_tcon_done(struct tevent_req *subreq) NTSTATUS status; struct iovec *iov; uint8_t *body; + uint32_t tcon_id; static const struct smb2cli_req_expected_response expected[] = { { .status = NT_STATUS_OK, @@ -121,7 +122,7 @@ static void smb2cli_tcon_done(struct tevent_req *subreq) return; } - cli->smb2.tid = IVAL(iov[0].iov_base, SMB2_HDR_TID); + tcon_id = IVAL(iov[0].iov_base, SMB2_HDR_TID); body = (uint8_t *)iov[1].iov_base; cli->smb2.share_type = CVAL(body, 2); @@ -137,7 +138,7 @@ static void smb2cli_tcon_done(struct tevent_req *subreq) } smb2cli_tcon_set_values(cli->smb2.tcon, - cli->smb2.tid, + tcon_id, cli->smb2.share_type, cli->smb2.share_flags, cli->smb2.share_capabilities, @@ -195,6 +196,7 @@ struct tevent_req *smb2cli_tdis_send(TALLOC_CTX *mem_ctx, { struct tevent_req *req, *subreq; struct smb2cli_tdis_state *state; + uint32_t tcon_id = 0; req = tevent_req_create(mem_ctx, &state, struct smb2cli_tdis_state); @@ -204,11 +206,15 @@ struct tevent_req *smb2cli_tdis_send(TALLOC_CTX *mem_ctx, state->cli = cli; SSVAL(state->fixed, 0, 4); + if (cli->smb2.tcon) { + tcon_id = smb2cli_tcon_current_id(cli->smb2.tcon); + } + subreq = smb2cli_req_send(state, ev, cli->conn, SMB2_OP_TDIS, 0, 0, /* flags */ cli->timeout, cli->smb2.pid, - cli->smb2.tid, + tcon_id, cli->smb2.session, state->fixed, sizeof(state->fixed), NULL, 0); @@ -241,7 +247,6 @@ static void smb2cli_tdis_done(struct tevent_req *subreq) if (tevent_req_nterror(req, status)) { return; } - state->cli->smb2.tid = 0; TALLOC_FREE(state->cli->smb2.tcon); tevent_req_done(req); } diff --git a/source3/torture/test_smb2.c b/source3/torture/test_smb2.c index 657883bb43..121ab4b9d0 100644 --- a/source3/torture/test_smb2.c +++ b/source3/torture/test_smb2.c @@ -169,7 +169,7 @@ bool run_smb2_basic(int dummy) return false; } - saved_tid = cli->smb2.tid; + saved_tid = smb2cli_tcon_current_id(cli->smb2.tcon); saved_tcon = cli->smb2.tcon; cli->smb2.tcon = smbXcli_tcon_create(cli); smb2cli_tcon_set_values(cli->smb2.tcon, @@ -185,7 +185,6 @@ bool run_smb2_basic(int dummy) } talloc_free(cli->smb2.tcon); cli->smb2.tcon = saved_tcon; - cli->smb2.tid = saved_tid; status = smb2cli_tdis(cli); if (!NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_NAME_DELETED)) { @@ -598,10 +597,8 @@ bool run_smb2_session_reconnect(int dummy) /* the tid seems to be irrelevant at this stage */ - cli2->smb2.tid = cli1->smb2.tid; - status = smb2cli_flush(cli2->conn, cli2->timeout, cli2->smb2.session, - cli2->smb2.tcon, fid_persistent, fid_volatile); + cli1->smb2.tcon, fid_persistent, fid_volatile); if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_CLOSED) && !NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_NAME_DELETED)) { @@ -610,7 +607,7 @@ bool run_smb2_session_reconnect(int dummy) } status = smb2cli_write(cli2->conn, cli2->timeout, cli2->smb2.session, - cli2->smb2.tcon, strlen(hello), 0, fid_persistent, + cli1->smb2.tcon, strlen(hello), 0, fid_persistent, fid_volatile, 0, 0, (const uint8_t *)hello); if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_CLOSED) && !NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_NAME_DELETED)) @@ -620,7 +617,7 @@ bool run_smb2_session_reconnect(int dummy) } status = smb2cli_read(cli2->conn, cli2->timeout, cli2->smb2.session, - cli2->smb2.tcon, 0x10000, 0, fid_persistent, + cli1->smb2.tcon, 0x10000, 0, fid_persistent, fid_volatile, 2, 0, talloc_tos(), &result, &nread); if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_CLOSED) && @@ -631,7 +628,7 @@ bool run_smb2_session_reconnect(int dummy) } status = smb2cli_create(cli2->conn, cli2->timeout, cli2->smb2.session, - cli2->smb2.tcon, "session-reconnect.txt", + cli1->smb2.tcon, "session-reconnect.txt", SMB2_OPLOCK_LEVEL_NONE, /* oplock_level, */ SMB2_IMPERSONATION_IMPERSONATION, /* impersonation_level, */ SEC_STD_ALL | SEC_FILE_ALL, /* desired_access, */ @@ -1036,8 +1033,6 @@ bool run_smb2_multi_channel(int dummy) return false; } - cli2->smb2.tid = cli1->smb2.tid; - status = smb2cli_session_create_channel(cli3, cli1->smb2.session, cli3->conn, @@ -1164,10 +1159,8 @@ bool run_smb2_multi_channel(int dummy) return false; } - cli3->smb2.tid = cli2->smb2.tid; - status = smb2cli_create(cli2->conn, cli2->timeout, cli2->smb2.session, - cli2->smb2.tcon, "multi-channel.txt", + cli1->smb2.tcon, "multi-channel.txt", SMB2_OPLOCK_LEVEL_NONE, /* oplock_level, */ SMB2_IMPERSONATION_IMPERSONATION, /* impersonation_level, */ SEC_STD_ALL | SEC_FILE_ALL, /* desired_access, */ @@ -1192,7 +1185,7 @@ bool run_smb2_multi_channel(int dummy) } status = smb2cli_flush(cli2->conn, cli2->timeout, cli2->smb2.session, - cli2->smb2.tcon, fid_persistent, fid_volatile); + cli1->smb2.tcon, fid_persistent, fid_volatile); if (!NT_STATUS_IS_OK(status)) { printf("smb2cli_flush returned %s\n", nt_errstr(status)); return false; @@ -1206,14 +1199,14 @@ bool run_smb2_multi_channel(int dummy) } status = smb2cli_flush(cli3->conn, cli3->timeout, cli3->smb2.session, - cli3->smb2.tcon, fid_persistent, fid_volatile); + cli1->smb2.tcon, fid_persistent, fid_volatile); if (!NT_STATUS_IS_OK(status)) { printf("smb2cli_flush returned %s\n", nt_errstr(status)); return false; } status = smb2cli_read(cli2->conn, cli2->timeout, cli2->smb2.session, - cli2->smb2.tcon, 0x10000, 0, fid_persistent, + cli1->smb2.tcon, 0x10000, 0, fid_persistent, fid_volatile, 2, 0, talloc_tos(), &result, &nread); if (!NT_STATUS_IS_OK(status)) { @@ -1313,14 +1306,14 @@ bool run_smb2_multi_channel(int dummy) } status = smb2cli_flush(cli2->conn, cli2->timeout, cli2->smb2.session, - cli2->smb2.tcon, fid_persistent, fid_volatile); + cli1->smb2.tcon, fid_persistent, fid_volatile); if (!NT_STATUS_IS_OK(status)) { printf("smb2cli_flush returned %s\n", nt_errstr(status)); return false; } status = smb2cli_flush(cli3->conn, cli3->timeout, cli3->smb2.session, - cli3->smb2.tcon, fid_persistent, fid_volatile); + cli1->smb2.tcon, fid_persistent, fid_volatile); if (!NT_STATUS_IS_OK(status)) { printf("smb2cli_flush returned %s\n", nt_errstr(status)); return false; @@ -1344,7 +1337,7 @@ bool run_smb2_multi_channel(int dummy) } status = smb2cli_create(cli2->conn, cli2->timeout, cli2->smb2.session, - cli2->smb2.tcon, "multi-channel-invalid.txt", + cli1->smb2.tcon, "multi-channel-invalid.txt", SMB2_OPLOCK_LEVEL_NONE, /* oplock_level, */ SMB2_IMPERSONATION_IMPERSONATION, /* impersonation_level, */ SEC_STD_ALL | SEC_FILE_ALL, /* desired_access, */ @@ -1361,7 +1354,7 @@ bool run_smb2_multi_channel(int dummy) } status = smb2cli_create(cli3->conn, cli3->timeout, cli3->smb2.session, - cli3->smb2.tcon, "multi-channel-invalid.txt", + cli1->smb2.tcon, "multi-channel-invalid.txt", SMB2_OPLOCK_LEVEL_NONE, /* oplock_level, */ SMB2_IMPERSONATION_IMPERSONATION, /* impersonation_level, */ SEC_STD_ALL | SEC_FILE_ALL, /* desired_access, */ @@ -1406,21 +1399,21 @@ bool run_smb2_multi_channel(int dummy) } status = smb2cli_close(cli3->conn, cli3->timeout, cli3->smb2.session, - cli3->smb2.tcon, 0, fid_persistent, fid_volatile); + cli1->smb2.tcon, 0, fid_persistent, fid_volatile); if (!NT_STATUS_IS_OK(status)) { printf("smb2cli_close returned %s\n", nt_errstr(status)); return false; } status = smb2cli_flush(cli3->conn, cli3->timeout, cli3->smb2.session, - cli3->smb2.tcon, fid_persistent, fid_volatile); + cli1->smb2.tcon, fid_persistent, fid_volatile); if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_CLOSED)) { printf("smb2cli_flush returned %s\n", nt_errstr(status)); return false; } status = smb2cli_flush(cli2->conn, cli2->timeout, cli2->smb2.session, - cli2->smb2.tcon, fid_persistent, fid_volatile); + cli1->smb2.tcon, fid_persistent, fid_volatile); if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_CLOSED)) { printf("smb2cli_flush returned %s\n", nt_errstr(status)); return false; @@ -1730,7 +1723,7 @@ bool run_smb2_session_reauth(int dummy) return false; } - saved_tid = cli->smb2.tid; + saved_tid = smb2cli_tcon_current_id(cli->smb2.tcon); saved_tcon = cli->smb2.tcon; cli->smb2.tcon = smbXcli_tcon_create(cli); smb2cli_tcon_set_values(cli->smb2.tcon, @@ -1746,7 +1739,6 @@ bool run_smb2_session_reauth(int dummy) } talloc_free(cli->smb2.tcon); cli->smb2.tcon = saved_tcon; - cli->smb2.tid = saved_tid; subreq = smb2cli_session_setup_send(talloc_tos(), ev, cli->conn, @@ -1909,7 +1901,7 @@ bool run_smb2_session_reauth(int dummy) return false; } - saved_tid = cli->smb2.tid; + saved_tid = smb2cli_tcon_current_id(cli->smb2.tcon); saved_tcon = cli->smb2.tcon; cli->smb2.tcon = smbXcli_tcon_create(cli); smb2cli_tcon_set_values(cli->smb2.tcon, @@ -1925,7 +1917,6 @@ bool run_smb2_session_reauth(int dummy) } talloc_free(cli->smb2.tcon); cli->smb2.tcon = saved_tcon; - cli->smb2.tid = saved_tid; return true; } |