From: Uri Simchoni Date: Wed, 27 Apr 2016 20:22:25 +0000 (+0300) Subject: smbd: dfree - ignore quota if not enforced X-Git-Tag: tdb-1.3.10~1047 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=42151f6fa25fefc8a6ae7388ca85379c07c93e1e;p=thirdparty%2Fsamba.git smbd: dfree - ignore quota if not enforced 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 Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Sat May 28 00:09:05 CEST 2016 on sn-devel-144 --- diff --git a/selftest/knownfail b/selftest/knownfail index fd86a9c998f..2f2d6bffbae 100644 --- a/selftest/knownfail +++ b/selftest/knownfail @@ -330,5 +330,3 @@ # ad_dc requires signing # ^samba4.smb.signing.*disabled.*signing=off.*\(ad_dc\) -#new disk-free tests fail the code -^samba3.blackbox.dfree_quota \(fileserver\).Test dfree share root quota not enforced\(fileserver\) diff --git a/source3/smbd/quotas.c b/source3/smbd/quotas.c index 58d8460641c..20f74b4aceb 100644 --- a/source3/smbd/quotas.c +++ b/source3/smbd/quotas.c @@ -489,9 +489,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 */ @@ -528,6 +543,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);