From 72047b40983352cf9904209e6fdeacce9a44290c Mon Sep 17 00:00:00 2001 From: cschantz Date: Fri, 2 Jan 2026 21:29:37 -0500 Subject: [PATCH] Fix Maldet directory detection after extraction Problem: - cd maldetect-* was failing because glob expansion doesn't work reliably in this context - Error: "Cannot find extracted directory" Solution: - Use find command to locate extracted directory explicitly - Store directory path in variable before cd - Add diagnostic output showing available directories on failure - More robust error handling with explicit directory checks --- modules/security/malware-scanner.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/security/malware-scanner.sh b/modules/security/malware-scanner.sh index 2f08f52..7f12b5f 100755 --- a/modules/security/malware-scanner.sh +++ b/modules/security/malware-scanner.sh @@ -235,9 +235,20 @@ install_all_scanners() { return 1 fi - # Change to extracted directory - if ! cd maldetect-* 2>/dev/null; then + # Find the extracted directory + local maldet_dir=$(find /tmp -maxdepth 1 -type d -name "maldetect-*" 2>/dev/null | head -1) + if [ -z "$maldet_dir" ]; then echo -e "${RED}✗ Cannot find extracted directory${NC}" + echo " Available directories in /tmp:" + ls -la /tmp | grep maldetect | sed 's/^/ /' + cd /tmp + rm -rf "maldetect-"* + return 1 + fi + + # Change to extracted directory + if ! cd "$maldet_dir"; then + echo -e "${RED}✗ Cannot access directory: $maldet_dir${NC}" cd /tmp rm -rf "maldetect-"* return 1