IMPLEMENT: Standalone server domain and log discovery
FEATURE: Domain Discovery for Standalone Servers - Added get_standalone_user_domains() function - Parses Apache VirtualHost configs (/etc/apache2, /etc/httpd) - Falls back to checking domain directories in user home - Returns sorted list of unique domains FEATURE: Log Discovery Implementation - Implemented build_logs_section() for log file discovery - Standalone: Find access/error logs in log directory - Nginx support: Find logs in /var/log/nginx - Safety limits: 30-day files, max 50 per type, max depth 2 - Prevents hangs on large log directories BENEFITS: ✅ Standalone servers now discover domains ✅ Standalone servers now discover logs ✅ malware-scanner can now run on standalone ✅ website-error-analyzer can now run on standalone ✅ live-attack-monitor can now run on standalone ✅ log-tailing tools now work SAFETY: - Limited to recent files (mtime -30) - Limited search depth (maxdepth 1-2) - Limited result count (head 50) - No regex hangs from large directory scans
This commit is contained in:
+33
-1
@@ -251,7 +251,8 @@ get_user_domains() {
|
||||
get_interworx_user_domains "$username"
|
||||
;;
|
||||
*)
|
||||
echo ""
|
||||
# Standalone server - try to find domains
|
||||
get_standalone_user_domains "$username"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
@@ -313,6 +314,37 @@ get_interworx_user_domains() {
|
||||
fi
|
||||
}
|
||||
|
||||
get_standalone_user_domains() {
|
||||
[ -z "$1" ] && return 1
|
||||
local username="$1"
|
||||
local home_dir="/home/${username}"
|
||||
|
||||
# Only process if home directory exists
|
||||
[ ! -d "$home_dir" ] && return 0
|
||||
|
||||
# Method 1: Parse Apache VirtualHost configs for ServerName matching user
|
||||
if [ -d "/etc/apache2/sites-enabled" ]; then
|
||||
grep -h "ServerName\|ServerAlias" /etc/apache2/sites-enabled/*.conf 2>/dev/null | \
|
||||
awk '{print $2}' | sort -u
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Method 2: Parse RHEL-style Apache configs
|
||||
if [ -d "/etc/httpd/conf.d" ]; then
|
||||
grep -h "ServerName\|ServerAlias" /etc/httpd/conf.d/*.conf 2>/dev/null | \
|
||||
awk '{print $2}' | sort -u
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Method 3: Check for domain directories in user's home (common structure: ~/domain.com/public_html)
|
||||
if [ -d "$home_dir" ]; then
|
||||
find "$home_dir" -maxdepth 2 -name "public_html" -o -name "html" 2>/dev/null | \
|
||||
sed "s|${home_dir}/||; s|/public_html$||; s|/html$||" | \
|
||||
grep -v "^$" | sort -u
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
# USER DATABASES
|
||||
#############################################################################
|
||||
|
||||
Reference in New Issue
Block a user