You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-08 14:02:17 +03:00
Fix for CONC-441:
Instead of getlogin() we first try to determine the current user of the process by calling getpwuid(). If for some reaon getpwuid() will fail, we will use getlogin() instead.
This commit is contained in:
@@ -22,3 +22,4 @@ CHECK_FUNCTION_EXISTS (nl_langinfo HAVE_NL_LANGINFO)
|
||||
CHECK_FUNCTION_EXISTS (setlocale HAVE_SETLOCALE)
|
||||
CHECK_FUNCTION_EXISTS (poll HAVE_POLL)
|
||||
CHECK_FUNCTION_EXISTS (getpwuid HAVE_GETPWUID)
|
||||
CHECK_FUNCTION_EXISTS (cuserid HAVE_CUSERID)
|
||||
|
@@ -45,6 +45,7 @@
|
||||
#cmakedefine HAVE_THR_YIELD 1
|
||||
#cmakedefine HAVE_VASPRINTF 1
|
||||
#cmakedefine HAVE_VSNPRINTF 1
|
||||
#cmakedefine HAVE_CUSERID 1
|
||||
|
||||
/*
|
||||
* types and sizes
|
||||
|
@@ -497,7 +497,7 @@ struct passwd *getpwuid(uid_t);
|
||||
char* getlogin(void);
|
||||
#endif
|
||||
|
||||
#if !defined(MSDOS) && ! defined(VMS) && !defined(_WIN32) && !defined(OS2)
|
||||
#if !defined(_WIN32)
|
||||
void read_user_name(char *name)
|
||||
{
|
||||
if (geteuid() == 0)
|
||||
@@ -507,11 +507,12 @@ void read_user_name(char *name)
|
||||
#ifdef HAVE_GETPWUID
|
||||
struct passwd *skr;
|
||||
const char *str;
|
||||
if ((str=getlogin()) == NULL)
|
||||
{
|
||||
if ((skr=getpwuid(geteuid())) != NULL)
|
||||
{
|
||||
str=skr->pw_name;
|
||||
else if (!(str=getenv("USER")) && !(str=getenv("LOGNAME")) &&
|
||||
} else if ((str=getlogin()) == NULL)
|
||||
{
|
||||
if (!(str=getenv("USER")) && !(str=getenv("LOGNAME")) &&
|
||||
!(str=getenv("LOGIN")))
|
||||
str="UNKNOWN_USER";
|
||||
}
|
||||
|
Reference in New Issue
Block a user