2013-10-26 19:46:09 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DiffusionSSHGitUploadPackWorkflow
|
|
|
|
extends DiffusionSSHGitWorkflow {
|
|
|
|
|
|
|
|
public function didConstruct() {
|
|
|
|
$this->setName('git-upload-pack');
|
|
|
|
$this->setArguments(
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'name' => 'dir',
|
|
|
|
'wildcard' => true,
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2013-11-11 21:19:06 +01:00
|
|
|
protected function executeRepositoryOperations() {
|
2013-10-26 19:46:09 +02:00
|
|
|
$args = $this->getArgs();
|
2013-11-11 21:19:06 +01:00
|
|
|
$path = head($args->getArg('dir'));
|
|
|
|
$repository = $this->loadRepository($path);
|
2013-10-26 21:18:54 +02:00
|
|
|
|
|
|
|
$future = new ExecFuture('git-upload-pack %s', $repository->getLocalPath());
|
|
|
|
|
2013-11-11 21:27:28 +01:00
|
|
|
$err = $this->newPassthruCommand()
|
Generalize SSH passthru for repository hosting
Summary:
Ref T2230. In Git, we can determine if a command is read-only or read/write from the command itself, but this isn't the case in Mercurial or SVN.
For Mercurial and SVN, we need to proxy the protocol that's coming over the wire, look at each request from the client, and then check if it's a read or a write. To support this, provide a more flexible version of `passthruIO`.
The way this will work is:
- The SSH IO channel is wrapped in a `ProtocolChannel` which can parse the the incoming stream into message objects.
- The `willWriteCallback` will look at those messages and determine if they're reads or writes.
- If they're writes, it will check for write permission.
- If we're good to go, the message object is converted back into a byte stream and handed to the underlying command.
Test Plan: Executed `git clone`, `git clone --depth 3`, `git push` (against no-write repo, got error), `git push` (against valid repo).
Reviewers: btrahan
Reviewed By: btrahan
CC: hach-que, asherkin, aran
Maniphest Tasks: T2230
Differential Revision: https://secure.phabricator.com/D7551
2013-11-11 21:12:21 +01:00
|
|
|
->setIOChannel($this->getIOChannel())
|
|
|
|
->setCommandChannelFromExecFuture($future)
|
|
|
|
->execute();
|
2013-11-11 21:27:28 +01:00
|
|
|
|
|
|
|
if (!$err) {
|
|
|
|
$this->waitForGitClient();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $err;
|
2013-10-26 21:18:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-26 19:46:09 +02:00
|
|
|
}
|