mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-05-30 17:09:34 +00:00
* feat(install): random PostgreSQL role + post-install credentials display The local-Postgres installer used to bake in a static role name (`xui`) and only printed `PostgreSQL (xui@127.0.0.1:5432/xui)` at the end of install, leaving operators without the random password or any hint of how to connect from the shell. Two changes: - install_postgres_local now generates an 8-char random role name alongside the random password, and double-quotes identifiers in the CREATE/ALTER statements (a random alphanumeric may start with a digit, which Postgres rejects for unquoted identifiers). - After a successful local install, a dedicated "PostgreSQL Credentials" block is rendered in the summary — DB / user / pass / host / port / DSN / env-file path, plus ready-to-paste psql commands for both the postgres superuser and the new role. Credentials cross the subshell boundary via a 0600 tmpfile (PG_CRED_FILE) that the parent shell sources and unlinks; the PG_* vars are unset after display. Only fires for the local-install flow; the external-DSN path is unchanged. * fix(install): address Copilot review on Postgres install flow - Use mktemp (unguessable, 0600) instead of /tmp/x-ui-pg-creds.$$ and cleanup in both success and failure paths to close the symlink/race attack on the predictable filename. - In install_postgres_local, capture the prior umask and restore it after writing PG_CRED_FILE; return 1 if the write fails so the caller does not source nothing and label the install with empty PG_* vars. - On reinstall, reuse the existing xui DB owner instead of generating a fresh role each run, so existing tables stay accessible after a re-run; only the password is rotated. Falls back to a fresh random role when the DB does not exist or is owned by postgres.
56 KiB
56 KiB