| 1 | /*
|
|---|
| 2 | Unix SMB/CIFS implementation.
|
|---|
| 3 | Pipe SMB reply routines
|
|---|
| 4 | Copyright (C) Andrew Tridgell 1992-1998
|
|---|
| 5 | Copyright (C) Luke Kenneth Casson Leighton 1996-1998
|
|---|
| 6 | Copyright (C) Paul Ashton 1997-1998.
|
|---|
| 7 | Copyright (C) Jeremy Allison 2005.
|
|---|
| 8 |
|
|---|
| 9 | This program is free software; you can redistribute it and/or modify
|
|---|
| 10 | it under the terms of the GNU General Public License as published by
|
|---|
| 11 | the Free Software Foundation; either version 3 of the License, or
|
|---|
| 12 | (at your option) any later version.
|
|---|
| 13 |
|
|---|
| 14 | This program is distributed in the hope that it will be useful,
|
|---|
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 17 | GNU General Public License for more details.
|
|---|
| 18 |
|
|---|
| 19 | You should have received a copy of the GNU General Public License
|
|---|
| 20 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 21 | */
|
|---|
| 22 | /*
|
|---|
| 23 | This file handles reply_ calls on named pipes that the server
|
|---|
| 24 | makes to handle specific protocols
|
|---|
| 25 | */
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 | #include "includes.h"
|
|---|
| 29 |
|
|---|
| 30 | #define PIPE "\\PIPE\\"
|
|---|
| 31 | #define PIPELEN strlen(PIPE)
|
|---|
| 32 |
|
|---|
| 33 | #define MAX_PIPE_NAME_LEN 24
|
|---|
| 34 |
|
|---|
| 35 | NTSTATUS open_np_file(struct smb_request *smb_req, const char *name,
|
|---|
| 36 | struct files_struct **pfsp)
|
|---|
| 37 | {
|
|---|
| 38 | struct connection_struct *conn = smb_req->conn;
|
|---|
| 39 | struct files_struct *fsp;
|
|---|
| 40 | struct smb_filename *smb_fname = NULL;
|
|---|
| 41 | NTSTATUS status;
|
|---|
| 42 |
|
|---|
| 43 | status = file_new(smb_req, conn, &fsp);
|
|---|
| 44 | if (!NT_STATUS_IS_OK(status)) {
|
|---|
| 45 | DEBUG(0, ("file_new failed: %s\n", nt_errstr(status)));
|
|---|
| 46 | return status;
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | fsp->conn = conn;
|
|---|
| 50 | fsp->fh->fd = -1;
|
|---|
| 51 | fsp->vuid = smb_req->vuid;
|
|---|
| 52 | fsp->can_lock = false;
|
|---|
| 53 | fsp->access_mask = FILE_READ_DATA | FILE_WRITE_DATA;
|
|---|
| 54 |
|
|---|
| 55 | status = create_synthetic_smb_fname(talloc_tos(), name, NULL, NULL,
|
|---|
| 56 | &smb_fname);
|
|---|
| 57 | if (!NT_STATUS_IS_OK(status)) {
|
|---|
| 58 | file_free(smb_req, fsp);
|
|---|
| 59 | return status;
|
|---|
| 60 | }
|
|---|
| 61 | status = fsp_set_smb_fname(fsp, smb_fname);
|
|---|
| 62 | TALLOC_FREE(smb_fname);
|
|---|
| 63 | if (!NT_STATUS_IS_OK(status)) {
|
|---|
| 64 | file_free(smb_req, fsp);
|
|---|
| 65 | return status;
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | status = np_open(NULL, name, conn->client_address,
|
|---|
| 69 | conn->server_info, &fsp->fake_file_handle);
|
|---|
| 70 | if (!NT_STATUS_IS_OK(status)) {
|
|---|
| 71 | DEBUG(10, ("np_open(%s) returned %s\n", name,
|
|---|
| 72 | nt_errstr(status)));
|
|---|
| 73 | file_free(smb_req, fsp);
|
|---|
| 74 | return status;
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | *pfsp = fsp;
|
|---|
| 78 |
|
|---|
| 79 | return NT_STATUS_OK;
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | /****************************************************************************
|
|---|
| 83 | Reply to an open and X on a named pipe.
|
|---|
| 84 | This code is basically stolen from reply_open_and_X with some
|
|---|
| 85 | wrinkles to handle pipes.
|
|---|
| 86 | ****************************************************************************/
|
|---|
| 87 |
|
|---|
| 88 | void reply_open_pipe_and_X(connection_struct *conn, struct smb_request *req)
|
|---|
| 89 | {
|
|---|
| 90 | const char *fname = NULL;
|
|---|
| 91 | char *pipe_name = NULL;
|
|---|
| 92 | files_struct *fsp;
|
|---|
| 93 | TALLOC_CTX *ctx = talloc_tos();
|
|---|
| 94 | NTSTATUS status;
|
|---|
| 95 |
|
|---|
| 96 | /* XXXX we need to handle passed times, sattr and flags */
|
|---|
| 97 | srvstr_pull_req_talloc(ctx, req, &pipe_name, req->buf, STR_TERMINATE);
|
|---|
| 98 | if (!pipe_name) {
|
|---|
| 99 | reply_botherror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND,
|
|---|
| 100 | ERRDOS, ERRbadpipe);
|
|---|
| 101 | return;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | /* If the name doesn't start \PIPE\ then this is directed */
|
|---|
| 105 | /* at a mailslot or something we really, really don't understand, */
|
|---|
| 106 | /* not just something we really don't understand. */
|
|---|
| 107 | if ( strncmp(pipe_name,PIPE,PIPELEN) != 0 ) {
|
|---|
| 108 | reply_nterror(req, NT_STATUS_ACCESS_DENIED);
|
|---|
| 109 | return;
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | DEBUG(4,("Opening pipe %s.\n", pipe_name));
|
|---|
| 113 |
|
|---|
| 114 | /* Strip \PIPE\ off the name. */
|
|---|
| 115 | fname = pipe_name + PIPELEN;
|
|---|
| 116 |
|
|---|
| 117 | #if 0
|
|---|
| 118 | /*
|
|---|
| 119 | * Hack for NT printers... JRA.
|
|---|
| 120 | */
|
|---|
| 121 | if(should_fail_next_srvsvc_open(fname)) {
|
|---|
| 122 | reply_nterror(req, NT_STATUS_ACCESS_DENIED);
|
|---|
| 123 | return;
|
|---|
| 124 | }
|
|---|
| 125 | #endif
|
|---|
| 126 |
|
|---|
| 127 | status = open_np_file(req, fname, &fsp);
|
|---|
| 128 | if (!NT_STATUS_IS_OK(status)) {
|
|---|
| 129 | if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
|
|---|
| 130 | reply_botherror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND,
|
|---|
| 131 | ERRDOS, ERRbadpipe);
|
|---|
| 132 | return;
|
|---|
| 133 | }
|
|---|
| 134 | reply_nterror(req, status);
|
|---|
| 135 | return;
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | /* Prepare the reply */
|
|---|
| 139 | reply_outbuf(req, 15, 0);
|
|---|
| 140 |
|
|---|
| 141 | /* Mark the opened file as an existing named pipe in message mode. */
|
|---|
| 142 | SSVAL(req->outbuf,smb_vwv9,2);
|
|---|
| 143 | SSVAL(req->outbuf,smb_vwv10,0xc700);
|
|---|
| 144 |
|
|---|
| 145 | SSVAL(req->outbuf, smb_vwv2, fsp->fnum);
|
|---|
| 146 | SSVAL(req->outbuf, smb_vwv3, 0); /* fmode */
|
|---|
| 147 | srv_put_dos_date3((char *)req->outbuf, smb_vwv4, 0); /* mtime */
|
|---|
| 148 | SIVAL(req->outbuf, smb_vwv6, 0); /* size */
|
|---|
| 149 | SSVAL(req->outbuf, smb_vwv8, 0); /* rmode */
|
|---|
| 150 | SSVAL(req->outbuf, smb_vwv11, 0x0001);
|
|---|
| 151 |
|
|---|
| 152 | chain_reply(req);
|
|---|
| 153 | return;
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | /****************************************************************************
|
|---|
| 157 | Reply to a write on a pipe.
|
|---|
| 158 | ****************************************************************************/
|
|---|
| 159 |
|
|---|
| 160 | struct pipe_write_state {
|
|---|
| 161 | size_t numtowrite;
|
|---|
| 162 | };
|
|---|
| 163 |
|
|---|
| 164 | static void pipe_write_done(struct tevent_req *subreq);
|
|---|
| 165 |
|
|---|
| 166 | void reply_pipe_write(struct smb_request *req)
|
|---|
| 167 | {
|
|---|
| 168 | files_struct *fsp = file_fsp(req, SVAL(req->vwv+0, 0));
|
|---|
| 169 | const uint8_t *data;
|
|---|
| 170 | struct pipe_write_state *state;
|
|---|
| 171 | struct tevent_req *subreq;
|
|---|
| 172 |
|
|---|
| 173 | if (!fsp_is_np(fsp)) {
|
|---|
| 174 | reply_nterror(req, NT_STATUS_INVALID_HANDLE);
|
|---|
| 175 | return;
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 | if (fsp->vuid != req->vuid) {
|
|---|
| 179 | reply_nterror(req, NT_STATUS_INVALID_HANDLE);
|
|---|
| 180 | return;
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | state = talloc(req, struct pipe_write_state);
|
|---|
| 184 | if (state == NULL) {
|
|---|
| 185 | reply_nterror(req, NT_STATUS_NO_MEMORY);
|
|---|
| 186 | return;
|
|---|
| 187 | }
|
|---|
| 188 | req->async_priv = state;
|
|---|
| 189 |
|
|---|
| 190 | state->numtowrite = SVAL(req->vwv+1, 0);
|
|---|
| 191 |
|
|---|
| 192 | data = req->buf + 3;
|
|---|
| 193 |
|
|---|
| 194 | DEBUG(6, ("reply_pipe_write: %x name: %s len: %d\n", (int)fsp->fnum,
|
|---|
| 195 | fsp_str_dbg(fsp), (int)state->numtowrite));
|
|---|
| 196 |
|
|---|
| 197 | subreq = np_write_send(state, smbd_event_context(),
|
|---|
| 198 | fsp->fake_file_handle, data, state->numtowrite);
|
|---|
| 199 | if (subreq == NULL) {
|
|---|
| 200 | TALLOC_FREE(state);
|
|---|
| 201 | reply_nterror(req, NT_STATUS_NO_MEMORY);
|
|---|
| 202 | return;
|
|---|
| 203 | }
|
|---|
| 204 | tevent_req_set_callback(subreq, pipe_write_done,
|
|---|
| 205 | talloc_move(req->conn, &req));
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | static void pipe_write_done(struct tevent_req *subreq)
|
|---|
| 209 | {
|
|---|
| 210 | struct smb_request *req = tevent_req_callback_data(
|
|---|
| 211 | subreq, struct smb_request);
|
|---|
| 212 | struct pipe_write_state *state = talloc_get_type_abort(
|
|---|
| 213 | req->async_priv, struct pipe_write_state);
|
|---|
| 214 | NTSTATUS status;
|
|---|
| 215 | ssize_t nwritten = -1;
|
|---|
| 216 |
|
|---|
| 217 | status = np_write_recv(subreq, &nwritten);
|
|---|
| 218 | TALLOC_FREE(subreq);
|
|---|
| 219 | if (nwritten < 0) {
|
|---|
| 220 | reply_nterror(req, status);
|
|---|
| 221 | goto send;
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | /* Looks bogus to me now. Needs to be removed ? JRA. */
|
|---|
| 225 | if ((nwritten == 0 && state->numtowrite != 0)) {
|
|---|
| 226 | reply_nterror(req, NT_STATUS_ACCESS_DENIED);
|
|---|
| 227 | goto send;
|
|---|
| 228 | }
|
|---|
| 229 |
|
|---|
| 230 | reply_outbuf(req, 1, 0);
|
|---|
| 231 |
|
|---|
| 232 | SSVAL(req->outbuf,smb_vwv0,nwritten);
|
|---|
| 233 |
|
|---|
| 234 | DEBUG(3,("write-IPC nwritten=%d\n", (int)nwritten));
|
|---|
| 235 |
|
|---|
| 236 | send:
|
|---|
| 237 | if (!srv_send_smb(smbd_server_fd(), (char *)req->outbuf,
|
|---|
| 238 | true, req->seqnum+1,
|
|---|
| 239 | IS_CONN_ENCRYPTED(req->conn)||req->encrypted,
|
|---|
| 240 | &req->pcd)) {
|
|---|
| 241 | exit_server_cleanly("construct_reply: srv_send_smb failed.");
|
|---|
| 242 | }
|
|---|
| 243 | TALLOC_FREE(req);
|
|---|
| 244 | }
|
|---|
| 245 |
|
|---|
| 246 | /****************************************************************************
|
|---|
| 247 | Reply to a write and X.
|
|---|
| 248 |
|
|---|
| 249 | This code is basically stolen from reply_write_and_X with some
|
|---|
| 250 | wrinkles to handle pipes.
|
|---|
| 251 | ****************************************************************************/
|
|---|
| 252 |
|
|---|
| 253 | struct pipe_write_andx_state {
|
|---|
| 254 | bool pipe_start_message_raw;
|
|---|
| 255 | size_t numtowrite;
|
|---|
| 256 | };
|
|---|
| 257 |
|
|---|
| 258 | static void pipe_write_andx_done(struct tevent_req *subreq);
|
|---|
| 259 |
|
|---|
| 260 | void reply_pipe_write_and_X(struct smb_request *req)
|
|---|
| 261 | {
|
|---|
| 262 | files_struct *fsp = file_fsp(req, SVAL(req->vwv+2, 0));
|
|---|
| 263 | int smb_doff = SVAL(req->vwv+11, 0);
|
|---|
| 264 | uint8_t *data;
|
|---|
| 265 | struct pipe_write_andx_state *state;
|
|---|
| 266 | struct tevent_req *subreq;
|
|---|
| 267 |
|
|---|
| 268 | if (!fsp_is_np(fsp)) {
|
|---|
| 269 | reply_nterror(req, NT_STATUS_INVALID_HANDLE);
|
|---|
| 270 | return;
|
|---|
| 271 | }
|
|---|
| 272 |
|
|---|
| 273 | if (fsp->vuid != req->vuid) {
|
|---|
| 274 | reply_nterror(req, NT_STATUS_INVALID_HANDLE);
|
|---|
| 275 | return;
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 | state = talloc(req, struct pipe_write_andx_state);
|
|---|
| 279 | if (state == NULL) {
|
|---|
| 280 | reply_nterror(req, NT_STATUS_NO_MEMORY);
|
|---|
| 281 | return;
|
|---|
| 282 | }
|
|---|
| 283 | req->async_priv = state;
|
|---|
| 284 |
|
|---|
| 285 | state->numtowrite = SVAL(req->vwv+10, 0);
|
|---|
| 286 | state->pipe_start_message_raw =
|
|---|
| 287 | ((SVAL(req->vwv+7, 0) & (PIPE_START_MESSAGE|PIPE_RAW_MODE))
|
|---|
| 288 | == (PIPE_START_MESSAGE|PIPE_RAW_MODE));
|
|---|
| 289 |
|
|---|
| 290 | DEBUG(6, ("reply_pipe_write_and_X: %x name: %s len: %d\n",
|
|---|
| 291 | (int)fsp->fnum, fsp_str_dbg(fsp), (int)state->numtowrite));
|
|---|
| 292 |
|
|---|
| 293 | data = (uint8_t *)smb_base(req->inbuf) + smb_doff;
|
|---|
| 294 |
|
|---|
| 295 | if (state->pipe_start_message_raw) {
|
|---|
| 296 | /*
|
|---|
| 297 | * For the start of a message in named pipe byte mode,
|
|---|
| 298 | * the first two bytes are a length-of-pdu field. Ignore
|
|---|
| 299 | * them (we don't trust the client). JRA.
|
|---|
| 300 | */
|
|---|
| 301 | if (state->numtowrite < 2) {
|
|---|
| 302 | DEBUG(0,("reply_pipe_write_and_X: start of message "
|
|---|
| 303 | "set and not enough data sent.(%u)\n",
|
|---|
| 304 | (unsigned int)state->numtowrite ));
|
|---|
| 305 | reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
|
|---|
| 306 | return;
|
|---|
| 307 | }
|
|---|
| 308 |
|
|---|
| 309 | data += 2;
|
|---|
| 310 | state->numtowrite -= 2;
|
|---|
| 311 | }
|
|---|
| 312 |
|
|---|
| 313 | subreq = np_write_send(state, smbd_event_context(),
|
|---|
| 314 | fsp->fake_file_handle, data, state->numtowrite);
|
|---|
| 315 | if (subreq == NULL) {
|
|---|
| 316 | TALLOC_FREE(state);
|
|---|
| 317 | reply_nterror(req, NT_STATUS_NO_MEMORY);
|
|---|
| 318 | return;
|
|---|
| 319 | }
|
|---|
| 320 | tevent_req_set_callback(subreq, pipe_write_andx_done,
|
|---|
| 321 | talloc_move(req->conn, &req));
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 | static void pipe_write_andx_done(struct tevent_req *subreq)
|
|---|
| 325 | {
|
|---|
| 326 | struct smb_request *req = tevent_req_callback_data(
|
|---|
| 327 | subreq, struct smb_request);
|
|---|
| 328 | struct pipe_write_andx_state *state = talloc_get_type_abort(
|
|---|
| 329 | req->async_priv, struct pipe_write_andx_state);
|
|---|
| 330 | NTSTATUS status;
|
|---|
| 331 | ssize_t nwritten = -1;
|
|---|
| 332 |
|
|---|
| 333 | status = np_write_recv(subreq, &nwritten);
|
|---|
| 334 | TALLOC_FREE(subreq);
|
|---|
| 335 |
|
|---|
| 336 | if (!NT_STATUS_IS_OK(status)) {
|
|---|
| 337 | reply_nterror(req, status);
|
|---|
| 338 | goto done;
|
|---|
| 339 | }
|
|---|
| 340 |
|
|---|
| 341 | /* Looks bogus to me now. Is this error message correct ? JRA. */
|
|---|
| 342 | if (nwritten != state->numtowrite) {
|
|---|
| 343 | reply_nterror(req, NT_STATUS_ACCESS_DENIED);
|
|---|
| 344 | goto done;
|
|---|
| 345 | }
|
|---|
| 346 |
|
|---|
| 347 | reply_outbuf(req, 6, 0);
|
|---|
| 348 |
|
|---|
| 349 | nwritten = (state->pipe_start_message_raw ? nwritten + 2 : nwritten);
|
|---|
| 350 | SSVAL(req->outbuf,smb_vwv2,nwritten);
|
|---|
| 351 |
|
|---|
| 352 | DEBUG(3,("writeX-IPC nwritten=%d\n", (int)nwritten));
|
|---|
| 353 |
|
|---|
| 354 | done:
|
|---|
| 355 | chain_reply(req);
|
|---|
| 356 | /*
|
|---|
| 357 | * We must free here as the ownership of req was
|
|---|
| 358 | * moved to the connection struct in reply_pipe_write_and_X().
|
|---|
| 359 | */
|
|---|
| 360 | TALLOC_FREE(req);
|
|---|
| 361 | }
|
|---|
| 362 |
|
|---|
| 363 | /****************************************************************************
|
|---|
| 364 | Reply to a read and X.
|
|---|
| 365 | This code is basically stolen from reply_read_and_X with some
|
|---|
| 366 | wrinkles to handle pipes.
|
|---|
| 367 | ****************************************************************************/
|
|---|
| 368 |
|
|---|
| 369 | struct pipe_read_andx_state {
|
|---|
| 370 | uint8_t *outbuf;
|
|---|
| 371 | int smb_mincnt;
|
|---|
| 372 | int smb_maxcnt;
|
|---|
| 373 | };
|
|---|
| 374 |
|
|---|
| 375 | static void pipe_read_andx_done(struct tevent_req *subreq);
|
|---|
| 376 |
|
|---|
| 377 | void reply_pipe_read_and_X(struct smb_request *req)
|
|---|
| 378 | {
|
|---|
| 379 | files_struct *fsp = file_fsp(req, SVAL(req->vwv+0, 0));
|
|---|
| 380 | uint8_t *data;
|
|---|
| 381 | struct pipe_read_andx_state *state;
|
|---|
| 382 | struct tevent_req *subreq;
|
|---|
| 383 |
|
|---|
| 384 | /* we don't use the offset given to use for pipe reads. This
|
|---|
| 385 | is deliberate, instead we always return the next lump of
|
|---|
| 386 | data on the pipe */
|
|---|
| 387 | #if 0
|
|---|
| 388 | uint32 smb_offs = IVAL(req->vwv+3, 0);
|
|---|
| 389 | #endif
|
|---|
| 390 |
|
|---|
| 391 | if (!fsp_is_np(fsp)) {
|
|---|
| 392 | reply_nterror(req, NT_STATUS_INVALID_HANDLE);
|
|---|
| 393 | return;
|
|---|
| 394 | }
|
|---|
| 395 |
|
|---|
| 396 | if (fsp->vuid != req->vuid) {
|
|---|
| 397 | reply_nterror(req, NT_STATUS_INVALID_HANDLE);
|
|---|
| 398 | return;
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | state = talloc(req, struct pipe_read_andx_state);
|
|---|
| 402 | if (state == NULL) {
|
|---|
| 403 | reply_nterror(req, NT_STATUS_NO_MEMORY);
|
|---|
| 404 | return;
|
|---|
| 405 | }
|
|---|
| 406 | req->async_priv = state;
|
|---|
| 407 |
|
|---|
| 408 | state->smb_maxcnt = SVAL(req->vwv+5, 0);
|
|---|
| 409 | state->smb_mincnt = SVAL(req->vwv+6, 0);
|
|---|
| 410 |
|
|---|
| 411 | reply_outbuf(req, 12, state->smb_maxcnt);
|
|---|
| 412 | data = (uint8_t *)smb_buf(req->outbuf);
|
|---|
| 413 |
|
|---|
| 414 | /*
|
|---|
| 415 | * We have to tell the upper layers that we're async.
|
|---|
| 416 | */
|
|---|
| 417 | state->outbuf = req->outbuf;
|
|---|
| 418 | req->outbuf = NULL;
|
|---|
| 419 |
|
|---|
| 420 | subreq = np_read_send(state, smbd_event_context(),
|
|---|
| 421 | fsp->fake_file_handle, data,
|
|---|
| 422 | state->smb_maxcnt);
|
|---|
| 423 | if (subreq == NULL) {
|
|---|
| 424 | reply_nterror(req, NT_STATUS_NO_MEMORY);
|
|---|
| 425 | return;
|
|---|
| 426 | }
|
|---|
| 427 | tevent_req_set_callback(subreq, pipe_read_andx_done,
|
|---|
| 428 | talloc_move(req->conn, &req));
|
|---|
| 429 | }
|
|---|
| 430 |
|
|---|
| 431 | static void pipe_read_andx_done(struct tevent_req *subreq)
|
|---|
| 432 | {
|
|---|
| 433 | struct smb_request *req = tevent_req_callback_data(
|
|---|
| 434 | subreq, struct smb_request);
|
|---|
| 435 | struct pipe_read_andx_state *state = talloc_get_type_abort(
|
|---|
| 436 | req->async_priv, struct pipe_read_andx_state);
|
|---|
| 437 | NTSTATUS status;
|
|---|
| 438 | ssize_t nread;
|
|---|
| 439 | bool is_data_outstanding;
|
|---|
| 440 |
|
|---|
| 441 | status = np_read_recv(subreq, &nread, &is_data_outstanding);
|
|---|
| 442 | TALLOC_FREE(subreq);
|
|---|
| 443 | if (!NT_STATUS_IS_OK(status)) {
|
|---|
| 444 | reply_nterror(req, status);
|
|---|
| 445 | goto done;
|
|---|
| 446 | }
|
|---|
| 447 |
|
|---|
| 448 | req->outbuf = state->outbuf;
|
|---|
| 449 | state->outbuf = NULL;
|
|---|
| 450 |
|
|---|
| 451 | srv_set_message((char *)req->outbuf, 12, nread, False);
|
|---|
| 452 |
|
|---|
| 453 | SSVAL(req->outbuf,smb_vwv5,nread);
|
|---|
| 454 | SSVAL(req->outbuf,smb_vwv6,
|
|---|
| 455 | req_wct_ofs(req)
|
|---|
| 456 | + 1 /* the wct field */
|
|---|
| 457 | + 12 * sizeof(uint16_t) /* vwv */
|
|---|
| 458 | + 2); /* the buflen field */
|
|---|
| 459 | SSVAL(req->outbuf,smb_vwv11,state->smb_maxcnt);
|
|---|
| 460 |
|
|---|
| 461 | DEBUG(3,("readX-IPC min=%d max=%d nread=%d\n",
|
|---|
| 462 | state->smb_mincnt, state->smb_maxcnt, (int)nread));
|
|---|
| 463 |
|
|---|
| 464 | done:
|
|---|
| 465 | chain_reply(req);
|
|---|
| 466 | /*
|
|---|
| 467 | * We must free here as the ownership of req was
|
|---|
| 468 | * moved to the connection struct in reply_pipe_read_and_X().
|
|---|
| 469 | */
|
|---|
| 470 | TALLOC_FREE(req);
|
|---|
| 471 | }
|
|---|