Check running user lnms (#11726)

This commit is contained in:
Tony Murray 2020-05-30 09:23:21 -05:00 committed by GitHub
parent 90e95f160d
commit 6a4f2025c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -116,6 +116,20 @@ class Checks
}
}
/**
* Check the script is running as the right user (works before config is available)
*/
public static function runningUser()
{
if (function_exists('posix_getpwuid') && posix_getpwuid(posix_geteuid())['name'] !== get_current_user()) {
self::printMessage(
'Error: You must run lnms as the user ' . get_current_user(),
null,
true
);
}
}
private static function printMessage($title, $content, $exit = false)
{
$content = (array)$content;

3
lnms
View File

@ -15,6 +15,9 @@
require __DIR__.'/bootstrap/autoload.php';
// Check that we don't run this as the wrong user and break the install
\App\Checks::runningUser();
$app = require_once __DIR__.'/bootstrap/app.php';
/*