diff options
author | Christof Schmitt <cs@samba.org> | 2019-08-13 13:40:48 -0700 |
---|---|---|
committer | Christof Schmitt <cs@samba.org> | 2019-08-14 16:27:43 +0000 |
commit | 02b7e6c79b866ba0d339cad6c4fc9eb0d0be8968 (patch) | |
tree | 76713d92cde7ecb65f4573baf969c8abdae91e50 /source3/smbd/quotas.c | |
parent | 9b7825d2d387bcb2515154418a990669ab96358d (diff) | |
download | samba-02b7e6c79b866ba0d339cad6c4fc9eb0d0be8968.tar.gz |
quotas: Check group quota for directory when SGID is set
On directories with the "set group id" (SGID) bit is set, new files and
subfolders will be created with the group of the directory, and not with
the primary group of the user. Checking for free space in this case
should query the group quota for the gid of the directory.
Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source3/smbd/quotas.c')
-rw-r--r-- | source3/smbd/quotas.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/source3/smbd/quotas.c b/source3/smbd/quotas.c index c9472682f8f..604631f81d6 100644 --- a/source3/smbd/quotas.c +++ b/source3/smbd/quotas.c @@ -447,11 +447,26 @@ try_group_quota: return false; } - id.gid = getegid(); - ZERO_STRUCT(D); - r = SMB_VFS_GET_QUOTA(conn, fname, SMB_GROUP_QUOTA_TYPE, id, - &D); + + /* + * If new files created under this folder get this folder's + * GID, then available space is governed by the quota of the + * folder's GID, not the primary group of the creating user. + */ + if (VALID_STAT(fname->st) && + S_ISDIR(fname->st.st_ex_mode) && + fname->st.st_ex_mode & S_ISGID) { + id.gid = fname->st.st_ex_gid; + become_root(); + r = SMB_VFS_GET_QUOTA(conn, fname, SMB_GROUP_QUOTA_TYPE, id, + &D); + unbecome_root(); + } else { + id.gid = getegid(); + r = SMB_VFS_GET_QUOTA(conn, fname, SMB_GROUP_QUOTA_TYPE, id, + &D); + } if (r == -1) { return False; |