]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: dfree - ignore quota if not enforced
authorUri Simchoni <uri@samba.org>
Wed, 27 Apr 2016 20:22:25 +0000 (23:22 +0300)
committerKarolin Seeger <kseeger@samba.org>
Wed, 1 Jun 2016 14:23:59 +0000 (16:23 +0200)
When calculating free disk space, do not take user quota
into account if quota is globally not enforced on the file
system.

This is meant to fix a specific problem with XFS. One might
say "why don't you fix the XFS-specific code instead?". The
reason for that is that getting and setting quota must not
be affected by whether quota is actually enforced. NTFS has
the same notion of separating quota accounting (and being
able to configure / retrieve configured quota), from quota
enforcement.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11937

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat May 28 00:09:05 CEST 2016 on sn-devel-144

(cherry picked from commit 42151f6fa25fefc8a6ae7388ca85379c07c93e1e)

Autobuild-User(v4-4-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-4-test): Wed Jun  1 16:23:59 CEST 2016 on sn-devel-144

selftest/knownfail
source3/smbd/quotas.c

index a2e5ff45d26aaa93443a001f842c665628a3d527..997d29cba82bc6774eff955f06bf821ce9c11c9a 100644 (file)
 # we don't allow auth_level_connect anymore...
 #
 ^samba3.blackbox.rpcclient.*ncacn_np.*with.*connect.*rpcclient # we don't allow auth_level_connect anymore
-#new disk-free tests fail the code
-^samba3.blackbox.dfree_quota \(fileserver\).Test dfree share root quota not enforced\(fileserver\)
index 8e41416892998d7c84b1742469687d376b42d81b..d71b0a06c90cc516f591d7ff3e325d2c66ea214f 100644 (file)
@@ -683,9 +683,24 @@ bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize,
        SMB_DISK_QUOTA D;
        unid_t id;
 
-       id.uid = geteuid();
+       /*
+        * First of all, check whether user quota is
+        * enforced. If the call fails, assume it is
+        * not enforced.
+        */
+       ZERO_STRUCT(D);
+       id.uid = -1;
+       r = SMB_VFS_GET_QUOTA(conn, path, SMB_USER_FS_QUOTA_TYPE, id, &D);
+       if (r == -1 && errno != ENOSYS) {
+               goto try_group_quota;
+       }
+       if (r == 0 && (D.qflags & QUOTAS_DENY_DISK) == 0) {
+               goto try_group_quota;
+       }
 
        ZERO_STRUCT(D);
+       id.uid = geteuid();
+
        r = SMB_VFS_GET_QUOTA(conn, path, SMB_USER_QUOTA_TYPE, id, &D);
 
        /* Use softlimit to determine disk space, except when it has been exceeded */
@@ -722,6 +737,21 @@ bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize,
        return True;
        
 try_group_quota:
+       /*
+        * First of all, check whether group quota is
+        * enforced. If the call fails, assume it is
+        * not enforced.
+        */
+       ZERO_STRUCT(D);
+       id.gid = -1;
+       r = SMB_VFS_GET_QUOTA(conn, path, SMB_GROUP_FS_QUOTA_TYPE, id, &D);
+       if (r == -1 && errno != ENOSYS) {
+               return false;
+       }
+       if (r == 0 && (D.qflags & QUOTAS_DENY_DISK) == 0) {
+               return false;
+       }
+
        id.gid = getegid();
 
        ZERO_STRUCT(D);