Page MenuHomeIsabelle/Phabricator
Diviner Phabricator Tech Docs PhabricatorSSHPassthruCommand

final class PhabricatorSSHPassthruCommand
Phabricator Technical Documentation ()

Proxy an IO channel to an underlying command, with optional callbacks. This is a mostly a more general version of PhutilExecPassthru. This class is used to proxy Git, SVN and Mercurial traffic to the commands which can actually serve it.

Largely, this just reads an IO channel (like stdin from SSH) and writes the results into a command channel (like a command's stdin). Then it reads the command channel (like the command's stdout) and writes it into the IO channel (like stdout from SSH):

IO Channel        Command Channel
stdin       ->    stdin
stdout      <-    stdout
stderr      <-    stderr

You can provide read and write callbacks which are invoked as data is passed through this class. They allow you to inspect and modify traffic.

IO Channel     Passthru        Command Channel
stdout     ->  willWrite   ->  stdin
stdin      <-  willRead    <-  stdout
stderr     <-  (identity)  <-  stderr

Primarily, this means:

  • the IO Channel can be a PhutilProtocolChannel if the write callback can convert protocol messages into strings; and
  • the write callback can inspect and reject requests over the channel, e.g. to enforce policies.

In practice, this is used when serving repositories to check each command issued over SSH and determine if it is a read command or a write command. Writes can then be checked for appropriate permissions.

Methods

public function setCommandChannelFromExecFuture($exec_future)

This method is not documented.
Parameters
ExecFuture$exec_future
Return
wild

public function setIOChannel($io_channel)

This method is not documented.
Parameters
PhutilChannel$io_channel
Return
wild

public function setErrorChannel($error_channel)

This method is not documented.
Parameters
PhutilChannel$error_channel
Return
wild

public function setWillReadCallback($will_read_callback)

This method is not documented.
Parameters
$will_read_callback
Return
wild

public function setWillWriteCallback($will_write_callback)

This method is not documented.
Parameters
$will_write_callback
Return
wild

public function writeErrorIOCallback($channel, $data)

This method is not documented.
Parameters
PhutilChannel$channel
$data
Return
wild

public function setPauseIOReads($pause)

This method is not documented.
Parameters
$pause
Return
wild

public function execute()

This method is not documented.
Return
wild

public function writeIORead($in_message)

This method is not documented.
Parameters
$in_message
Return
wild

public function willWriteData($message)

This method is not documented.
Parameters
$message
Return
wild

public function willReadData($message)

This method is not documented.
Parameters
$message
Return
wild