Commit fb38d264 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

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.
parent 39b7affc
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment