Skip to content

Commit

Permalink
MDEV-11104 Fix client to correctly retrieve current user name on Windows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vaintroub committed Oct 22, 2016
1 parent 39b7aff commit fb38d26
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libmysql/libmysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fb38d26

Please sign in to comment.