3 final class PhabricatorSSHLog
extends Phobject
{
7 public static function getLog() {
9 $path = PhabricatorEnv
::getEnvConfig('log.ssh.path');
10 $format = PhabricatorEnv
::getEnvConfig('log.ssh.format');
13 "[%D]\t%p\t%h\t%r\t%s\t%S\t%u\t%C\t%U\t%c\t%T\t%i\t%o");
15 // NOTE: Path may be null. We still create the log, it just won't write
20 'h' => php_uname('n'),
23 'I' => PhabricatorEnv
::getEnvConfig('cluster.instance'),
26 $sudo_user = PhabricatorEnv
::getEnvConfig('phd.user');
27 if ($sudo_user !== null && strlen($sudo_user)) {
28 $data['S'] = $sudo_user;
31 if (function_exists('posix_geteuid')) {
32 $system_uid = posix_geteuid();
33 $system_info = posix_getpwuid($system_uid);
34 $data['s'] = idx($system_info, 'name');
37 $client = getenv('SSH_CLIENT');
38 if (strlen($client)) {
39 $remote_address = head(explode(' ', $client));
40 $data['r'] = $remote_address;
43 $log = id(new PhutilDeferredLog($path, $format))
44 ->setFailQuietly(true)