mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
smbd: Move reply_pipe_read_and_X to smb1_pipes.c
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
3d3713860f
commit
0a68f9d47c
@ -239,133 +239,3 @@ static void pipe_write_done(struct tevent_req *subreq)
|
||||
}
|
||||
TALLOC_FREE(req);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Reply to a read and X.
|
||||
This code is basically stolen from reply_read_and_X with some
|
||||
wrinkles to handle pipes.
|
||||
****************************************************************************/
|
||||
|
||||
struct pipe_read_andx_state {
|
||||
uint8_t *outbuf;
|
||||
int smb_mincnt;
|
||||
int smb_maxcnt;
|
||||
};
|
||||
|
||||
static void pipe_read_andx_done(struct tevent_req *subreq);
|
||||
|
||||
void reply_pipe_read_and_X(struct smb_request *req)
|
||||
{
|
||||
files_struct *fsp = file_fsp(req, SVAL(req->vwv+0, 0));
|
||||
uint8_t *data;
|
||||
struct pipe_read_andx_state *state;
|
||||
struct tevent_req *subreq;
|
||||
|
||||
/* we don't use the offset given to use for pipe reads. This
|
||||
is deliberate, instead we always return the next lump of
|
||||
data on the pipe */
|
||||
#if 0
|
||||
uint32_t smb_offs = IVAL(req->vwv+3, 0);
|
||||
#endif
|
||||
|
||||
if (!fsp_is_np(fsp)) {
|
||||
reply_nterror(req, NT_STATUS_INVALID_HANDLE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fsp->vuid != req->vuid) {
|
||||
reply_nterror(req, NT_STATUS_INVALID_HANDLE);
|
||||
return;
|
||||
}
|
||||
|
||||
state = talloc(req, struct pipe_read_andx_state);
|
||||
if (state == NULL) {
|
||||
reply_nterror(req, NT_STATUS_NO_MEMORY);
|
||||
return;
|
||||
}
|
||||
req->async_priv = state;
|
||||
|
||||
state->smb_maxcnt = SVAL(req->vwv+5, 0);
|
||||
state->smb_mincnt = SVAL(req->vwv+6, 0);
|
||||
|
||||
reply_outbuf(req, 12, state->smb_maxcnt + 1 /* padding byte */);
|
||||
SSVAL(req->outbuf, smb_vwv0, 0xff); /* andx chain ends */
|
||||
SSVAL(req->outbuf, smb_vwv1, 0); /* no andx offset */
|
||||
SCVAL(smb_buf(req->outbuf), 0, 0); /* padding byte */
|
||||
|
||||
data = (uint8_t *)smb_buf(req->outbuf) + 1 /* padding byte */;
|
||||
|
||||
/*
|
||||
* We have to tell the upper layers that we're async.
|
||||
*/
|
||||
state->outbuf = req->outbuf;
|
||||
req->outbuf = NULL;
|
||||
|
||||
subreq = np_read_send(state, req->sconn->ev_ctx,
|
||||
fsp->fake_file_handle, data,
|
||||
state->smb_maxcnt);
|
||||
if (subreq == NULL) {
|
||||
reply_nterror(req, NT_STATUS_NO_MEMORY);
|
||||
return;
|
||||
}
|
||||
tevent_req_set_callback(subreq, pipe_read_andx_done,
|
||||
talloc_move(req->conn, &req));
|
||||
}
|
||||
|
||||
static void pipe_read_andx_done(struct tevent_req *subreq)
|
||||
{
|
||||
struct smb_request *req = tevent_req_callback_data(
|
||||
subreq, struct smb_request);
|
||||
struct pipe_read_andx_state *state = talloc_get_type_abort(
|
||||
req->async_priv, struct pipe_read_andx_state);
|
||||
NTSTATUS status;
|
||||
ssize_t nread;
|
||||
bool is_data_outstanding;
|
||||
|
||||
status = np_read_recv(subreq, &nread, &is_data_outstanding);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
NTSTATUS old = status;
|
||||
status = nt_status_np_pipe(old);
|
||||
reply_nterror(req, status);
|
||||
goto done;
|
||||
}
|
||||
|
||||
req->outbuf = state->outbuf;
|
||||
state->outbuf = NULL;
|
||||
|
||||
srv_set_message((char *)req->outbuf, 12, nread + 1 /* padding byte */,
|
||||
false);
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* we should return STATUS_BUFFER_OVERFLOW if there's
|
||||
* out standing data.
|
||||
*
|
||||
* But we can't enable it yet, as it has bad interactions
|
||||
* with fixup_chain_error_packet() in chain_reply().
|
||||
*/
|
||||
if (is_data_outstanding) {
|
||||
error_packet_set((char *)req->outbuf, ERRDOS, ERRmoredata,
|
||||
STATUS_BUFFER_OVERFLOW, __LINE__, __FILE__);
|
||||
}
|
||||
#endif
|
||||
|
||||
SSVAL(req->outbuf,smb_vwv5,nread);
|
||||
SSVAL(req->outbuf,smb_vwv6,
|
||||
(smb_wct - 4) /* offset from smb header to wct */
|
||||
+ 1 /* the wct field */
|
||||
+ 12 * sizeof(uint16_t) /* vwv */
|
||||
+ 2 /* the buflen field */
|
||||
+ 1); /* padding byte */
|
||||
|
||||
DEBUG(3,("readX-IPC min=%d max=%d nread=%d\n",
|
||||
state->smb_mincnt, state->smb_maxcnt, (int)nread));
|
||||
|
||||
done:
|
||||
/*
|
||||
* We must free here as the ownership of req was
|
||||
* moved to the connection struct in reply_pipe_read_and_X().
|
||||
*/
|
||||
smb_request_done(req);
|
||||
}
|
||||
|
@ -805,7 +805,6 @@ int register_homes_share(const char *username);
|
||||
NTSTATUS open_np_file(struct smb_request *smb_req, const char *name,
|
||||
struct files_struct **pfsp);
|
||||
void reply_pipe_write(struct smb_request *req);
|
||||
void reply_pipe_read_and_X(struct smb_request *req);
|
||||
|
||||
/* The following definitions come from smbd/posix_acls.c */
|
||||
|
||||
|
@ -234,3 +234,133 @@ static void pipe_write_andx_done(struct tevent_req *subreq)
|
||||
*/
|
||||
smb_request_done(req);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Reply to a read and X.
|
||||
This code is basically stolen from reply_read_and_X with some
|
||||
wrinkles to handle pipes.
|
||||
****************************************************************************/
|
||||
|
||||
struct pipe_read_andx_state {
|
||||
uint8_t *outbuf;
|
||||
int smb_mincnt;
|
||||
int smb_maxcnt;
|
||||
};
|
||||
|
||||
static void pipe_read_andx_done(struct tevent_req *subreq);
|
||||
|
||||
void reply_pipe_read_and_X(struct smb_request *req)
|
||||
{
|
||||
files_struct *fsp = file_fsp(req, SVAL(req->vwv+0, 0));
|
||||
uint8_t *data;
|
||||
struct pipe_read_andx_state *state;
|
||||
struct tevent_req *subreq;
|
||||
|
||||
/* we don't use the offset given to use for pipe reads. This
|
||||
is deliberate, instead we always return the next lump of
|
||||
data on the pipe */
|
||||
#if 0
|
||||
uint32_t smb_offs = IVAL(req->vwv+3, 0);
|
||||
#endif
|
||||
|
||||
if (!fsp_is_np(fsp)) {
|
||||
reply_nterror(req, NT_STATUS_INVALID_HANDLE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fsp->vuid != req->vuid) {
|
||||
reply_nterror(req, NT_STATUS_INVALID_HANDLE);
|
||||
return;
|
||||
}
|
||||
|
||||
state = talloc(req, struct pipe_read_andx_state);
|
||||
if (state == NULL) {
|
||||
reply_nterror(req, NT_STATUS_NO_MEMORY);
|
||||
return;
|
||||
}
|
||||
req->async_priv = state;
|
||||
|
||||
state->smb_maxcnt = SVAL(req->vwv+5, 0);
|
||||
state->smb_mincnt = SVAL(req->vwv+6, 0);
|
||||
|
||||
reply_outbuf(req, 12, state->smb_maxcnt + 1 /* padding byte */);
|
||||
SSVAL(req->outbuf, smb_vwv0, 0xff); /* andx chain ends */
|
||||
SSVAL(req->outbuf, smb_vwv1, 0); /* no andx offset */
|
||||
SCVAL(smb_buf(req->outbuf), 0, 0); /* padding byte */
|
||||
|
||||
data = (uint8_t *)smb_buf(req->outbuf) + 1 /* padding byte */;
|
||||
|
||||
/*
|
||||
* We have to tell the upper layers that we're async.
|
||||
*/
|
||||
state->outbuf = req->outbuf;
|
||||
req->outbuf = NULL;
|
||||
|
||||
subreq = np_read_send(state, req->sconn->ev_ctx,
|
||||
fsp->fake_file_handle, data,
|
||||
state->smb_maxcnt);
|
||||
if (subreq == NULL) {
|
||||
reply_nterror(req, NT_STATUS_NO_MEMORY);
|
||||
return;
|
||||
}
|
||||
tevent_req_set_callback(subreq, pipe_read_andx_done,
|
||||
talloc_move(req->conn, &req));
|
||||
}
|
||||
|
||||
static void pipe_read_andx_done(struct tevent_req *subreq)
|
||||
{
|
||||
struct smb_request *req = tevent_req_callback_data(
|
||||
subreq, struct smb_request);
|
||||
struct pipe_read_andx_state *state = talloc_get_type_abort(
|
||||
req->async_priv, struct pipe_read_andx_state);
|
||||
NTSTATUS status;
|
||||
ssize_t nread;
|
||||
bool is_data_outstanding;
|
||||
|
||||
status = np_read_recv(subreq, &nread, &is_data_outstanding);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
NTSTATUS old = status;
|
||||
status = nt_status_np_pipe(old);
|
||||
reply_nterror(req, status);
|
||||
goto done;
|
||||
}
|
||||
|
||||
req->outbuf = state->outbuf;
|
||||
state->outbuf = NULL;
|
||||
|
||||
srv_set_message((char *)req->outbuf, 12, nread + 1 /* padding byte */,
|
||||
false);
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* we should return STATUS_BUFFER_OVERFLOW if there's
|
||||
* out standing data.
|
||||
*
|
||||
* But we can't enable it yet, as it has bad interactions
|
||||
* with fixup_chain_error_packet() in chain_reply().
|
||||
*/
|
||||
if (is_data_outstanding) {
|
||||
error_packet_set((char *)req->outbuf, ERRDOS, ERRmoredata,
|
||||
STATUS_BUFFER_OVERFLOW, __LINE__, __FILE__);
|
||||
}
|
||||
#endif
|
||||
|
||||
SSVAL(req->outbuf,smb_vwv5,nread);
|
||||
SSVAL(req->outbuf,smb_vwv6,
|
||||
(smb_wct - 4) /* offset from smb header to wct */
|
||||
+ 1 /* the wct field */
|
||||
+ 12 * sizeof(uint16_t) /* vwv */
|
||||
+ 2 /* the buflen field */
|
||||
+ 1); /* padding byte */
|
||||
|
||||
DEBUG(3,("readX-IPC min=%d max=%d nread=%d\n",
|
||||
state->smb_mincnt, state->smb_maxcnt, (int)nread));
|
||||
|
||||
done:
|
||||
/*
|
||||
* We must free here as the ownership of req was
|
||||
* moved to the connection struct in reply_pipe_read_and_X().
|
||||
*/
|
||||
smb_request_done(req);
|
||||
}
|
||||
|
@ -22,3 +22,4 @@
|
||||
|
||||
void reply_open_pipe_and_X(connection_struct *conn, struct smb_request *req);
|
||||
void reply_pipe_write_and_X(struct smb_request *req);
|
||||
void reply_pipe_read_and_X(struct smb_request *req);
|
||||
|
Loading…
Reference in New Issue
Block a user