mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
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:
parent
39b7affcb1
commit
fb38d26420
1 changed files with 3 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue