mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
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 d9fdaae54e
)
This commit is contained in:
parent
06a50f5184
commit
18f3f5ff92
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user