libsmb: Pass "flags" through cli_close_send() and pylibsmb
authorVolker Lendecke <vl@samba.org>
Sat, 7 Oct 2023 10:13:09 +0000 (12:13 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 10 Oct 2023 08:19:29 +0000 (08:19 +0000)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=15487

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
examples/winexe/winexe.c
source3/libsmb/clifile.c
source3/libsmb/clisymlink.c
source3/libsmb/proto.h
source3/libsmb/pylibsmb.c
source3/torture/nbench.c
source3/torture/test_chain3.c
source3/torture/test_notify.c
source3/torture/test_notify_online.c
source3/torture/torture.c

index 29e1fe2055bc6e4dda23f07515aad91c853796d5..5c2529cb2de220e46cdf2ad99724a2fd7358f670 100644 (file)
@@ -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;
                }
index fff450729369f8fde769d95decde603cb111dbee..6f1625ce1902e9a460198533757906fdb506bc1b 100644 (file)
@@ -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;
        }
index 81d8646afccdac412c066a431432ecf25e4ffea4..d7ecf5457614c3ed07f25a4873414391dd5f6638 100644 (file)
@@ -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;
        }
index 6ed2be9757a0e011f859514ee722cebfd2273775..b5a0311469e0530bd5542d96f4d1ee87e6e256f2 100644 (file)
@@ -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,
index 9ac49437820434beee88e3d96c5552d6f5f908cb..9fa7ea278eae05b15d12437b06d570917ad879ce 100644 (file)
@@ -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;
index e9a0b4f2f33f8176dd3c56963ea622876d34f2c3..8646d7a9b7cbab5b697f55ad2544420d3dc76824 100644 (file)
@@ -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: {
index d957e5145d40699e79e3c9a74da971d8154cb5e6..5320ef898f0b3ef1933f4c309b2b230948c95e7a 100644 (file)
@@ -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;
        }
index 33c2381fbbdf48abda559d1f53edfaead2fd8fcb..b265845f8222db25290c9da23fcd5cee26edf936 100644 (file)
@@ -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;
        }
index c8ddf7c0fab9a5a6967048973cee3b6e3ec96ce6..d8a5d37e33f15bd9b506190f672dcff35a2d561a 100644 (file)
@@ -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;
        }
index e80e8f7d8b69126a47a49aa43da2b9625466c22f..eecc5948a3bd588328bb1d5ac7e9284f0ecfb545 100644 (file)
@@ -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;
        }