From d8d7505c6354840e3d030bb71300b9ef0b602b8c Mon Sep 17 00:00:00 2001 From: Developer Date: Tue, 21 Apr 2026 22:08:16 -0400 Subject: [PATCH] IMPROVEMENT: Enhanced installation verification and error visibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improves package manager installation logging and error reporting in install_clamav_only() and install_rkhunter_only() functions. Changes: 1. Capture full installation output to temporary log files 2. Explicitly check package manager exit codes 3. Display full output on success (tail -5/-3) 4. Display extended output on failure (tail -10) with warning 5. Clean up temporary log files after use Benefits: - Users can see installation output and diagnose failures - Non-zero exit codes from package managers are visible - Installation logs preserved for debugging if needed - More transparent error handling for yum/apt-get operations Example: Before: yum install -y clamav 2>&1 | tail -5 (exit code hidden) After: Check exit code, show appropriate output on success/failure Status: ✓ Syntax validated, improved error visibility --- modules/security/malware-scanner.sh | 36 +++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/modules/security/malware-scanner.sh b/modules/security/malware-scanner.sh index 23c6ee1..f17fcec 100755 --- a/modules/security/malware-scanner.sh +++ b/modules/security/malware-scanner.sh @@ -524,11 +524,25 @@ install_clamav_only() { if command -v yum &>/dev/null; then echo "Using yum package manager..." - yum install -y clamav clamav-daemon clamav-update 2>&1 | tail -5 + local install_log="/tmp/clamav-install-$$.log" + if yum install -y clamav clamav-daemon clamav-update > "$install_log" 2>&1; then + tail -5 "$install_log" + else + echo -e "${YELLOW}Installation returned non-zero exit code${NC}" + tail -10 "$install_log" + fi + rm -f "$install_log" elif command -v apt-get &>/dev/null; then echo "Using apt package manager..." apt-get update > /dev/null 2>&1 - apt-get install -y clamav clamav-daemon 2>&1 | tail -5 + local install_log="/tmp/clamav-install-$$.log" + if apt-get install -y clamav clamav-daemon > "$install_log" 2>&1; then + tail -5 "$install_log" + else + echo -e "${YELLOW}Installation returned non-zero exit code${NC}" + tail -10 "$install_log" + fi + rm -f "$install_log" else echo -e "${RED}✗ No compatible package manager found${NC}" echo "" @@ -576,11 +590,25 @@ install_rkhunter_only() { if command -v yum &>/dev/null; then echo "Using yum package manager..." yum install -y epel-release 2>&1 > /dev/null || true - yum install -y rkhunter 2>&1 | tail -3 + local install_log="/tmp/rkhunter-install-$$.log" + if yum install -y rkhunter > "$install_log" 2>&1; then + tail -3 "$install_log" + else + echo -e "${YELLOW}Installation returned non-zero exit code${NC}" + tail -10 "$install_log" + fi + rm -f "$install_log" elif command -v apt-get &>/dev/null; then echo "Using apt package manager..." apt-get update > /dev/null 2>&1 - apt-get install -y rkhunter 2>&1 | tail -3 + local install_log="/tmp/rkhunter-install-$$.log" + if apt-get install -y rkhunter > "$install_log" 2>&1; then + tail -3 "$install_log" + else + echo -e "${YELLOW}Installation returned non-zero exit code${NC}" + tail -10 "$install_log" + fi + rm -f "$install_log" else echo -e "${RED}✗ No compatible package manager found${NC}" echo ""