mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-02 03:52:49 -05:00
When looking for a local username on Windows, if we can get hold of the
NameUserPrincipal, use that; this avoids an issue with SSPI/GSSAPI where the user logged in to the local machine with a different case of username to the (case-sensitive) Kerberos username. Falls back to GetUserName as before if that doesn't work (for machines not on a domain, and Win9x). Based on a patch by SebastianUnger. [originally from svn r8909]
This commit is contained in:
10
settings.c
10
settings.c
@ -84,9 +84,13 @@ int get_remote_username(Config *cfg, char *user, size_t len)
|
||||
if (cfg->username_from_env) {
|
||||
/* Use local username. */
|
||||
char *luser = get_username();
|
||||
strncpy(user, luser, len);
|
||||
user[len-1] = '\0';
|
||||
sfree(luser);
|
||||
if (luser) {
|
||||
strncpy(user, luser, len);
|
||||
user[len-1] = '\0';
|
||||
sfree(luser);
|
||||
} else {
|
||||
*user = '\0';
|
||||
}
|
||||
} else {
|
||||
*user = '\0';
|
||||
}
|
||||
|
Reference in New Issue
Block a user