From 8cce2645486d1e60c76d2a1527de6c47dabebee0 Mon Sep 17 00:00:00 2001 From: Arvid Requate Date: Wed, 26 Sep 2012 18:46:09 +0200 Subject: [PATCH] s3:smbd fix SGID bit inheritance --- source3/smbd/open.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 10c855c..29d91f4 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -3468,7 +3468,29 @@ static NTSTATUS inherit_new_acl(files_struct *fsp) inheritable_components = sd_has_inheritable_components(parent_desc, fsp->is_directory); - 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; } -- 1.7.10.4