Pass cluster.instance to ssh-exec if it is defined

Summary: Ref T7034. This is a second special case, like commit hooks, where we need some help from Phabricator to make instance identity knowable.

Test Plan: Connected to an instance and ran SSH commands.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7034

Differential Revision: https://secure.phabricator.com/D11539
This commit is contained in:
epriestley
2015-01-28 10:17:40 -08:00
parent 170dc15c05
commit 834079f766
2 changed files with 16 additions and 6 deletions

View File

@@ -26,7 +26,17 @@ $bin = $root.'/bin/ssh-exec';
foreach ($keys as $ssh_key) {
$user = $ssh_key->getObject()->getUsername();
$cmd = csprintf('%s --phabricator-ssh-user %s', $bin, $user);
$key_argv = array();
$key_argv[] = '--phabricator-ssh-user';
$key_argv[] = $user;
$cmd = csprintf('%s %Ls', $bin, $key_argv);
$instance = PhabricatorEnv::getEnvConfig('cluster.instance');
if (strlen($instance)) {
$cmd = csprintf('PHABRICATOR_INSTANCE=%s %C', $instance, $cmd);
}
// This is additional escaping for the SSH 'command="..."' string.
$cmd = addcslashes($cmd, '"\\');