コード例 #1
0
ファイル: SudoDecorator.php プロジェクト: mlebkowski/crane
 public function decorateCommand($command, CommandExecutor $executor)
 {
     $command = $this->parent ? $this->parent->decorateCommand($command, $executor) : $command;
     if ($this->onlyForCommands) {
         list($arg) = explode(' ', $command);
         if (false === in_array($arg, $this->onlyForCommands)) {
             return $command;
         }
     }
     return 'sudo -- ' . $command;
 }
コード例 #2
0
ファイル: SSHDecorator.php プロジェクト: mlebkowski/crane
 public function decorateCommand($command, CommandExecutor $executor)
 {
     $command = $this->parent ? $this->parent->decorateCommand($command, $executor) : $command;
     $sshCommand = 'ssh -A';
     if ($executor->getTty()) {
         $sshCommand .= ' -t';
     }
     if ($this->getVerbose()) {
         $sshCommand .= ' -v';
     }
     if ($this->getPort()) {
         $sshCommand .= ' -p ' . $this->getPort();
     }
     if ($this->getIdentityFile()) {
         $sshCommand .= ' -i ' . escapeshellarg($this->getIdentityFile());
     }
     if ($this->getUser()) {
         $target = escapeshellarg($this->getUser() . '@' . $this->getHost());
     } else {
         $target = escapeshellarg($this->getHost());
     }
     return sprintf("%s %s %s", $sshCommand, $target, escapeshellarg($command));
 }