summaryrefslogtreecommitdiffstats
path: root/source3/smbd/sec_ctx.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd/sec_ctx.c')
-rw-r--r--source3/smbd/sec_ctx.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/source3/smbd/sec_ctx.c b/source3/smbd/sec_ctx.c
index e3aac77d8e..bbd801d76b 100644
--- a/source3/smbd/sec_ctx.c
+++ b/source3/smbd/sec_ctx.c
@@ -184,11 +184,15 @@ void set_sec_ctx(uid_t uid, gid_t gid, int ngroups, gid_t *groups)
#ifdef HAVE_SETGROUPS
sys_setgroups(ngroups, groups);
+#endif
sec_ctx_stack[sec_ctx_stack_ndx].ngroups = ngroups;
+
+ if (sec_ctx_stack[sec_ctx_stack_ndx].groups != NULL)
+ free(sec_ctx_stack[sec_ctx_stack_ndx].groups);
+
sec_ctx_stack[sec_ctx_stack_ndx].groups =
memdup(groups, sizeof(gid_t) * ngroups);
-#endif
become_id(uid, gid);