diff options
author | Gerald Carter <jerry@samba.org> | 2004-07-06 21:43:12 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:52:08 -0500 |
commit | 600e904aa1ddf620df2ed6e5a02d0fe00e627dbb (patch) | |
tree | 4167ca72887ed629c930d157eb2420dbbe71425b /source3 | |
parent | 39354eaa6ca1559d2f9419734639391e08c181f0 (diff) | |
download | samba-600e904aa1ddf620df2ed6e5a02d0fe00e627dbb.tar.gz samba-600e904aa1ddf620df2ed6e5a02d0fe00e627dbb.tar.bz2 samba-600e904aa1ddf620df2ed6e5a02d0fe00e627dbb.zip |
r1370: BUG 1297 - prevent map_username() from being called twice during logon
(This used to be commit e1364ff774b62f46c0f50864695da49972352126)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/auth/auth_util.c | 32 | ||||
-rw-r--r-- | source3/smbd/sesssetup.c | 2 |
2 files changed, 19 insertions, 15 deletions
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c index ddfe88d28d..5e8f18881f 100644 --- a/source3/auth/auth_util.c +++ b/source3/auth/auth_util.c @@ -972,25 +972,25 @@ struct passwd *smb_getpwnam( char *domuser, fstring save_username, BOOL create ) { struct passwd *pw = NULL; char *p; - fstring mapped_username; - fstring strip_username; + fstring username; /* we only save a copy of the username it has been mangled by winbindd use default domain */ save_username[0] = '\0'; - - /* save a local copy of the username and run it through the - username map */ - fstrcpy( mapped_username, domuser ); - map_username( mapped_username ); + /* don't call map_username() here since it has to be done higher + up the stack so we don't call it mutliple times */ + + fstrcpy( username, domuser ); - p = strchr_m( mapped_username, *lp_winbind_separator() ); + p = strchr_m( username, *lp_winbind_separator() ); /* code for a DOMAIN\user string */ if ( p ) { + fstring strip_username; + pw = Get_Pwnam( domuser ); if ( pw ) { /* make sure we get the case of the username correct */ @@ -999,8 +999,10 @@ struct passwd *smb_getpwnam( char *domuser, fstring save_username, BOOL create ) if ( !strchr_m( pw->pw_name, *lp_winbind_separator() ) ) { char *domain; - domain = mapped_username; + /* split the domain and username into 2 strings */ *p = '\0'; + domain = username; + fstr_sprintf(save_username, "%s%c%s", domain, *lp_winbind_separator(), pw->pw_name); } else @@ -1011,26 +1013,26 @@ struct passwd *smb_getpwnam( char *domuser, fstring save_username, BOOL create ) } /* setup for lookup of just the username */ - /* remember that p and mapped_username are overlapping memory */ + /* remember that p and username are overlapping memory */ p++; fstrcpy( strip_username, p ); - fstrcpy( mapped_username, strip_username ); + fstrcpy( username, strip_username ); } /* just lookup a plain username */ - pw = Get_Pwnam(mapped_username); + pw = Get_Pwnam(username); /* Create local user if requested. */ if ( !pw && create ) { /* Don't add a machine account. */ - if (mapped_username[strlen(mapped_username)-1] == '$') + if (username[strlen(username)-1] == '$') return NULL; - auth_add_user_script(NULL, mapped_username); - pw = Get_Pwnam(mapped_username); + auth_add_user_script(NULL, username); + pw = Get_Pwnam(username); } /* one last check for a valid passwd struct */ diff --git a/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c index 49acd371a5..0122b662eb 100644 --- a/source3/smbd/sesssetup.c +++ b/source3/smbd/sesssetup.c @@ -242,6 +242,8 @@ static int reply_spnego_kerberos(connection_struct *conn, /* lookup the passwd struct, create a new user if necessary */ + map_username( user ); + pw = smb_getpwnam( user, real_username, True ); if (!pw) { |