--- samba-3.6.6.orig/source3/modules/vfs_acl_common.c 2011-12-25 03:56:28.000000000 +0100 +++ samba-3.6.6/source3/modules/vfs_acl_common.c 2011-12-25 04:00:30.000000000 +0100 @@ -483,7 +483,29 @@ static NTSTATUS inherit_new_acl(vfs_hand is_directory); size_t size; - if (!inheritable_components && !inherit_owner) { + /* SGID handling */ + bool inherit_sgid = false; + struct smb_filename parent_fname = { 0, }; + int res; + if (!parent_dirname(ctx, fsp->fsp_name->base_name, &parent_fname.base_name, NULL)) { + DEBUG(1, ("parent_dirname failed\n")); + /* TODO */ + } + + res = SMB_VFS_NEXT_STAT(handle, &parent_fname); + if (res == -1) { + DEBUG(10, ("NEXT_STAT(%s) failed: %s\n", parent_fname.base_name, + strerror(errno))); + /* TODO */ + } + TALLOC_FREE(parent_fname.base_name); + if ((parent_fname.st.st_ex_mode & S_ISGID) != 0) { + /* SGID to inherit */ + inherit_sgid = true; + group_sid = parent_desc->group_sid; + } + + if (!inheritable_components && !inherit_owner && !inherit_sgid) { /* Nothing to inherit and not setting owner. */ return NT_STATUS_OK; }