CRITICAL FIX: Add /dev/tty redirection and error handling to all read commands
- Fix run_module() read commands (lines 59, 80) with /dev/tty and error handler - Fix all submenu handler read commands with /dev/tty redirection: * handle_threat_analysis_menu (line 199) * handle_live_monitoring_menu (line 233) * handle_log_viewers_menu (line 265) * handle_security_actions_menu (line 296) * handle_security_menu (line 330) * handle_website_menu (line 378) * handle_performance_menu (line 431) * handle_backup_menu (line 537) * handle_acronis_menu (line 552) * handle_email_menu (line 606) - Fix startup_detection() call with error handler (line 699) Impact: Prevents tmux crashes on non-interactive terminals by gracefully handling read failures. Closes terminal crash issue on AlmaLinux 8.
This commit is contained in:
+37
-13
@@ -56,7 +56,9 @@ run_module() {
|
||||
echo ""
|
||||
echo -e "✗ Module not found: $category/$module"
|
||||
echo ""
|
||||
read -p "Press Enter to continue..."
|
||||
if ! read -p "Press Enter to continue..." </dev/tty 2>/dev/null; then
|
||||
true # Continue even if read fails
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -77,7 +79,9 @@ run_module() {
|
||||
echo -e "✗ Exited with code: $exit_code"
|
||||
fi
|
||||
echo ""
|
||||
read -p "Press Enter to continue..."
|
||||
if ! read -p "Press Enter to continue..." </dev/tty 2>/dev/null; then
|
||||
true # Continue even if read fails
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
@@ -196,7 +200,9 @@ show_threat_analysis_menu() {
|
||||
handle_threat_analysis_menu() {
|
||||
while true; do
|
||||
show_threat_analysis_menu
|
||||
read -r choice
|
||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
||||
return 0 # Exit if read fails
|
||||
fi
|
||||
|
||||
case "$choice" in
|
||||
1) run_module "security" "bot-analyzer.sh" ;;
|
||||
@@ -230,7 +236,9 @@ show_live_monitoring_menu() {
|
||||
handle_live_monitoring_menu() {
|
||||
while true; do
|
||||
show_live_monitoring_menu
|
||||
read -r choice
|
||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
||||
return 0 # Exit if read fails
|
||||
fi
|
||||
|
||||
case "$choice" in
|
||||
1) run_module "security" "live-attack-monitor.sh" ;;
|
||||
@@ -262,7 +270,9 @@ show_log_viewers_menu() {
|
||||
handle_log_viewers_menu() {
|
||||
while true; do
|
||||
show_log_viewers_menu
|
||||
read -r choice
|
||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
||||
return 0 # Exit if read fails
|
||||
fi
|
||||
|
||||
case "$choice" in
|
||||
1) run_module "security" "tail-apache-access.sh" ;;
|
||||
@@ -293,7 +303,9 @@ show_security_actions_menu() {
|
||||
handle_security_actions_menu() {
|
||||
while true; do
|
||||
show_security_actions_menu
|
||||
read -r choice
|
||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
||||
return 0 # Exit if read fails
|
||||
fi
|
||||
|
||||
case "$choice" in
|
||||
1) run_module "security" "enable-cphulk.sh" ;;
|
||||
@@ -327,7 +339,9 @@ show_security_menu() {
|
||||
handle_security_menu() {
|
||||
while true; do
|
||||
show_security_menu
|
||||
read -r choice
|
||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
||||
return 0 # Exit if read fails
|
||||
fi
|
||||
|
||||
case "$choice" in
|
||||
1) handle_threat_analysis_menu ;;
|
||||
@@ -375,7 +389,9 @@ show_website_menu() {
|
||||
handle_website_menu() {
|
||||
while true; do
|
||||
show_website_menu
|
||||
read -r choice
|
||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
||||
return 0 # Exit if read fails
|
||||
fi
|
||||
|
||||
case "$choice" in
|
||||
1) run_module "website" "website-error-analyzer.sh" ;;
|
||||
@@ -428,7 +444,9 @@ show_performance_menu() {
|
||||
handle_performance_menu() {
|
||||
while true; do
|
||||
show_performance_menu
|
||||
read -r choice
|
||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
||||
return 0 # Exit if read fails
|
||||
fi
|
||||
|
||||
case "$choice" in
|
||||
1) run_module "performance" "mysql-query-analyzer.sh" ;;
|
||||
@@ -534,7 +552,9 @@ show_acronis_menu() {
|
||||
handle_backup_menu() {
|
||||
while true; do
|
||||
show_backup_menu
|
||||
read -r choice
|
||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
||||
return 0 # Exit if read fails
|
||||
fi
|
||||
|
||||
case "$choice" in
|
||||
1) handle_acronis_menu ;;
|
||||
@@ -549,7 +569,9 @@ handle_backup_menu() {
|
||||
handle_acronis_menu() {
|
||||
while true; do
|
||||
show_acronis_menu
|
||||
read -r choice
|
||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
||||
return 0 # Exit if read fails
|
||||
fi
|
||||
|
||||
case "$choice" in
|
||||
1) run_module "backup" "acronis-install.sh" ;;
|
||||
@@ -603,7 +625,9 @@ show_email_menu() {
|
||||
handle_email_menu() {
|
||||
while true; do
|
||||
show_email_menu
|
||||
read -r choice
|
||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
||||
return 0 # Exit if read fails
|
||||
fi
|
||||
|
||||
case "$choice" in
|
||||
1) run_module "email" "email-diagnostics.sh" ;;
|
||||
@@ -696,7 +720,7 @@ main() {
|
||||
}
|
||||
|
||||
# Detect system configuration (builds database if cache expired)
|
||||
startup_detection
|
||||
startup_detection || true
|
||||
|
||||
while true; do
|
||||
show_main_menu
|
||||
|
||||
Reference in New Issue
Block a user