From 0d0936550cdb9231167500a029f647409042b243 Mon Sep 17 00:00:00 2001 From: Thomas Daniels Date: Tue, 1 Aug 2023 01:16:29 +0200 Subject: [PATCH] PostgreSQL: Show only accessible databases --- adminer/drivers/pgsql.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index 198e6429..80f5b13e 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -274,7 +274,9 @@ if (isset($_GET["pgsql"])) { } function get_databases() { - return get_vals("SELECT datname FROM pg_database WHERE has_database_privilege(datname, 'CONNECT') ORDER BY datname"); + return get_vals("SELECT d.datname FROM pg_database d JOIN pg_roles r ON d.datdba = r.oid + WHERE d.datallowconn = TRUE AND has_database_privilege(d.datname, 'CONNECT') AND pg_has_role(r.rolname, 'USAGE') + ORDER BY d.datname"); } function limit($query, $where, $limit, $offset = 0, $separator = " ") {