mirror of
https://github.com/samba-team/samba.git
synced 2025-08-02 00:22:11 +03:00
s3: libsmb: Correctly do lifecycle management on cli->smb1.tcon and cli->smb2.tcon.
Treat them identically. Create them on demand after for a tcon call,
and delete them on a tdis call.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12831
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
(cherry picked from commit 50f50256aa
)
This commit is contained in:
committed by
Karolin Seeger
parent
de0fbbe0dd
commit
d2a309b90e
@ -1945,6 +1945,13 @@ struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
|
|||||||
state->cli = cli;
|
state->cli = cli;
|
||||||
vwv = state->vwv;
|
vwv = state->vwv;
|
||||||
|
|
||||||
|
TALLOC_FREE(cli->smb1.tcon);
|
||||||
|
cli->smb1.tcon = smbXcli_tcon_create(cli);
|
||||||
|
if (tevent_req_nomem(cli->smb1.tcon, req)) {
|
||||||
|
return tevent_req_post(req, ev);
|
||||||
|
}
|
||||||
|
smb1cli_tcon_set_id(cli->smb1.tcon, UINT16_MAX);
|
||||||
|
|
||||||
cli->share = talloc_strdup(cli, share);
|
cli->share = talloc_strdup(cli, share);
|
||||||
if (!cli->share) {
|
if (!cli->share) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -2254,6 +2261,7 @@ static struct tevent_req *cli_tree_connect_send(
|
|||||||
if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
|
if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
|
||||||
char *unc;
|
char *unc;
|
||||||
|
|
||||||
|
TALLOC_FREE(cli->smb2.tcon);
|
||||||
cli->smb2.tcon = smbXcli_tcon_create(cli);
|
cli->smb2.tcon = smbXcli_tcon_create(cli);
|
||||||
if (tevent_req_nomem(cli->smb2.tcon, req)) {
|
if (tevent_req_nomem(cli->smb2.tcon, req)) {
|
||||||
return tevent_req_post(req, ev);
|
return tevent_req_post(req, ev);
|
||||||
@ -2426,7 +2434,7 @@ static void cli_tdis_done(struct tevent_req *subreq)
|
|||||||
tevent_req_nterror(req, status);
|
tevent_req_nterror(req, status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cli_state_set_tid(state->cli, UINT16_MAX);
|
TALLOC_FREE(state->cli->smb1.tcon);
|
||||||
tevent_req_done(req);
|
tevent_req_done(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2442,10 +2450,14 @@ NTSTATUS cli_tdis(struct cli_state *cli)
|
|||||||
NTSTATUS status = NT_STATUS_NO_MEMORY;
|
NTSTATUS status = NT_STATUS_NO_MEMORY;
|
||||||
|
|
||||||
if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
|
if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
|
||||||
return smb2cli_tdis(cli->conn,
|
status = smb2cli_tdis(cli->conn,
|
||||||
cli->timeout,
|
cli->timeout,
|
||||||
cli->smb2.session,
|
cli->smb2.session,
|
||||||
cli->smb2.tcon);
|
cli->smb2.tcon);
|
||||||
|
if (NT_STATUS_IS_OK(status)) {
|
||||||
|
TALLOC_FREE(cli->smb2.tcon);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (smbXcli_conn_has_async_calls(cli->conn)) {
|
if (smbXcli_conn_has_async_calls(cli->conn)) {
|
||||||
@ -3619,6 +3631,13 @@ static struct tevent_req *cli_raw_tcon_send(
|
|||||||
return tevent_req_post(req, ev);
|
return tevent_req_post(req, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TALLOC_FREE(cli->smb1.tcon);
|
||||||
|
cli->smb1.tcon = smbXcli_tcon_create(cli);
|
||||||
|
if (tevent_req_nomem(cli->smb1.tcon, req)) {
|
||||||
|
return tevent_req_post(req, ev);
|
||||||
|
}
|
||||||
|
smb1cli_tcon_set_id(cli->smb1.tcon, UINT16_MAX);
|
||||||
|
|
||||||
bytes = talloc_array(state, uint8_t, 0);
|
bytes = talloc_array(state, uint8_t, 0);
|
||||||
bytes = smb_bytes_push_bytes(bytes, 4, NULL, 0);
|
bytes = smb_bytes_push_bytes(bytes, 4, NULL, 0);
|
||||||
bytes = smb_bytes_push_str(bytes, smbXcli_conn_use_unicode(cli->conn),
|
bytes = smb_bytes_push_str(bytes, smbXcli_conn_use_unicode(cli->conn),
|
||||||
|
@ -227,11 +227,6 @@ struct cli_state *cli_state_create(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
cli->smb1.pid = (uint32_t)getpid();
|
cli->smb1.pid = (uint32_t)getpid();
|
||||||
cli->smb1.vc_num = cli->smb1.pid;
|
cli->smb1.vc_num = cli->smb1.pid;
|
||||||
cli->smb1.tcon = smbXcli_tcon_create(cli);
|
|
||||||
if (cli->smb1.tcon == NULL) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
smb1cli_tcon_set_id(cli->smb1.tcon, UINT16_MAX);
|
|
||||||
cli->smb1.session = smbXcli_session_create(cli, cli->conn);
|
cli->smb1.session = smbXcli_session_create(cli, cli->conn);
|
||||||
if (cli->smb1.session == NULL) {
|
if (cli->smb1.session == NULL) {
|
||||||
goto error;
|
goto error;
|
||||||
|
Reference in New Issue
Block a user