hide databases/users from normal postgres user - Mailing list pgsql-general

From Mario Weilguni
Subject hide databases/users from normal postgres user
Date
Msg-id 000701c2e309$49b5feb0$8f01c00a@icomedias.com
Whole thread Raw
List pgsql-general
Is it possible to hide the list of databases. The query is
SELECT d.datname as "Name",
       u.usename as "Owner"
FROM pg_database d LEFT JOIN pg_user u ON d.datdba = u.usesysid
ORDER BY 1;

so I tried to play with rules like this one:
create rule hide_db as on select to pg_database
do instead
SELECT datname, datdba, encoding, datistemplate, datallowconn,
datlastsysoid, datvacuumxid, datfrozenxid, datpath, datconfig, datacl
FROM pg_catalog.pg_database d
where (
       exists (select 1 from pg_user where current_user = usename and
usesuper = true)
       or
       d.datname=current_user
      )
ORDER BY 1;

This would allow a user to see only "his" databases, but that seems to be
impossible to achieve with a rule. Same rules would be for pg_user. A
"revoke select on pg_database" seems to work too, but imo this is not the
best approach. And I'm not sure if a "revoke select on pg_user" will break
the database system.

Regards,
    Mario Weilguni



pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Help me!
Next
From: Tom Lane
Date:
Subject: Re: foreign key constraint