Changeset 989 for vendor/current/source3/smbd
- Timestamp:
- Nov 25, 2016, 8:04:54 PM (9 years ago)
- Location:
- vendor/current/source3/smbd
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/smbd/aio.c
r988 r989 273 273 int outsize; 274 274 char *outbuf = (char *)aio_ex->outbuf.data; 275 char *data = smb_buf(outbuf) + 1 /* padding byte */;276 275 ssize_t nread; 277 276 int err; … … 302 301 outsize = srv_set_message(outbuf,0,0,true); 303 302 } else { 304 outsize = srv_set_message(outbuf, 12, 305 nread + 1 /* padding byte */, false); 306 SSVAL(outbuf,smb_vwv2, 0xFFFF); /* Remaining - must be * -1. */ 307 SSVAL(outbuf,smb_vwv5, nread); 308 SSVAL(outbuf,smb_vwv6, smb_offset(data,outbuf)); 309 SSVAL(outbuf,smb_vwv7, ((nread >> 16) & 1)); 310 SSVAL(smb_buf(outbuf), -2, nread); 303 outsize = setup_readX_header(outbuf, nread); 311 304 312 305 aio_ex->fsp->fh->pos = aio_ex->offset + nread; -
vendor/current/source3/smbd/close.c
r988 r989 169 169 TALLOC_CTX *frame = talloc_stackframe(); 170 170 NTSTATUS status; 171 bool saved_posix_pathnames; 171 172 172 173 status = vfs_streaminfo(conn, NULL, fname, talloc_tos(), … … 192 193 return NT_STATUS_OK; 193 194 } 195 196 /* 197 * Any stream names *must* be treated as Windows 198 * pathnames, even if we're using UNIX extensions. 199 */ 200 201 saved_posix_pathnames = lp_set_posix_pathnames(false); 194 202 195 203 for (i=0; i<num_streams; i++) { … … 224 232 225 233 fail: 234 235 (void)lp_set_posix_pathnames(saved_posix_pathnames); 226 236 TALLOC_FREE(frame); 227 237 return status; … … 247 257 bool got_tokens = false; 248 258 bool normal_close; 249 int ret_flock;250 259 251 260 /* Ensure any pending write time updates are done. */ … … 268 277 "lock for file %s\n", fsp_str_dbg(fsp))); 269 278 return NT_STATUS_INVALID_PARAMETER; 279 } 280 281 /* Remove the oplock before potentially deleting the file. */ 282 if(fsp->oplock_type) { 283 remove_oplock_under_lock(fsp, lck); 270 284 } 271 285 … … 471 485 } 472 486 473 /* remove filesystem sharemodes */ 474 ret_flock = SMB_VFS_KERNEL_FLOCK(fsp, 0, 0); 475 if (ret_flock == -1) { 476 DEBUG(2, ("close_remove_share_mode: removing kernel flock for " 477 "%s failed: %s\n", fsp_str_dbg(fsp), 478 strerror(errno))); 487 if (fsp->kernel_share_modes_taken) { 488 int ret_flock; 489 490 /* remove filesystem sharemodes */ 491 ret_flock = SMB_VFS_KERNEL_FLOCK(fsp, 0, 0); 492 if (ret_flock == -1) { 493 DEBUG(2, ("close_remove_share_mode: removing kernel " 494 "flock for %s failed: %s\n", 495 fsp_str_dbg(fsp), strerror(errno))); 496 } 479 497 } 480 498 … … 732 750 file_free(req, fsp); 733 751 return NT_STATUS_OK; 734 }735 736 /* Remove the oplock before potentially deleting the file. */737 if(fsp->oplock_type) {738 remove_oplock(fsp);739 752 } 740 753 -
vendor/current/source3/smbd/dfree.c
r988 r989 50 50 ****************************************************************************/ 51 51 52 uint64_t sys_disk_free(connection_struct *conn, const char *path,52 uint64_t sys_disk_free(connection_struct *conn, struct smb_filename *fname, 53 53 uint64_t *bsize, uint64_t *dfree, uint64_t *dsize) 54 54 { … … 59 59 const char *dfree_command; 60 60 static bool dfree_broken = false; 61 const char *path = fname->base_name; 61 62 62 63 (*dfree) = (*dsize) = 0; … … 124 125 } 125 126 126 if (disk_quotas(conn, path, &bsize_q, &dfree_q, &dsize_q)) {127 if (disk_quotas(conn, fname, &bsize_q, &dfree_q, &dsize_q)) { 127 128 uint64_t min_bsize = MIN(*bsize, bsize_q); 128 129 … … 168 169 ****************************************************************************/ 169 170 170 uint64_t get_dfree_info(connection_struct *conn, 171 const char *path, 172 uint64_t *bsize, 173 uint64_t *dfree, 174 uint64_t *dsize) 171 uint64_t get_dfree_info(connection_struct *conn, struct smb_filename *fname, 172 uint64_t *bsize, uint64_t *dfree, uint64_t *dsize) 175 173 { 176 174 int dfree_cache_time = lp_dfree_cache_time(SNUM(conn)); … … 179 177 180 178 if (!dfree_cache_time) { 181 return sys_disk_free(conn, path, bsize, dfree, dsize);179 return sys_disk_free(conn, fname, bsize, dfree, dsize); 182 180 } 183 181 … … 190 188 } 191 189 192 dfree_ret = sys_disk_free(conn, path, bsize, dfree, dsize);190 dfree_ret = sys_disk_free(conn, fname, bsize, dfree, dsize); 193 191 194 192 if (dfree_ret == (uint64_t)-1) { -
vendor/current/source3/smbd/dosmode.c
r988 r989 258 258 ****************************************************************************/ 259 259 260 staticbool get_ea_dos_attribute(connection_struct *conn,261 262 260 bool get_ea_dos_attribute(connection_struct *conn, 261 struct smb_filename *smb_fname, 262 uint32_t *pattr) 263 263 { 264 264 struct xattr_DOSATTRIB dosattrib; … … 553 553 } 554 554 555 static uint32_t dos_mode_from_name(connection_struct *conn, 556 const struct smb_filename *smb_fname, 557 uint32_t dosmode) 558 { 559 const char *p = NULL; 560 uint32_t result = dosmode; 561 562 if (!(result & FILE_ATTRIBUTE_HIDDEN) && 563 lp_hide_dot_files(SNUM(conn))) 564 { 565 p = strrchr_m(smb_fname->base_name, '/'); 566 if (p) { 567 p++; 568 } else { 569 p = smb_fname->base_name; 570 } 571 572 /* Only . and .. are not hidden. */ 573 if ((p[0] == '.') && 574 !((p[1] == '\0') || (p[1] == '.' && p[2] == '\0'))) 575 { 576 result |= FILE_ATTRIBUTE_HIDDEN; 577 } 578 } 579 580 if (!(result & FILE_ATTRIBUTE_HIDDEN) && 581 IS_HIDDEN_PATH(conn, smb_fname->base_name)) 582 { 583 result |= FILE_ATTRIBUTE_HIDDEN; 584 } 585 586 return result; 587 } 588 555 589 /**************************************************************************** 556 590 Change a unix mode to a dos mode. … … 568 602 if (!VALID_STAT(smb_fname->st)) { 569 603 return 0; 570 }571 572 /* First do any modifications that depend on the path name. */573 /* hide files with a name starting with a . */574 if (lp_hide_dot_files(SNUM(conn))) {575 const char *p = strrchr_m(smb_fname->base_name,'/');576 if (p) {577 p++;578 } else {579 p = smb_fname->base_name;580 }581 582 /* Only . and .. are not hidden. */583 if (p[0] == '.' && !((p[1] == '\0') ||584 (p[1] == '.' && p[2] == '\0'))) {585 result |= FILE_ATTRIBUTE_HIDDEN;586 }587 604 } 588 605 … … 606 623 } 607 624 608 /* Optimization : Only call is_hidden_path if it's not already 609 hidden. */ 610 if (!(result & FILE_ATTRIBUTE_HIDDEN) && 611 IS_HIDDEN_PATH(conn, smb_fname->base_name)) { 612 result |= FILE_ATTRIBUTE_HIDDEN; 613 } 625 result |= dos_mode_from_name(conn, smb_fname, result); 614 626 615 627 if (result == 0) { 616 result = FILE_ATTRIBUTE_NORMAL; 628 if (S_ISDIR(smb_fname->st.st_ex_mode)) { 629 result = FILE_ATTRIBUTE_DIRECTORY; 630 } else { 631 result = FILE_ATTRIBUTE_NORMAL; 632 } 617 633 } 618 634 -
vendor/current/source3/smbd/filename.c
r988 r989 940 940 TALLOC_FREE(found_name); 941 941 } /* end else */ 942 943 #ifdef DEVELOPER944 /*945 * This sucks!946 * We should never provide different behaviors947 * depending on DEVELOPER!!!948 */949 if (VALID_STAT(smb_fname->st)) {950 bool delete_pending;951 uint32_t name_hash;952 953 status = file_name_hash(conn,954 smb_fname_str_dbg(smb_fname),955 &name_hash);956 if (!NT_STATUS_IS_OK(status)) {957 goto fail;958 }959 960 get_file_infos(vfs_file_id_from_sbuf(conn,961 &smb_fname->st),962 name_hash,963 &delete_pending, NULL);964 if (delete_pending) {965 status = NT_STATUS_DELETE_PENDING;966 goto fail;967 }968 }969 #endif970 942 971 943 /* -
vendor/current/source3/smbd/globals.h
r988 r989 728 728 729 729 /* 730 * Keep track of whether the outstanding request counters 731 * had been updated in dispatch, so that they need to be 732 * adapted again in reply. 733 */ 734 bool request_counters_updated; 735 736 /* 730 737 * The sub request for async backend calls. 731 738 * This is used for SMB2 Cancel. -
vendor/current/source3/smbd/notifyd/notifyd.c
r988 r989 1247 1247 size_t i; 1248 1248 1249 dbwrap_traverse_read(p->db, notifyd_db_del_syswatches, NULL, NULL); 1249 if (p->db != NULL) { 1250 dbwrap_traverse_read(p->db, notifyd_db_del_syswatches, 1251 NULL, NULL); 1252 } 1250 1253 1251 1254 for (i = 0; i<state->num_peers; i++) { -
vendor/current/source3/smbd/open.c
r988 r989 884 884 } 885 885 886 if (local_flags & O_NONBLOCK) { 887 /* 888 * GPFS can return ETIMEDOUT for pread on 889 * nonblocking file descriptors when files 890 * migrated to tape need to be recalled. I 891 * could imagine this happens elsehwere 892 * too. With blocking file descriptors this 893 * does not happen. 894 */ 895 ret = set_blocking(fsp->fh->fd, true); 896 if (ret == -1) { 897 status = map_nt_error_from_unix(errno); 898 DBG_WARNING("Could not set fd to blocking: " 899 "%s\n", strerror(errno)); 900 fd_close(fsp); 901 return status; 902 } 903 } 904 886 905 ret = SMB_VFS_FSTAT(fsp, &smb_fname->st); 887 906 if (ret == -1) { … … 2518 2537 new_dos_attributes &= SAMBA_ATTRIBUTES_MASK; 2519 2538 if (file_existed) { 2520 existing_dos_attributes = dos_mode(conn, smb_fname); 2539 /* 2540 * Only use strored DOS attributes for checks 2541 * against requested attributes (below via 2542 * open_match_attributes()), cf bug #11992 2543 * for details. -slow 2544 */ 2545 bool ok; 2546 uint32_t attr = 0; 2547 2548 ok = get_ea_dos_attribute(conn, smb_fname, &attr); 2549 if (ok) { 2550 existing_dos_attributes = attr; 2551 } 2521 2552 } 2522 2553 } … … 3085 3116 return NT_STATUS_SHARING_VIOLATION; 3086 3117 } 3118 3119 fsp->kernel_share_modes_taken = true; 3087 3120 } 3088 3121 … … 3858 3891 TALLOC_CTX *frame = talloc_stackframe(); 3859 3892 NTSTATUS status; 3893 bool saved_posix_pathnames; 3860 3894 3861 3895 status = vfs_streaminfo(conn, NULL, fname, talloc_tos(), … … 3889 3923 goto fail; 3890 3924 } 3925 3926 /* 3927 * Any stream names *must* be treated as Windows 3928 * pathnames, even if we're using UNIX extensions. 3929 */ 3930 3931 saved_posix_pathnames = lp_set_posix_pathnames(false); 3891 3932 3892 3933 for (i=0; i<num_streams; i++) { … … 3957 3998 3958 3999 fail: 4000 4001 (void)lp_set_posix_pathnames(saved_posix_pathnames); 3959 4002 TALLOC_FREE(frame); 3960 4003 return status; -
vendor/current/source3/smbd/oplock.c
r988 r989 191 191 * If we're the only one, we don't need a brlock entry 192 192 */ 193 remove_stale_share_mode_entries(d); 193 194 SMB_ASSERT(d->num_share_modes == 1); 194 195 SMB_ASSERT(EXCLUSIVE_OPLOCK_TYPE(d->share_modes[0].op_type)); … … 220 221 TALLOC_FREE(br_lck); 221 222 return true; 223 } 224 225 /**************************************************************************** 226 Remove a file oplock with lock already held. Copes with level II and exclusive. 227 ****************************************************************************/ 228 229 bool remove_oplock_under_lock(files_struct *fsp, struct share_mode_lock *lck) 230 { 231 bool ret; 232 233 ret = remove_share_oplock(lck, fsp); 234 if (!ret) { 235 DBG_ERR("failed to remove share oplock for " 236 "file %s, %s, %s\n", 237 fsp_str_dbg(fsp), fsp_fnum_dbg(fsp), 238 file_id_string_tos(&fsp->file_id)); 239 } 240 release_file_oplock(fsp); 241 242 ret = update_num_read_oplocks(fsp, lck); 243 if (!ret) { 244 DBG_ERR("update_num_read_oplocks failed for " 245 "file %s, %s, %s\n", 246 fsp_str_dbg(fsp), fsp_fnum_dbg(fsp), 247 file_id_string_tos(&fsp->file_id)); 248 } 249 250 return ret; 222 251 } 223 252 … … 233 262 struct share_mode_lock *lck; 234 263 235 DEBUG(10, ("remove_oplock called for %s\n", 236 fsp_str_dbg(fsp))); 264 DBG_DEBUG("remove_oplock called for %s\n", fsp_str_dbg(fsp)); 237 265 238 266 /* Remove the oplock flag from the sharemode. */ 239 267 lck = get_existing_share_mode_lock(talloc_tos(), fsp->file_id); 240 268 if (lck == NULL) { 241 DEBUG(0,("remove_oplock: failed to lock share entry for " 242 "file %s\n", fsp_str_dbg(fsp))); 243 return False; 244 } 245 246 ret = remove_share_oplock(lck, fsp); 247 if (!ret) { 248 DEBUG(0,("remove_oplock: failed to remove share oplock for " 249 "file %s, %s, %s\n", 250 fsp_str_dbg(fsp), fsp_fnum_dbg(fsp), 251 file_id_string_tos(&fsp->file_id))); 252 } 253 release_file_oplock(fsp); 254 255 ret = update_num_read_oplocks(fsp, lck); 256 if (!ret) { 257 DEBUG(0, ("%s: update_num_read_oplocks failed for " 258 "file %s, %s, %s\n", 259 __func__, fsp_str_dbg(fsp), fsp_fnum_dbg(fsp), 260 file_id_string_tos(&fsp->file_id))); 261 } 269 DBG_ERR("failed to lock share entry for " 270 "file %s\n", fsp_str_dbg(fsp)); 271 return false; 272 } 273 274 ret = remove_oplock_under_lock(fsp, lck); 262 275 263 276 TALLOC_FREE(lck); -
vendor/current/source3/smbd/pipes.c
r988 r989 493 493 + 2 /* the buflen field */ 494 494 + 1); /* padding byte */ 495 SSVAL(req->outbuf,smb_vwv11,state->smb_maxcnt);496 495 497 496 DEBUG(3,("readX-IPC min=%d max=%d nread=%d\n", -
vendor/current/source3/smbd/posix_acls.c
r988 r989 4663 4663 } 4664 4664 4665 /* Stolen shamelessly from pvfs_default_acl() in source4 :-). */4666 4667 NTSTATUS make_default_filesystem_acl(TALLOC_CTX *ctx,4668 const char *name,4669 SMB_STRUCT_STAT *psbuf,4670 struct security_descriptor **ppdesc)4671 {4672 struct dom_sid owner_sid, group_sid;4673 size_t size = 0;4674 struct security_ace aces[4];4675 uint32_t access_mask = 0;4676 mode_t mode = psbuf->st_ex_mode;4677 struct security_acl *new_dacl = NULL;4678 int idx = 0;4679 4680 DEBUG(10,("make_default_filesystem_acl: file %s mode = 0%o\n",4681 name, (int)mode ));4682 4683 uid_to_sid(&owner_sid, psbuf->st_ex_uid);4684 gid_to_sid(&group_sid, psbuf->st_ex_gid);4685 4686 /*4687 We provide up to 4 ACEs4688 - Owner4689 - Group4690 - Everyone4691 - NT System4692 */4693 4694 if (mode & S_IRUSR) {4695 if (mode & S_IWUSR) {4696 access_mask |= SEC_RIGHTS_FILE_ALL;4697 } else {4698 access_mask |= SEC_RIGHTS_FILE_READ | SEC_FILE_EXECUTE;4699 }4700 }4701 if (mode & S_IWUSR) {4702 access_mask |= SEC_RIGHTS_FILE_WRITE | SEC_STD_DELETE;4703 }4704 4705 init_sec_ace(&aces[idx],4706 &owner_sid,4707 SEC_ACE_TYPE_ACCESS_ALLOWED,4708 access_mask,4709 0);4710 idx++;4711 4712 access_mask = 0;4713 if (mode & S_IRGRP) {4714 access_mask |= SEC_RIGHTS_FILE_READ | SEC_FILE_EXECUTE;4715 }4716 if (mode & S_IWGRP) {4717 /* note that delete is not granted - this matches posix behaviour */4718 access_mask |= SEC_RIGHTS_FILE_WRITE;4719 }4720 if (access_mask) {4721 init_sec_ace(&aces[idx],4722 &group_sid,4723 SEC_ACE_TYPE_ACCESS_ALLOWED,4724 access_mask,4725 0);4726 idx++;4727 }4728 4729 access_mask = 0;4730 if (mode & S_IROTH) {4731 access_mask |= SEC_RIGHTS_FILE_READ | SEC_FILE_EXECUTE;4732 }4733 if (mode & S_IWOTH) {4734 access_mask |= SEC_RIGHTS_FILE_WRITE;4735 }4736 if (access_mask) {4737 init_sec_ace(&aces[idx],4738 &global_sid_World,4739 SEC_ACE_TYPE_ACCESS_ALLOWED,4740 access_mask,4741 0);4742 idx++;4743 }4744 4745 init_sec_ace(&aces[idx],4746 &global_sid_System,4747 SEC_ACE_TYPE_ACCESS_ALLOWED,4748 SEC_RIGHTS_FILE_ALL,4749 0);4750 idx++;4751 4752 new_dacl = make_sec_acl(ctx,4753 NT4_ACL_REVISION,4754 idx,4755 aces);4756 4757 if (!new_dacl) {4758 return NT_STATUS_NO_MEMORY;4759 }4760 4761 *ppdesc = make_sec_desc(ctx,4762 SECURITY_DESCRIPTOR_REVISION_1,4763 SEC_DESC_SELF_RELATIVE|SEC_DESC_DACL_PRESENT,4764 &owner_sid,4765 &group_sid,4766 NULL,4767 new_dacl,4768 &size);4769 if (!*ppdesc) {4770 return NT_STATUS_NO_MEMORY;4771 }4772 return NT_STATUS_OK;4773 }4774 4775 4665 int posix_sys_acl_blob_get_file(vfs_handle_struct *handle, 4776 4666 const char *path_p, -
vendor/current/source3/smbd/process.c
r988 r989 3224 3224 state->xconn = xconn; 3225 3225 state->parent_pipe = parent_pipe; 3226 state->ev = s 3_tevent_context_init(state);3226 state->ev = samba_tevent_context_init(state); 3227 3227 if (state->ev == NULL) { 3228 DEBUG(1, (" tevent_context_init failed\n"));3228 DEBUG(1, ("samba_tevent_context_init failed\n")); 3229 3229 TALLOC_FREE(state); 3230 3230 return; -
vendor/current/source3/smbd/proto.h
r988 r989 172 172 /* The following definitions come from smbd/dfree.c */ 173 173 174 uint64_t sys_disk_free(connection_struct *conn, const char *path, 175 uint64_t *bsize,uint64_t *dfree,uint64_t *dsize); 176 uint64_t get_dfree_info(connection_struct *conn, 177 const char *path, 178 uint64_t *bsize, 179 uint64_t *dfree, 180 uint64_t *dsize); 174 uint64_t sys_disk_free(connection_struct *conn, struct smb_filename *fname, 175 uint64_t *bsize, uint64_t *dfree, uint64_t *dsize); 176 uint64_t get_dfree_info(connection_struct *conn, struct smb_filename *fname, 177 uint64_t *bsize, uint64_t *dfree, uint64_t *dsize); 181 178 182 179 /* The following definitions come from smbd/dir.c */ … … 260 257 int file_set_dosmode(connection_struct *conn, struct smb_filename *smb_fname, 261 258 uint32_t dosmode, const char *parent_dir, bool newfile); 259 bool get_ea_dos_attribute(connection_struct *conn, 260 struct smb_filename *smb_fname, 261 uint32_t *pattr); 262 262 NTSTATUS file_set_sparse(connection_struct *conn, 263 263 struct files_struct *fsp, … … 681 681 void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp); 682 682 NTSTATUS set_file_oplock(files_struct *fsp); 683 bool remove_oplock_under_lock(files_struct *fsp, struct share_mode_lock *lck); 683 684 bool remove_oplock(files_struct *fsp); 684 685 bool downgrade_oplock(files_struct *fsp); … … 762 763 uint32_t security_info_wanted, 763 764 struct security_descriptor **sd); 764 NTSTATUS make_default_filesystem_acl(TALLOC_CTX *ctx,765 const char *name,766 SMB_STRUCT_STAT *psbuf,767 struct security_descriptor **ppdesc);768 765 int posix_sys_acl_blob_get_file(vfs_handle_struct *handle, 769 766 const char *path_p, … … 830 827 /* The following definitions come from smbd/quotas.c */ 831 828 832 bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize, 833 uint64_t *dfree, uint64_t *dsize); 834 bool disk_quotas_vxfs(const char *name, char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize); 829 bool disk_quotas(connection_struct *conn, struct smb_filename *fname, 830 uint64_t *bsize, uint64_t *dfree, uint64_t *dsize); 835 831 836 832 /* The following definitions come from smbd/reply.c */ … … 916 912 void reply_readbraw(struct smb_request *req); 917 913 void reply_lockread(struct smb_request *req); 914 int setup_readX_header(char *outbuf, size_t smb_maxcnt); 918 915 void reply_read(struct smb_request *req); 919 916 void reply_read_and_X(struct smb_request *req); -
vendor/current/source3/smbd/quotas.c
r988 r989 237 237 ****************************************************************************/ 238 238 239 bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize,240 uint64_t * dfree, uint64_t *dsize)239 bool disk_quotas(connection_struct *conn, struct smb_filename *fname, 240 uint64_t *bsize, uint64_t *dfree, uint64_t *dsize) 241 241 { 242 242 uid_t euser_id; … … 255 255 SMB_DEV_T devno; 256 256 bool found = false; 257 const char *path = fname->base_name; 257 258 258 259 euser_id = geteuid(); 259 260 260 if (sys_stat(path, &sbuf, false) == -1) { 261 return false; 262 } 263 264 devno = sbuf.st_ex_dev ; 261 devno = fname->st.st_ex_dev; 265 262 DEBUG(5,("disk_quotas: looking for path \"%s\" devno=%x\n", 266 263 path, (unsigned int)devno)); … … 427 424 ****************************************************************************/ 428 425 429 bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize,430 uint64_t * dfree, uint64_t *dsize)426 bool disk_quotas(connection_struct *conn, struct smb_filename *fname, 427 uint64_t *bsize, uint64_t *dfree, uint64_t *dsize) 431 428 { 432 429 int r; 433 430 struct dqblk D; 434 431 uid_t euser_id; 432 const char *path = fname->base_name; 435 433 #if !defined(AIX) 436 434 char dev_disk[256]; 437 SMB_STRUCT_STAT S ;435 SMB_STRUCT_STAT S = fname->st; 438 436 439 437 /* find the block device file */ … … 658 656 #else /* WITH_QUOTAS */ 659 657 660 bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize,661 uint64_t * dfree, uint64_t *dsize)658 bool disk_quotas(connection_struct *conn, struct smb_filename *fname, 659 uint64_t *bsize, uint64_t *dfree, uint64_t *dsize) 662 660 { 663 661 (*bsize) = 512; /* This value should be ignored */ … … 677 675 this file should be removed later 678 676 */ 679 bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize,680 uint64_t * dfree, uint64_t *dsize)677 bool disk_quotas(connection_struct *conn, struct smb_filename *fname, 678 uint64_t *bsize, uint64_t *dfree, uint64_t *dsize) 681 679 { 682 680 int r; … … 684 682 unid_t id; 685 683 684 /* 685 * First of all, check whether user quota is 686 * enforced. If the call fails, assume it is 687 * not enforced. 688 */ 689 ZERO_STRUCT(D); 690 id.uid = -1; 691 r = SMB_VFS_GET_QUOTA(conn, fname->base_name, SMB_USER_FS_QUOTA_TYPE, 692 id, &D); 693 if (r == -1 && errno != ENOSYS) { 694 goto try_group_quota; 695 } 696 if (r == 0 && (D.qflags & QUOTAS_DENY_DISK) == 0) { 697 goto try_group_quota; 698 } 699 700 ZERO_STRUCT(D); 686 701 id.uid = geteuid(); 687 702 688 ZERO_STRUCT(D); 689 r = SMB_VFS_GET_QUOTA(conn, path, SMB_USER_QUOTA_TYPE, id, &D); 703 /* if new files created under this folder get this 704 * folder's UID, then available space is governed by 705 * the quota of the folder's UID, not the creating user. 706 */ 707 if (lp_inherit_owner(SNUM(conn)) && 708 id.uid != fname->st.st_ex_uid && id.uid != sec_initial_uid()) { 709 int save_errno; 710 711 id.uid = fname->st.st_ex_uid; 712 become_root(); 713 r = SMB_VFS_GET_QUOTA(conn, fname->base_name, 714 SMB_USER_QUOTA_TYPE, id, &D); 715 save_errno = errno; 716 unbecome_root(); 717 errno = save_errno; 718 } else { 719 r = SMB_VFS_GET_QUOTA(conn, fname->base_name, 720 SMB_USER_QUOTA_TYPE, id, &D); 721 } 690 722 691 723 /* Use softlimit to determine disk space, except when it has been exceeded */ … … 723 755 724 756 try_group_quota: 757 /* 758 * First of all, check whether group quota is 759 * enforced. If the call fails, assume it is 760 * not enforced. 761 */ 762 ZERO_STRUCT(D); 763 id.gid = -1; 764 r = SMB_VFS_GET_QUOTA(conn, fname->base_name, SMB_GROUP_FS_QUOTA_TYPE, 765 id, &D); 766 if (r == -1 && errno != ENOSYS) { 767 return false; 768 } 769 if (r == 0 && (D.qflags & QUOTAS_DENY_DISK) == 0) { 770 return false; 771 } 772 725 773 id.gid = getegid(); 726 774 727 775 ZERO_STRUCT(D); 728 r = SMB_VFS_GET_QUOTA(conn, path, SMB_GROUP_QUOTA_TYPE, id, &D); 776 r = SMB_VFS_GET_QUOTA(conn, fname->base_name, SMB_GROUP_QUOTA_TYPE, id, 777 &D); 729 778 730 779 /* Use softlimit to determine disk space, except when it has been exceeded */ -
vendor/current/source3/smbd/reply.c
r988 r989 1574 1574 uint64_t ret; 1575 1575 uint64_t dfree,dsize,bsize; 1576 struct smb_filename smb_fname; 1576 1577 START_PROFILE(SMBdskattr); 1577 1578 1578 ret = get_dfree_info(conn, ".", &bsize, &dfree, &dsize); 1579 ZERO_STRUCT(smb_fname); 1580 smb_fname.base_name = discard_const_p(char, "."); 1581 1582 if (SMB_VFS_STAT(conn, &smb_fname) != 0) { 1583 reply_nterror(req, map_nt_error_from_unix(errno)); 1584 DBG_WARNING("stat of . failed (%s)\n", strerror(errno)); 1585 END_PROFILE(SMBdskattr); 1586 return; 1587 } 1588 1589 ret = get_dfree_info(conn, &smb_fname, &bsize, &dfree, &dsize); 1579 1590 if (ret == (uint64_t)-1) { 1580 1591 reply_nterror(req, map_nt_error_from_unix(errno)); … … 3897 3908 ****************************************************************************/ 3898 3909 3899 static int setup_readX_header(struct smb_request *req, char *outbuf, 3900 size_t smb_maxcnt) 3910 int setup_readX_header(char *outbuf, size_t smb_maxcnt) 3901 3911 { 3902 3912 int outsize; … … 3917 3927 + 1); /* padding byte */ 3918 3928 SSVAL(outbuf,smb_vwv7,(smb_maxcnt >> 16)); 3919 SSVAL(outbuf,smb_vwv11,smb_maxcnt);3920 3929 SCVAL(smb_buf(outbuf), 0, 0); /* padding byte */ 3921 3930 /* Reset the outgoing length, set_message truncates at 0x1FFFF. */ … … 3985 3994 3986 3995 construct_reply_common_req(req, (char *)headerbuf); 3987 setup_readX_header( req,(char *)headerbuf, smb_maxcnt);3996 setup_readX_header((char *)headerbuf, smb_maxcnt); 3988 3997 3989 3998 nread = SMB_VFS_SENDFILE(xconn->transport.sock, fsp, &header, … … 4086 4095 4087 4096 construct_reply_common_req(req, (char *)headerbuf); 4088 setup_readX_header( req,(char *)headerbuf, smb_maxcnt);4097 setup_readX_header((char *)headerbuf, smb_maxcnt); 4089 4098 4090 4099 /* Send out the header. */ … … 4136 4145 } 4137 4146 4138 setup_readX_header( req,(char *)req->outbuf, nread);4147 setup_readX_header((char *)req->outbuf, nread); 4139 4148 4140 4149 DEBUG(3, ("send_file_readX %s max=%d nread=%d\n", -
vendor/current/source3/smbd/server.c
r988 r989 397 397 } 398 398 399 status = reinit_after_fork(msg, ev, true, "smbd-notifyd");399 status = smbd_reinit_after_fork(msg, ev, true, "smbd-notifyd"); 400 400 if (!NT_STATUS_IS_OK(status)) { 401 401 DEBUG(1, ("%s: reinit_after_fork failed: %s\n", … … 479 479 close(up_pipe[0]); 480 480 481 status = reinit_after_fork(msg, ev, true, "cleanupd");481 status = smbd_reinit_after_fork(msg, ev, true, "cleanupd"); 482 482 if (!NT_STATUS_IS_OK(status)) { 483 483 DBG_WARNING("reinit_after_fork failed: %s\n", … … 1413 1413 * initialized before the messaging context, cause the messaging 1414 1414 * context holds an event context. 1415 * FIXME: This should be s3_tevent_context_init()1416 1415 */ 1417 1416 ev_ctx = server_event_context(); -
vendor/current/source3/smbd/service.c
r988 r989 182 182 { 183 183 int snum; 184 enum remote_arch_types ra_type; 184 185 185 186 if (!conn) { … … 207 208 last_flags = flags; 208 209 209 /* Obey the client case sensitivity requests - only for clients that support it. */ 210 /* 211 * Obey the client case sensitivity requests - only for clients that 212 * support it. */ 210 213 switch (lp_case_sensitive(snum)) { 211 case Auto: 212 { 213 /* We need this uglyness due to DOS/Win9x clients that lie about case insensitivity. */ 214 enum remote_arch_types ra_type = get_remote_arch(); 215 if ((ra_type != RA_SAMBA) && (ra_type != RA_CIFSFS)) { 216 /* Client can't support per-packet case sensitive pathnames. */ 217 conn->case_sensitive = False; 218 } else { 219 conn->case_sensitive = !(flags & FLAG_CASELESS_PATHNAMES); 220 } 221 } 222 break; 223 case True: 224 conn->case_sensitive = True; 225 break; 226 default: 227 conn->case_sensitive = False; 228 break; 229 } 230 return(True); 214 case Auto: 215 /* 216 * We need this uglyness due to DOS/Win9x clients that lie 217 * about case insensitivity. */ 218 ra_type = get_remote_arch(); 219 if (conn->sconn->using_smb2) { 220 conn->case_sensitive = false; 221 } else if ((ra_type != RA_SAMBA) && (ra_type != RA_CIFSFS)) { 222 /* 223 * Client can't support per-packet case sensitive 224 * pathnames. */ 225 conn->case_sensitive = false; 226 } else { 227 conn->case_sensitive = 228 !(flags & FLAG_CASELESS_PATHNAMES); 229 } 230 break; 231 case True: 232 conn->case_sensitive = true; 233 break; 234 default: 235 conn->case_sensitive = false; 236 break; 237 } 238 return true; 231 239 } 232 240 -
vendor/current/source3/smbd/sesssetup.c
r988 r989 131 131 struct smbd_server_connection *sconn = req->sconn; 132 132 uint16_t action = 0; 133 bool is_authenticated = false; 133 134 NTTIME now = timeval_to_nttime(&req->request_time); 134 135 struct smbXsrv_session *session = NULL; … … 337 338 338 339 if (security_session_user_level(session_info, NULL) >= SECURITY_USER) { 340 is_authenticated = true; 339 341 session->compat->homes_snum = 340 342 register_homes_share(session_info->unix_info->unix_name); … … 342 344 343 345 if (srv_is_signing_negotiated(xconn) && 344 action == 0&&346 is_authenticated && 345 347 session->global->signing_key.length > 0) 346 348 { … … 602 604 uint16_t smb_flag2 = req->flags2; 603 605 uint16_t action = 0; 606 bool is_authenticated = false; 604 607 NTTIME now = timeval_to_nttime(&req->request_time); 605 608 struct smbXsrv_session *session = NULL; … … 1039 1042 1040 1043 if (security_session_user_level(session_info, NULL) >= SECURITY_USER) { 1044 is_authenticated = true; 1041 1045 session->compat->homes_snum = 1042 1046 register_homes_share(session_info->unix_info->unix_name); … … 1044 1048 1045 1049 if (srv_is_signing_negotiated(xconn) && 1046 action == 0&&1050 is_authenticated && 1047 1051 session->global->signing_key.length > 0) 1048 1052 { -
vendor/current/source3/smbd/smb2_glue.c
r988 r989 49 49 FLAGS2_LONG_PATH_COMPONENTS | 50 50 FLAGS2_IS_LONG_NAME; 51 52 /* This is not documented in revision 49 of [MS-SMB2] but should be 53 * added in a later revision (and torture test smb2.read.access 54 * as well as smb2.ioctl_copy_chunk_bad_access against 55 * Server 2012R2 confirms this) 56 * 57 * If FILE_EXECUTE is granted to a handle then the SMB2 server 58 * acts as if FILE_READ_DATA has also been granted. We must still 59 * keep the original granted mask, because with ioctl requests, 60 * access checks are made on the file handle, "below" the SMB2 61 * server, and the object store below the SMB layer is not aware 62 * of this arrangement (see smb2.ioctl.copy_chunk_bad_access 63 * torture test). 64 */ 65 smbreq->flags2 |= FLAGS2_READ_PERMIT_EXECUTE; 66 51 67 if (IVAL(inhdr, SMB2_HDR_FLAGS) & SMB2_HDR_FLAG_DFS) { 52 68 smbreq->flags2 |= FLAGS2_DFS_PATHNAMES; -
vendor/current/source3/smbd/smb2_ioctl_filesys.c
r988 r989 49 49 /* Windows doesn't check for SEC_FILE_READ_ATTRIBUTE permission here */ 50 50 51 if ((fsp->conn->fs_capabilities & FILE_FILE_COMPRESSION) == 0) {52 DEBUG(4, ("FS does not advertise compression support\n"));53 return NT_STATUS_NOT_SUPPORTED;54 }55 56 51 ZERO_STRUCT(cmpr_state); 57 status = SMB_VFS_GET_COMPRESSION(fsp->conn, 58 mem_ctx, 59 fsp, 60 NULL, 61 &cmpr_state.format); 62 if (!NT_STATUS_IS_OK(status)) { 63 return status; 52 if (fsp->conn->fs_capabilities & FILE_FILE_COMPRESSION) { 53 status = SMB_VFS_GET_COMPRESSION(fsp->conn, 54 mem_ctx, 55 fsp, 56 NULL, 57 &cmpr_state.format); 58 if (!NT_STATUS_IS_OK(status)) { 59 return status; 60 } 61 } else { 62 /* 63 * bso#12144: The underlying filesystem doesn't support 64 * compression, so we should respond with "not-compressed" 65 * (like WS2016 ReFS) instead of STATUS_NOT_SUPPORTED or 66 * NT_STATUS_INVALID_DEVICE_REQUEST. 67 */ 68 cmpr_state.format = COMPRESSION_FORMAT_NONE; 64 69 } 65 70 -
vendor/current/source3/smbd/smb2_ioctl_network_fs.c
r988 r989 118 118 * FILE_READ_DATA, and the CtlCode is FSCTL_SRV_COPYCHUNK. 119 119 */ 120 if ((ctl_code == FSCTL_SRV_COPYCHUNK) 121 && !CHECK_READ(dst_fsp, smb1req)) {120 if ((ctl_code == FSCTL_SRV_COPYCHUNK) && 121 !CHECK_READ_IOCTL(dst_fsp, smb1req)) { 122 122 DEBUG(5, ("copy chunk no read on dest handle (%s).\n", 123 123 smb_fname_str_dbg(dst_fsp->fsp_name) )); -
vendor/current/source3/smbd/smb2_server.c
r988 r989 47 47 uint16_t fileid_ofs; 48 48 bool allow_invalid_fileid; 49 bool modify; 49 50 } smbd_smb2_table[] = { 50 51 #define _OP(o) .opcode = o, .name = #o … … 99 100 .need_tcon = true, 100 101 .fileid_ofs = 0x10, 102 .modify = true, 101 103 },{ 102 104 _OP(SMB2_OP_LOCK), … … 110 112 .fileid_ofs = 0x08, 111 113 .allow_invalid_fileid = true, 114 .modify = true, 112 115 },{ 113 116 _OP(SMB2_OP_CANCEL), … … 136 139 .need_tcon = true, 137 140 .fileid_ofs = 0x10, 141 .modify = true, 138 142 },{ 139 143 _OP(SMB2_OP_BREAK), … … 2108 2112 } 2109 2113 2114 static NTSTATUS smbd_smb2_request_dispatch_update_counts( 2115 struct smbd_smb2_request *req, 2116 bool modify_call) 2117 { 2118 struct smbXsrv_connection *xconn = req->xconn; 2119 const uint8_t *inhdr; 2120 uint16_t channel_sequence; 2121 uint32_t flags; 2122 int cmp; 2123 struct smbXsrv_open *op; 2124 bool update_open = false; 2125 NTSTATUS status = NT_STATUS_OK; 2126 2127 req->request_counters_updated = false; 2128 2129 if (xconn->protocol < PROTOCOL_SMB2_22) { 2130 return NT_STATUS_OK; 2131 } 2132 2133 if (req->compat_chain_fsp == NULL) { 2134 return NT_STATUS_OK; 2135 } 2136 2137 op = req->compat_chain_fsp->op; 2138 if (op == NULL) { 2139 return NT_STATUS_OK; 2140 } 2141 2142 inhdr = SMBD_SMB2_IN_HDR_PTR(req); 2143 flags = IVAL(inhdr, SMB2_HDR_FLAGS); 2144 channel_sequence = SVAL(inhdr, SMB2_HDR_CHANNEL_SEQUENCE); 2145 2146 cmp = channel_sequence - op->global->channel_sequence; 2147 2148 if (abs(cmp) > INT16_MAX) { 2149 /* 2150 * [MS-SMB2] 3.3.5.2.10 - Verifying the Channel Sequence Number: 2151 * 2152 * If the channel sequence number of the request and the one 2153 * known to the server are not equal, the channel sequence 2154 * number and outstanding request counts are only updated 2155 * "... if the unsigned difference using 16-bit arithmetic 2156 * between ChannelSequence and Open.ChannelSequence is less than 2157 * or equal to 0x7FFF ...". 2158 * Otherwise, an error is returned for the modifying 2159 * calls write, set_info, and ioctl. 2160 * 2161 * There are currently two issues with the description: 2162 * 2163 * * For the other calls, the document seems to imply 2164 * that processing continues without adapting the 2165 * counters (if the sequence numbers are not equal). 2166 * 2167 * TODO: This needs clarification! 2168 * 2169 * * Also, the behaviour if the difference is larger 2170 * than 0x7FFF is not clear. The document seems to 2171 * imply that if such a difference is reached, 2172 * the server starts to ignore the counters or 2173 * in the case of the modifying calls, return errors. 2174 * 2175 * TODO: This needs clarification! 2176 * 2177 * At this point Samba tries to be a little more 2178 * clever than the description in the MS-SMB2 document 2179 * by heuristically detecting and properly treating 2180 * a 16 bit overflow of the client-submitted sequence 2181 * number: 2182 * 2183 * If the stored channel squence number is more than 2184 * 0x7FFF larger than the one from the request, then 2185 * the client-provided sequence number has likely 2186 * overflown. We treat this case as valid instead 2187 * of as failure. 2188 * 2189 * The MS-SMB2 behaviour would be setting cmp = -1. 2190 */ 2191 cmp *= -1; 2192 } 2193 2194 if (!(flags & SMB2_HDR_FLAG_REPLAY_OPERATION)) { 2195 if (cmp == 0) { 2196 op->request_count += 1; 2197 req->request_counters_updated = true; 2198 } else if (cmp > 0) { 2199 op->pre_request_count += op->request_count; 2200 op->request_count = 1; 2201 op->global->channel_sequence = channel_sequence; 2202 update_open = true; 2203 req->request_counters_updated = true; 2204 } else if (modify_call) { 2205 return NT_STATUS_FILE_NOT_AVAILABLE; 2206 } 2207 } else { 2208 if (cmp == 0 && op->pre_request_count == 0) { 2209 op->request_count += 1; 2210 req->request_counters_updated = true; 2211 } else if (cmp > 0 && op->pre_request_count == 0) { 2212 op->pre_request_count += op->request_count; 2213 op->request_count = 1; 2214 op->global->channel_sequence = channel_sequence; 2215 update_open = true; 2216 req->request_counters_updated = true; 2217 } else if (modify_call) { 2218 return NT_STATUS_FILE_NOT_AVAILABLE; 2219 } 2220 } 2221 2222 if (update_open) { 2223 status = smbXsrv_open_update(op); 2224 } 2225 2226 return status; 2227 } 2228 2110 2229 NTSTATUS smbd_smb2_request_dispatch(struct smbd_smb2_request *req) 2111 2230 { … … 2405 2524 } 2406 2525 2526 status = smbd_smb2_request_dispatch_update_counts(req, call->modify); 2527 if (!NT_STATUS_IS_OK(status)) { 2528 return smbd_smb2_request_error(req, status); 2529 } 2530 2407 2531 if (call->as_root) { 2408 2532 SMB_ASSERT(call->fileid_ofs == 0); … … 2553 2677 } 2554 2678 2679 static void smbd_smb2_request_reply_update_counts(struct smbd_smb2_request *req) 2680 { 2681 struct smbXsrv_connection *xconn = req->xconn; 2682 const uint8_t *inhdr; 2683 uint16_t channel_sequence; 2684 struct smbXsrv_open *op; 2685 2686 if (!req->request_counters_updated) { 2687 return; 2688 } 2689 2690 if (xconn->protocol < PROTOCOL_SMB2_22) { 2691 return; 2692 } 2693 2694 if (req->compat_chain_fsp == NULL) { 2695 return; 2696 } 2697 2698 op = req->compat_chain_fsp->op; 2699 if (op == NULL) { 2700 return; 2701 } 2702 2703 inhdr = SMBD_SMB2_IN_HDR_PTR(req); 2704 channel_sequence = SVAL(inhdr, SMB2_HDR_CHANNEL_SEQUENCE); 2705 2706 if (op->global->channel_sequence == channel_sequence) { 2707 SMB_ASSERT(op->request_count > 0); 2708 op->request_count -= 1; 2709 } else { 2710 SMB_ASSERT(op->pre_request_count > 0); 2711 op->pre_request_count -= 1; 2712 } 2713 } 2714 2555 2715 static NTSTATUS smbd_smb2_request_reply(struct smbd_smb2_request *req) 2556 2716 { … … 2565 2725 req->subreq = NULL; 2566 2726 TALLOC_FREE(req->async_te); 2727 2728 /* MS-SMB2: 3.3.4.1 Sending Any Outgoing Message */ 2729 smbd_smb2_request_reply_update_counts(req); 2567 2730 2568 2731 if (req->do_encryption && -
vendor/current/source3/smbd/trans2.c
r988 r989 3378 3378 uint64_t dfree,dsize,bsize,block_size,sectors_per_unit; 3379 3379 data_len = 18; 3380 df_ret = get_dfree_info(conn, filename, &bsize, &dfree,3381 &d size);3380 df_ret = get_dfree_info(conn, &smb_fname, &bsize, 3381 &dfree, &dsize); 3382 3382 if (df_ret == (uint64_t)-1) { 3383 3383 return map_nt_error_from_unix(errno); … … 3529 3529 uint64_t dfree,dsize,bsize,block_size,sectors_per_unit; 3530 3530 data_len = 24; 3531 df_ret = get_dfree_info(conn, filename, &bsize, &dfree,3532 &d size);3531 df_ret = get_dfree_info(conn, &smb_fname, &bsize, 3532 &dfree, &dsize); 3533 3533 if (df_ret == (uint64_t)-1) { 3534 3534 return map_nt_error_from_unix(errno); … … 3563 3563 uint64_t dfree,dsize,bsize,block_size,sectors_per_unit; 3564 3564 data_len = 32; 3565 df_ret = get_dfree_info(conn, filename, &bsize, &dfree,3566 &d size);3565 df_ret = get_dfree_info(conn, &smb_fname, &bsize, 3566 &dfree, &dsize); 3567 3567 if (df_ret == (uint64_t)-1) { 3568 3568 return map_nt_error_from_unix(errno); … … 4153 4153 /* Here is where we must switch to posix pathname processing... */ 4154 4154 if (xconn->smb1.unix_info.client_cap_low & CIFS_UNIX_POSIX_PATHNAMES_CAP) { 4155 lp_set_posix_pathnames();4155 (void)lp_set_posix_pathnames(true); 4156 4156 mangle_change_to_posix(); 4157 4157 } … … 5701 5701 if (info_level == SMB_QUERY_FILE_UNIX_BASIC || 5702 5702 info_level == SMB_QUERY_FILE_UNIX_INFO2 || 5703 info_level == SMB_QUERY_FILE_UNIX_LINK) { 5703 info_level == SMB_QUERY_FILE_UNIX_LINK || 5704 req->posix_pathnames) { 5704 5705 ucf_flags |= UCF_UNIX_NAME_LOOKUP; 5705 5706 } … … 5762 5763 } 5763 5764 5764 if (INFO_LEVEL_IS_UNIX(info_level) ) {5765 if (INFO_LEVEL_IS_UNIX(info_level) || req->posix_pathnames) { 5765 5766 /* Always do lstat for UNIX calls. */ 5766 5767 if (SMB_VFS_LSTAT(conn, smb_fname_base) != 0) { … … 5808 5809 } 5809 5810 5810 if (INFO_LEVEL_IS_UNIX(info_level) ) {5811 if (INFO_LEVEL_IS_UNIX(info_level) || req->posix_pathnames) { 5811 5812 /* Always do lstat for UNIX calls. */ 5812 5813 if (SMB_VFS_LSTAT(conn, smb_fname)) { -
vendor/current/source3/smbd/vfs.c
r988 r989 594 594 len -= fsp->fsp_name->st.st_ex_size; 595 595 len /= 1024; /* Len is now number of 1k blocks needed. */ 596 space_avail = get_dfree_info(conn, fsp->fsp_name->base_name,597 596 space_avail = 597 get_dfree_info(conn, fsp->fsp_name, &bsize, &dfree, &dsize); 598 598 if (space_avail == (uint64_t)-1) { 599 599 return -1;
Note:
See TracChangeset
for help on using the changeset viewer.