From 18f3f5ff9282417b350873fd572e9e0c4d4bcea4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 15 Apr 2001 23:36:05 +0000 Subject: 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) --- source3/smbd/uid.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'source3') 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; -- cgit