Skip to content

fix: prevent 'admin with no permissions' on fresh install#49

Merged
baeyc0510 merged 1 commit intomainfrom
fix/init-permission-issues
Dec 11, 2025
Merged

fix: prevent 'admin with no permissions' on fresh install#49
baeyc0510 merged 1 commit intomainfrom
fix/init-permission-issues

Conversation

@baeyc0510
Copy link
Contributor

Fixes permission issues when user-policy.json creation fails or is missing.

Changes:

  1. init.go: Make createDefaultPolicy() failure fatal

    • Previously: warning only, continued execution
    • Now: exits with detailed error message
    • Provides actionable guidance (antivirus, permissions, disk space)
  2. manager.go: Add safe RBAC fallback in LoadPolicy()

    • Previously: returned RBAC=nil when file missing
    • Now: returns minimal admin role with full permissions
    • Prevents "admin with no permissions" scenario in dashboard
  3. manager.go: Enhanced error messages for SavePolicy()

    • Added specific causes for write failures
    • Windows-specific guidance (antivirus, OneDrive, UAC)

Root Cause:

  • On Windows, file write can fail due to:
    • Antivirus real-time protection scanning binary
    • OneDrive/Dropbox sync conflicts
    • Controlled Folder Access (ransomware protection)
    • Transient I/O errors
  • Silent failure left .env with CURRENT_ROLE=admin but no policy file
  • Dashboard loaded RBAC=nil → permission check failed

Impact:

  • Prevents confusing UX where admin role has no edit buttons
  • Provides clear error messages to help users resolve issues
  • Fails fast instead of creating inconsistent state

Fixes permission issues when user-policy.json creation fails or is missing.

Changes:
1. init.go: Make createDefaultPolicy() failure fatal
   - Previously: warning only, continued execution
   - Now: exits with detailed error message
   - Provides actionable guidance (antivirus, permissions, disk space)

2. manager.go: Add safe RBAC fallback in LoadPolicy()
   - Previously: returned RBAC=nil when file missing
   - Now: returns minimal admin role with full permissions
   - Prevents "admin with no permissions" scenario in dashboard

3. manager.go: Enhanced error messages for SavePolicy()
   - Added specific causes for write failures
   - Windows-specific guidance (antivirus, OneDrive, UAC)

Root Cause:
- On Windows, file write can fail due to:
  * Antivirus real-time protection scanning binary
  * OneDrive/Dropbox sync conflicts
  * Controlled Folder Access (ransomware protection)
  * Transient I/O errors
- Silent failure left .env with CURRENT_ROLE=admin but no policy file
- Dashboard loaded RBAC=nil → permission check failed

Impact:
- Prevents confusing UX where admin role has no edit buttons
- Provides clear error messages to help users resolve issues
- Fails fast instead of creating inconsistent state
@baeyc0510 baeyc0510 merged commit f6fc272 into main Dec 11, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant