Skip to content

Commit 10162ad

Browse files
author
epriestley
committed
Support an SSH error log
Summary: Ref T13624. Depends on D21578. In "sshd" subprocess contexts, use "PhutilErrorLog" to direct errors to both stderr and, if configured, a logfile on disk. Test Plan: - Confiugured an error log. - Forced `ssh-auth` to fatal. - Saw errors on stderr and in log. Maniphest Tasks: T13624 Differential Revision: https://secure.phabricator.com/D21579
1 parent f970b35 commit 10162ad

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

scripts/ssh/ssh-auth.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
$root = dirname(dirname(dirname(__FILE__)));
55
require_once $root.'/scripts/init/init-script.php';
66

7+
$error_log = id(new PhutilErrorLog())
8+
->setLogName(pht('SSH Error Log'))
9+
->setLogPath(PhabricatorEnv::getEnvConfig('log.ssh-error.path'))
10+
->activateLog();
11+
712
// TODO: For now, this is using "parseParital()", not "parse()". This allows
813
// the script to accept (and ignore) additional arguments. This preserves
914
// backward compatibility until installs have time to migrate to the new

scripts/ssh/ssh-exec.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
$ssh_start_time = microtime(true);
55

66
$root = dirname(dirname(dirname(__FILE__)));
7-
require_once $root.'/scripts/__init_script__.php';
7+
require_once $root.'/scripts/init/init-script.php';
8+
9+
$error_log = id(new PhutilErrorLog())
10+
->setLogName(pht('SSH Error Log'))
11+
->setLogPath(PhabricatorEnv::getEnvConfig('log.ssh-error.path'))
12+
->activateLog();
813

914
$ssh_log = PhabricatorSSHLog::getLog();
1015

src/applications/config/option/PhabricatorAccessLogConfigOptions.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,20 @@ public function getOptions() {
116116
->setLocked(true)
117117
->setSummary(pht('SSH log format.'))
118118
->setDescription($ssh_desc),
119+
$this->newOption('log.ssh-error.path', 'string', null)
120+
->setLocked(true)
121+
->setSummary(pht('SSH error log location.'))
122+
->setDescription(
123+
pht(
124+
'To enable the Phabricator SSH error log, specify a path. Errors '.
125+
'occurring in contexts where Phabricator is serving SSH requests '.
126+
'will be written to this log.'.
127+
"\n\n".
128+
'If not set, no log will be written.'))
129+
->addExample(null, pht('Disable SSH error log.'))
130+
->addExample(
131+
'/var/log/phabricator/ssh-error.log',
132+
pht('Write SSH error log here.')),
119133
);
120134
}
121135

0 commit comments

Comments
 (0)