Ignore:
Timestamp:
Nov 25, 2016, 8:04:54 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/smbd/quotas.c

    r988 r989  
    237237****************************************************************************/
    238238
    239 bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize,
    240                  uint64_t *dfree, uint64_t *dsize)
     239bool disk_quotas(connection_struct *conn, struct smb_filename *fname,
     240                 uint64_t *bsize, uint64_t *dfree, uint64_t *dsize)
    241241{
    242242        uid_t euser_id;
     
    255255        SMB_DEV_T devno;
    256256        bool found = false;
     257        const char *path = fname->base_name;
    257258
    258259        euser_id = geteuid();
    259260
    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;
    265262        DEBUG(5,("disk_quotas: looking for path \"%s\" devno=%x\n",
    266263                path, (unsigned int)devno));
     
    427424****************************************************************************/
    428425
    429 bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize,
    430                  uint64_t *dfree, uint64_t *dsize)
     426bool disk_quotas(connection_struct *conn, struct smb_filename *fname,
     427                 uint64_t *bsize, uint64_t *dfree, uint64_t *dsize)
    431428{
    432429  int r;
    433430  struct dqblk D;
    434431  uid_t euser_id;
     432  const char *path = fname->base_name;
    435433#if !defined(AIX)
    436434  char dev_disk[256];
    437   SMB_STRUCT_STAT S;
     435  SMB_STRUCT_STAT S = fname->st;
    438436
    439437  /* find the block device file */
     
    658656#else /* WITH_QUOTAS */
    659657
    660 bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize,
    661                  uint64_t *dfree, uint64_t *dsize)
     658bool disk_quotas(connection_struct *conn, struct smb_filename *fname,
     659                 uint64_t *bsize, uint64_t *dfree, uint64_t *dsize)
    662660{
    663661        (*bsize) = 512; /* This value should be ignored */
     
    677675   this file should be removed later
    678676   */
    679 bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize,
    680                  uint64_t *dfree, uint64_t *dsize)
     677bool disk_quotas(connection_struct *conn, struct smb_filename *fname,
     678                 uint64_t *bsize, uint64_t *dfree, uint64_t *dsize)
    681679{
    682680        int r;
     
    684682        unid_t id;
    685683
     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);
    686701        id.uid = geteuid();
    687702
    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        }
    690722
    691723        /* Use softlimit to determine disk space, except when it has been exceeded */
     
    723755       
    724756try_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
    725773        id.gid = getegid();
    726774
    727775        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);
    729778
    730779        /* Use softlimit to determine disk space, except when it has been exceeded */
Note: See TracChangeset for help on using the changeset viewer.