Changeset 988 for vendor/current/source3/smbd/ipc.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/smbd/ipc.c
r740 r988 80 80 } 81 81 82 NTSTATUS nt_status_np_pipe(NTSTATUS status) 83 { 84 if (NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_DISCONNECTED)) { 85 status = NT_STATUS_PIPE_DISCONNECTED; 86 } else if (NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_RESET)) { 87 status = NT_STATUS_PIPE_BROKEN; 88 } 89 90 return status; 91 } 92 82 93 /**************************************************************************** 83 94 Send a trans reply. … … 97 108 int ldata = rdata ? rdata_len : 0; 98 109 int lparam = rparam ? rparam_len : 0; 99 struct smbd_server_connection *sconn = req->sconn; 100 int max_send = sconn->smb1.sessions.max_send; 110 struct smbXsrv_connection *xconn = req->xconn; 111 int max_send = xconn->smb1.sessions.max_send; 112 /* HACK: make sure we send at least 128 byte in one go */ 113 int hdr_overhead = SMB_BUFFER_SIZE_MIN - 128; 101 114 102 115 if (buffer_too_large) 103 116 DEBUG(5,("send_trans_reply: buffer %d too large\n", ldata )); 104 117 105 this_lparam = MIN(lparam,max_send - 500); /* hack */106 this_ldata = MIN(ldata,max_send - ( 500+this_lparam));118 this_lparam = MIN(lparam,max_send - hdr_overhead); 119 this_ldata = MIN(ldata,max_send - (hdr_overhead+this_lparam)); 107 120 108 121 align = ((this_lparam)%4); … … 139 152 140 153 show_msg((char *)req->outbuf); 141 if (!srv_send_smb( sconn, (char *)req->outbuf,154 if (!srv_send_smb(xconn, (char *)req->outbuf, 142 155 true, req->seqnum+1, 143 156 IS_CONN_ENCRYPTED(conn), &req->pcd)) { … … 153 166 { 154 167 this_lparam = MIN(lparam-tot_param_sent, 155 max_send - 500); /* hack */168 max_send - hdr_overhead); 156 169 this_ldata = MIN(ldata -tot_data_sent, 157 max_send - ( 500+this_lparam));170 max_send - (hdr_overhead+this_lparam)); 158 171 159 172 if(this_lparam < 0) … … 199 212 200 213 show_msg((char *)req->outbuf); 201 if (!srv_send_smb( sconn, (char *)req->outbuf,214 if (!srv_send_smb(xconn, (char *)req->outbuf, 202 215 true, req->seqnum+1, 203 216 IS_CONN_ENCRYPTED(conn), &req->pcd)) … … 269 282 state->max_read = max_read; 270 283 271 subreq = np_write_send(state, smbd_event_context(), state->handle,284 subreq = np_write_send(state, req->sconn->ev_ctx, state->handle, 272 285 state->data, length); 273 286 if (subreq == NULL) { … … 291 304 status = np_write_recv(subreq, &nwritten); 292 305 TALLOC_FREE(subreq); 293 if (!NT_STATUS_IS_OK(status) || (nwritten != state->num_data)) { 294 DEBUG(10, ("Could not write to pipe: %s (%d/%d)\n", 295 nt_errstr(status), (int)state->num_data, 296 (int)nwritten)); 297 reply_nterror(req, NT_STATUS_PIPE_NOT_AVAILABLE); 306 if (!NT_STATUS_IS_OK(status)) { 307 NTSTATUS old = status; 308 status = nt_status_np_pipe(old); 309 310 DEBUG(10, ("Could not write to pipe: %s%s%s\n", 311 nt_errstr(old), 312 NT_STATUS_EQUAL(old, status)?"":" => ", 313 NT_STATUS_EQUAL(old, status)?"":nt_errstr(status))); 314 reply_nterror(req, status); 298 315 goto send; 299 316 } 300 301 state->data = TALLOC_REALLOC_ARRAY(state, state->data, uint8_t, 317 if (nwritten != state->num_data) { 318 status = NT_STATUS_PIPE_NOT_AVAILABLE; 319 DEBUG(10, ("Could not write to pipe: (%d/%d) => %s\n", 320 (int)state->num_data, 321 (int)nwritten, nt_errstr(status))); 322 reply_nterror(req, status); 323 goto send; 324 } 325 326 state->data = talloc_realloc(state, state->data, uint8_t, 302 327 state->max_read); 303 328 if (state->data == NULL) { … … 306 331 } 307 332 308 subreq = np_read_send( req->conn, smbd_event_context(),333 subreq = np_read_send(state, req->sconn->ev_ctx, 309 334 state->handle, state->data, state->max_read); 310 335 if (subreq == NULL) { … … 317 342 send: 318 343 if (!srv_send_smb( 319 req-> sconn, (char *)req->outbuf,344 req->xconn, (char *)req->outbuf, 320 345 true, req->seqnum+1, 321 346 IS_CONN_ENCRYPTED(req->conn) || req->encrypted, … … 341 366 342 367 if (!NT_STATUS_IS_OK(status)) { 343 DEBUG(10, ("Could not read from to pipe: %s\n", 344 nt_errstr(status))); 368 NTSTATUS old = status; 369 status = nt_status_np_pipe(old); 370 371 DEBUG(10, ("Could not read from to pipe: %s%s%s\n", 372 nt_errstr(old), 373 NT_STATUS_EQUAL(old, status)?"":" => ", 374 NT_STATUS_EQUAL(old, status)?"":nt_errstr(status))); 345 375 reply_nterror(req, status); 346 376 347 if (!srv_send_smb(req-> sconn, (char *)req->outbuf,377 if (!srv_send_smb(req->xconn, (char *)req->outbuf, 348 378 true, req->seqnum+1, 349 379 IS_CONN_ENCRYPTED(req->conn) … … 422 452 ****************************************************************************/ 423 453 424 static void api_fd_reply(connection_struct *conn, uint 16vuid,454 static void api_fd_reply(connection_struct *conn, uint64_t vuid, 425 455 struct smb_request *req, 426 uint16 *setup, uint8_t *data, char *params,456 uint16_t *setup, uint8_t *data, char *params, 427 457 int suwcnt, int tdscnt, int tpscnt, 428 458 int mdrcnt, int mprcnt) … … 466 496 467 497 if (vuid != fsp->vuid) { 468 DEBUG(1, ("Got pipe request (pnum %x) using invalid VUID %d, " 469 "expected %d\n", pnum, vuid, fsp->vuid)); 498 DEBUG(1, ("Got pipe request (pnum %x) using invalid VUID %llu, " 499 "expected %llu\n", pnum, (unsigned long long)vuid, 500 (unsigned long long)fsp->vuid)); 470 501 reply_nterror(req, NT_STATUS_INVALID_HANDLE); 471 502 return; … … 502 533 ****************************************************************************/ 503 534 504 static void named_pipe(connection_struct *conn, uint 16vuid,535 static void named_pipe(connection_struct *conn, uint64_t vuid, 505 536 struct smb_request *req, 506 const char *name, uint16 *setup,537 const char *name, uint16_t *setup, 507 538 char *data, char *params, 508 539 int suwcnt, int tdscnt,int tpscnt, … … 603 634 604 635 if (state->close_on_completion) { 605 close_cnum(conn,state->vuid); 636 struct smbXsrv_tcon *tcon; 637 NTSTATUS status; 638 639 tcon = conn->tcon; 606 640 req->conn = NULL; 641 conn = NULL; 642 643 /* 644 * TODO: cancel all outstanding requests on the tcon 645 */ 646 status = smbXsrv_tcon_disconnect(tcon, state->vuid); 647 if (!NT_STATUS_IS_OK(status)) { 648 DEBUG(0, ("handle_trans: " 649 "smbXsrv_tcon_disconnect() failed: %s\n", 650 nt_errstr(status))); 651 /* 652 * If we hit this case, there is something completely 653 * wrong, so we better disconnect the transport connection. 654 */ 655 exit_server(__location__ ": smbXsrv_tcon_disconnect failed"); 656 return; 657 } 658 659 TALLOC_FREE(tcon); 607 660 } 608 661 … … 646 699 } 647 700 648 if ((state = TALLOC_P(conn, struct trans_state)) == NULL) {701 if ((state = talloc(conn, struct trans_state)) == NULL) { 649 702 DEBUG(0, ("talloc failed\n")); 650 703 reply_nterror(req, NT_STATUS_NO_MEMORY); … … 743 796 } 744 797 745 if((state->setup = TALLOC_ARRAY(746 state, uint16 , state->setup_count)) == NULL) {798 if((state->setup = talloc_array( 799 state, uint16_t, state->setup_count)) == NULL) { 747 800 DEBUG(0,("reply_trans: setup malloc fail for %u " 748 801 "bytes !\n", (unsigned int) 749 (state->setup_count * sizeof(uint16 ))));802 (state->setup_count * sizeof(uint16_t)))); 750 803 SAFE_FREE(state->data); 751 804 SAFE_FREE(state->param); … … 809 862 START_PROFILE(SMBtranss); 810 863 811 show_msg((c har *)req->inbuf);864 show_msg((const char *)req->inbuf); 812 865 813 866 if (req->wct < 8) {
Note:
See TracChangeset
for help on using the changeset viewer.