diff --git a/app/Checks.php b/app/Checks.php index 40f0177a29..d1af6fa5a7 100644 --- a/app/Checks.php +++ b/app/Checks.php @@ -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; diff --git a/lnms b/lnms index ea2b9795c7..321b209195 100755 --- a/lnms +++ b/lnms @@ -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'; /*