Re: Restoring default privileges on objects - Mailing list pgsql-general

From Erik Wienhold
Subject Re: Restoring default privileges on objects
Date
Msg-id 1166048641.281962.1693308151542@office.mailbox.org
Whole thread Raw
In response to Restoring default privileges on objects  (Stuart McGraw <smcgraw@mtneva.com>)
Responses Re: Restoring default privileges on objects
List pgsql-general
> On 29/08/2023 03:23 CEST Stuart McGraw <smcgraw@mtneva.com> wrote:
>
> If I've done a GRANT or REVOKE on some of the tables, how do I restore
> the default privileges so that the “Access privileges” appears empty
> again?  I re-granted what I think are the default privileges but the
> "Access privileges" column for that table contains "user1=arwdDxt/user1"
> rather than being blank.  This is Postgresql-14.

Yes, "user1=arwdDxt/user1" matches the default privileges if user1 is the table
owner.  Function acldefault('r', 'user1'::regrole) [1] gives you the default
privileges for tables.

You could set pg_class.relacl to NULL to restore the default privileges, but
messing with pg_catalog is at your own risk.  Besides that I don't know of any
way to restore the default privileges other than revoking all privileges before
granting whatever acldefault gives you.  Changing the table owner will then
also change the grantee and grantor in pg_class.relacl to the new owner.

[1] https://www.postgresql.org/docs/14/functions-info.html#FUNCTIONS-ACLITEM-FN-TABLE

--
Erik



pgsql-general by date:

Previous
From: Luca Ferrari
Date:
Subject: Re: PL/Perl function signatures
Next
From: Tom Lane
Date:
Subject: Re: Restoring default privileges on objects