pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: philip@americanefficient.com
Subject: BUG #16279: Permissions doc incorrect for pg_buffercache
Date: Wed, 26 Feb 2020 16:46:18 +0000
Message-ID: <16279-fcaac33c68aab0ab@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      16279
Logged by:          Philip Semanchuk
Email address:      philip@americanefficient.com
PostgreSQL version: 11.6
Operating system:   macOS, also AWS Aurora
Description:        

The doc for pg_buffercache says, "By default use is restricted to superusers
and members of the pg_read_all_stats role. Access may be granted to others
using GRANT." (https://www.postgresql.org/docs/11/pgbuffercache.html)

In my experience, users need to be members of pg_monitor, not
pg_read_all_stats. Here's a demo on Postgres 11.6 installed on my Mac.
(Behavior on AWS Aurora Postgres is the same.) 'a_user' is a user with no
special privileges. This first block of SQL shows that a_user can't read
pg_buffercache, as expected.

a_user $ SELECT
      r.rolname, r.rolsuper, r.rolinherit, r.rolcreaterole,
      r.rolcanlogin, r.rolvaliduntil,
      ARRAY(SELECT b.rolname
            FROM pg_catalog.pg_auth_members m
            JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)
            WHERE m.member = r.oid) as memberof
FROM pg_catalog.pg_roles r
WHERE rolname = current_user
;
 rolname | rolsuper | rolinherit | rolcreaterole | rolcanlogin |
rolvaliduntil | memberof
---------+----------+------------+---------------+-------------+---------------+----------
 a_user  | f        | t          | f             | t           |            
  | {}
(1 row)

a_user $
a_user $ select * from pg_buffercache limit 1;
ERROR:  permission denied for view pg_buffercache


In a different session where I'm logged in as superuser, I GRANTed a_user
membership to pg_read_all_stats, but a_user still can't read from
pg_buffercache.

a_user $ SELECT
      r.rolname, r.rolsuper, r.rolinherit, r.rolcreaterole,
      r.rolcanlogin, r.rolvaliduntil,
      ARRAY(SELECT b.rolname
            FROM pg_catalog.pg_auth_members m
            JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)
            WHERE m.member = r.oid) as memberof
FROM pg_catalog.pg_roles r
WHERE rolname = current_user
;
 rolname | rolsuper | rolinherit | rolcreaterole | rolcanlogin |
rolvaliduntil |      memberof
---------+----------+------------+---------------+-------------+---------------+---------------------
 a_user  | f        | t          | f             | t           |            
  | {pg_read_all_stats}
(1 row)

a_user $ select * from pg_buffercache limit 1;
ERROR:  permission denied for view pg_buffercache


In my superuser session, I REVOKEd a_user's membership in pg_read_all_stats
and GRANTed membership in pg_monitor, and that enabled access to
pg_buffercache.

a_user $ SELECT
      r.rolname, r.rolsuper, r.rolinherit, r.rolcreaterole,
      r.rolcanlogin, r.rolvaliduntil,
      ARRAY(SELECT b.rolname
            FROM pg_catalog.pg_auth_members m
            JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)
            WHERE m.member = r.oid) as memberof
FROM pg_catalog.pg_roles r
WHERE rolname = current_user
;
 rolname | rolsuper | rolinherit | rolcreaterole | rolcanlogin |
rolvaliduntil |   memberof
---------+----------+------------+---------------+-------------+---------------+--------------
 a_user  | f        | t          | f             | t           |            
  | {pg_monitor}
(1 row)

a_user $
a_user $ select * from pg_buffercache limit 1;
 bufferid | relfilenode | reltablespace | reldatabase | relforknumber |
relblocknumber | isdirty | usagecount | pinning_backends
----------+-------------+---------------+-------------+---------------+----------------+---------+------------+------------------
        1 |        1262 |          1664 |           0 |             0 |     
        0 | f       |          5 |                0
(1 row)

a_user $



view thread (6+ messages)  latest in thread

Message-ID: <16279-fcaac33c68aab0ab@postgresql.org>
Permalink:  ../16279-fcaac33c68aab0ab@postgresql.org/
Also on:    postgresql.org/message-id/16279-fcaac33c68aab0ab@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, philip@americanefficient.com
  Subject: Re: BUG #16279: Permissions doc incorrect for pg_buffercache
  In-Reply-To: <16279-fcaac33c68aab0ab@postgresql.org>
  References: <16279-fcaac33c68aab0ab@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox