Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionServeController.php
Show First 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | private function serveRequest(AphrontRequest $request) { | ||||
// If authentication credentials have been provided, try to find a user | // If authentication credentials have been provided, try to find a user | ||||
// that actually matches those credentials. | // that actually matches those credentials. | ||||
// We require both the username and password to be nonempty, because Git | // We require both the username and password to be nonempty, because Git | ||||
// won't prompt users who provide a username but no password otherwise. | // won't prompt users who provide a username but no password otherwise. | ||||
// See T10797 for discussion. | // See T10797 for discussion. | ||||
$have_user = strlen(idx($_SERVER, 'PHP_AUTH_USER')); | $http_user = idx($_SERVER, 'PHP_AUTH_USER'); | ||||
$have_pass = strlen(idx($_SERVER, 'PHP_AUTH_PW')); | $http_pass = idx($_SERVER, 'PHP_AUTH_PW'); | ||||
$have_user = $http_user !== null && strlen($http_user); | |||||
$have_pass = $http_pass !== null && strlen($http_pass); | |||||
if ($have_user && $have_pass) { | if ($have_user && $have_pass) { | ||||
$username = $_SERVER['PHP_AUTH_USER']; | $username = $http_user; | ||||
$password = new PhutilOpaqueEnvelope($_SERVER['PHP_AUTH_PW']); | $password = new PhutilOpaqueEnvelope($http_pass); | ||||
// Try Git LFS auth first since we can usually reject it without doing | // Try Git LFS auth first since we can usually reject it without doing | ||||
// any queries, since the username won't match the one we expect or the | // any queries, since the username won't match the one we expect or the | ||||
// request won't be LFS. | // request won't be LFS. | ||||
$viewer = $this->authenticateGitLFSUser( | $viewer = $this->authenticateGitLFSUser( | ||||
$username, | $username, | ||||
$password, | $password, | ||||
$identifier); | $identifier); | ||||
▲ Show 20 Lines • Show All 320 Lines • ▼ Show 20 Lines | switch ($repository->getVersionControlSystem()) { | ||||
if ($path == '/git-upload-pack') { | if ($path == '/git-upload-pack') { | ||||
return true; | return true; | ||||
} | } | ||||
break; | break; | ||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: | case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: | ||||
$cmd = $request->getStr('cmd'); | $cmd = $request->getStr('cmd'); | ||||
if ($cmd === null) { | |||||
return false; | |||||
} | |||||
if ($cmd == 'batch') { | if ($cmd == 'batch') { | ||||
$cmds = idx($this->getMercurialArguments(), 'cmds'); | $cmds = idx($this->getMercurialArguments(), 'cmds'); | ||||
return DiffusionMercurialWireProtocol::isReadOnlyBatchCommand($cmds); | if ($cmds !== null) { | ||||
return DiffusionMercurialWireProtocol::isReadOnlyBatchCommand( | |||||
$cmds); | |||||
} | |||||
} | } | ||||
return DiffusionMercurialWireProtocol::isReadOnlyCommand($cmd); | return DiffusionMercurialWireProtocol::isReadOnlyCommand($cmd); | ||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | ||||
break; | break; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | if ($err) { | ||||
if ($this->isValidGitShallowCloneResponse($stdout, $stderr)) { | if ($this->isValidGitShallowCloneResponse($stdout, $stderr)) { | ||||
// Ignore the error if the response passes this special check for | // Ignore the error if the response passes this special check for | ||||
// validity. | // validity. | ||||
$err = 0; | $err = 0; | ||||
} | } | ||||
} | } | ||||
if ($err) { | if ($err) { | ||||
return new PhabricatorVCSResponse( | return new PhabricatorVCSResponse( | ||||
epriestley: Unrelated change. | |||||
500, | 500, | ||||
pht( | pht( | ||||
'Error %d: %s', | 'Error %d: %s', | ||||
$err, | $err, | ||||
phutil_utf8ize($stderr))); | phutil_utf8ize($stderr))); | ||||
} | } | ||||
return id(new DiffusionGitResponse())->setGitData($stdout); | return id(new DiffusionGitResponse())->setGitData($stdout); | ||||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Lines | private function serveMercurialRequest( | ||||
list($err, $stdout, $stderr) = id(new ExecFuture('%C', $command)) | list($err, $stdout, $stderr) = id(new ExecFuture('%C', $command)) | ||||
->setEnv($env, true) | ->setEnv($env, true) | ||||
->setCWD($repository->getLocalPath()) | ->setCWD($repository->getLocalPath()) | ||||
->write("{$cmd}\n{$args}{$input}") | ->write("{$cmd}\n{$args}{$input}") | ||||
->resolve(); | ->resolve(); | ||||
if ($err) { | if ($err) { | ||||
return new PhabricatorVCSResponse( | return new PhabricatorVCSResponse( | ||||
Not Done Inline ActionsUnrelated change. epriestley: Unrelated change. | |||||
500, | 500, | ||||
pht('Error %d: %s', $err, $stderr)); | pht('Error %d: %s', $err, $stderr)); | ||||
} | } | ||||
if ($cmd == 'getbundle' || | if ($cmd == 'getbundle' || | ||||
$cmd == 'changegroup' || | $cmd == 'changegroup' || | ||||
$cmd == 'changegroupsubset') { | $cmd == 'changegroupsubset') { | ||||
// We're not completely sure that "changegroup" and "changegroupsubset" | // We're not completely sure that "changegroup" and "changegroupsubset" | ||||
▲ Show 20 Lines • Show All 452 Lines • Show Last 20 Lines |
Unrelated change.