MDEV-11104 Fix client to correctly retrieve current user name on Windows

Prior to this patch name of the user was  read from environment variable
USER, with a fallback to 'ODBC', if the environment variable is not set.

The name of the env.variable is incorrect (USERNAME usually contains current
user's name,  but not USER), which made client to  always determine
current user as 'ODBC'.

The fix is to use GetUserName() instead.
This commit is contained in:
Vladislav Vaintroub 2016-10-22 07:34:23 +00:00
parent 39b7affcb1
commit fb38d26420

View file

@ -450,8 +450,9 @@ void read_user_name(char *name)
void read_user_name(char *name)
{
char *str=getenv("USER"); /* ODBC will send user variable */
strmake(name,str ? str : "ODBC", USERNAME_LENGTH);
DWORD len= USERNAME_LENGTH;
if (!GetUserName(name, &len))
strmov(name,"UNKNOWN_USER");
}
#endif