You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +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:
@@ -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,13 +507,14 @@ void read_user_name(char *name)
|
||||
#ifdef HAVE_GETPWUID
|
||||
struct passwd *skr;
|
||||
const char *str;
|
||||
if ((str=getlogin()) == NULL)
|
||||
if ((skr=getpwuid(geteuid())) != NULL)
|
||||
{
|
||||
if ((skr=getpwuid(geteuid())) != NULL)
|
||||
str=skr->pw_name;
|
||||
else if (!(str=getenv("USER")) && !(str=getenv("LOGNAME")) &&
|
||||
!(str=getenv("LOGIN")))
|
||||
str="UNKNOWN_USER";
|
||||
str=skr->pw_name;
|
||||
} else if ((str=getlogin()) == NULL)
|
||||
{
|
||||
if (!(str=getenv("USER")) && !(str=getenv("LOGNAME")) &&
|
||||
!(str=getenv("LOGIN")))
|
||||
str="UNKNOWN_USER";
|
||||
}
|
||||
ma_strmake(name,str,USERNAME_LENGTH);
|
||||
#elif defined(HAVE_CUSERID)
|
||||
|
Reference in New Issue
Block a user