Merge pull request #12590 from snipe/fixes/check_for_array_in_linux_setup

Fixes/check for array in linux setup
This commit is contained in:
snipe 2023-03-01 11:06:31 -08:00 committed by GitHub
commit d954c841e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -111,17 +111,17 @@ class SettingsController extends Controller
$start_settings['prod'] = true; $start_settings['prod'] = true;
} }
$start_settings['owner'] = '';
if (function_exists('posix_getpwuid')) { // Probably Linux if (function_exists('posix_getpwuid')) { // Probably Linux
$owner = posix_getpwuid(fileowner($_SERVER['SCRIPT_FILENAME'])); $owner = posix_getpwuid(fileowner($_SERVER['SCRIPT_FILENAME']));
$start_settings['owner'] = $owner['name']; // This *should* be an array, but we've seen this return a bool in some chrooted environments
} else { // Windows if (is_array($owner)) {
// TODO: Is there a way of knowing if a windows user has elevated permissions $start_settings['owner'] = $owner['name'];
// This just gets the user name, which likely isn't 'root' }
// $start_settings['owner'] = getenv('USERNAME');
$start_settings['owner'] = '';
} }
if (('root' === $start_settings['owner']) || ('0' === $start_settings['owner'])) { if (($start_settings['owner'] === 'root') || ($start_settings['owner'] === '0')) {
$start_settings['owner_is_admin'] = true; $start_settings['owner_is_admin'] = true;
} else { } else {
$start_settings['owner_is_admin'] = false; $start_settings['owner_is_admin'] = false;