Changeset View
Changeset View
Standalone View
Standalone View
scripts/ssh/ssh-auth.php
Show All 30 Lines | |||||
// the path on disk to "ssh-exec" is arbitrarily mutable at runtime. See T12397. | // the path on disk to "ssh-exec" is arbitrarily mutable at runtime. See T12397. | ||||
$cache = PhabricatorCaches::getMutableCache(); | $cache = PhabricatorCaches::getMutableCache(); | ||||
$authstruct_key = PhabricatorAuthSSHKeyQuery::AUTHSTRUCT_CACHEKEY; | $authstruct_key = PhabricatorAuthSSHKeyQuery::AUTHSTRUCT_CACHEKEY; | ||||
$authstruct_raw = $cache->getKey($authstruct_key); | $authstruct_raw = $cache->getKey($authstruct_key); | ||||
$authstruct = null; | $authstruct = null; | ||||
if (strlen($authstruct_raw)) { | if ($authstruct_raw !== null && strlen($authstruct_raw)) { | ||||
try { | try { | ||||
$authstruct = phutil_json_decode($authstruct_raw); | $authstruct = phutil_json_decode($authstruct_raw); | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
// Ignore any issues with the cached data; we'll just rebuild the | // Ignore any issues with the cached data; we'll just rebuild the | ||||
// structure below. | // structure below. | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | |||||
$lines = array(); | $lines = array(); | ||||
foreach ($authstruct['keys'] as $key_struct) { | foreach ($authstruct['keys'] as $key_struct) { | ||||
$key_argv = $key_struct['argv']; | $key_argv = $key_struct['argv']; | ||||
$key = $key_struct['key']; | $key = $key_struct['key']; | ||||
$type = $key_struct['type']; | $type = $key_struct['type']; | ||||
$cmd = csprintf('%s %Ls', $bin, $key_argv); | $cmd = csprintf('%s %Ls', $bin, $key_argv); | ||||
if (strlen($instance)) { | if ($instance !== null && strlen($instance)) { | ||||
$cmd = csprintf('PHABRICATOR_INSTANCE=%s %C', $instance, $cmd); | $cmd = csprintf('PHABRICATOR_INSTANCE=%s %C', $instance, $cmd); | ||||
} | } | ||||
// This is additional escaping for the SSH 'command="..."' string. | // This is additional escaping for the SSH 'command="..."' string. | ||||
$cmd = addcslashes($cmd, '"\\'); | $cmd = addcslashes($cmd, '"\\'); | ||||
$options = array( | $options = array( | ||||
'command="'.$cmd.'"', | 'command="'.$cmd.'"', | ||||
Show All 15 Lines |