Skip to content

A free open source IT asset/license management system

Prevent users from running this as root/admin user

sniped585a34a2688
diff --git a/upgrade.php b/upgrade.php
index 42c4735cfb..368bbeccd5 100644
--- a/upgrade.php
+++ b/upgrade.php
@@ -1,6 +1,13 @@
<?php
(PHP_SAPI !== 'cli' || isset($_SERVER['HTTP_USER_AGENT'])) && die('Access denied.');
+$pwu_data = posix_getpwuid(posix_geteuid());
+$username = $pwu_data['name'];
+
+if (($username=='root') || ($username=='admin')) {
+ die("\nERROR: This script should not be run as root/admin. Exiting.\n\n");
+}
+
echo "Welcome to the Snipe-IT upgrader.\n\n";
echo "Please note that this script will not download the latest Snipe-IT \n";
echo "files for you, it simply runs the standard composer and artisan \n";