Provide a more helpful message if a user connects via raw SSH
Summary: We currently print a fairly vague, technical message which is ambiguous about indicating success or an error if you aren't familiar with SSH. Test Plan: $ ssh -T dweller@localhost phabricator-ssh-exec: Welcome to Phabricator. You are logged in as epriestley. You haven't specified a command to run. This means you're requesting an interactive shell, but Phabricator does not provide an interactive shell over SSH. Usually, you should run a command like `git clone` or `hg push` rather than connecting directly with SSH. Supported commands are: conduit, git-receive-pack, git-upload-pack, hg, svnserve. Reviewers: btrahan, dctrwatson Reviewed By: dctrwatson CC: aran Differential Revision: https://secure.phabricator.com/D7854
This commit is contained in:
@@ -58,11 +58,28 @@ try {
|
|||||||
$original_command = getenv('SSH_ORIGINAL_COMMAND');
|
$original_command = getenv('SSH_ORIGINAL_COMMAND');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$workflows = id(new PhutilSymbolLoader())
|
||||||
|
->setAncestorClass('PhabricatorSSHWorkflow')
|
||||||
|
->loadObjects();
|
||||||
|
|
||||||
|
$workflow_names = mpull($workflows, 'getName', 'getName');
|
||||||
|
|
||||||
// Now, rebuild the original command.
|
// Now, rebuild the original command.
|
||||||
$original_argv = id(new PhutilShellLexer())
|
$original_argv = id(new PhutilShellLexer())
|
||||||
->splitArguments($original_command);
|
->splitArguments($original_command);
|
||||||
if (!$original_argv) {
|
if (!$original_argv) {
|
||||||
throw new Exception("No interactive logins.");
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
"Welcome to Phabricator.\n\n".
|
||||||
|
"You are logged in as %s.\n\n".
|
||||||
|
"You haven't specified a command to run. This means you're requesting ".
|
||||||
|
"an interactive shell, but Phabricator does not provide an ".
|
||||||
|
"interactive shell over SSH.\n\n".
|
||||||
|
"Usually, you should run a command like `git clone` or `hg push` ".
|
||||||
|
"rather than connecting directly with SSH.\n\n".
|
||||||
|
"Supported commands are: %s.",
|
||||||
|
$user->getUsername(),
|
||||||
|
implode(', ', $workflow_names)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$ssh_log->setData(
|
$ssh_log->setData(
|
||||||
@@ -78,15 +95,6 @@ try {
|
|||||||
|
|
||||||
$original_args = new PhutilArgumentParser($original_argv);
|
$original_args = new PhutilArgumentParser($original_argv);
|
||||||
|
|
||||||
$workflows = array(
|
|
||||||
new ConduitSSHWorkflow(),
|
|
||||||
new DiffusionSSHSubversionServeWorkflow(),
|
|
||||||
new DiffusionSSHMercurialServeWorkflow(),
|
|
||||||
new DiffusionSSHGitUploadPackWorkflow(),
|
|
||||||
new DiffusionSSHGitReceivePackWorkflow(),
|
|
||||||
);
|
|
||||||
|
|
||||||
$workflow_names = mpull($workflows, 'getName', 'getName');
|
|
||||||
if (empty($workflow_names[$command])) {
|
if (empty($workflow_names[$command])) {
|
||||||
throw new Exception("Invalid command.");
|
throw new Exception("Invalid command.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user