From: Jeremy Allison Date: Mon, 27 Nov 2017 22:38:49 +0000 (-0800) Subject: s3: libsmb: Make cli_close_send()/cli_close_recv() work for SMB1 and SMB2. X-Git-Tag: talloc-2.1.11~285 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1b6e8e52f0a5beb4eb0da0a8d6483dd7914010e1;p=thirdparty%2Fsamba.git s3: libsmb: Make cli_close_send()/cli_close_recv() work for SMB1 and SMB2. Remove the escape into synchronous smb2 code. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13159 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 2e3c2426030..5f6e98ce460 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -2818,26 +2818,65 @@ static void cli_smb1_close_done(struct tevent_req *subreq) tevent_req_done(req); } +struct cli_close_state { + int dummy; +}; + +static void cli_close_done(struct tevent_req *subreq); + struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, uint16_t fnum) { struct tevent_req *req, *subreq; + struct cli_close_state *state; NTSTATUS status; - req = cli_smb1_close_create(mem_ctx, ev, cli, fnum, &subreq); + req = tevent_req_create(mem_ctx, &state, struct cli_close_state); if (req == NULL) { return NULL; } - status = smb1cli_req_chain_submit(&subreq, 1); - if (tevent_req_nterror(req, status)) { - return tevent_req_post(req, ev); + if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { + subreq = cli_smb2_close_fnum_send(state, + ev, + cli, + fnum); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + } else { + struct tevent_req *ch_req = NULL; + subreq = cli_smb1_close_create(state, ev, cli, fnum, &ch_req); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + status = smb1cli_req_chain_submit(&ch_req, 1); + if (tevent_req_nterror(req, status)) { + return tevent_req_post(req, ev); + } } + + tevent_req_set_callback(subreq, cli_close_done, req); return req; } +static void cli_close_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + NTSTATUS status = NT_STATUS_OK; + bool err = tevent_req_is_nterror(subreq, &status); + + TALLOC_FREE(subreq); + if (err) { + tevent_req_nterror(req, status); + return; + } + tevent_req_done(req); +} + NTSTATUS cli_close_recv(struct tevent_req *req) { return tevent_req_simple_recv_ntstatus(req); @@ -2850,10 +2889,6 @@ NTSTATUS cli_close(struct cli_state *cli, uint16_t fnum) struct tevent_req *req; NTSTATUS status = NT_STATUS_OK; - if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { - return cli_smb2_close_fnum(cli, fnum); - } - frame = talloc_stackframe(); if (smbXcli_conn_has_async_calls(cli->conn)) {