From 4a2581581e9c5337838910f39d7b9167fb4ac33c Mon Sep 17 00:00:00 2001 From: Developer Date: Sat, 21 Mar 2026 01:25:24 -0400 Subject: [PATCH] CRITICAL FIX: Handle grep failures with set -eo pipefail in scanner installation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FIXED: - Added '|| true' to all grep commands that filter installation output - ClamAV installation: Fixed grep exit code issue on yum/apt-get output - Maldet installation: Fixed signature update grep failure handling - ImunifyAV installation: Fixed deployment script grep and update grep failures - Changed imunify update from pipe-to-grep-or-retry to proper if-statement check BEHAVIOR CHANGE: - Installation continues even if output patterns don't match expected strings - Signature updates now use if-statement with grep -q instead of bare pipes - Better status reporting: shows 'unclear' instead of error when status unknown ROOT CAUSE: With 'set -eo pipefail' enabled, grep commands that return 1 (no match) cause the entire pipeline to fail. This was causing the installation to exit with code 1 even though the software was actually installing successfully. EXAMPLE: Before: yum output 'Complete!' → grep looks for 'Installing' → grep returns 1 → exit After: yum output 'Complete!' → grep returns 1 → handled with '|| true' → continue --- modules/security/malware-scanner.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/security/malware-scanner.sh b/modules/security/malware-scanner.sh index b503e88..9cadaf6 100755 --- a/modules/security/malware-scanner.sh +++ b/modules/security/malware-scanner.sh @@ -223,13 +223,13 @@ install_all_scanners() { if rpm -qa | grep -q "cpanel-clamav"; then echo -e "${GREEN}✓ ClamAV already installed (cPanel)${NC}" else - /scripts/update_local_rpm_versions --edit target_settings.clamav installed 2>/dev/null - /scripts/check_cpanel_rpms --fix --targets=clamav 2>&1 | grep -E "Installing|Updating|up to date" + /scripts/update_local_rpm_versions --edit target_settings.clamav installed 2>/dev/null || true + /scripts/check_cpanel_rpms --fix --targets=clamav 2>&1 | grep -E "Installing|Updating|up to date" || true fi elif command -v yum &>/dev/null; then - yum install -y clamav clamav-update 2>&1 | grep -E "Installing|Updating|already installed" + yum install -y clamav clamav-update 2>&1 | grep -E "Installing|Updating|already installed" || true elif command -v apt-get &>/dev/null; then - apt-get update && apt-get install -y clamav clamav-daemon + apt-get update && apt-get install -y clamav clamav-daemon || true fi if is_clamav_installed; then @@ -374,7 +374,7 @@ install_all_scanners() { if [ -f imav-deploy.sh ]; then # Run deployment script with progress indicators - bash imav-deploy.sh 2>&1 | grep -E "Installing|Installed|Complete|Error|Failed" || bash imav-deploy.sh + bash imav-deploy.sh 2>&1 | grep -E "Installing|Installed|Complete|Error|Failed" || true rm -f imav-deploy.sh # Enable cPanel UI plugin if installed