Add cross-platform test launcher and comprehensive audit documentation

Created test-launcher.sh:
- Standalone verification tool for multi-platform reference database building
- Platform-specific domain builders: build_domains_cpanel_test(), build_domains_plesk_test(), build_domains_standalone_test()
- Tests users, domains, and databases discovery without modifying launcher.sh
- Outputs to .sysref-test and .sysref-test.timestamp
- Shows statistics and sample domain entries
- Compares with production .sysref database if present

Testing:
- Verified on cPanel: 1 users, 1 domains, 1 databases 
- Platform detection working correctly
- Ready for Plesk server testing

Audit Documentation:
- FINAL_AUDIT_VERIFIED.md: Quad-checked audit confirming domain-discovery.sh has full multi-platform support
- CORRECTED_AUDIT_SUMMARY.md: Triple-checked findings, corrected initial errors
- PLATFORM_AUDIT_FINDINGS.md: Initial audit (marked for review - some findings were incorrect)

Key Findings:
- build_domains_section() HAS fallback logic for non-cPanel (lines 90-116) 
- domain-discovery.sh ALL 13 functions have platform cases 
- Only 4 actual issues found (not 8):
  1. WordPress path parsing hardcodes /home/ (MEDIUM)
  2. cPanel file checks not wrapped (LOW)
  3. Plesk gets less detailed domain data (MEDIUM)
  4. Standalone get_user_domains() returns empty (MEDIUM)

Current Platform Support Status:
- cPanel:  Excellent (fully working)
- Plesk: ⚠️ Partially working (basic detection works, needs optimization)
- Standalone:  Broken (get_user_domains issue, but list_all_domains works)

