s3: libsmb: Add SMB2 calls cli_smb2_get_reparse_point_fnum_send()/cli_smb2_get_repars...
authorJeremy Allison <jra@samba.org>
Wed, 29 Nov 2017 20:37:36 +0000 (12:37 -0800)
committerRalph Boehme <slow@samba.org>
Wed, 6 Dec 2017 14:02:16 +0000 (15:02 +0100)
Allow reparse points to be queried over SMB2.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13159

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/libsmb/cli_smb2_fnum.c
source3/libsmb/cli_smb2_fnum.h

index c40d6dd3a45476ec9aee4443c1b22ca4dbc8947f..2d87b58d730ff1355f0d8edc82e8da16a5fd780b 100644 (file)
@@ -4337,3 +4337,103 @@ NTSTATUS cli_smb2_set_reparse_point_fnum_recv(struct tevent_req *req)
 {
         return tevent_req_simple_recv_ntstatus(req);
 }
+
+struct cli_smb2_get_reparse_point_fnum_state {
+       struct cli_state *cli;
+       uint16_t fnum;
+       struct smb2_hnd *ph;
+       DATA_BLOB output_buffer;
+};
+
+static void cli_smb2_get_reparse_point_fnum_done(struct tevent_req *subreq);
+
+struct tevent_req *cli_smb2_get_reparse_point_fnum_send(
+                               TALLOC_CTX *mem_ctx,
+                               struct tevent_context *ev,
+                               struct cli_state *cli,
+                               uint16_t fnum)
+{
+       struct tevent_req *req, *subreq;
+       struct cli_smb2_set_reparse_point_fnum_state *state = NULL;
+       NTSTATUS status;
+
+       req = tevent_req_create(mem_ctx, &state,
+                               struct cli_smb2_get_reparse_point_fnum_state);
+       if (req == NULL) {
+               return NULL;
+       }
+
+       if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
+               tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+               return tevent_req_post(req, ev);
+       }
+
+       state->cli = cli;
+       state->fnum = fnum;
+
+       status = map_fnum_to_smb2_handle(cli, fnum, &state->ph);
+       if (tevent_req_nterror(req, status)) {
+               return tevent_req_post(req, ev);
+       }
+
+       subreq = smb2cli_ioctl_send(state, ev, state->cli->conn,
+                       state->cli->timeout,
+                       state->cli->smb2.session,
+                       state->cli->smb2.tcon,
+                       state->ph->fid_persistent, /* in_fid_persistent */
+                       state->ph->fid_volatile, /* in_fid_volatile */
+                       FSCTL_GET_REPARSE_POINT,
+                       0, /* in_max_input_length */
+                       NULL,
+                       64*1024,
+                       NULL,
+                       SMB2_IOCTL_FLAG_IS_FSCTL);
+
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq,
+                               cli_smb2_get_reparse_point_fnum_done,
+                               req);
+
+       return req;
+}
+
+static void cli_smb2_get_reparse_point_fnum_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       struct cli_smb2_get_reparse_point_fnum_state *state = tevent_req_data(
+               req, struct cli_smb2_get_reparse_point_fnum_state);
+       NTSTATUS status;
+
+       status = smb2cli_ioctl_recv(subreq, state,
+                               NULL,
+                               &state->output_buffer);
+       TALLOC_FREE(subreq);
+       if (tevent_req_nterror(req, status)) {
+               state->cli->raw_status = status;
+               return;
+       }
+       tevent_req_done(req);
+}
+
+NTSTATUS cli_smb2_get_reparse_point_fnum_recv(struct tevent_req *req,
+                               TALLOC_CTX *mem_ctx,
+                               DATA_BLOB *output)
+{
+       struct cli_smb2_get_reparse_point_fnum_state *state = tevent_req_data(
+               req, struct cli_smb2_get_reparse_point_fnum_state);
+
+       if (tevent_req_is_nterror(req, &state->cli->raw_status)) {
+               tevent_req_received(req);
+               return state->cli->raw_status;
+       }
+       *output = data_blob_dup_talloc(mem_ctx, state->output_buffer);
+       if (output->data == NULL) {
+               tevent_req_received(req);
+               return NT_STATUS_NO_MEMORY;
+       }
+       tevent_req_received(req);
+       return NT_STATUS_OK;
+}
index 0f6809fe4ca2d0af04a6cb218e709f7e7f24c0b2..0ceddd0b9ab6863da76e73bad33a67992ec8cc67 100644 (file)
@@ -250,4 +250,13 @@ struct tevent_req *cli_smb2_set_reparse_point_fnum_send(
                        DATA_BLOB in_buf);
 NTSTATUS cli_smb2_set_reparse_point_fnum_recv(struct tevent_req *req);
 
+struct tevent_req *cli_smb2_get_reparse_point_fnum_send(
+                       TALLOC_CTX *mem_ctx,
+                       struct tevent_context *ev,
+                       struct cli_state *cli,
+                       uint16_t fnum);
+NTSTATUS cli_smb2_get_reparse_point_fnum_recv(struct tevent_req *req,
+                       TALLOC_CTX *mem_ctx,
+                       DATA_BLOB *output);
+
 #endif /* __SMB2CLI_FNUM_H__ */