summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/client.h2
-rw-r--r--source3/libsmb/async_smb.c2
-rw-r--r--source3/libsmb/cliconnect.c9
-rw-r--r--source3/libsmb/clidfs.c4
-rw-r--r--source3/libsmb/clientgen.c25
-rw-r--r--source3/libsmb/libsmb_server.c2
-rw-r--r--source3/libsmb/proto.h3
-rw-r--r--source3/torture/torture.c32
-rw-r--r--source3/utils/net_rpc.c4
-rw-r--r--source3/utils/smbcacls.c8
10 files changed, 55 insertions, 36 deletions
diff --git a/source3/include/client.h b/source3/include/client.h
index 67c858f76f..5e4e0a3690 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -52,7 +52,6 @@ struct cli_state {
*/
struct cli_state *prev, *next;
int fd;
- uint16 cnum;
uint16 vuid;
int protocol;
int sec_mode;
@@ -135,6 +134,7 @@ struct cli_state {
uint16_t mid;
uint16_t pid;
uint16_t vc_num;
+ uint16_t tid;
} smb1;
struct {
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index 2c42cec6b9..b621919dbd 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -317,7 +317,7 @@ struct tevent_req *cli_smb_req_create(TALLOC_CTX *mem_ctx,
cli_setup_packet_buf(cli, (char *)state->header);
SCVAL(state->header, smb_com, smb_command);
- SSVAL(state->header, smb_tid, cli->cnum);
+ SSVAL(state->header, smb_tid, cli->smb1.tid);
SCVAL(state->header, smb_wct, wct);
state->vwv = vwv;
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 03251f965b..4e3e47f512 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -2405,7 +2405,7 @@ static void cli_tcon_andx_done(struct tevent_req *subreq)
cli->dfsroot = ((SVAL(vwv+2, 0) & SMB_SHARE_IN_DFS) != 0);
}
- cli->cnum = SVAL(inbuf,smb_tid);
+ cli->smb1.tid = SVAL(inbuf,smb_tid);
tevent_req_done(req);
}
@@ -2498,7 +2498,7 @@ static void cli_tdis_done(struct tevent_req *subreq)
tevent_req_nterror(req, status);
return;
}
- state->cli->cnum = -1;
+ state->cli->smb1.tid = UINT16_MAX;
tevent_req_done(req);
}
@@ -2551,7 +2551,6 @@ struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
struct cli_negprot_state *state;
uint8_t *bytes = NULL;
int numprots;
- uint16_t cnum;
req = tevent_req_create(mem_ctx, &state, struct cli_negprot_state);
if (req == NULL) {
@@ -2582,12 +2581,8 @@ struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
}
}
- cnum = cli->cnum;
-
- cli->cnum = 0;
subreq = cli_smb_send(state, ev, cli, SMBnegprot, 0, 0, NULL,
talloc_get_size(bytes), bytes);
- cli->cnum = cnum;
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index a0d503a802..d677f9e0ac 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -1031,7 +1031,7 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
return false;
}
- cnum = cli->cnum;
+ cnum = cli_state_get_tid(cli);
/* special case. never check for a referral on the IPC$ share */
@@ -1072,7 +1072,7 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
return false;
}
- cli->cnum = cnum;
+ cli_state_set_tid(cli, cnum);
if (!res || !num_refs) {
return false;
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 67e8e06d1a..0ee361f862 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -184,7 +184,6 @@ struct cli_state *cli_initialise_ex(int signing_state)
}
cli->fd = -1;
cli->raw_status = NT_STATUS_INTERNAL_ERROR;
- cli->cnum = -1;
cli->vuid = UID_FIELD_INVALID;
cli->protocol = PROTOCOL_NT1;
cli->timeout = 20000; /* Timeout is in milliseconds. */
@@ -241,6 +240,7 @@ struct cli_state *cli_initialise_ex(int signing_state)
cli->smb1.mid = 1;
cli->smb1.pid = (uint16_t)sys_getpid();
cli->smb1.vc_num = cli->smb1.pid;
+ cli->smb1.tid = UINT16_MAX;
return cli;
@@ -287,7 +287,7 @@ static void _cli_shutdown(struct cli_state *cli)
* later. This tree disconnect forces the peer to clean up, since the
* connection will be going away.
*/
- if (cli->cnum != (uint16)-1) {
+ if (cli_state_has_tcon(cli)) {
cli_tdis(cli);
}
@@ -364,6 +364,27 @@ uint16_t cli_getpid(struct cli_state *cli)
return cli->smb1.pid;
}
+bool cli_state_has_tcon(struct cli_state *cli)
+{
+ if (cli->smb1.tid == UINT16_MAX) {
+ return false;
+ }
+
+ return true;
+}
+
+uint16_t cli_state_get_tid(struct cli_state *cli)
+{
+ return cli->smb1.tid;
+}
+
+uint16_t cli_state_set_tid(struct cli_state *cli, uint16_t tid)
+{
+ uint16_t ret = cli->smb1.tid;
+ cli->smb1.tid = tid;
+ return ret;
+}
+
/****************************************************************************
Set the case sensitivity flag on the packets. Returns old state.
****************************************************************************/
diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c
index 49018a8320..760bd9a8d3 100644
--- a/source3/libsmb/libsmb_server.c
+++ b/source3/libsmb/libsmb_server.c
@@ -289,7 +289,7 @@ SMBC_server_internal(TALLOC_CTX *ctx,
* i.e., a normal share or a referred share from
* 'msdfs proxy' share.
*/
- if (srv->cli->cnum == (uint16) -1) {
+ if (!cli_state_has_tcon(srv->cli)) {
/* Ensure we have accurate auth info */
SMBC_call_auth_fn(ctx, context,
srv->cli->desthost,
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 9775bd775d..fe30509bb6 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -167,6 +167,9 @@ void cli_sockopt(struct cli_state *cli, const char *options);
uint16_t cli_state_get_vc_num(struct cli_state *cli);
uint16 cli_setpid(struct cli_state *cli, uint16 pid);
uint16_t cli_getpid(struct cli_state *cli);
+bool cli_state_has_tcon(struct cli_state *cli);
+uint16_t cli_state_get_tid(struct cli_state *cli);
+uint16_t cli_state_set_tid(struct cli_state *cli, uint16_t tid);
bool cli_set_case_sensitive(struct cli_state *cli, bool case_sensitive);
struct tevent_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
struct cli_state *cli, uint16_t num_echos,
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index e0e7275e8b..6e66d9d53f 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -1355,7 +1355,7 @@ static bool run_tcon_test(int dummy)
return False;
}
- cnum1 = cli->cnum;
+ cnum1 = cli_state_get_tid(cli);
vuid1 = cli->vuid;
status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
@@ -1373,12 +1373,12 @@ static bool run_tcon_test(int dummy)
return False;
}
- cnum2 = cli->cnum;
+ cnum2 = cli_state_get_tid(cli);
cnum3 = MAX(cnum1, cnum2) + 1; /* any invalid number */
vuid2 = cli->vuid + 1;
/* try a write with the wrong tid */
- cli->cnum = cnum2;
+ cli_state_set_tid(cli, cnum2);
status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
if (NT_STATUS_IS_OK(status)) {
@@ -1391,7 +1391,7 @@ static bool run_tcon_test(int dummy)
/* try a write with an invalid tid */
- cli->cnum = cnum3;
+ cli_state_set_tid(cli, cnum3);
status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
if (NT_STATUS_IS_OK(status)) {
@@ -1404,7 +1404,7 @@ static bool run_tcon_test(int dummy)
/* try a write with an invalid vuid */
cli->vuid = vuid2;
- cli->cnum = cnum1;
+ cli_state_set_tid(cli, cnum1);
status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
if (NT_STATUS_IS_OK(status)) {
@@ -1415,7 +1415,7 @@ static bool run_tcon_test(int dummy)
nt_errstr(status));
}
- cli->cnum = cnum1;
+ cli_state_set_tid(cli, cnum1);
cli->vuid = vuid1;
status = cli_close(cli, fnum1);
@@ -1424,7 +1424,7 @@ static bool run_tcon_test(int dummy)
return False;
}
- cli->cnum = cnum2;
+ cli_state_set_tid(cli, cnum2);
status = cli_tdis(cli);
if (!NT_STATUS_IS_OK(status)) {
@@ -1432,7 +1432,7 @@ static bool run_tcon_test(int dummy)
return False;
}
- cli->cnum = cnum1;
+ cli_state_set_tid(cli, cnum1);
if (!torture_close_connection(cli)) {
return False;
@@ -2724,7 +2724,7 @@ static bool run_fdpasstest(int dummy)
}
cli2->vuid = cli1->vuid;
- cli2->cnum = cli1->cnum;
+ cli_state_set_tid(cli2, cli_state_get_tid(cli1));
cli_setpid(cli2, cli_getpid(cli1));
if (cli_read(cli2, fnum1, buf, 0, 13) == 13) {
@@ -2765,11 +2765,11 @@ static bool run_fdsesstest(int dummy)
if (!torture_cli_session_setup2(cli, &new_vuid))
return False;
- saved_cnum = cli->cnum;
+ saved_cnum = cli_state_get_tid(cli);
if (!NT_STATUS_IS_OK(cli_tcon_andx(cli, share, "?????", "", 1)))
return False;
- new_cnum = cli->cnum;
- cli->cnum = saved_cnum;
+ new_cnum = cli_state_get_tid(cli);
+ cli_state_set_tid(cli, saved_cnum);
printf("starting fdsesstest\n");
@@ -2811,7 +2811,7 @@ static bool run_fdsesstest(int dummy)
cli->vuid = saved_vuid;
/* Try with same vuid, different cnum. */
- cli->cnum = new_cnum;
+ cli_state_set_tid(cli, new_cnum);
if (cli_read(cli, fnum1, buf, 0, 13) == 13) {
printf("read succeeded with different cnum![%s]\n",
@@ -2819,7 +2819,7 @@ static bool run_fdsesstest(int dummy)
ret = False;
}
- cli->cnum = saved_cnum;
+ cli_state_set_tid(cli, saved_cnum);
cli_close(cli, fnum1);
cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
@@ -7109,7 +7109,7 @@ static bool run_uid_regression_test(int dummy)
}
}
- old_cnum = cli->cnum;
+ old_cnum = cli_state_get_tid(cli);
/* Now try a SMBtdis with the invald vuid set to zero. */
cli->vuid = 0;
@@ -7126,7 +7126,7 @@ static bool run_uid_regression_test(int dummy)
}
cli->vuid = old_vuid;
- cli->cnum = old_cnum;
+ cli_state_set_tid(cli, old_cnum);
/* This should fail. */
status = cli_tdis(cli);
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index 5952f4fe32..d0cc2d1043 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -4855,7 +4855,7 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd,
netname));
}
- cnum = cli->cnum;
+ cnum = cli_state_get_tid(cli);
if (!NT_STATUS_IS_OK(cli_tcon_andx(cli, netname, "A:", "", 0))) {
return;
@@ -4899,7 +4899,7 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd,
if (fnum != (uint16_t)-1)
cli_close(cli, fnum);
cli_tdis(cli);
- cli->cnum = cnum;
+ cli_state_set_tid(cli, cnum);
return;
}
diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c
index d226c84b9a..208f4e0c64 100644
--- a/source3/utils/smbcacls.c
+++ b/source3/utils/smbcacls.c
@@ -77,7 +77,7 @@ static NTSTATUS cli_lsa_lookup_sid(struct cli_state *cli,
enum lsa_SidType *type,
char **domain, char **name)
{
- uint16 orig_cnum = cli->cnum;
+ uint16 orig_cnum = cli_state_get_tid(cli);
struct rpc_pipe_client *p = NULL;
struct policy_handle handle;
NTSTATUS status;
@@ -117,7 +117,7 @@ static NTSTATUS cli_lsa_lookup_sid(struct cli_state *cli,
fail:
TALLOC_FREE(p);
cli_tdis(cli);
- cli->cnum = orig_cnum;
+ cli_state_set_tid(cli, orig_cnum);
TALLOC_FREE(frame);
return status;
}
@@ -127,7 +127,7 @@ static NTSTATUS cli_lsa_lookup_name(struct cli_state *cli,
enum lsa_SidType *type,
struct dom_sid *sid)
{
- uint16 orig_cnum = cli->cnum;
+ uint16 orig_cnum = cli_state_get_tid(cli);
struct rpc_pipe_client *p;
struct policy_handle handle;
NTSTATUS status;
@@ -165,7 +165,7 @@ static NTSTATUS cli_lsa_lookup_name(struct cli_state *cli,
fail:
TALLOC_FREE(p);
cli_tdis(cli);
- cli->cnum = orig_cnum;
+ cli_state_set_tid(cli, orig_cnum);
TALLOC_FREE(frame);
return status;
}