Differential D25149 Diff 567 src/applications/config/controller/PhabricatorConfigConsoleController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/controller/PhabricatorConfigConsoleController.php
Show First 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | private function loadVersions(PhabricatorUser $viewer) { | ||||
$all_libraries = PhutilBootloader::getInstance()->getAllLibraries(); | $all_libraries = PhutilBootloader::getInstance()->getAllLibraries(); | ||||
// This puts the core libraries at the top: | // This puts the core libraries at the top: | ||||
$other_libraries = array_diff($all_libraries, $specs); | $other_libraries = array_diff($all_libraries, $specs); | ||||
$specs = array_merge($specs, $other_libraries); | $specs = array_merge($specs, $other_libraries); | ||||
$log_futures = array(); | $log_futures = array(); | ||||
$remote_futures = array(); | $remote_futures = array(); | ||||
// Git commands needs the HOME environment variable | |||||
// to read their .gitconfig - otherwise you cannot | |||||
// fix errors like "detected dubious ownership" | |||||
// https://we.phorge.it/T15282 | |||||
$commands_env = array(); | |||||
$webserver_home = self::webserverHomePath(); | |||||
if ($webserver_home) { | |||||
$commands_env['HOME'] = $webserver_home; | |||||
} | |||||
foreach ($specs as $lib) { | foreach ($specs as $lib) { | ||||
$root = dirname(phutil_get_library_root($lib)); | $root = dirname(phutil_get_library_root($lib)); | ||||
$log_command = csprintf( | $log_command = csprintf( | ||||
'git log --format=%s -n 1 --', | 'git log --format=%s -n 1 --', | ||||
'%H %ct'); | '%H %ct'); | ||||
$remote_command = csprintf( | $remote_command = csprintf( | ||||
'git remote -v'); | 'git remote -v'); | ||||
$log_futures[$lib] = id(new ExecFuture('%C', $log_command)) | $log_futures[$lib] = id(new ExecFuture('%C', $log_command)) | ||||
->setEnv($commands_env) | |||||
->setCWD($root); | ->setCWD($root); | ||||
$remote_futures[$lib] = id(new ExecFuture('%C', $remote_command)) | $remote_futures[$lib] = id(new ExecFuture('%C', $remote_command)) | ||||
->setEnv($commands_env) | |||||
->setCWD($root); | ->setCWD($root); | ||||
} | } | ||||
$all_futures = array_merge($log_futures, $remote_futures); | $all_futures = array_merge($log_futures, $remote_futures); | ||||
id(new FutureIterator($all_futures)) | id(new FutureIterator($all_futures)) | ||||
->resolveAll(); | ->resolveAll(); | ||||
▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | $table_view = id(new AphrontTableView($rows)) | ||||
)); | )); | ||||
return id(new PHUIObjectBoxView()) | return id(new PHUIObjectBoxView()) | ||||
->setHeaderText(pht('Other Version Information')) | ->setHeaderText(pht('Other Version Information')) | ||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ||||
->appendChild($table_view); | ->appendChild($table_view); | ||||
} | } | ||||
/** | |||||
* Get the HOME of the current webserver user | |||||
* | |||||
* Example: In mod_php it returns something like "/var/www/html" | |||||
* Example: In PHP-FPM it returns the home of the configured pool user | |||||
* | |||||
* @return string|null|false | |||||
avivey: can we avoid returning `false` here? it's just confusing. | |||||
*/ | |||||
private static function webserverHomePath() { | |||||
$home = null; | |||||
// Almost surely Microsoft Windows does not have these functions | |||||
if (function_exists('posix_geteuid') && function_exists('posix_getpwuid')) { | |||||
// This is almost surely Unix/Linux | |||||
// Let's read the "effective" user UID (not the "real" one) | |||||
// Example: in PHP-FPM we want the effective pool user, not root daemon | |||||
// https://we.phorge.it/T15298 | |||||
$webserver_user = posix_getpwuid(posix_geteuid()); | |||||
if ($webserver_user !== false) { | |||||
$home = $webserver_user['dir']; | |||||
Done Inline Actionsreturn ASAP, don't keep the value for later. avivey: return ASAP, don't keep the value for later. | |||||
} | |||||
} else { | |||||
// This is almost surely Microsoft Windows | |||||
Done Inline ActionsPhorge doesn't run on Windows. avivey: Phorge doesn't run on Windows. | |||||
// Let's read this environment var | |||||
// if missing, it's just false | |||||
$home = getenv('USERPROFILE'); | |||||
} | |||||
return $home; | |||||
} | |||||
} | } |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
can we avoid returning false here? it's just confusing.