]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Use cli_smb2_qpathinfo() for streams
authorVolker Lendecke <vl@samba.org>
Fri, 18 Aug 2023 13:47:20 +0000 (15:47 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 22 Aug 2023 16:45:31 +0000 (16:45 +0000)
Remove sync cli_smb2_qpathinfo_streams() wrapper.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/cli_smb2_fnum.c
source3/libsmb/cli_smb2_fnum.h
source3/libsmb/clirap.c

index cc70af1a876bbfd07dd2bb1e6c8e2f8262f5cd17..14fa8ae2708327e0b2f61cd27f3087d0cf487aa6 100644 (file)
@@ -2611,80 +2611,6 @@ NTSTATUS cli_smb2_qpathinfo2_recv(struct tevent_req *req,
        return NT_STATUS_OK;
 }
 
-/***************************************************************
- Wrapper that allows SMB2 to query pathname streams.
- Synchronous only.
-***************************************************************/
-
-NTSTATUS cli_smb2_qpathinfo_streams(struct cli_state *cli,
-                               const char *name,
-                               TALLOC_CTX *mem_ctx,
-                               unsigned int *pnum_streams,
-                               struct stream_struct **pstreams)
-{
-       NTSTATUS status;
-       uint16_t fnum = 0xffff;
-       DATA_BLOB outbuf = data_blob_null;
-       TALLOC_CTX *frame = talloc_stackframe();
-
-       if (smbXcli_conn_has_async_calls(cli->conn)) {
-               /*
-                * Can't use sync call while an async call is in flight
-                */
-               status = NT_STATUS_INVALID_PARAMETER;
-               goto fail;
-       }
-
-       status = get_fnum_from_path(cli,
-                               name,
-                               FILE_READ_ATTRIBUTES,
-                               &fnum);
-
-       if (!NT_STATUS_IS_OK(status)) {
-               goto fail;
-       }
-
-       /* getinfo on the handle with info_type SMB2_GETINFO_FILE (1),
-          level 22 (SMB2_FILE_STREAM_INFORMATION). */
-
-       status = cli_smb2_query_info_fnum(
-               cli,
-               fnum,
-               1, /* in_info_type */
-               (SMB_FILE_STREAM_INFORMATION - 1000), /* in_file_info_class */
-               0xFFFF, /* in_max_output_length */
-               NULL, /* in_input_buffer */
-               0, /* in_additional_info */
-               0, /* in_flags */
-               frame,
-               &outbuf);
-
-       if (!NT_STATUS_IS_OK(status)) {
-               goto fail;
-       }
-
-       /* Parse the reply. */
-       if (!parse_streams_blob(mem_ctx,
-                               outbuf.data,
-                               outbuf.length,
-                               pnum_streams,
-                               pstreams)) {
-               status = NT_STATUS_INVALID_NETWORK_RESPONSE;
-               goto fail;
-       }
-
-  fail:
-
-       if (fnum != 0xffff) {
-               cli_smb2_close_fnum(cli, fnum);
-       }
-
-       cli->raw_status = status;
-
-       TALLOC_FREE(frame);
-       return status;
-}
-
 /***************************************************************
  Wrapper that allows SMB2 to set SMB_FILE_BASIC_INFORMATION on
  a pathname.
index 60ed108334d287d216bb468dfdb7c8e07e881412..1068165dcdb934e425df5f73b83dfe61b5528bf7 100644 (file)
@@ -187,11 +187,6 @@ NTSTATUS cli_smb2_qpathinfo2_recv(struct tevent_req *req,
                                  off_t *size,
                                  uint32_t *attr,
                                  SMB_INO_T *ino);
-NTSTATUS cli_smb2_qpathinfo_streams(struct cli_state *cli,
-                       const char *name,
-                       TALLOC_CTX *mem_ctx,
-                       unsigned int *pnum_streams,
-                       struct stream_struct **pstreams);
 NTSTATUS cli_smb2_setpathinfo(struct cli_state *cli,
                        const char *name,
                        uint8_t in_info_type,
index 25edd21771591cbe38618cf5297633252ef1c814..ebe97d8c0e5cb1c44988a492186fa1accc895271 100644 (file)
@@ -1099,6 +1099,7 @@ struct cli_qpathinfo_streams_state {
 };
 
 static void cli_qpathinfo_streams_done(struct tevent_req *subreq);
+static void cli_qpathinfo_streams_done2(struct tevent_req *subreq);
 
 struct tevent_req *cli_qpathinfo_streams_send(TALLOC_CTX *mem_ctx,
                                              struct tevent_context *ev,
@@ -1113,6 +1114,22 @@ struct tevent_req *cli_qpathinfo_streams_send(TALLOC_CTX *mem_ctx,
        if (req == NULL) {
                return NULL;
        }
+       if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+               subreq = cli_smb2_qpathinfo_send(state,
+                                                ev,
+                                                cli,
+                                                fname,
+                                                FSCC_FILE_STREAM_INFORMATION,
+                                                0,
+                                                CLI_BUFFER_SIZE);
+               if (tevent_req_nomem(subreq, req)) {
+                       return tevent_req_post(req, ev);
+               }
+               tevent_req_set_callback(subreq,
+                                       cli_qpathinfo_streams_done2,
+                                       req);
+               return req;
+       }
        subreq = cli_qpathinfo_send(state, ev, cli, fname,
                                    SMB_FILE_STREAM_INFORMATION,
                                    0, CLI_BUFFER_SIZE);
@@ -1133,12 +1150,22 @@ static void cli_qpathinfo_streams_done(struct tevent_req *subreq)
 
        status = cli_qpathinfo_recv(subreq, state, &state->data,
                                    &state->num_data);
-       TALLOC_FREE(subreq);
-       if (!NT_STATUS_IS_OK(status)) {
-               tevent_req_nterror(req, status);
-               return;
-       }
-       tevent_req_done(req);
+       tevent_req_simple_finish_ntstatus(subreq, status);
+}
+
+static void cli_qpathinfo_streams_done2(struct tevent_req *subreq)
+{
+       struct tevent_req *req =
+               tevent_req_callback_data(subreq, struct tevent_req);
+       struct cli_qpathinfo_streams_state *state =
+               tevent_req_data(req, struct cli_qpathinfo_streams_state);
+       NTSTATUS status;
+
+       status = cli_smb2_qpathinfo_recv(subreq,
+                                        state,
+                                        &state->data,
+                                        &state->num_data);
+       tevent_req_simple_finish_ntstatus(subreq, status);
 }
 
 NTSTATUS cli_qpathinfo_streams_recv(struct tevent_req *req,
@@ -1170,14 +1197,6 @@ NTSTATUS cli_qpathinfo_streams(struct cli_state *cli, const char *fname,
        struct tevent_req *req;
        NTSTATUS status = NT_STATUS_NO_MEMORY;
 
-       if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
-               return cli_smb2_qpathinfo_streams(cli,
-                                       fname,
-                                       mem_ctx,
-                                       pnum_streams,
-                                       pstreams);
-       }
-
        frame = talloc_stackframe();
 
        if (smbXcli_conn_has_async_calls(cli->conn)) {