FIX Prioritise posix_getuid() when attempting to find current process owner (#10137)

This commit is contained in:
Loz Calver 2021-11-07 22:56:44 +00:00 committed by GitHub
parent 766a024a03
commit b1eb9514d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,17 +36,20 @@ class TempFolder
*/
public static function getTempFolderUsername()
{
$user = Environment::getEnv('APACHE_RUN_USER');
$user = '';
if (function_exists('posix_getpwuid') && function_exists('posix_getuid')) {
$userDetails = posix_getpwuid(posix_getuid());
$user = $userDetails['name'];
}
if (!$user) {
$user = Environment::getEnv('APACHE_RUN_USER');
}
if (!$user) {
$user = Environment::getEnv('USER');
}
if (!$user) {
$user = Environment::getEnv('USERNAME');
}
if (!$user && function_exists('posix_getpwuid') && function_exists('posix_getuid')) {
$userDetails = posix_getpwuid(posix_getuid());
$user = $userDetails['name'];
}
if (!$user) {
$user = 'unknown';
}