CRITICAL: Fix domain detection bug in get_cpanel_user_domains

Root cause: grep -F with regex anchor
- grep -F means 'fixed string' (no regex)
- Pattern 'grep -F "$username\$"' was looking for literal backslash-dollar
- Changed to 'grep "${username}$"' (regex mode with end-of-line anchor)

Impact:
- PHP optimizer showed 0 domains analyzed
- Server memory check showed 0MB required
- ALL domain-based functionality was broken

This is why the script appeared to work but returned no data.

Files fixed:
- lib/user-manager.sh:254,258 (2 lines changed)
This commit is contained in:
cschantz
2025-12-03 01:08:08 -05:00
parent b72a44d65e
commit 36f7d71a98
+2 -2
View File
@@ -251,11 +251,11 @@ get_cpanel_user_domains() {
local username="$1"
# Primary domain (format: domain: user)
grep -F ": ${username}" /etc/trueuserdomains 2>/dev/null | grep -F "$username\$" 2>/dev/null | cut -d: -f1 || true
grep -F ": ${username}" /etc/trueuserdomains 2>/dev/null | grep "${username}$" 2>/dev/null | cut -d: -f1 || true
# Addon domains
if [ -f "/etc/userdatadomains" ]; then
grep -F "==${username}" /etc/userdatadomains 2>/dev/null | grep -F "$username\$" 2>/dev/null | cut -d: -f1 || true
grep -F "==${username}" /etc/userdatadomains 2>/dev/null | grep "${username}$" 2>/dev/null | cut -d: -f1 || true
fi
}