From 90d2460cf0e644e82650763c502332e5adad27e7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 17 Aug 2001 05:38:44 +0000 Subject: [PATCH] One less getpwnam() call... Andrew Bartlett (This used to be commit 204da7ba96b0c562bab5e5536728a0378077bdc7) --- source3/smbd/password.c | 13 +++---------- source3/smbd/reply.c | 4 +++- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/source3/smbd/password.c b/source3/smbd/password.c index 4aa5a0211eb..b4d22a38500 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -203,10 +203,9 @@ tell random client vuid's (normally zero) from valid vuids. ****************************************************************************/ int register_vuid(uid_t uid,gid_t gid, char *unix_name, char *requested_name, - char *domain,BOOL guest) + char *domain,BOOL guest, char* full_name) { user_struct *vuser = NULL; - struct passwd *pwfile; /* for getting real name from passwd file */ /* Ensure no vuid gets registered in share level security. */ if(lp_security() == SEC_SHARE) @@ -243,6 +242,8 @@ int register_vuid(uid_t uid,gid_t gid, char *unix_name, char *requested_name, fstrcpy(vuser->user.unix_name,unix_name); fstrcpy(vuser->user.smb_name,requested_name); fstrcpy(vuser->user.domain,domain); + fstrcpy(vuser->user.full_name, full_name); + DEBUG(3, ("User name: %s\tReal name: %s\n",vuser->user.unix_name,vuser->user.full_name)); vuser->n_groups = 0; vuser->groups = NULL; @@ -260,14 +261,6 @@ int register_vuid(uid_t uid,gid_t gid, char *unix_name, char *requested_name, DLIST_ADD(validated_users, vuser); - DEBUG(3,("uid %d registered to name %s\n",(int)uid,unix_name)); - - DEBUG(3, ("Clearing default real name\n")); - if ((pwfile=sys_getpwnam(vuser->user.unix_name))!= NULL) { - DEBUG(3, ("User name: %s\tReal name: %s\n",vuser->user.unix_name,pwfile->pw_gecos)); - fstrcpy(vuser->user.full_name, pwfile->pw_gecos); - } - if (!session_claim(vuser->vuid)) { DEBUG(1,("Failed to claim session for vuid=%d\n", vuser->vuid)); invalidate_vuid(vuser->vuid); diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 3ba1d4eea94..47a363ae8d1 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -567,6 +567,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int int sess_vuid; gid_t gid; uid_t uid; + char* full_name; int smb_bufsize; int smb_apasslen = 0; pstring smb_apasswd; @@ -879,6 +880,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int } gid = pw->pw_gid; uid = pw->pw_uid; + full_name = pw->pw_gecos; } if (guest) @@ -887,7 +889,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int /* register the name and uid as being validated, so further connections to a uid can get through without a password, on the same VC */ - sess_vuid = register_vuid(uid,gid,user,current_user_info.smb_name,domain,guest); + sess_vuid = register_vuid(uid,gid,user,current_user_info.smb_name,domain,guest, full_name); if (sess_vuid == -1) { return(ERROR(ERRDOS,ERRnoaccess));