1
0
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:
Jacob Nevins
2010-03-24 20:12:25 +00:00
parent 4a8c45f9f7
commit c18b150623
3 changed files with 61 additions and 15 deletions

View File

@ -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';
}