diff --git a/lib/user-manager.sh b/lib/user-manager.sh index 4f375a9..854f1bc 100755 --- a/lib/user-manager.sh +++ b/lib/user-manager.sh @@ -319,30 +319,19 @@ get_standalone_user_domains() { local username="$1" local home_dir="/home/${username}" - # Only process if home directory exists + # Only process if home directory exists for this user [ ! -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 + # User-specific domain discovery: Check home directory for domain structure + # Expected common structures: + # /home/username/domain.com/public_html + # /home/username/domain.com/html + # /home/username/domain.org/public_html + # This is USER-SPECIFIC and doesn't require parsing Apache configs - # 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 + find "$home_dir" -maxdepth 2 \( -name "public_html" -o -name "html" \) -type d 2>/dev/null | \ + sed "s|${home_dir}/||; s|/public_html$||; s|/html$||" | \ + grep -v "^$" | sort -u } #############################################################################