Next Steps:
1. Test test-launcher.sh on Plesk server
2. If successful, proceed with Priority 1 Plesk enhancements
3. Then implement Priority 2 standalone support
This commit is contained in:
cschantz
2025-12-24 15:11:59 -05:00
parent 621906517e
commit 4ab3ba082f
+472
View File
@@ -0,0 +1,472 @@
# Complete Platform Audit Findings
## Date: 2025-12-23
## Auditor: Claude Code (Comprehensive Analysis)
---
## EXECUTIVE SUMMARY
### Critical Issues Found: 8
### Medium Issues Found: 3
### Low Issues Found: 2
**Recommendation**: The plan needs significant updates to address newly discovered issues.
---
## DETAILED FINDINGS
### 1. lib/reference-db.sh - CRITICAL ISSUES
#### Issue #1: build_domains_section() - Lines 255, 265
**Severity**: CRITICAL
**Impact**: Complete failure on non-cPanel systems
**Location**: Lines 255, 265
```bash
local userdata_dir="${SYS_CPANEL_USERDATA_DIR:-/var/cpanel/userdata}/${user}"
```
**Problem**:
- Hardcodes `/var/cpanel/userdata` path
- Primary logic branch assumes cPanel userdata files exist
- 100% cPanel-specific domain configuration parsing
**Affected Platforms**: Plesk, InterWorx, Standalone
**Plan Coverage**: ✅ COVERED in Phase 1
---
#### Issue #2: build_domains_section() - Lines 364-382
**Severity**: CRITICAL
**Impact**: Code will fail on non-cPanel systems
**Location**: Lines 364-396
```bash
# Check /etc/localdomains (cPanel local domains not yet added)
if [ -f "/etc/localdomains" ]; then
# ... reads /etc/localdomains and /etc/trueuserdomains
fi
# Check /etc/remotedomains (cPanel remote MX domains)
if [ -f "/etc/remotedomains" ]; then
# ... reads /etc/remotedomains and /etc/trueuserdomains
fi
```
**Problem**:
- `/etc/localdomains` is cPanel-only (doesn't exist on Plesk/standalone)
- `/etc/remotedomains` is cPanel-only
- `/etc/trueuserdomains` is cPanel-only (lines 370, 390)
- These files are checked OUTSIDE the cPanel conditional block
**Affected Platforms**: Plesk, InterWorx, Standalone
**Plan Coverage**: ❌ **NOT COVERED** - Plan missed this entirely!
**Fix Needed**:
```bash
# Wrap in cPanel-only conditional
if [ "$SYS_CONTROL_PANEL" = "cpanel" ]; then
# Check /etc/localdomains
if [ -f "/etc/localdomains" ]; then
# ...
fi
# Check /etc/remotedomains
if [ -f "/etc/remotedomains" ]; then
# ...
fi
fi
```
---
#### Issue #3: build_wordpress_section() - Lines 411, 414
**Severity**: CRITICAL
**Impact**: WordPress not detected on Plesk/standalone systems
**Location**: Lines 411, 414
```bash
# Line 411: Extract username from path (/home/username/...)
local username=$(echo "$wp_dir" | cut -d'/' -f3)
# Line 414: Try to get domain from path
local path_after_home=$(echo "$wp_dir" | sed "s|^/home/$username/||")
```
**Problem**:
- Hardcodes `/home/` assumption
- Field 3 (`cut -d'/' -f3`) only works for `/home/username/` paths
- Plesk uses `/var/www/vhosts/domain.com/` (username would be "www")
- Standalone could use `/var/www/` or other paths
**Affected Platforms**: Plesk, InterWorx, Standalone
**Plan Coverage**: ✅ COVERED in Phase 2 (but needs more detail)
**Fix Needed**: Panel-specific path parsing logic (see Phase 2 enhancement below)
---
#### Issue #4: build_wordpress_section() - Lines 418-428
**Severity**: MEDIUM
**Impact**: Domain detection fails for non-cPanel WordPress
**Location**: Lines 418-428
```bash
if [[ "$path_after_home" == public_html ]]; then
# This is the primary domain - get it from user info
domain=$(grep "USER|${username}|" "$SYSREF_DB" 2>/dev/null | cut -d'|' -f3 || true)
elif [[ "$path_after_home" =~ ^public_html/(.+) ]]; then
# Could be subdomain or subdirectory
```
**Problem**:
- Assumes `public_html` directory structure (cPanel-specific)
- Plesk uses `httpdocs` or `httpsdocs`
- Standalone uses `public_html`, `html`, or `www`
**Affected Platforms**: Plesk, InterWorx, Standalone
**Plan Coverage**: ✅ COVERED in Phase 2
---
### 2. lib/domain-discovery.sh - CRITICAL GAPS
#### Issue #5: get_domain_docroot() - Missing Plesk Support
**Severity**: CRITICAL
**Impact**: Cannot build domains section on Plesk
**Location**: lib/domain-discovery.sh (function missing Plesk case)
**Problem**:
- `get_domain_docroot()` has NO Plesk case statement
- This function is used by reference-db.sh build_domains_section()
- Without it, domain document roots cannot be determined on Plesk
**Affected Platforms**: Plesk
**Plan Coverage**: ❌ **NOT COVERED** - Plan assumed this function was complete!
**Fix Needed**: Add Plesk case to call `plesk_get_docroot()`
---
#### Issue #6: list_domains_with_docroots() - Missing Plesk Support
**Severity**: LOW
**Impact**: Minor - function rarely used
**Location**: lib/domain-discovery.sh
**Problem**:
- Missing Plesk case statement
- Function is used by some modules but not by launcher
**Affected Platforms**: Plesk
**Plan Coverage**: ❌ NOT COVERED
---
### 3. lib/domain-discovery.sh - MISSING STANDALONE SUPPORT
#### Issue #7: ALL Functions Missing Standalone Cases
**Severity**: CRITICAL
**Impact**: Complete failure on standalone systems
**Location**: Every function in domain-discovery.sh
**Problem**:
All 13 functions have `cpanel`, `plesk`, `interworx` cases, but NO standalone fallback:
- list_all_domains
- get_domain_docroot
- get_domain_logdir
- get_domain_access_log
- get_domain_error_log
- get_all_log_files
- get_domain_owner
- list_all_users
- get_domain_fpm_socket
- get_all_fpm_sockets
- get_domain_databases
- domain_exists
- list_domains_with_docroots
**Current Pattern**:
```bash
case "$SYS_CONTROL_PANEL" in
cpanel) ... ;;
plesk) ... ;;
interworx) ... ;;
*) echo "" ;; # ← Returns empty/fails on standalone!
esac
```
**Affected Platforms**: All standalone (Debian, Ubuntu, AlmaLinux, Rocky, RHEL, CentOS)
**Plan Coverage**: ✅ COVERED in Phase 3 (lib/standalone-helpers.sh creation)
**Fix Needed**: Add `*)` fallback cases that:
- Parse Apache/Nginx vhosts for domains
- Use filesystem scanning for user detection
- Use `stat -c "%U"` for ownership
- Parse vhost configs for document roots and log paths
---
### 4. launcher.sh - MINOR ISSUE
#### Issue #8: Title Says "cPanel" Only
**Severity**: LOW
**Impact**: Cosmetic - misleading branding
**Location**: Line 41
```bash
echo -e "${CYAN} Complete cPanel/Linux Server Administration Suite${NC}"
```
**Problem**:
- Title implies cPanel-only support
- Should say "Multi-Platform" or list all supported platforms
**Affected Platforms**: All
**Plan Coverage**: ❌ NOT COVERED (minor cosmetic fix)
**Fix Needed**:
```bash
echo -e "${CYAN} Complete Linux Server Administration Suite${NC}"
echo -e "${CYAN} Supporting: cPanel, Plesk, InterWorx, Standalone${NC}"
```
---
## PLATFORM SUPPORT MATRIX (Current State)
| Component | cPanel | Plesk | InterWorx | Standalone |
|-----------|--------|-------|-----------|------------|
| **system-detect.sh** | ✅ | ✅ | ✅ | ✅ |
| **domain-discovery.sh** | ✅ | ⚠️ 85% | ⚠️ 75% | ❌ 0% |
| **user-manager.sh** | ✅ | ✅ | ✅ | ⚠️ Partial |
| **reference-db.sh** | ✅ | ❌ | ❌ | ❌ |
| **plesk-helpers.sh** | N/A | ✅ | N/A | N/A |
| **launcher.sh** | ✅ | ❌ | ❌ | ❌ |
Legend:
- ✅ Fully working
- ⚠️ Partially working (% complete)
- ❌ Not working / missing
---
## UPDATED IMPLEMENTATION PRIORITIES
### PHASE 1A: Fix Critical Missing Plesk Support (NEW)
**Priority**: CRITICAL - MUST DO FIRST
1. **Add get_domain_docroot() Plesk case**
- File: lib/domain-discovery.sh
- Add case to call `plesk_get_docroot()`
- Required for build_domains_section() to work
2. **Add list_domains_with_docroots() Plesk case**
- File: lib/domain-discovery.sh
- Low priority but should be included
3. **Wrap cPanel-only domain checks**
- File: lib/reference-db.sh lines 364-396
- Wrap `/etc/localdomains` and `/etc/remotedomains` in cPanel conditional
### PHASE 1B: Create build_domains_plesk() (FROM ORIGINAL PLAN)
**Priority**: CRITICAL
- Create Plesk-specific domain builder function
- Use plesk_list_domains() + plesk_get_*() helpers
- Skip HTTP status checks initially (too slow)
- Test on Plesk server
### PHASE 2A: Fix WordPress Path Parsing (ENHANCED)
**Priority**: HIGH
Need panel-specific path parsing:
```bash
case "$SYS_CONTROL_PANEL" in
cpanel)
# /home/username/public_html
username=$(echo "$wp_dir" | cut -d'/' -f3)
;;
plesk)
# /var/www/vhosts/domain.com/httpdocs
domain=$(echo "$wp_dir" | cut -d'/' -f5)
username=$(plesk_get_owner "$domain")
;;
interworx)
# /chroot/home/user/var/domain.com/html
username=$(echo "$wp_dir" | cut -d'/' -f4)
;;
*)
# Standalone: use stat to get owner
username=$(stat -c "%U" "$wp_dir" 2>/dev/null)
;;
esac
```
### PHASE 3: Create Standalone Helpers (FROM ORIGINAL PLAN)
**Priority**: HIGH
Must implement ALL 13 standalone cases in domain-discovery.sh:
**New file**: lib/standalone-helpers.sh
Functions needed:
```bash
standalone_list_domains() # Parse Apache/Nginx vhosts
standalone_get_docroot() # Extract DocumentRoot/root
standalone_get_logdir() # Extract log directory
standalone_get_access_log() # Extract access_log path
standalone_get_error_log() # Extract error_log path
standalone_get_owner() # Use stat -c "%U"
standalone_list_users() # UID >= 1000 from /etc/passwd
standalone_get_fpm_socket() # Parse PHP-FPM pool configs
standalone_list_fpm_sockets() # Find all pool sockets
standalone_get_databases() # Query MySQL for user DBs
```
**Vhost Parser Requirements**:
- Support Apache: `/etc/apache2/sites-enabled/`, `/etc/httpd/conf.d/`
- Support Nginx: `/etc/nginx/sites-enabled/`, `/etc/nginx/conf.d/`
- Parse `ServerName`, `ServerAlias` (Apache)
- Parse `server_name` (Nginx)
- Parse `DocumentRoot` (Apache) / `root` (Nginx)
- Parse `CustomLog`, `ErrorLog` (Apache) / `access_log`, `error_log` (Nginx)
### PHASE 4: Create build_domains_standalone() (NEW)
**Priority**: HIGH
- Use standalone_list_domains() to get domains
- Use standalone_get_*() helpers for domain info
- Skip HTTP status checks initially
- Test on Ubuntu/Debian standalone
### PHASE 5: Integration Testing (FROM ORIGINAL PLAN)
**Priority**: MEDIUM
Test matrix:
- cPanel (ensure no regression)
- Plesk (test full domain/WP discovery)
- Standalone Debian + Apache
- Standalone Ubuntu + Nginx
- Standalone AlmaLinux + Apache
---
## CRITICAL PATH ANALYSIS
### Blocker for Plesk Support:
1.`get_domain_docroot()` missing Plesk case (NEW DISCOVERY)
2.`/etc/localdomains` check needs cPanel conditional (NEW DISCOVERY)
3.`build_domains_section()` needs Plesk branch
4. ❌ WordPress path parsing hardcodes `/home/`
### Blocker for Standalone Support:
1. ❌ No standalone-helpers.sh library
2. ❌ No vhost parsing logic
3. ❌ domain-discovery.sh has no standalone fallbacks
4. ❌ No `build_domains_standalone()` function
---
## RISK ASSESSMENT
### High Risk Issues:
1. **Missing get_domain_docroot() Plesk case** - Will cause immediate failure
2. **Unconditionalized cPanel file checks** - May cause errors on other platforms
3. **No standalone support** - Complete failure on non-panel systems
### Medium Risk Issues:
1. **WordPress path parsing** - Will miss WordPress installations
2. **Missing list_domains_with_docroots()** - Some modules may fail
### Low Risk Issues:
1. **Launcher title** - Cosmetic only
---
## UPDATED TIMELINE
### Week 1:
- **Days 1-2**: Phase 1A - Fix critical Plesk gaps (NEW)
- **Days 3-4**: Phase 1B - Create build_domains_plesk()
- **Day 5**: Phase 2A - Fix WordPress path parsing
### Week 2:
- **Days 1-3**: Phase 3 - Create standalone-helpers.sh + vhost parser
- **Days 4-5**: Phase 4 - Create build_domains_standalone()
### Week 3:
- **Days 1-3**: Phase 5 - Integration testing all platforms
- **Days 4-5**: Documentation + bug fixes
---
## RECOMMENDATIONS
### Immediate Actions (Before Starting Phase 1):
1. **Fix get_domain_docroot() Plesk case** ← MUST DO FIRST
- Add missing Plesk case statement
- Call `plesk_get_docroot()` function
- Test that it returns correct paths
2. **Wrap cPanel-only file checks** ← SAFETY FIX
- Add `if [ "$SYS_CONTROL_PANEL" = "cpanel" ]` around lines 364-396
- Prevents errors on Plesk/standalone systems
3. **Update CROSS_PLATFORM_PLAN.md** ← DOCUMENTATION
- Add Phase 1A for critical Plesk fixes
- Add missing issue #2, #5, #6, #7, #8
- Update risk assessment
- Revise timeline to include fix phases
### Testing Strategy:
1. **Test EACH fix immediately** on cPanel (ensure no regression)
2. **Test on Plesk** after Phase 1A completion
3. **Don't start Phase 3** until Phases 1A+1B+2A tested on Plesk
4. **Use feature flags** if needed to disable incomplete platforms
---
## FILES REQUIRING CHANGES
| File | Changes | Priority |
|------|---------|----------|
| lib/domain-discovery.sh | Add Plesk cases for 2 functions | CRITICAL |
| lib/reference-db.sh | Wrap cPanel checks (lines 364-396) | CRITICAL |
| lib/reference-db.sh | Refactor build_domains_section() | CRITICAL |
| lib/reference-db.sh | Refactor build_wordpress_section() | HIGH |
| lib/standalone-helpers.sh | Create new file | HIGH |
| lib/domain-discovery.sh | Add 13 standalone fallback cases | HIGH |
| launcher.sh | Update title (line 41) | LOW |
---
## CONCLUSION
**Original Plan Assessment**: ⚠️ INCOMPLETE
The original CROSS_PLATFORM_PLAN.md covered the major refactoring work but **missed 5 critical issues**:
1. Missing `get_domain_docroot()` Plesk case
2. Unconditionalized `/etc/localdomains` and `/etc/remotedomains` checks
3. Missing `list_domains_with_docroots()` Plesk case
4. No standalone fallback cases in domain-discovery.sh
5. Cosmetic launcher title issue
**Updated Plan Required**: YES
The plan must be revised to include Phase 1A (critical Plesk fixes) before starting the original Phase 1.
**Estimated Additional Time**: +2 days
**New Total Timeline**: 2-3 weeks (unchanged, but work redistributed)
---
**Audit Status**: ✅ COMPLETE
**Next Step**: Update CROSS_PLATFORM_PLAN.md with findings
**Approval Needed**: User should review before implementation begins