]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Move reply_pipe_write to smb1_pipes.c
authorDavid Mulder <dmulder@suse.com>
Thu, 31 Mar 2022 17:37:25 +0000 (11:37 -0600)
committerJeremy Allison <jra@samba.org>
Thu, 7 Apr 2022 17:37:30 +0000 (17:37 +0000)
Signed-off-by: David Mulder <dmulder@suse.com>
Signed-off-by: Jeremy Allison <jra@samba.org>
source3/smbd/proto.h
source3/smbd/smb1_pipes.c
source3/smbd/smb1_pipes.h
source3/smbd/smb2_pipes.c

index de03cb77795908b1382fabba739f2c166495b95f..ef409183e7f882dca48970a2727be1e986ae5f2d 100644 (file)
@@ -793,7 +793,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);
 
 /* The following definitions come from smbd/posix_acls.c  */
 
index 25862c1842b6c2c16fe3c2ca892bfcdbe268e1f2..bc5837fb632d86b9f402fb4a2875e742eca458f7 100644 (file)
@@ -364,3 +364,93 @@ static void pipe_read_andx_done(struct tevent_req *subreq)
         */
        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);
+}
index c480138109c564156442ef07d77935a21a6b9d70..20e8a99157c9e3895274f0d949c36567f0199ea8 100644 (file)
@@ -23,3 +23,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);
+void reply_pipe_write(struct smb_request *req);
index 23cc1a3bc087328e6791ae93d25ce5727b0d3e94..b637ddf216abd044d1789deb981b17cbb03d13c2 100644 (file)
@@ -149,93 +149,3 @@ NTSTATUS open_np_file(struct smb_request *smb_req, const char *name,
 
        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);
-}