1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

smbd: use owner uid for free disk calculation if owner is inherited

If "inherit owner" is enabled, then new files created under a
directory shall consume the quota of the directory's owner, so
the free disk calculation should take that quota into account,
not the quota of the user creating the file.

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

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Uri Simchoni 2016-08-11 23:37:42 +03:00 committed by Jeremy Allison
parent bd2ec88dca
commit ea73bcd87b

View File

@ -506,8 +506,25 @@ bool disk_quotas(connection_struct *conn, struct smb_filename *fname,
ZERO_STRUCT(D);
id.uid = geteuid();
r = SMB_VFS_GET_QUOTA(conn, fname->base_name, SMB_USER_QUOTA_TYPE, id,
&D);
/* if new files created under this folder get this
* folder's UID, then available space is governed by
* the quota of the folder's UID, not the creating user.
*/
if (lp_inherit_owner(SNUM(conn)) != INHERIT_OWNER_NO &&
id.uid != fname->st.st_ex_uid && id.uid != sec_initial_uid()) {
int save_errno;
id.uid = fname->st.st_ex_uid;
become_root();
r = SMB_VFS_GET_QUOTA(conn, fname->base_name,
SMB_USER_QUOTA_TYPE, id, &D);
save_errno = errno;
unbecome_root();
errno = save_errno;
} else {
r = SMB_VFS_GET_QUOTA(conn, fname->base_name,
SMB_USER_QUOTA_TYPE, id, &D);
}
if (r == -1) {
goto try_group_quota;