Changeset 370 for branches/samba-3.3.x/source/smbd
- Timestamp:
- Jan 15, 2010, 8:23:30 AM (16 years ago)
- Location:
- branches/samba-3.3.x/source/smbd
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.3.x/source/smbd/aio.c
r222 r370 427 427 *****************************************************************************/ 428 428 429 static int handle_aio_read_complete(struct aio_extra *aio_ex) 430 { 431 int ret = 0; 429 static int handle_aio_read_complete(struct aio_extra *aio_ex, int errcode) 430 { 432 431 int outsize; 433 432 char *outbuf = aio_ex->outbuf; … … 441 440 true.... JRA. */ 442 441 443 /* If errno is ECANCELED then don't return anything to the 444 * client. */ 445 if (errno == ECANCELED) { 446 srv_cancel_sign_response(aio_ex->mid, false); 447 return 0; 448 } 449 450 DEBUG( 3,( "handle_aio_read_complete: file %s nread == -1. " 442 DEBUG( 3,( "handle_aio_read_complete: file %s nread == %d. " 451 443 "Error = %s\n", 452 aio_ex->fsp->fsp_name, strerror(errno) )); 453 454 ret = errno; 455 ERROR_NT(map_nt_error_from_unix(ret)); 444 aio_ex->fsp->fsp_name, (int)nread, strerror(errcode) )); 445 446 ERROR_NT(map_nt_error_from_unix(errcode)); 456 447 outsize = srv_set_message(outbuf,0,0,true); 457 448 } else { … … 485 476 (unsigned int)nread )); 486 477 487 return ret;478 return errcode; 488 479 } 489 480 … … 493 484 *****************************************************************************/ 494 485 495 static int handle_aio_write_complete(struct aio_extra *aio_ex) 496 { 497 int ret = 0; 486 static int handle_aio_write_complete(struct aio_extra *aio_ex, int errcode) 487 { 498 488 files_struct *fsp = aio_ex->fsp; 499 489 char *outbuf = aio_ex->outbuf; … … 507 497 "aio_write_behind failed ! File %s " 508 498 "is corrupt ! Error %s\n", 509 fsp->fsp_name, strerror(errno) )); 510 ret = errno; 499 fsp->fsp_name, strerror(errcode) )); 511 500 } else { 512 501 DEBUG(0,("handle_aio_write_complete: " … … 516 505 (unsigned int)numtowrite, 517 506 (int)nwritten )); 518 ret= EIO;507 errcode = EIO; 519 508 } 520 509 } else { … … 523 512 fsp->fsp_name )); 524 513 } 514 /* TODO: should no return 0 in case of an error !!! */ 525 515 return 0; 526 516 } … … 535 525 (int)nwritten, strerror(errno) )); 536 526 537 /* If errno is ECANCELED then don't return anything to the 538 * client. */ 539 if (errno == ECANCELED) { 540 srv_cancel_sign_response(aio_ex->mid, false); 541 return 0; 542 } 543 544 ret = errno; 545 ERROR_BOTH(map_nt_error_from_unix(ret), ERRHRD, ERRdiskfull); 527 ERROR_NT(map_nt_error_from_unix(errcode)); 546 528 srv_set_message(outbuf,0,0,true); 547 529 } else { … … 560 542 status = sync_file(fsp->conn,fsp, write_through); 561 543 if (!NT_STATUS_IS_OK(status)) { 562 ret= errno;563 ERROR_BOTH(map_nt_error_from_unix( ret),544 errcode = errno; 545 ERROR_BOTH(map_nt_error_from_unix(errcode), 564 546 ERRHRD, ERRdiskfull); 565 547 srv_set_message(outbuf,0,0,true); … … 581 563 (unsigned int)numtowrite, (unsigned int)nwritten )); 582 564 583 return ret;565 return errcode; 584 566 } 585 567 … … 599 581 600 582 /* Ensure the operation has really completed. */ 601 if (SMB_VFS_AIO_ERROR(aio_ex->fsp, &aio_ex->acb) == EINPROGRESS) { 583 err = SMB_VFS_AIO_ERROR(aio_ex->fsp, &aio_ex->acb); 584 if (err == EINPROGRESS) { 602 585 DEBUG(10,( "handle_aio_completed: operation mid %u still in " 603 586 "process for file %s\n", 604 587 aio_ex->mid, aio_ex->fsp->fsp_name )); 605 588 return False; 606 } 589 } else if (err == ECANCELED) { 590 /* If error is ECANCELED then don't return anything to the 591 * client. */ 592 DEBUG(10,( "handle_aio_completed: operation mid %u" 593 " canceled\n", aio_ex->mid)); 594 srv_cancel_sign_response(aio_ex->mid, false); 595 return True; 596 } 597 607 598 608 599 if (aio_ex->read_req) { 609 err = handle_aio_read_complete(aio_ex );600 err = handle_aio_read_complete(aio_ex, err); 610 601 } else { 611 err = handle_aio_write_complete(aio_ex );602 err = handle_aio_write_complete(aio_ex, err); 612 603 } 613 604 -
branches/samba-3.3.x/source/smbd/blocking.c
r206 r370 95 95 96 96 /**************************************************************************** 97 We need a version of timeval_min that treats zero timval as infinite. 98 ****************************************************************************/ 99 100 static struct timeval timeval_brl_min(const struct timeval *tv1, 101 const struct timeval *tv2) 102 { 103 if (timeval_is_zero(tv1)) { 104 return *tv2; 105 } 106 if (timeval_is_zero(tv2)) { 107 return *tv1; 108 } 109 return timeval_min(tv1, tv2); 110 } 111 112 /**************************************************************************** 97 113 After a change to blocking_lock_queue, recalculate the timed_event for the 98 114 next processing. … … 117 133 if (brl->blocking_pid == 0xFFFFFFFF) { 118 134 struct timeval psx_to = timeval_current_ofs(10, 0); 119 next_timeout = timeval_ min(&next_timeout, &psx_to);135 next_timeout = timeval_brl_min(&next_timeout, &psx_to); 120 136 } 121 137 … … 123 139 } 124 140 125 if (timeval_is_zero(&next_timeout)) { 126 next_timeout = brl->expire_time; 127 } 128 else { 129 next_timeout = timeval_min(&next_timeout, 130 &brl->expire_time); 131 } 141 next_timeout = timeval_brl_min(&next_timeout, &brl->expire_time); 132 142 } 133 143 … … 687 697 struct timeval tv_curr = timeval_current(); 688 698 blocking_lock_record *blr, *next = NULL; 689 bool recalc_timeout = False;690 699 691 700 /* … … 737 746 DLIST_REMOVE(blocking_lock_queue, blr); 738 747 free_blocking_lock_record(blr); 739 recalc_timeout = True;740 748 continue; 741 749 } … … 762 770 DLIST_REMOVE(blocking_lock_queue, blr); 763 771 free_blocking_lock_record(blr); 764 recalc_timeout = True;765 772 change_to_root_user(); 766 773 continue; … … 788 795 DLIST_REMOVE(blocking_lock_queue, blr); 789 796 free_blocking_lock_record(blr); 790 recalc_timeout = True;791 797 change_to_root_user(); 792 798 continue; … … 824 830 DLIST_REMOVE(blocking_lock_queue, blr); 825 831 free_blocking_lock_record(blr); 826 recalc_timeout = True; 827 } 828 } 829 830 if (recalc_timeout) { 831 recalc_brl_timeout(); 832 } 832 } 833 } 834 835 recalc_brl_timeout(); 833 836 } 834 837 -
branches/samba-3.3.x/source/smbd/dnsregister.c
r222 r370 169 169 int mdnsd_conn_fd = -1; 170 170 171 if ( dns_state->srv_ref == NULL) {171 if ((dns_state == NULL) || (dns_state->srv_ref == NULL)) { 172 172 return false; 173 173 } -
branches/samba-3.3.x/source/smbd/dosmode.c
r244 r370 20 20 21 21 #include "includes.h" 22 23 extern enum protocol_types Protocol; 24 25 static uint32_t filter_mode_by_protocol(uint32_t mode) 26 { 27 if (Protocol <= PROTOCOL_LANMAN2) { 28 DEBUG(10,("filter_mode_by_protocol: " 29 "filtering result 0x%x to 0x%x\n", 30 (unsigned int)mode, 31 (unsigned int)(mode & 0x3f) )); 32 mode &= 0x3f; 33 } 34 return mode; 35 } 22 36 23 37 static int set_sparse_flag(const SMB_STRUCT_STAT * const sbuf) … … 361 375 } 362 376 377 if (result == 0) { 378 result = FILE_ATTRIBUTE_NORMAL; 379 } 380 381 result = filter_mode_by_protocol(result); 382 363 383 DEBUG(8,("dos_mode_msdfs returning ")); 364 384 … … 425 445 result |= aHIDDEN; 426 446 } 447 448 if (result == 0) { 449 result = FILE_ATTRIBUTE_NORMAL; 450 } 451 452 result = filter_mode_by_protocol(result); 427 453 428 454 DEBUG(8,("dos_mode returning ")); -
branches/samba-3.3.x/source/smbd/mangle_hash.c
r206 r370 433 433 /* Truncate at the '.' */ 434 434 *s1 = '\0'; 435 /* 436 * DANGER WILL ROBINSON - this 437 * is changing a const string via 438 * an aliased pointer ! Remember to 439 * put it back once we've used it. 440 * JRA 441 */ 435 442 *s2 = '\0'; 436 443 } … … 444 451 DEBUG(5,("cache_mangled_name: Stored entry %s -> %s\n", mangled_name_key, raw_name)); 445 452 } 453 /* Restore the change we made to the const string. */ 454 *s2 = '.'; 446 455 } 447 456 … … 614 623 status = is_valid_name(name_ucs2, False, False); 615 624 SAFE_FREE(name_ucs2); 616 return NT_STATUS_IS_OK(status); 625 /* We return true if we *must* mangle, so if it's 626 * a valid name (status == OK) then we must return 627 * false. Bug #6939. */ 628 return !NT_STATUS_IS_OK(status); 617 629 } 618 630 -
branches/samba-3.3.x/source/smbd/nttrans.c
r222 r370 1905 1905 1906 1906 /* needed_data_count 4 bytes */ 1907 SIVAL(pdata, 8,labels_data_count);1907 SIVAL(pdata, 8, labels_data_count+4); 1908 1908 1909 1909 cur_pdata+=12; -
branches/samba-3.3.x/source/smbd/posix_acls.c
r342 r370 930 930 nt_mask |= ((perms & S_IWUSR) ? UNIX_ACCESS_W : 0 ); 931 931 nt_mask |= ((perms & S_IXUSR) ? UNIX_ACCESS_X : 0 ); 932 } 933 if ((perms & S_IWUSR) && lp_dos_filemode(snum)) { 934 nt_mask |= (WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS); 932 935 } 933 936 } -
branches/samba-3.3.x/source/smbd/reply.c
r342 r370 51 51 char *d = path; 52 52 const char *s = path; 53 NTSTATUS ret = NT_STATUS_OK;54 53 bool start_of_name_component = True; 55 54 bool stream_started = false; 55 bool check_quota = false; 56 56 57 57 *p_last_component_contains_wcard = False; … … 71 71 } 72 72 if (StrCaseCmp(s, ":$DATA") != 0) { 73 return NT_STATUS_INVALID_PARAMETER;73 check_quota = true; 74 74 } 75 75 break; … … 132 132 /* Are we at the start ? Can't go back further if so. */ 133 133 if (d <= path) { 134 ret = NT_STATUS_OBJECT_PATH_SYNTAX_BAD; 135 break; 134 return NT_STATUS_OBJECT_PATH_SYNTAX_BAD; 136 135 } 137 136 /* Go back one level... */ … … 206 205 *d = '\0'; 207 206 208 return ret; 207 if (check_quota) { 208 if (StrCaseCmp(path, FAKE_FILE_NAME_QUOTA_UNIX) != 0) { 209 return NT_STATUS_INVALID_PARAMETER; 210 } 211 } 212 213 return NT_STATUS_OK; 209 214 } 210 215 -
branches/samba-3.3.x/source/smbd/server.c
r309 r370 652 652 FD_ZERO(&w_fds); 653 653 GetTimeOfDay(&now); 654 655 /* Kick off our mDNS registration. */ 656 if (dns_port != 0) { 657 dns_register_smbd(&dns_reg, dns_port, &maxfd, 658 &r_fds, &idle_timeout); 659 } 654 660 655 661 event_add_to_select_args(smbd_event_context(), &now, -
branches/samba-3.3.x/source/smbd/trans2.c
r309 r370 1280 1280 char *last_entry_ptr; 1281 1281 bool was_8_3; 1282 uint32 nt_extmode; /* Used for NT connections instead of mode */1283 1282 bool needslash = ( conn->dirpath[strlen(conn->dirpath) -1] != '/'); 1284 1283 bool check_mangled_names = lp_manglednames(conn->params); … … 1466 1465 p = pdata; 1467 1466 last_entry_ptr = p; 1468 1469 nt_extmode = mode ? mode : FILE_ATTRIBUTE_NORMAL;1470 1467 1471 1468 switch (info_level) { … … 1615 1612 SOFF_T(p,0,file_size); p += 8; 1616 1613 SOFF_T(p,0,allocation_size); p += 8; 1617 SIVAL(p,0, nt_extmode); p += 4;1614 SIVAL(p,0,mode); p += 4; 1618 1615 q = p; p += 4; /* q is placeholder for name length. */ 1619 1616 { … … 1666 1663 SOFF_T(p,0,file_size); p += 8; 1667 1664 SOFF_T(p,0,allocation_size); p += 8; 1668 SIVAL(p,0, nt_extmode); p += 4;1665 SIVAL(p,0,mode); p += 4; 1669 1666 len = srvstr_push(base_data, flags2, 1670 1667 p + 4, fname, PTR_DIFF(end_data, p+4), … … 1689 1686 SOFF_T(p,0,file_size); p += 8; 1690 1687 SOFF_T(p,0,allocation_size); p += 8; 1691 SIVAL(p,0, nt_extmode); p += 4;1688 SIVAL(p,0,mode); p += 4; 1692 1689 q = p; p += 4; /* q is placeholder for name length. */ 1693 1690 { … … 1738 1735 SOFF_T(p,0,file_size); p += 8; 1739 1736 SOFF_T(p,0,allocation_size); p += 8; 1740 SIVAL(p,0, nt_extmode); p += 4;1737 SIVAL(p,0,mode); p += 4; 1741 1738 q = p; p += 4; /* q is placeholder for name length. */ 1742 1739 { … … 1771 1768 SOFF_T(p,0,file_size); p += 8; 1772 1769 SOFF_T(p,0,allocation_size); p += 8; 1773 SIVAL(p,0, nt_extmode); p += 4;1770 SIVAL(p,0,mode); p += 4; 1774 1771 q = p; p += 4; /* q is placeholder for name length */ 1775 1772 { … … 2270 2267 continue_bit = (findnext_flags & FLAG_TRANS2_FIND_CONTINUE); 2271 2268 2272 srvstr_get_path_wcard(ctx, params, req->flags2, &resume_name, 2269 if (!continue_bit) { 2270 /* We only need resume_name if continue_bit is zero. */ 2271 srvstr_get_path_wcard(ctx, params, req->flags2, &resume_name, 2273 2272 params+12, 2274 2273 total_params - 12, STR_TERMINATE, &ntstatus, 2275 2274 &mask_contains_wcard); 2276 if (!NT_STATUS_IS_OK(ntstatus)) {2277 /* Win9x or OS/2 can send a resume name of ".." or ".". This will cause the parser to2278 complain (it thinks we're asking for the directory above the shared2279 path or an invalid name). Catch this as the resume name is only compared, never used in2280 a file access. JRA. */2281 srvstr_pull_talloc(ctx, params, req->flags2,2275 if (!NT_STATUS_IS_OK(ntstatus)) { 2276 /* Win9x or OS/2 can send a resume name of ".." or ".". This will cause the parser to 2277 complain (it thinks we're asking for the directory above the shared 2278 path or an invalid name). Catch this as the resume name is only compared, never used in 2279 a file access. JRA. */ 2280 srvstr_pull_talloc(ctx, params, req->flags2, 2282 2281 &resume_name, params+12, 2283 2282 total_params - 12, 2284 2283 STR_TERMINATE); 2285 2284 2286 if (!resume_name || !(ISDOT(resume_name) || ISDOTDOT(resume_name))) { 2287 reply_nterror(req, ntstatus); 2288 return; 2285 if (!resume_name || !(ISDOT(resume_name) || ISDOTDOT(resume_name))) { 2286 reply_nterror(req, ntstatus); 2287 return; 2288 } 2289 2289 } 2290 2290 } … … 2294 2294 resume_key = %d resume name = %s continue=%d level = %d\n", 2295 2295 dptr_num, max_data_bytes, maxentries, close_after_request, close_if_end, 2296 requires_resume_key, resume_key, resume_name, continue_bit, info_level)); 2296 requires_resume_key, resume_key, 2297 resume_name ? resume_name : "(NULL)", continue_bit, info_level)); 2297 2298 2298 2299 if (!maxentries) { … … 2416 2417 */ 2417 2418 2418 if( *resume_name && !continue_bit) {2419 if(!continue_bit && resume_name && *resume_name) { 2419 2420 SMB_STRUCT_STAT st; 2420 2421 … … 4078 4079 mode = dos_mode(conn,fname,&sbuf); 4079 4080 } 4080 if (!mode)4081 mode = FILE_ATTRIBUTE_NORMAL;4082 4081 4083 4082 nlink = sbuf.st_nlink;
Note:
See TracChangeset
for help on using the changeset viewer.