From: Jeremy Allison Date: Tue, 28 Nov 2017 22:09:39 +0000 (-0800) Subject: s3: libsmb: Add SMB2 calls cli_smb2_set_reparse_point_fnum_send()/cli_smb2_set_repars... X-Git-Tag: talloc-2.1.11~284 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4581bfe76ce924d170f2dd2b436ca9acc1b8ec37;p=thirdparty%2Fsamba.git s3: libsmb: Add SMB2 calls cli_smb2_set_reparse_point_fnum_send()/cli_smb2_set_reparse_point_fnum_recv(). Allow reparse points to be created over SMB2. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13159 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Böhme --- diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c index 78f61fbedd4..f8861e53345 100644 --- a/source3/libsmb/cli_smb2_fnum.c +++ b/source3/libsmb/cli_smb2_fnum.c @@ -4181,3 +4181,96 @@ fail: TALLOC_FREE(frame); return status; } + +struct cli_smb2_set_reparse_point_fnum_state { + struct cli_state *cli; + uint16_t fnum; + struct smb2_hnd *ph; + DATA_BLOB input_buffer; +}; + +static void cli_smb2_set_reparse_point_fnum_done(struct tevent_req *subreq); + +struct tevent_req *cli_smb2_set_reparse_point_fnum_send( + TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct cli_state *cli, + uint16_t fnum, + DATA_BLOB in_buf) +{ + 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_set_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); + } + + state->input_buffer = data_blob_talloc(state, + in_buf.data, + in_buf.length); + if (state->input_buffer.data == NULL) { + tevent_req_nterror(req, NT_STATUS_NO_MEMORY); + 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_SET_REPARSE_POINT, + 0, /* in_max_input_length */ + &state->input_buffer , + 0, + 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_set_reparse_point_fnum_done, + req); + + return req; +} + +static void cli_smb2_set_reparse_point_fnum_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct cli_smb2_set_reparse_point_fnum_state *state = tevent_req_data( + req, struct cli_smb2_set_reparse_point_fnum_state); + NTSTATUS status; + + status = smb2cli_ioctl_recv(subreq, state, + NULL, + NULL); + TALLOC_FREE(subreq); + if (tevent_req_nterror(req, status)) { + return; + } + tevent_req_done(req); +} + +NTSTATUS cli_smb2_set_reparse_point_fnum_recv(struct tevent_req *req) +{ + return tevent_req_simple_recv_ntstatus(req); +} diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h index 3d9b6eb3fe6..0f6809fe4ca 100644 --- a/source3/libsmb/cli_smb2_fnum.h +++ b/source3/libsmb/cli_smb2_fnum.h @@ -242,4 +242,12 @@ NTSTATUS cli_smb2_notify(struct cli_state *cli, uint16_t fnum, bool recursive, TALLOC_CTX *mem_ctx, struct notify_change **pchanges, uint32_t *pnum_changes); +struct tevent_req *cli_smb2_set_reparse_point_fnum_send( + TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct cli_state *cli, + uint16_t fnum, + DATA_BLOB in_buf); +NTSTATUS cli_smb2_set_reparse_point_fnum_recv(struct tevent_req *req); + #endif /* __SMB2CLI_FNUM_H__ */