NTSTATUS open_np_file(struct smb_request *smb_req, const char *name,
struct files_struct **pfsp);
-void reply_pipe_write(struct smb_request *req);
/* The following definitions come from smbd/posix_acls.c */
*/
smb_request_done(req);
}
+
+/****************************************************************************
+ Reply to a write on a pipe.
+****************************************************************************/
+
+struct pipe_write_state {
+ size_t numtowrite;
+};
+
+static void pipe_write_done(struct tevent_req *subreq);
+
+void reply_pipe_write(struct smb_request *req)
+{
+ files_struct *fsp = file_fsp(req, SVAL(req->vwv+0, 0));
+ const uint8_t *data;
+ struct pipe_write_state *state;
+ struct tevent_req *subreq;
+
+ 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_write_state);
+ if (state == NULL) {
+ reply_nterror(req, NT_STATUS_NO_MEMORY);
+ return;
+ }
+ req->async_priv = state;
+
+ state->numtowrite = SVAL(req->vwv+1, 0);
+
+ data = req->buf + 3;
+
+ DEBUG(6, ("reply_pipe_write: %s, name: %s len: %d\n", fsp_fnum_dbg(fsp),
+ fsp_str_dbg(fsp), (int)state->numtowrite));
+
+ subreq = np_write_send(state, req->sconn->ev_ctx,
+ fsp->fake_file_handle, data, state->numtowrite);
+ if (subreq == NULL) {
+ TALLOC_FREE(state);
+ reply_nterror(req, NT_STATUS_NO_MEMORY);
+ return;
+ }
+ tevent_req_set_callback(subreq, pipe_write_done,
+ talloc_move(req->conn, &req));
+}
+
+static void pipe_write_done(struct tevent_req *subreq)
+{
+ struct smb_request *req = tevent_req_callback_data(
+ subreq, struct smb_request);
+ struct pipe_write_state *state = talloc_get_type_abort(
+ req->async_priv, struct pipe_write_state);
+ NTSTATUS status;
+ ssize_t nwritten = -1;
+
+ status = np_write_recv(subreq, &nwritten);
+ TALLOC_FREE(subreq);
+ if (nwritten < 0) {
+ reply_nterror(req, status);
+ goto send;
+ }
+
+ /* Looks bogus to me now. Needs to be removed ? JRA. */
+ if ((nwritten == 0 && state->numtowrite != 0)) {
+ reply_nterror(req, NT_STATUS_ACCESS_DENIED);
+ goto send;
+ }
+
+ reply_outbuf(req, 1, 0);
+
+ SSVAL(req->outbuf,smb_vwv0,nwritten);
+
+ DEBUG(3,("write-IPC nwritten=%d\n", (int)nwritten));
+
+ send:
+ if (!srv_send_smb(req->xconn, (char *)req->outbuf,
+ true, req->seqnum+1,
+ IS_CONN_ENCRYPTED(req->conn)||req->encrypted,
+ &req->pcd)) {
+ exit_server_cleanly("construct_reply: srv_send_smb failed.");
+ }
+ TALLOC_FREE(req);
+}
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);
+void reply_pipe_write(struct smb_request *req);
return NT_STATUS_OK;
}
-
-/****************************************************************************
- Reply to a write on a pipe.
-****************************************************************************/
-
-struct pipe_write_state {
- size_t numtowrite;
-};
-
-static void pipe_write_done(struct tevent_req *subreq);
-
-void reply_pipe_write(struct smb_request *req)
-{
- files_struct *fsp = file_fsp(req, SVAL(req->vwv+0, 0));
- const uint8_t *data;
- struct pipe_write_state *state;
- struct tevent_req *subreq;
-
- 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_write_state);
- if (state == NULL) {
- reply_nterror(req, NT_STATUS_NO_MEMORY);
- return;
- }
- req->async_priv = state;
-
- state->numtowrite = SVAL(req->vwv+1, 0);
-
- data = req->buf + 3;
-
- DEBUG(6, ("reply_pipe_write: %s, name: %s len: %d\n", fsp_fnum_dbg(fsp),
- fsp_str_dbg(fsp), (int)state->numtowrite));
-
- subreq = np_write_send(state, req->sconn->ev_ctx,
- fsp->fake_file_handle, data, state->numtowrite);
- if (subreq == NULL) {
- TALLOC_FREE(state);
- reply_nterror(req, NT_STATUS_NO_MEMORY);
- return;
- }
- tevent_req_set_callback(subreq, pipe_write_done,
- talloc_move(req->conn, &req));
-}
-
-static void pipe_write_done(struct tevent_req *subreq)
-{
- struct smb_request *req = tevent_req_callback_data(
- subreq, struct smb_request);
- struct pipe_write_state *state = talloc_get_type_abort(
- req->async_priv, struct pipe_write_state);
- NTSTATUS status;
- ssize_t nwritten = -1;
-
- status = np_write_recv(subreq, &nwritten);
- TALLOC_FREE(subreq);
- if (nwritten < 0) {
- reply_nterror(req, status);
- goto send;
- }
-
- /* Looks bogus to me now. Needs to be removed ? JRA. */
- if ((nwritten == 0 && state->numtowrite != 0)) {
- reply_nterror(req, NT_STATUS_ACCESS_DENIED);
- goto send;
- }
-
- reply_outbuf(req, 1, 0);
-
- SSVAL(req->outbuf,smb_vwv0,nwritten);
-
- DEBUG(3,("write-IPC nwritten=%d\n", (int)nwritten));
-
- send:
- if (!srv_send_smb(req->xconn, (char *)req->outbuf,
- true, req->seqnum+1,
- IS_CONN_ENCRYPTED(req->conn)||req->encrypted,
- &req->pcd)) {
- exit_server_cleanly("construct_reply: srv_send_smb failed.");
- }
- TALLOC_FREE(req);
-}