summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-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;