Commit Graph
1 Commits
  • fix(database): keep the SQLite store owner-only (#6390)
    * fix(database): keep the SQLite store owner-only
    
    InitDB created the data directory 0755 and let SQLite create x-ui.db
    and its -wal/-shm side files under the default umask, so on a stock
    install they are world-readable. The store holds client UUIDs, Reality
    private keys and the admin password hash, so any local account could
    read them.
    
    Create the directory 0700 and chmod the database files to 0600 right
    after opening. SQLite gives -wal/-shm the mode of the main file, so
    files created later inherit it; existing installs are tightened on the
    next start. PostgreSQL deployments are untouched.
    
    Assisted-by: Claude Code:claude-fable-5-1
    
    * fix(database): tolerate chmod failures, keep the dump and install dir owner-only
    
    Review follow-ups. A store the panel cannot chmod (root_squash NFS, a
    foreign uid in a container) refused to start, which is worse than the
    0644 it had before; log and continue instead, as the backup-directory
    cleanup above already does. install.sh reset /etc/x-ui to 0755 right
    after the binary created it 0700, so the directory hunk was inert on
    real installs; create it 0700 there too. The migrate-db dump in the same
    directory is a plaintext copy of the same secrets and was written 0644.
    
    Assisted-by: Claude Code:claude-fable-5-1