Differential D21759 Diff 51879 src/applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php
Show First 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | if ($submodules) { | ||||
// continues to work fine and we've seen at least two cases of this in | // continues to work fine and we've seen at least two cases of this in | ||||
// the wild. | // the wild. | ||||
list($err, $contents) = $repository->execLocalCommand( | list($err, $contents) = $repository->execLocalCommand( | ||||
'cat-file blob -- %s:.gitmodules', | 'cat-file blob -- %s:.gitmodules', | ||||
$commit); | $commit); | ||||
if (!$err) { | if (!$err) { | ||||
$tmp = new TempFile(); | |||||
Filesystem::writeFile($tmp, $contents); | // NOTE: After T13673, the user executing "git" may not be the same | ||||
list($module_info) = $repository->execxLocalCommand( | // as the user this process is running as (usually the webserver user), | ||||
'config -l -f %s', | // so we can't reliably use a temporary file: the daemon user may not | ||||
$tmp); | // be able to use it. | ||||
// Use "--file -" to read from stdin instead. If this fails in some | |||||
// older versions of Git, we could exempt this particular command from | |||||
// sudoing to the daemon user. | |||||
$future = $repository->getLocalCommandFuture('config -l --file - --'); | |||||
$future->write($contents); | |||||
list($module_info) = $future->resolvex(); | |||||
$dict = array(); | $dict = array(); | ||||
$lines = explode("\n", trim($module_info)); | $lines = explode("\n", trim($module_info)); | ||||
foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
list($key, $value) = explode('=', $line, 2); | list($key, $value) = explode('=', $line, 2); | ||||
$parts = explode('.', $key); | $parts = explode('.', $key); | ||||
$dict[$key] = $value; | $dict[$key] = $value; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 322 Lines • Show Last 20 Lines |