Changeset View
Changeset View
Standalone View
Standalone View
scripts/ssh/ssh-exec.php
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | if (!$remote_address) { | ||||
'variable. Device authentication is accepted only from trusted '. | 'variable. Device authentication is accepted only from trusted '. | ||||
'sources.', | 'sources.', | ||||
'SSH_CLIENT')); | 'SSH_CLIENT')); | ||||
} | } | ||||
if (!PhabricatorEnv::isClusterAddress($remote_address)) { | if (!PhabricatorEnv::isClusterAddress($remote_address)) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'This request originates from outside of the Phabricator cluster '. | 'This request originates from outside of the cluster address range. '. | ||||
'address range. Requests signed with a trusted device key must '. | 'Requests signed with a trusted device key must originate from '. | ||||
'originate from trusted hosts.')); | 'trusted hosts.')); | ||||
} | } | ||||
$device = id(new AlmanacDeviceQuery()) | $device = id(new AlmanacDeviceQuery()) | ||||
->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
->withNames(array($device_name)) | ->withNames(array($device_name)) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$device) { | if (!$device) { | ||||
throw new Exception( | throw new Exception( | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | $workflows = id(new PhutilClassMapQuery()) | ||||
->setAncestorClass('PhabricatorSSHWorkflow') | ->setAncestorClass('PhabricatorSSHWorkflow') | ||||
->setUniqueMethod('getName') | ->setUniqueMethod('getName') | ||||
->execute(); | ->execute(); | ||||
$command_list = array_keys($workflows); | $command_list = array_keys($workflows); | ||||
$command_list = implode(', ', $command_list); | $command_list = implode(', ', $command_list); | ||||
$error_lines = array(); | $error_lines = array(); | ||||
$error_lines[] = pht('Welcome to Phabricator.'); | $error_lines[] = pht( | ||||
'Welcome to %s.', | |||||
PlatformSymbols::getPlatformServerName()); | |||||
$error_lines[] = pht( | $error_lines[] = pht( | ||||
'You are logged in as %s.', | 'You are logged in as %s.', | ||||
$user_name); | $user_name); | ||||
if (!$original_argv) { | if (!$original_argv) { | ||||
$error_lines[] = pht( | $error_lines[] = pht( | ||||
'You have not specified a command to run. This means you are requesting '. | 'You have not specified a command to run. This means you are requesting '. | ||||
'an interactive shell, but Phabricator does not provide interactive '. | 'an interactive shell, but this server does not provide interactive '. | ||||
'shells over SSH.'); | 'shells over SSH.'); | ||||
$error_lines[] = pht( | $error_lines[] = pht( | ||||
'(Usually, you should run a command like "git clone" or "hg push" '. | '(Usually, you should run a command like "git clone" or "hg push" '. | ||||
'instead of connecting directly with SSH.)'); | 'instead of connecting directly with SSH.)'); | ||||
$error_lines[] = pht( | $error_lines[] = pht( | ||||
'Supported commands are: %s.', | 'Supported commands are: %s.', | ||||
$command_list); | $command_list); | ||||
Show All 17 Lines | try { | ||||
$parseable_argv = $original_argv; | $parseable_argv = $original_argv; | ||||
array_unshift($parseable_argv, 'phabricator-ssh-exec'); | array_unshift($parseable_argv, 'phabricator-ssh-exec'); | ||||
$parsed_args = new PhutilArgumentParser($parseable_argv); | $parsed_args = new PhutilArgumentParser($parseable_argv); | ||||
if (empty($workflows[$command])) { | if (empty($workflows[$command])) { | ||||
$error_lines[] = pht( | $error_lines[] = pht( | ||||
'You have specified the command "%s", but that command is not '. | 'You have specified the command "%s", but that command is not '. | ||||
'supported by Phabricator. As received by Phabricator, your entire '. | 'supported by this server. As received by this server, your entire '. | ||||
'argument list was:', | 'argument list was:', | ||||
$command); | $command); | ||||
$error_lines[] = csprintf(' $ ssh ... -- %Ls', $parseable_argv); | $error_lines[] = csprintf(' $ ssh ... -- %Ls', $parseable_argv); | ||||
$error_lines[] = pht( | $error_lines[] = pht( | ||||
'Supported commands are: %s.', | 'Supported commands are: %s.', | ||||
$command_list); | $command_list); | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |