diff options
-rw-r--r-- | libcli/smb/smb2cli_close.c | 7 | ||||
-rw-r--r-- | libcli/smb/smb2cli_create.c | 7 | ||||
-rw-r--r-- | libcli/smb/smb2cli_flush.c | 7 | ||||
-rw-r--r-- | libcli/smb/smb2cli_ioctl.c | 7 | ||||
-rw-r--r-- | libcli/smb/smb2cli_query_directory.c | 7 | ||||
-rw-r--r-- | libcli/smb/smb2cli_query_info.c | 7 | ||||
-rw-r--r-- | libcli/smb/smb2cli_read.c | 7 | ||||
-rw-r--r-- | libcli/smb/smb2cli_session.c | 4 | ||||
-rw-r--r-- | libcli/smb/smb2cli_set_info.c | 7 | ||||
-rw-r--r-- | libcli/smb/smb2cli_write.c | 7 | ||||
-rw-r--r-- | libcli/smb/smbXcli_base.c | 29 | ||||
-rw-r--r-- | libcli/smb/smbXcli_base.h | 4 | ||||
-rw-r--r-- | source3/libsmb/smb2cli_tcon.c | 9 | ||||
-rw-r--r-- | source4/libcli/smb2/transport.c | 12 |
14 files changed, 40 insertions, 81 deletions
diff --git a/libcli/smb/smb2cli_close.c b/libcli/smb/smb2cli_close.c index 42ed65a5de..05877702ba 100644 --- a/libcli/smb/smb2cli_close.c +++ b/libcli/smb/smb2cli_close.c @@ -42,7 +42,6 @@ struct tevent_req *smb2cli_close_send(TALLOC_CTX *mem_ctx, struct tevent_req *req, *subreq; struct smb2cli_close_state *state; uint8_t *fixed; - uint32_t tcon_id = 0; req = tevent_req_create(mem_ctx, &state, struct smb2cli_close_state); @@ -55,15 +54,11 @@ struct tevent_req *smb2cli_close_send(TALLOC_CTX *mem_ctx, SBVAL(fixed, 8, fid_persistent); SBVAL(fixed, 16, fid_volatile); - if (tcon) { - tcon_id = smb2cli_tcon_current_id(tcon); - } - subreq = smb2cli_req_send(state, ev, conn, SMB2_OP_CLOSE, 0, 0, /* flags */ timeout_msec, 0xFEFF, /* pid */ - tcon_id, + tcon, session, state->fixed, sizeof(state->fixed), NULL, 0); diff --git a/libcli/smb/smb2cli_create.c b/libcli/smb/smb2cli_create.c index 33af378f90..350c2e5081 100644 --- a/libcli/smb/smb2cli_create.c +++ b/libcli/smb/smb2cli_create.c @@ -70,7 +70,6 @@ struct tevent_req *smb2cli_create_send( size_t blobs_offset; uint8_t *dyn; size_t dyn_len; - uint32_t tcon_id = 0; req = tevent_req_create(mem_ctx, &state, struct smb2cli_create_state); @@ -138,15 +137,11 @@ struct tevent_req *smb2cli_create_send( data_blob_free(&blob); } - if (tcon) { - tcon_id = smb2cli_tcon_current_id(tcon); - } - subreq = smb2cli_req_send(state, ev, conn, SMB2_OP_CREATE, 0, 0, /* flags */ timeout_msec, 0xFEFF, /* pid */ - tcon_id, + tcon, session, state->fixed, sizeof(state->fixed), dyn, dyn_len); diff --git a/libcli/smb/smb2cli_flush.c b/libcli/smb/smb2cli_flush.c index ca7a0fe8ba..60ae04da40 100644 --- a/libcli/smb/smb2cli_flush.c +++ b/libcli/smb/smb2cli_flush.c @@ -41,7 +41,6 @@ struct tevent_req *smb2cli_flush_send(TALLOC_CTX *mem_ctx, struct tevent_req *req, *subreq; struct smb2cli_flush_state *state; uint8_t *fixed; - uint32_t tcon_id = 0; req = tevent_req_create(mem_ctx, &state, struct smb2cli_flush_state); @@ -53,15 +52,11 @@ struct tevent_req *smb2cli_flush_send(TALLOC_CTX *mem_ctx, SBVAL(fixed, 8, fid_persistent); SBVAL(fixed, 16, fid_volatile); - if (tcon) { - tcon_id = smb2cli_tcon_current_id(tcon); - } - subreq = smb2cli_req_send(state, ev, conn, SMB2_OP_FLUSH, 0, 0, /* flags */ timeout_msec, 0xFEFF, /* pid */ - tcon_id, + tcon, session, state->fixed, sizeof(state->fixed), NULL, 0); diff --git a/libcli/smb/smb2cli_ioctl.c b/libcli/smb/smb2cli_ioctl.c index 03296c69f6..751f26dacf 100644 --- a/libcli/smb/smb2cli_ioctl.c +++ b/libcli/smb/smb2cli_ioctl.c @@ -61,7 +61,6 @@ struct tevent_req *smb2cli_ioctl_send(TALLOC_CTX *mem_ctx, uint32_t output_buffer_offset = 0; uint32_t output_buffer_length = 0; uint32_t pad_length = 0; - uint32_t tcon_id = 0; req = tevent_req_create(mem_ctx, &state, struct smb2cli_ioctl_state); @@ -134,15 +133,11 @@ struct tevent_req *smb2cli_ioctl_send(TALLOC_CTX *mem_ctx, dyn_len = sizeof(state->dyn_pad); } - if (tcon) { - tcon_id = smb2cli_tcon_current_id(tcon); - } - subreq = smb2cli_req_send(state, ev, conn, SMB2_OP_IOCTL, 0, 0, /* flags */ timeout_msec, 0xFEFF, /* pid */ - tcon_id, + tcon, session, state->fixed, sizeof(state->fixed), dyn, dyn_len); diff --git a/libcli/smb/smb2cli_query_directory.c b/libcli/smb/smb2cli_query_directory.c index 4ff93de68d..781efbd066 100644 --- a/libcli/smb/smb2cli_query_directory.c +++ b/libcli/smb/smb2cli_query_directory.c @@ -52,7 +52,6 @@ struct tevent_req *smb2cli_query_directory_send(TALLOC_CTX *mem_ctx, uint8_t *fixed; uint8_t *dyn; size_t dyn_len; - uint32_t tcon_id = 0; req = tevent_req_create(mem_ctx, &state, struct smb2cli_query_directory_state); @@ -88,15 +87,11 @@ struct tevent_req *smb2cli_query_directory_send(TALLOC_CTX *mem_ctx, dyn_len = sizeof(state->dyn_pad); } - if (tcon) { - tcon_id = smb2cli_tcon_current_id(tcon); - } - subreq = smb2cli_req_send(state, ev, conn, SMB2_OP_FIND, 0, 0, /* flags */ timeout_msec, 0xFEFF, /* pid */ - tcon_id, + tcon, session, state->fixed, sizeof(state->fixed), dyn, dyn_len); diff --git a/libcli/smb/smb2cli_query_info.c b/libcli/smb/smb2cli_query_info.c index b5d9e791aa..b1664c1585 100644 --- a/libcli/smb/smb2cli_query_info.c +++ b/libcli/smb/smb2cli_query_info.c @@ -55,7 +55,6 @@ struct tevent_req *smb2cli_query_info_send(TALLOC_CTX *mem_ctx, size_t dyn_len; uint16_t input_buffer_offset = 0; uint32_t input_buffer_length = 0; - uint32_t tcon_id = 0; req = tevent_req_create(mem_ctx, &state, struct smb2cli_query_info_state); @@ -91,15 +90,11 @@ struct tevent_req *smb2cli_query_info_send(TALLOC_CTX *mem_ctx, dyn_len = sizeof(state->dyn_pad); } - if (tcon) { - tcon_id = smb2cli_tcon_current_id(tcon); - } - subreq = smb2cli_req_send(state, ev, conn, SMB2_OP_GETINFO, 0, 0, /* flags */ timeout_msec, 0xFEFF, /* pid */ - tcon_id, + tcon, session, state->fixed, sizeof(state->fixed), dyn, dyn_len); diff --git a/libcli/smb/smb2cli_read.c b/libcli/smb/smb2cli_read.c index 5ff4b6443d..35298876bd 100644 --- a/libcli/smb/smb2cli_read.c +++ b/libcli/smb/smb2cli_read.c @@ -49,7 +49,6 @@ struct tevent_req *smb2cli_read_send(TALLOC_CTX *mem_ctx, struct tevent_req *req, *subreq; struct smb2cli_read_state *state; uint8_t *fixed; - uint32_t tcon_id = 0; req = tevent_req_create(mem_ctx, &state, struct smb2cli_read_state); @@ -67,15 +66,11 @@ struct tevent_req *smb2cli_read_send(TALLOC_CTX *mem_ctx, SBVAL(fixed, 32, minimum_count); SBVAL(fixed, 40, remaining_bytes); - if (tcon) { - tcon_id = smb2cli_tcon_current_id(tcon); - } - subreq = smb2cli_req_send(state, ev, conn, SMB2_OP_READ, 0, 0, /* flags */ timeout_msec, 0xFEFF, /* pid */ - tcon_id, + tcon, session, state->fixed, sizeof(state->fixed), state->dyn_pad, sizeof(state->dyn_pad)); diff --git a/libcli/smb/smb2cli_session.c b/libcli/smb/smb2cli_session.c index 640eb95f0b..946e02cd48 100644 --- a/libcli/smb/smb2cli_session.c +++ b/libcli/smb/smb2cli_session.c @@ -100,7 +100,7 @@ struct tevent_req *smb2cli_session_setup_send(TALLOC_CTX *mem_ctx, 0, 0, /* flags */ timeout_msec, 0xFEFF, - 0, /* tid */ + NULL, /* tcon */ session, state->fixed, sizeof(state->fixed), dyn, dyn_len); @@ -257,7 +257,7 @@ struct tevent_req *smb2cli_logoff_send(TALLOC_CTX *mem_ctx, 0, 0, /* flags */ timeout_msec, 0xFEFF, /* pid */ - 0, /* tid */ + NULL, /* tcon */ session, state->fixed, sizeof(state->fixed), NULL, 0); diff --git a/libcli/smb/smb2cli_set_info.c b/libcli/smb/smb2cli_set_info.c index e33ba8367d..e7464e65e8 100644 --- a/libcli/smb/smb2cli_set_info.c +++ b/libcli/smb/smb2cli_set_info.c @@ -50,7 +50,6 @@ struct tevent_req *smb2cli_set_info_send(TALLOC_CTX *mem_ctx, size_t dyn_len; uint16_t input_buffer_offset = 0; uint32_t input_buffer_length = 0; - uint32_t tcon_id = 0; req = tevent_req_create(mem_ctx, &state, struct smb2cli_set_info_state); @@ -83,15 +82,11 @@ struct tevent_req *smb2cli_set_info_send(TALLOC_CTX *mem_ctx, dyn_len = sizeof(state->dyn_pad); } - if (tcon) { - tcon_id = smb2cli_tcon_current_id(tcon); - } - subreq = smb2cli_req_send(state, ev, conn, SMB2_OP_SETINFO, 0, 0, /* flags */ timeout_msec, 0xFEFF, /* pid */ - tcon_id, + tcon, session, state->fixed, sizeof(state->fixed), dyn, dyn_len); diff --git a/libcli/smb/smb2cli_write.c b/libcli/smb/smb2cli_write.c index cd98e5e723..60182c6c13 100644 --- a/libcli/smb/smb2cli_write.c +++ b/libcli/smb/smb2cli_write.c @@ -49,7 +49,6 @@ struct tevent_req *smb2cli_write_send(TALLOC_CTX *mem_ctx, uint8_t *fixed; const uint8_t *dyn; size_t dyn_len; - uint32_t tcon_id = 0; req = tevent_req_create(mem_ctx, &state, struct smb2cli_write_state); @@ -76,15 +75,11 @@ struct tevent_req *smb2cli_write_send(TALLOC_CTX *mem_ctx, dyn_len = sizeof(state->dyn_pad); } - if (tcon) { - tcon_id = smb2cli_tcon_current_id(tcon); - } - subreq = smb2cli_req_send(state, ev, conn, SMB2_OP_WRITE, 0, 0, /* flags */ timeout_msec, 0xFEFF, /* pid */ - tcon_id, + tcon, session, state->fixed, sizeof(state->fixed), dyn, dyn_len); diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c index 4c094ea87e..1b1b92aa03 100644 --- a/libcli/smb/smbXcli_base.c +++ b/libcli/smb/smbXcli_base.c @@ -2366,9 +2366,9 @@ static bool smb2cli_req_cancel(struct tevent_req *req) struct smbXcli_req_state); uint32_t flags = IVAL(state->smb2.hdr, SMB2_HDR_FLAGS); uint32_t pid = IVAL(state->smb2.hdr, SMB2_HDR_PID); - uint32_t tid = IVAL(state->smb2.hdr, SMB2_HDR_TID); uint64_t mid = BVAL(state->smb2.hdr, SMB2_HDR_MESSAGE_ID); uint64_t aid = BVAL(state->smb2.hdr, SMB2_HDR_ASYNC_ID); + struct smbXcli_tcon *tcon = state->tcon; struct smbXcli_session *session = state->session; uint8_t *fixed = state->smb2.pad; uint16_t fixed_len = 4; @@ -2384,7 +2384,7 @@ static bool smb2cli_req_cancel(struct tevent_req *req) SMB2_OP_CANCEL, flags, 0, 0, /* timeout */ - pid, tid, session, + pid, tcon, session, fixed, fixed_len, NULL, 0); if (subreq == NULL) { @@ -2398,7 +2398,6 @@ static bool smb2cli_req_cancel(struct tevent_req *req) SIVAL(substate->smb2.hdr, SMB2_HDR_FLAGS, flags); SIVAL(substate->smb2.hdr, SMB2_HDR_PID, pid); - SIVAL(substate->smb2.hdr, SMB2_HDR_TID, tid); SBVAL(substate->smb2.hdr, SMB2_HDR_MESSAGE_ID, mid); SBVAL(substate->smb2.hdr, SMB2_HDR_ASYNC_ID, aid); @@ -2427,7 +2426,7 @@ struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx, uint32_t clear_flags, uint32_t timeout_msec, uint32_t pid, - uint32_t tid, + struct smbXcli_tcon *tcon, struct smbXcli_session *session, const uint8_t *fixed, uint16_t fixed_len, @@ -2437,6 +2436,7 @@ struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx, struct tevent_req *req; struct smbXcli_req_state *state; uint32_t flags = 0; + uint32_t tid = 0; uint64_t uid = 0; req = tevent_req_create(mem_ctx, &state, @@ -2448,6 +2448,7 @@ struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx, state->ev = ev; state->conn = conn; state->session = session; + state->tcon = tcon; if (session) { uid = session->smb2.session_id; @@ -2455,8 +2456,6 @@ struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx, state->smb2.should_sign = session->smb2.should_sign; state->smb2.should_encrypt = session->smb2.should_encrypt; - /* TODO: turn on encryption based on the tree connect. */ - if (cmd == SMB2_OP_SESSSETUP && session->smb2.signing_key.length != 0) { state->smb2.should_sign = true; @@ -2466,10 +2465,16 @@ struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx, session->smb2.channel_signing_key.length == 0) { state->smb2.should_encrypt = false; } + } - if (state->smb2.should_encrypt) { - state->smb2.should_sign = false; - } + if (tcon) { + tid = tcon->smb2.tcon_id; + + /* TODO: turn on encryption based on the tree connect. */ + } + + if (state->smb2.should_encrypt) { + state->smb2.should_sign = false; } state->smb2.recv_iov = talloc_zero_array(state, struct iovec, 3); @@ -2795,7 +2800,7 @@ struct tevent_req *smb2cli_req_send(TALLOC_CTX *mem_ctx, uint32_t clear_flags, uint32_t timeout_msec, uint32_t pid, - uint32_t tid, + struct smbXcli_tcon *tcon, struct smbXcli_session *session, const uint8_t *fixed, uint16_t fixed_len, @@ -2808,7 +2813,7 @@ struct tevent_req *smb2cli_req_send(TALLOC_CTX *mem_ctx, req = smb2cli_req_create(mem_ctx, ev, conn, cmd, additional_flags, clear_flags, timeout_msec, - pid, tid, session, + pid, tcon, session, fixed, fixed_len, dyn, dyn_len); if (req == NULL) { return NULL; @@ -3999,7 +4004,7 @@ static struct tevent_req *smbXcli_negprot_smb2_subreq(struct smbXcli_negprot_sta state->conn, SMB2_OP_NEGPROT, 0, 0, /* flags */ state->timeout_msec, - 0xFEFF, 0, NULL, /* pid, tid, session */ + 0xFEFF, NULL, NULL, /* pid, tcon, session */ state->smb2.fixed, sizeof(state->smb2.fixed), state->smb2.dyn, dialect_count*2); } diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h index 665fb9c8ce..0260ab64a7 100644 --- a/libcli/smb/smbXcli_base.h +++ b/libcli/smb/smbXcli_base.h @@ -201,7 +201,7 @@ struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx, uint32_t clear_flags, uint32_t timeout_msec, uint32_t pid, - uint32_t tid, + struct smbXcli_tcon *tcon, struct smbXcli_session *session, const uint8_t *fixed, uint16_t fixed_len, @@ -225,7 +225,7 @@ struct tevent_req *smb2cli_req_send(TALLOC_CTX *mem_ctx, uint32_t clear_flags, uint32_t timeout_msec, uint32_t pid, - uint32_t tid, + struct smbXcli_tcon *tcon, struct smbXcli_session *session, const uint8_t *fixed, uint16_t fixed_len, diff --git a/source3/libsmb/smb2cli_tcon.c b/source3/libsmb/smb2cli_tcon.c index 7271ddaa8e..d2607824ff 100644 --- a/source3/libsmb/smb2cli_tcon.c +++ b/source3/libsmb/smb2cli_tcon.c @@ -85,7 +85,7 @@ struct tevent_req *smb2cli_tcon_send(TALLOC_CTX *mem_ctx, 0, 0, /* flags */ cli->timeout, cli->smb2.pid, - 0, /* tid */ + NULL, /* tcon */ cli->smb2.session, state->fixed, sizeof(state->fixed), dyn, dyn_len); @@ -198,7 +198,6 @@ 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); @@ -208,15 +207,11 @@ 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, - tcon_id, + cli->smb2.tcon, cli->smb2.session, state->fixed, sizeof(state->fixed), NULL, 0); diff --git a/source4/libcli/smb2/transport.c b/source4/libcli/smb2/transport.c index a3845a60cb..423b634765 100644 --- a/source4/libcli/smb2/transport.c +++ b/source4/libcli/smb2/transport.c @@ -116,7 +116,7 @@ void smb2_transport_send(struct smb2_request *req) uint32_t additional_flags = IVAL(req->out.hdr, SMB2_HDR_FLAGS); uint32_t clear_flags = 0; uint32_t pid = IVAL(req->out.hdr, SMB2_HDR_PID); - uint32_t tid = IVAL(req->out.hdr, SMB2_HDR_TID); + struct smbXcli_tcon *tcon = NULL; struct smbXcli_session *session = NULL; bool need_pending_break = false; size_t hdr_ofs; @@ -148,7 +148,7 @@ void smb2_transport_send(struct smb2_request *req) 0, /*clear_flags */ 0, /* timeout_msec */ 0, /* pid */ - 0, /* tid */ + NULL, /* tcon */ NULL, /* session */ NULL, /* body */ 0, /* body_fixed */ @@ -167,6 +167,10 @@ void smb2_transport_send(struct smb2_request *req) session = req->session->smbXcli; } + if (req->tree) { + tcon = req->tree->smbXcli; + } + if (transport->compound.related) { additional_flags |= SMB2_HDR_FLAG_CHAINED; } @@ -186,7 +190,7 @@ void smb2_transport_send(struct smb2_request *req) clear_flags, timeout_msec, pid, - tid, + tcon, session, body.data, body.length, dyn.data, dyn.length); @@ -342,7 +346,7 @@ static void smb2_transport_break_handler(struct tevent_req *subreq) 0, /*clear_flags */ 0, /* timeout_msec */ 0, /* pid */ - 0, /* tid */ + NULL, /* tcon */ NULL, /* session */ NULL, /* body */ 0, /* body_fixed */ |