summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2000-08-28 06:50:45 +0000
committerTim Potter <tpot@samba.org>2000-08-28 06:50:45 +0000
commit8b889a84a2b318d377e219345df2ecf9a160d2a2 (patch)
tree27261be2b93bdf9b485a5ed65eaf4f6ce7d89f7c /source3
parentd12f3fea7529c03b6a3650e7aa8b4b47a445d548 (diff)
downloadsamba-8b889a84a2b318d377e219345df2ecf9a160d2a2.tar.gz
samba-8b889a84a2b318d377e219345df2ecf9a160d2a2.tar.bz2
samba-8b889a84a2b318d377e219345df2ecf9a160d2a2.zip
Oops - missed a file.
(This used to be commit 5aed84b74981a4f4fcc4d466ef03178eff22ba85)
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/sec_ctx.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/source3/smbd/sec_ctx.c b/source3/smbd/sec_ctx.c
index f185ffcdaa..0cab2a7e9c 100644
--- a/source3/smbd/sec_ctx.c
+++ b/source3/smbd/sec_ctx.c
@@ -211,6 +211,48 @@ NT_USER_TOKEN *dup_nt_token(NT_USER_TOKEN *ptoken)
}
/****************************************************************************
+ Initialize the groups a user belongs to.
+****************************************************************************/
+
+BOOL initialise_groups(char *user, uid_t uid, gid_t gid)
+{
+ struct sec_ctx *prev_ctx_p;
+ BOOL result = True;
+
+ become_root();
+
+ /* Call initgroups() to get user groups */
+
+ if (initgroups(user,gid) == -1) {
+ DEBUG(0,("Unable to initgroups. Error was %s\n", strerror(errno) ));
+ if (getuid() == 0) {
+ if (gid < 0 || gid > 32767 || uid < 0 || uid > 32767) {
+ DEBUG(0,("This is probably a problem with the account %s\n", user));
+ }
+ }
+ result = False;
+ goto done;
+ }
+
+ /* Store groups in previous user's security context. This will
+ always work as the become_root() call increments the stack
+ pointer. */
+
+ prev_ctx_p = &sec_ctx_stack[sec_ctx_stack_ndx - 1];
+
+ safe_free(prev_ctx_p->groups);
+ prev_ctx_p->groups = NULL;
+ prev_ctx_p->ngroups = 0;
+
+ get_current_groups(&prev_ctx_p->ngroups, &prev_ctx_p->groups);
+
+ done:
+ unbecome_root();
+
+ return result;
+}
+
+/****************************************************************************
Create a new security context on the stack. It is the same as the old
one. User changes are done using the set_sec_ctx() function.
****************************************************************************/