chg: try to get user via posix method first

pull/7939/head
Luciano Righetti 2021-11-10 08:37:06 +01:00
parent 30bb52d705
commit 69a69e6e10
1 changed files with 10 additions and 1 deletions

View File

@ -55,7 +55,7 @@ class StartWorkerShell extends AppShell
[
'pid' => getmypid(),
'queue' => $this->args[0],
'user' => trim(shell_exec('whoami'))
'user' => $this->whoami()
]
);
@ -97,4 +97,13 @@ class StartWorkerShell extends AppShell
exit;
}
}
private function whoami(): string
{
if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
return posix_getpwuid(posix_geteuid())['name'];
} else {
return trim(shell_exec('whoami'));
}
}
}