Changeset View
Changeset View
Standalone View
Standalone View
scripts/ssh/ssh-connect.php
| Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | |||||
| if ($as_device) { | if ($as_device) { | ||||
| $pattern[] = '-l %R'; | $pattern[] = '-l %R'; | ||||
| $arguments[] = AlmanacKeys::getClusterSSHUser(); | $arguments[] = AlmanacKeys::getClusterSSHUser(); | ||||
| $pattern[] = '-i %R'; | $pattern[] = '-i %R'; | ||||
| $arguments[] = AlmanacKeys::getKeyPath('device.key'); | $arguments[] = AlmanacKeys::getKeyPath('device.key'); | ||||
| } | } | ||||
| // Subversion passes us a host in the form "domain.com:port", which is not | |||||
| // valid for normal SSH but which we can parse into a valid "-p" flag. | |||||
| $passthru_args = $unconsumed_argv; | |||||
| $host = array_shift($passthru_args); | |||||
| $parts = explode(':', $host, 2); | |||||
| $host = $parts[0]; | |||||
| $port = $args->getArg('port'); | $port = $args->getArg('port'); | ||||
| if (!$port) { | |||||
| if (count($parts) == 2) { | |||||
| $port = $parts[1]; | |||||
| } | |||||
| } | |||||
| if ($port) { | if ($port) { | ||||
| $pattern[] = '-p %d'; | $pattern[] = '-p %d'; | ||||
| $arguments[] = $port; | $arguments[] = $port; | ||||
| } | } | ||||
| $pattern[] = '--'; | $pattern[] = '--'; | ||||
| $passthru_args = $unconsumed_argv; | $pattern[] = '%s'; | ||||
| $arguments[] = $host; | |||||
| foreach ($passthru_args as $passthru_arg) { | foreach ($passthru_args as $passthru_arg) { | ||||
| $pattern[] = '%s'; | $pattern[] = '%s'; | ||||
| $arguments[] = $passthru_arg; | $arguments[] = $passthru_arg; | ||||
| } | } | ||||
| $pattern = implode(' ', $pattern); | $pattern = implode(' ', $pattern); | ||||
| array_unshift($arguments, $pattern); | array_unshift($arguments, $pattern); | ||||
| $err = newv('PhutilExecPassthru', $arguments) | $err = newv('PhutilExecPassthru', $arguments) | ||||
| ->execute(); | ->execute(); | ||||
| exit($err); | exit($err); | ||||