Changeset View
Changeset View
Standalone View
Standalone View
scripts/ssh/ssh-connect.php
| #!/usr/bin/env php | #!/usr/bin/env php | ||||
| <?php | <?php | ||||
| // This is a wrapper script for Git, Mercurial, and Subversion. It primarily | // This is a wrapper script for Git, Mercurial, and Subversion. It primarily | ||||
| // serves to inject "-o StrictHostKeyChecking=no" into the SSH arguments. | // serves to inject "-o StrictHostKeyChecking=no" into the SSH arguments. | ||||
| // In some cases, Subversion sends us SIGTERM. If we don't catch the signal and | |||||
| // react to it, we won't run object destructors by default and thus won't clean | |||||
| // up temporary files. Declare ticks so we can install a signal handler. | |||||
| declare(ticks=1); | |||||
| $root = dirname(dirname(dirname(__FILE__))); | $root = dirname(dirname(dirname(__FILE__))); | ||||
| require_once $root.'/scripts/__init_script__.php'; | require_once $root.'/scripts/__init_script__.php'; | ||||
| // Contrary to the documentation, Git may pass a "-p" flag. If it does, respect | // Contrary to the documentation, Git may pass a "-p" flag. If it does, respect | ||||
| // it and move it before the "--" argument. | // it and move it before the "--" argument. | ||||
| $args = new PhutilArgumentParser($argv); | $args = new PhutilArgumentParser($argv); | ||||
| $args->parsePartial( | $args->parsePartial( | ||||
| array( | array( | ||||
| array( | array( | ||||
| 'name' => 'port', | 'name' => 'port', | ||||
| 'short' => 'p', | 'short' => 'p', | ||||
| 'param' => pht('port'), | 'param' => pht('port'), | ||||
| 'help' => pht('Port number to connect to.'), | 'help' => pht('Port number to connect to.'), | ||||
| ), | ), | ||||
| )); | )); | ||||
| $unconsumed_argv = $args->getUnconsumedArgumentVector(); | $unconsumed_argv = $args->getUnconsumedArgumentVector(); | ||||
| if (function_exists('pcntl_signal')) { | |||||
| pcntl_signal(SIGTERM, 'ssh_connect_signal'); | |||||
| } | |||||
| function ssh_connect_signal($signo) { | |||||
| // This is just letting destructors fire. In particular, we want to clean | |||||
| // up any temporary files we wrote. See T10547. | |||||
| exit(128 + $signo); | |||||
| } | |||||
| $pattern = array(); | $pattern = array(); | ||||
| $arguments = array(); | $arguments = array(); | ||||
| $pattern[] = 'ssh'; | $pattern[] = 'ssh'; | ||||
| $pattern[] = '-o'; | $pattern[] = '-o'; | ||||
| $pattern[] = 'StrictHostKeyChecking=no'; | $pattern[] = 'StrictHostKeyChecking=no'; | ||||
| ▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines | |||||