Re: [Patch Review] TRUNCATE Permission

From: "Ryan Bradetich" <rbradetich(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [Patch Review] TRUNCATE Permission
Date: 2008-09-01 19:32:09
Message-ID: e739902b0809011232q55d0bd00q72b8d8019104feb7@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello all,

On Sun, Aug 31, 2008 at 11:55 PM, Ryan Bradetich <rbradetich(at)gmail(dot)com>wrote:

>
> I do not believe this is a huge issue since truncate is prohibited on the
> system catalogs
> by the truncate_check_rel().
>
> template1=# truncate pg_authid;
> ERROR: permission denied: "pg_authid" is a system catalog
>

I thought about this some more. I believe my suggestion was incorrect.
Since truncate_check_rel() prevents the use of the truncate command on
system catalogs, the TRUNCATE permission should always be stripped
from the system catalogs.

Here is the inconsistency I observed:

template1=# \z pg_catalog.pg_authid

Access privileges
Schema | Name | Type | Access privileges
------------+-----------+-------+---------------------
pg_catalog | pg_authid | table | rbrad=arwdDxt/rbrad
(1 row)

template1=# select rolname, rolcatupdate from pg_authid;
rolname | rolcatupdate
---------+--------------
rbrad | t
(1 row)

template1=# select has_table_privilege('pg_authid', 'truncate');
has_table_privilege
---------------------
t
(1 row)

template1=# truncate pg_authid;
ERROR: permission denied: "pg_authid" is a system catalog

The TRUNCATE fails even though \z and has_table_privilege() said I had
permissions.
Compare with the DELETE privilege:

template1=# select has_table_privilege('pg_authid', 'delete');
has_table_privilege
---------------------
t
(1 row)

template1=# delete from pg_authid;
DELETE 1

Thanks,

- Ryan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-09-01 20:00:58 Re: [Patch Review] TRUNCATE Permission
Previous Message Heikki Linnakangas 2008-09-01 18:00:47 Re: Window functions patch v04 for the September commit fest