Changeset 989 for vendor/current/source3/smbd/quotas.c
- Timestamp:
- Nov 25, 2016, 8:04:54 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 */
Note:
See TracChangeset
for help on using the changeset viewer.