Fixed fallback to getlogin for android

This commit is contained in:
akallabeth 2020-06-02 14:41:37 +02:00 committed by Armin Novak
parent 308c2c3544
commit caff01877d
2 changed files with 8 additions and 0 deletions

View File

@ -600,8 +600,12 @@ static BOOL isAutomountLocation(const char* path)
uid_t uid = getuid(); uid_t uid = getuid();
char uname[MAX_PATH] = { 0 }; char uname[MAX_PATH] = { 0 };
#ifndef getlogin_r
strncpy(uname, getlogin(), sizeof(uname));
#else
if (getlogin_r(uname, sizeof(uname)) != 0) if (getlogin_r(uname, sizeof(uname)) != 0)
return FALSE; return FALSE;
#endif
if (!path) if (!path)
return FALSE; return FALSE;

View File

@ -206,8 +206,12 @@ BOOL GetUserNameExA(EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, PULONG
switch (NameFormat) switch (NameFormat)
{ {
case NameSamCompatible: case NameSamCompatible:
#ifndef getlogin_r
strncpy(login, getlogin(), sizeof(login));
#else
if (getlogin_r(login, sizeof(login)) != 0) if (getlogin_r(login, sizeof(login)) != 0)
return FALSE; return FALSE;
#endif
length = strlen(login); length = strlen(login);
if (*nSize >= length) if (*nSize >= length)