summaryrefslogtreecommitdiff
path: root/source3/smbd/uid.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-04-15 23:36:05 +0000
committerJeremy Allison <jra@samba.org>2001-04-15 23:36:05 +0000
commit18f3f5ff9282417b350873fd572e9e0c4d4bcea4 (patch)
treeb971c1cccaea3192f8ef9f01b453a8bb2350e492 /source3/smbd/uid.c
parent06a50f51845bf639f7abd47cf39638054f255131 (diff)
downloadsamba-18f3f5ff9282417b350873fd572e9e0c4d4bcea4.tar.gz
samba-18f3f5ff9282417b350873fd572e9e0c4d4bcea4.tar.bz2
samba-18f3f5ff9282417b350873fd572e9e0c4d4bcea4.zip
Fixed potential bug in "become_guest" pointed out by elrond. Get_Pwnam()
returns a pointer to changable storage so ensure we save the details and don't use the pointer directly. Jeremy. (This used to be commit d9fdaae54ee3a267aebd02ff6058a98aefc084c2)
Diffstat (limited to 'source3/smbd/uid.c')
-rw-r--r--source3/smbd/uid.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c
index 02522a37a2..da4c538319 100644
--- a/source3/smbd/uid.c
+++ b/source3/smbd/uid.c
@@ -33,19 +33,26 @@ extern struct current_user current_user;
BOOL become_guest(void)
{
static struct passwd *pass=NULL;
-
- if (!pass)
+ static uid_t guest_uid = (uid_t)-1;
+ static gid_t guest_gid = (gid_t)-1;
+ static fstring guest_name;
+
+ if (!pass) {
pass = Get_Pwnam(lp_guestaccount(-1),True);
- if (!pass)
- return(False);
+ if (!pass)
+ return(False);
+ guest_uid = pass->pw_uid;
+ guest_gid = pass->pw_gid;
+ fstrcpy(guest_name, pass->pw_name);
+ }
#ifdef AIX
/* MWW: From AIX FAQ patch to WU-ftpd: call initgroups before
setting IDs */
- initgroups(pass->pw_name, (gid_t)pass->pw_gid);
+ initgroups(guest_name, guest_gid);
#endif
- set_sec_ctx(pass->pw_uid, pass->pw_gid, 0, NULL, NULL);
+ set_sec_ctx(guest_uid, guest_gid, 0, NULL, NULL);
current_user.conn = NULL;
current_user.vuid = UID_FIELD_INVALID;