Changeset 988 for vendor/current/source3/smbd/pipes.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/smbd/pipes.c
r740 r988 1 /* 1 /* 2 2 Unix SMB/CIFS implementation. 3 3 Pipe SMB reply routines … … 6 6 Copyright (C) Paul Ashton 1997-1998. 7 7 Copyright (C) Jeremy Allison 2005. 8 8 9 9 This program is free software; you can redistribute it and/or modify 10 10 it under the terms of the GNU General Public License as published by 11 11 the Free Software Foundation; either version 3 of the License, or 12 12 (at your option) any later version. 13 13 14 14 This program is distributed in the hope that it will be useful, 15 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 17 GNU General Public License for more details. 18 18 19 19 You should have received a copy of the GNU General Public License 20 20 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 32 32 #include "rpc_server/srv_pipe_hnd.h" 33 33 34 #define PIPE "\\PIPE\\"35 #define PIPELEN strlen(PIPE)36 37 #define MAX_PIPE_NAME_LEN 2438 39 34 NTSTATUS open_np_file(struct smb_request *smb_req, const char *name, 40 35 struct files_struct **pfsp) … … 57 52 fsp->access_mask = FILE_READ_DATA | FILE_WRITE_DATA; 58 53 59 status = create_synthetic_smb_fname(talloc_tos(), name, NULL, NULL, 60 &smb_fname); 61 if (!NT_STATUS_IS_OK(status)) { 54 smb_fname = synthetic_smb_fname(talloc_tos(), name, NULL, NULL); 55 if (smb_fname == NULL) { 62 56 file_free(smb_req, fsp); 63 return status;57 return NT_STATUS_NO_MEMORY; 64 58 } 65 59 status = fsp_set_smb_fname(fsp, smb_fname); … … 73 67 conn->sconn->local_address, 74 68 conn->sconn->remote_address, 75 &conn->sconn->client_id,76 69 conn->session_info, 70 conn->sconn->ev_ctx, 77 71 conn->sconn->msg_ctx, 78 72 &fsp->fake_file_handle); … … 114 108 /* at a mailslot or something we really, really don't understand, */ 115 109 /* not just something we really don't understand. */ 116 if ( strncmp(pipe_name,PIPE,PIPELEN) != 0 ) { 117 reply_nterror(req, NT_STATUS_ACCESS_DENIED); 118 return; 119 } 120 121 DEBUG(4,("Opening pipe %s.\n", pipe_name)); 122 123 /* Strip \PIPE\ off the name. */ 124 fname = pipe_name + PIPELEN; 110 111 #define PIPE "PIPE\\" 112 #define PIPELEN strlen(PIPE) 113 114 fname = pipe_name; 115 while (fname[0] == '\\') { 116 fname++; 117 } 118 if (!strnequal(fname, PIPE, PIPELEN)) { 119 reply_nterror(req, NT_STATUS_OBJECT_PATH_SYNTAX_BAD); 120 return; 121 } 122 fname += PIPELEN; 123 while (fname[0] == '\\') { 124 fname++; 125 } 126 127 DEBUG(4,("Opening pipe %s => %s.\n", pipe_name, fname)); 125 128 126 129 #if 0 … … 148 151 reply_outbuf(req, 15, 0); 149 152 153 SSVAL(req->outbuf, smb_vwv0, 0xff); /* andx chain ends */ 154 SSVAL(req->outbuf, smb_vwv1, 0); /* no andx offset */ 155 150 156 /* Mark the opened file as an existing named pipe in message mode. */ 151 157 SSVAL(req->outbuf,smb_vwv9,2); … … 158 164 SSVAL(req->outbuf, smb_vwv8, 0); /* rmode */ 159 165 SSVAL(req->outbuf, smb_vwv11, 0x0001); 160 161 chain_reply(req);162 return;163 166 } 164 167 … … 201 204 data = req->buf + 3; 202 205 203 DEBUG(6, ("reply_pipe_write: % x name: %s len: %d\n", (int)fsp->fnum,206 DEBUG(6, ("reply_pipe_write: %s, name: %s len: %d\n", fsp_fnum_dbg(fsp), 204 207 fsp_str_dbg(fsp), (int)state->numtowrite)); 205 208 206 subreq = np_write_send(state, smbd_event_context(),209 subreq = np_write_send(state, req->sconn->ev_ctx, 207 210 fsp->fake_file_handle, data, state->numtowrite); 208 211 if (subreq == NULL) { … … 244 247 245 248 send: 246 if (!srv_send_smb(req-> sconn, (char *)req->outbuf,249 if (!srv_send_smb(req->xconn, (char *)req->outbuf, 247 250 true, req->seqnum+1, 248 251 IS_CONN_ENCRYPTED(req->conn)||req->encrypted, … … 271 274 files_struct *fsp = file_fsp(req, SVAL(req->vwv+2, 0)); 272 275 int smb_doff = SVAL(req->vwv+11, 0); 273 uint8_t *data;276 const uint8_t *data; 274 277 struct pipe_write_andx_state *state; 275 278 struct tevent_req *subreq; … … 297 300 == (PIPE_START_MESSAGE|PIPE_RAW_MODE)); 298 301 299 DEBUG(6, ("reply_pipe_write_and_X: % xname: %s len: %d\n",300 (int)fsp->fnum, fsp_str_dbg(fsp), (int)state->numtowrite));301 302 data = ( uint8_t *)smb_base(req->inbuf) + smb_doff;302 DEBUG(6, ("reply_pipe_write_and_X: %s, name: %s len: %d\n", 303 fsp_fnum_dbg(fsp), fsp_str_dbg(fsp), (int)state->numtowrite)); 304 305 data = (const uint8_t *)smb_base(req->inbuf) + smb_doff; 303 306 304 307 if (state->pipe_start_message_raw) { … … 320 323 } 321 324 322 subreq = np_write_send(state, smbd_event_context(),325 subreq = np_write_send(state, req->sconn->ev_ctx, 323 326 fsp->fake_file_handle, data, state->numtowrite); 324 327 if (subreq == NULL) { … … 356 359 reply_outbuf(req, 6, 0); 357 360 361 SSVAL(req->outbuf, smb_vwv0, 0xff); /* andx chain ends */ 362 SSVAL(req->outbuf, smb_vwv1, 0); /* no andx offset */ 363 358 364 nwritten = (state->pipe_start_message_raw ? nwritten + 2 : nwritten); 359 365 SSVAL(req->outbuf,smb_vwv2,nwritten); … … 362 368 363 369 done: 364 chain_reply(req);365 370 /* 366 371 * We must free here as the ownership of req was 367 372 * moved to the connection struct in reply_pipe_write_and_X(). 368 373 */ 369 TALLOC_FREE(req);374 smb_request_done(req); 370 375 } 371 376 … … 395 400 data on the pipe */ 396 401 #if 0 397 uint32 smb_offs = IVAL(req->vwv+3, 0);402 uint32_t smb_offs = IVAL(req->vwv+3, 0); 398 403 #endif 399 404 … … 418 423 state->smb_mincnt = SVAL(req->vwv+6, 0); 419 424 420 reply_outbuf(req, 12, state->smb_maxcnt); 421 data = (uint8_t *)smb_buf(req->outbuf); 425 reply_outbuf(req, 12, state->smb_maxcnt + 1 /* padding byte */); 426 SSVAL(req->outbuf, smb_vwv0, 0xff); /* andx chain ends */ 427 SSVAL(req->outbuf, smb_vwv1, 0); /* no andx offset */ 428 SCVAL(smb_buf(req->outbuf), 0, 0); /* padding byte */ 429 430 data = (uint8_t *)smb_buf(req->outbuf) + 1 /* padding byte */; 422 431 423 432 /* … … 427 436 req->outbuf = NULL; 428 437 429 subreq = np_read_send(state, smbd_event_context(),438 subreq = np_read_send(state, req->sconn->ev_ctx, 430 439 fsp->fake_file_handle, data, 431 440 state->smb_maxcnt); … … 451 460 TALLOC_FREE(subreq); 452 461 if (!NT_STATUS_IS_OK(status)) { 462 NTSTATUS old = status; 463 status = nt_status_np_pipe(old); 453 464 reply_nterror(req, status); 454 465 goto done; … … 458 469 state->outbuf = NULL; 459 470 460 srv_set_message((char *)req->outbuf, 12, nread, False); 471 srv_set_message((char *)req->outbuf, 12, nread + 1 /* padding byte */, 472 false); 461 473 462 474 #if 0 … … 476 488 SSVAL(req->outbuf,smb_vwv5,nread); 477 489 SSVAL(req->outbuf,smb_vwv6, 478 req_wct_ofs(req)490 (smb_wct - 4) /* offset from smb header to wct */ 479 491 + 1 /* the wct field */ 480 492 + 12 * sizeof(uint16_t) /* vwv */ 481 + 2); /* the buflen field */ 493 + 2 /* the buflen field */ 494 + 1); /* padding byte */ 482 495 SSVAL(req->outbuf,smb_vwv11,state->smb_maxcnt); 483 496 484 497 DEBUG(3,("readX-IPC min=%d max=%d nread=%d\n", 485 498 state->smb_mincnt, state->smb_maxcnt, (int)nread)); 486 499 487 500 done: 488 chain_reply(req);489 501 /* 490 502 * We must free here as the ownership of req was 491 503 * moved to the connection struct in reply_pipe_read_and_X(). 492 504 */ 493 TALLOC_FREE(req);494 } 505 smb_request_done(req); 506 }
Note:
See TracChangeset
for help on using the changeset viewer.