From 676536d310cc51a2d370ba72d93a00aab4848925 Mon Sep 17 00:00:00 2001 From: johnysigma Date: Mon, 4 Aug 2025 16:03:04 +0300 Subject: [PATCH] Implement root execution with security warning - Add security warning when running as root - Require explicit confirmation in interactive mode - Allow automatic proceeding in non-interactive mode - Use sudo alias approach for clean root execution - Maintain security consciousness while enabling automation - Prevent accidental root execution without user awareness --- scripts/install-debros-network.sh | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/scripts/install-debros-network.sh b/scripts/install-debros-network.sh index 4427086..9bbc7bc 100755 --- a/scripts/install-debros-network.sh +++ b/scripts/install-debros-network.sh @@ -46,16 +46,26 @@ warning() { echo -e "${YELLOW}[WARNING]${NOCOLOR} $1" } -# Check if running as root +# Check if running as root and warn user if [[ $EUID -eq 0 ]]; then - error "This script should not be run as root. Please run as a regular user with sudo privileges." - exit 1 -fi - -# Check if sudo is available -if ! command -v sudo &>/dev/null; then - error "sudo command not found. Please ensure you have sudo privileges." - exit 1 + warning "Running as root is not recommended for security reasons." + if [ "$NON_INTERACTIVE" != true ]; then + read -rp "Are you sure you want to continue? (yes/no): " ROOT_CONFIRM + if [[ "$ROOT_CONFIRM" != "yes" ]]; then + error "Installation cancelled for security reasons." + exit 1 + fi + else + log "Non-interactive mode: proceeding with root (use at your own risk)" + fi + # Create sudo alias that does nothing when running as root + alias sudo='' +else + # Check if sudo is available for non-root users + if ! command -v sudo &>/dev/null; then + error "sudo command not found. Please ensure you have sudo privileges." + exit 1 + fi fi # Detect OS