summaryrefslogtreecommitdiff
path: root/libmysql
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2016-10-22 07:34:23 +0000
committerVladislav Vaintroub <wlad@mariadb.com>2016-10-22 07:34:23 +0000
commitfb38d2642011c574cc9103ae1a1f9dd77f7f027e (patch)
tree816fe2f0293e526d7bd395823194abdc472d3268 /libmysql
parent39b7affcb13f9f508242e90ecd5db03b3bb3cb85 (diff)
downloadmariadb-git-fb38d2642011c574cc9103ae1a1f9dd77f7f027e.tar.gz
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.
Diffstat (limited to 'libmysql')
-rw-r--r--libmysql/libmysql.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 446f1da0b0c..3a08ea26b1d 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -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