mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-10-06 12:09: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,16 +46,26 @@ warning() {
|
|||||||
echo -e "${YELLOW}[WARNING]${NOCOLOR} $1"
|
echo -e "${YELLOW}[WARNING]${NOCOLOR} $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if running as root
|
# Check if running as root and warn user
|
||||||
if [[ $EUID -eq 0 ]]; then
|
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."
|
||||||
exit 1
|
if [ "$NON_INTERACTIVE" != true ]; then
|
||||||
fi
|
read -rp "Are you sure you want to continue? (yes/no): " ROOT_CONFIRM
|
||||||
|
if [[ "$ROOT_CONFIRM" != "yes" ]]; then
|
||||||
# Check if sudo is available
|
error "Installation cancelled for security reasons."
|
||||||
if ! command -v sudo &>/dev/null; then
|
exit 1
|
||||||
error "sudo command not found. Please ensure you have sudo privileges."
|
fi
|
||||||
exit 1
|
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
|
fi
|
||||||
|
|
||||||
# Detect OS
|
# Detect OS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user