From: Volker Lendecke Date: Sat, 7 Oct 2023 10:13:09 +0000 (+0200) Subject: libsmb: Pass "flags" through cli_close_send() and pylibsmb X-Git-Tag: tevent-0.16.0~218 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4047443a511f003eb855504315eeb8499fafcb7;p=thirdparty%2Fsamba.git libsmb: Pass "flags" through cli_close_send() and pylibsmb Bug: https://bugzilla.samba.org/show_bug.cgi?id=15487 Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/examples/winexe/winexe.c b/examples/winexe/winexe.c index 29e1fe2055b..5c2529cb2de 100644 --- a/examples/winexe/winexe.c +++ b/examples/winexe/winexe.c @@ -993,11 +993,11 @@ static void winexe_out_pipe_got_data(struct tevent_req *subreq) nt_errstr(status)); if (NT_STATUS_EQUAL(status, NT_STATUS_PIPE_DISCONNECTED)) { - subreq = cli_close_send( - state, - state->ev, - state->cli, - state->out_pipe); + subreq = cli_close_send(state, + state->ev, + state->cli, + state->out_pipe, + 0); if (tevent_req_nomem(subreq, req)) { return; } @@ -1206,11 +1206,11 @@ static void winexe_in_pipe_written(struct tevent_req *subreq) if (NT_STATUS_EQUAL(status, NT_STATUS_PIPE_DISCONNECTED) || state->close_requested) { - subreq = cli_close_send( - state, - state->ev, - state->cli, - state->in_pipe); + subreq = cli_close_send(state, + state->ev, + state->cli, + state->in_pipe, + 0); if (tevent_req_nomem(subreq, req)) { return; } @@ -1275,11 +1275,8 @@ static bool winexe_in_pipe_close(struct tevent_req *req) TALLOC_FREE(state->fd_read_req); - subreq = cli_close_send( - state, - state->ev, - state->cli, - state->in_pipe); + subreq = + cli_close_send(state, state->ev, state->cli, state->in_pipe, 0); if (subreq == NULL) { return false; } @@ -1597,11 +1594,11 @@ static void winexe_ctrl_got_read(struct tevent_req *subreq) TALLOC_FREE(subreq); if (NT_STATUS_EQUAL(status, NT_STATUS_PIPE_DISCONNECTED)) { - subreq = cli_close_send( - state, - state->ev, - state->cli, - state->ctrl_pipe); + subreq = cli_close_send(state, + state->ev, + state->cli, + state->ctrl_pipe, + 0); if (tevent_req_nomem(subreq, req)) { return; } diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index fff45072936..6f1625ce190 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -3637,9 +3637,10 @@ struct cli_close_state { 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_context *ev, + struct cli_state *cli, + uint16_t fnum, + uint16_t flags) { struct tevent_req *req, *subreq; struct cli_close_state *state; @@ -3651,7 +3652,7 @@ struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx, } if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { - subreq = cli_smb2_close_fnum_send(state, ev, cli, fnum, 0); + subreq = cli_smb2_close_fnum_send(state, ev, cli, fnum, flags); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); } @@ -3714,7 +3715,7 @@ NTSTATUS cli_close(struct cli_state *cli, uint16_t fnum) goto fail; } - req = cli_close_send(frame, ev, cli, fnum); + req = cli_close_send(frame, ev, cli, fnum, 0); if (req == NULL) { status = NT_STATUS_NO_MEMORY; goto fail; @@ -5117,7 +5118,7 @@ static void cli_chkpath_opened(struct tevent_req *subreq) return; } - subreq = cli_close_send(state, state->ev, state->cli, fnum); + subreq = cli_close_send(state, state->ev, state->cli, fnum, 0); if (tevent_req_nomem(subreq, req)) { return; } diff --git a/source3/libsmb/clisymlink.c b/source3/libsmb/clisymlink.c index 81d8646afcc..d7ecf545761 100644 --- a/source3/libsmb/clisymlink.c +++ b/source3/libsmb/clisymlink.c @@ -125,8 +125,11 @@ static void cli_create_reparse_point_done(struct tevent_req *subreq) TALLOC_FREE(subreq); if (NT_STATUS_IS_OK(state->set_reparse_status)) { - subreq = cli_close_send(state, state->ev, state->cli, - state->fnum); + subreq = cli_close_send(state, + state->ev, + state->cli, + state->fnum, + 0); if (tevent_req_nomem(subreq, req)) { return; } @@ -159,7 +162,7 @@ static void cli_create_reparse_point_doc_done(struct tevent_req *subreq) (void)cli_nt_delete_on_close_recv(subreq); TALLOC_FREE(subreq); - subreq = cli_close_send(state, state->ev, state->cli, state->fnum); + subreq = cli_close_send(state, state->ev, state->cli, state->fnum, 0); if (tevent_req_nomem(subreq, req)) { return; } @@ -390,7 +393,7 @@ static void cli_get_reparse_data_done(struct tevent_req *subreq) state->datalen = out.length; } - subreq = cli_close_send(state, state->ev, state->cli, state->fnum); + subreq = cli_close_send(state, state->ev, state->cli, state->fnum, 0); if (tevent_req_nomem(subreq, req)) { return; } diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h index 6ed2be9757a..b5a0311469e 100644 --- a/source3/libsmb/proto.h +++ b/source3/libsmb/proto.h @@ -435,7 +435,9 @@ struct tevent_req *cli_smb1_close_create(TALLOC_CTX *mem_ctx, struct tevent_req **psubreq); struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, - struct cli_state *cli, uint16_t fnum); + struct cli_state *cli, + uint16_t fnum, + uint16_t flags); NTSTATUS cli_close_recv(struct tevent_req *req); NTSTATUS cli_close(struct cli_state *cli, uint16_t fnum); struct tevent_req *cli_ftruncate_send(TALLOC_CTX *mem_ctx, diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c index 9ac49437820..9fa7ea278ea 100644 --- a/source3/libsmb/pylibsmb.c +++ b/source3/libsmb/pylibsmb.c @@ -1242,13 +1242,14 @@ static PyObject *py_cli_close(struct py_cli_state *self, PyObject *args) { struct tevent_req *req; int fnum; + int flags = 0; NTSTATUS status; - if (!PyArg_ParseTuple(args, "i", &fnum)) { + if (!PyArg_ParseTuple(args, "i|i", &fnum, &flags)) { return NULL; } - req = cli_close_send(NULL, self->ev, self->cli, fnum); + req = cli_close_send(NULL, self->ev, self->cli, fnum, flags); if (!py_tevent_req_wait_exc(self, req)) { return NULL; } @@ -1370,7 +1371,7 @@ static PyObject *py_smb_savefile(struct py_cli_state *self, PyObject *args) PyErr_NTSTATUS_NOT_OK_RAISE(status); /* close the file handle */ - req = cli_close_send(NULL, self->ev, self->cli, fnum); + req = cli_close_send(NULL, self->ev, self->cli, fnum, 0); if (!py_tevent_req_wait_exc(self, req)) { return NULL; } @@ -1492,7 +1493,7 @@ static PyObject *py_smb_loadfile(struct py_cli_state *self, PyObject *args) } /* close the file handle */ - req = cli_close_send(NULL, self->ev, self->cli, fnum); + req = cli_close_send(NULL, self->ev, self->cli, fnum, 0); if (!py_tevent_req_wait_exc(self, req)) { Py_XDECREF(result); return NULL; diff --git a/source3/torture/nbench.c b/source3/torture/nbench.c index e9a0b4f2f33..8646d7a9b7c 100644 --- a/source3/torture/nbench.c +++ b/source3/torture/nbench.c @@ -274,8 +274,11 @@ static struct tevent_req *nbench_cmd_send(TALLOC_CTX *mem_ctx, tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); return tevent_req_post(req, ev); } - subreq = cli_close_send( - state, ev, nb_state->cli, state->ft->fnum); + subreq = cli_close_send(state, + ev, + nb_state->cli, + state->ft->fnum, + 0); break; } case NBENCH_CMD_MKDIR: { diff --git a/source3/torture/test_chain3.c b/source3/torture/test_chain3.c index d957e5145d4..5320ef898f0 100644 --- a/source3/torture/test_chain3.c +++ b/source3/torture/test_chain3.c @@ -206,7 +206,7 @@ static void chain3_got_break(struct tevent_req *subreq) if (tevent_req_nterror(req, status)) { return; } - subreq = cli_close_send(state, state->ev, state->cli, fnum); + subreq = cli_close_send(state, state->ev, state->cli, fnum, 0); if (tevent_req_nomem(subreq, req)) { return; } diff --git a/source3/torture/test_notify.c b/source3/torture/test_notify.c index 33c2381fbbd..b265845f822 100644 --- a/source3/torture/test_notify.c +++ b/source3/torture/test_notify.c @@ -137,7 +137,7 @@ static void wait_for_one_notify_done(struct tevent_req *subreq) if (tevent_req_nterror(req, status)) { return; } - subreq = cli_close_send(state, state->ev, state->cli, state->dnum); + subreq = cli_close_send(state, state->ev, state->cli, state->dnum, 0); if (tevent_req_nomem(subreq, req)) { return; } @@ -501,8 +501,11 @@ static void notify_bench3_before_close_subdir(struct tevent_req *subreq) tevent_req_nterror(req, map_nt_error_from_unix(ret)); return; } - subreq = cli_close_send(state, state->ev, state->cli, - state->subdir_dnum); + subreq = cli_close_send(state, + state->ev, + state->cli, + state->subdir_dnum, + 0); if (tevent_req_nomem(subreq, req)) { return; } @@ -586,7 +589,7 @@ static void notify_bench3_del_on_close_set(struct tevent_req *subreq) return; } - subreq = cli_close_send(state, state->ev, state->cli, state->dnum); + subreq = cli_close_send(state, state->ev, state->cli, state->dnum, 0); if (tevent_req_nomem(subreq, req)) { return; } diff --git a/source3/torture/test_notify_online.c b/source3/torture/test_notify_online.c index c8ddf7c0fab..d8a5d37e33f 100644 --- a/source3/torture/test_notify_online.c +++ b/source3/torture/test_notify_online.c @@ -160,8 +160,7 @@ static void notify_online_sent_read(struct tevent_req *subreq) if (tevent_req_nterror(req, status)) { return; } - subreq = cli_close_send( - state, state->ev, state->cli, state->fnum); + subreq = cli_close_send(state, state->ev, state->cli, state->fnum, 0); if (tevent_req_nomem(subreq, req)) { return; } @@ -198,8 +197,7 @@ static void notify_online_waited(struct tevent_req *subreq) tevent_wakeup_recv(subreq); TALLOC_FREE(subreq); - subreq = cli_close_send( - state, state->ev, state->cli, state->dnum); + subreq = cli_close_send(state, state->ev, state->cli, state->dnum, 0); if (tevent_req_nomem(subreq, req)) { return; } diff --git a/source3/torture/torture.c b/source3/torture/torture.c index e80e8f7d8b6..eecc5948a3b 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -3177,7 +3177,7 @@ static void deferred_close_waited(struct tevent_req *subreq) return; } - subreq = cli_close_send(state, state->ev, state->cli, state->fnum); + subreq = cli_close_send(state, state->ev, state->cli, state->fnum, 0); if (tevent_req_nomem(subreq, req)) { return; } @@ -5945,7 +5945,7 @@ static struct tevent_req *delete_stream_send( } tevent_req_set_callback(subreq, delete_stream_unlinked, req); - subreq = cli_close_send(state, ev, cli, stream_fnum); + subreq = cli_close_send(state, ev, cli, stream_fnum, 0); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); } @@ -10698,7 +10698,7 @@ static void torture_createdel_created(struct tevent_req *subreq) return; } - subreq = cli_close_send(state, state->ev, state->cli, fnum); + subreq = cli_close_send(state, state->ev, state->cli, fnum, 0); if (tevent_req_nomem(subreq, req)) { return; }