From a2bddb20ed078c3e1b9cb60a7420b3d107898f52 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 6 May 1998 01:34:51 +0000 Subject: Fixes for the %U and %G problems people have reported. Essentially, multiple session_setup_and_X's may be done to an smbd. As there is only one global variable containing the requested connection name (sessionsetup_user), then any subsequent sessionsetups overwrite this name (causing %U and %G to get the wrong name). This is particularly common when an NT client does a null session setup to get a browse list after the user has connected, but before a share has been mounted. These changes store the requested_name in the vuid structure (so this only really works for user level and above security) and copies this name back into the global variable before the standard_sub call. Jeremy. (This used to be commit b5187ad6a3b3af9fbbeee8bced0ab16b41e9825b) --- source3/smbd/password.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source3/smbd/password.c') diff --git a/source3/smbd/password.c b/source3/smbd/password.c index 5127539466..53ed8c85f1 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -251,7 +251,7 @@ register a uid/name pair as being valid and that a valid password has been given. vuid is biased by an offset. This allows us to tell random client vuid's (normally zero) from valid vuids. ****************************************************************************/ -uint16 register_vuid(int uid,int gid, char *name,BOOL guest) +uint16 register_vuid(int uid,int gid, char *unix_name, char *requested_name, BOOL guest) { user_struct *vuser; struct passwd *pwfile; /* for getting real name from passwd file */ @@ -298,7 +298,8 @@ uint16 register_vuid(int uid,int gid, char *name,BOOL guest) vuser->uid = uid; vuser->gid = gid; vuser->guest = guest; - strcpy(vuser->name,name); + fstrcpy(vuser->name,unix_name); + fstrcpy(vuser->requested_name,requested_name); vuser->n_sids = 0; vuser->sids = NULL; @@ -310,13 +311,13 @@ uint16 register_vuid(int uid,int gid, char *name,BOOL guest) /* Find all the groups this uid is in and store them. Used by become_user() */ - setup_groups(name,uid,gid, + setup_groups(unix_name,uid,gid, &vuser->n_groups, &vuser->igroups, &vuser->groups, &vuser->attrs); - DEBUG(3,("uid %d registered to name %s\n",uid,name)); + DEBUG(3,("uid %d registered to name %s\n",uid,unix_name)); DEBUG(3, ("Clearing default real name\n")); fstrcpy(vuser->real_name, "\0"); -- cgit