diff --git a/application/utils.inc.php b/application/utils.inc.php index dfcb9034f..934a7a874 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -2172,4 +2172,14 @@ class utils { return APPROOT.'env-'.utils::GetCurrentEnvironment().'/'.$sModule.'/'; } + + public static function GetCurrentUserName() + { + if (function_exists('posix_getpwuid')) + { + return posix_getpwuid(posix_geteuid())['name']; + } + + return getenv('username'); + } } diff --git a/webservices/cron.php b/webservices/cron.php index 88ab503ac..1b56450d2 100644 --- a/webservices/cron.php +++ b/webservices/cron.php @@ -92,7 +92,7 @@ function RunTask($oProcess, BackgroundTask $oTask, $oStartDate, $iTimeLimit) // Record (when starting) that this task was started, just in case it crashes during the execution $oTask->Set('latest_run_date', $oDateStarted->format('Y-m-d H:i:s')); // Record the current user running the cron - $oTask->Set('system_user', getenv("username")); + $oTask->Set('system_user', utils::GetCurrentUserName()); $oTask->DBUpdate(); $sMessage = $oProcess->Process($iTimeLimit); }