mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-10-06 08:19:07 +00:00
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
This commit is contained in:
parent
ec3cca20aa
commit
676536d310
@ -46,17 +46,27 @@ 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."
|
||||
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
|
||||
|
||||
# Check if sudo is available
|
||||
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
|
||||
detect_os() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user