From 1a2aaeb0db1bccd97140d479c4247127f6cb9378 Mon Sep 17 00:00:00 2001 From: Amit Kapila Date: Wed, 8 Dec 2021 11:31:16 +0530 Subject: Fix changing the ownership of ALL TABLES IN SCHEMA publication. Ensure that the new owner of ALL TABLES IN SCHEMA publication must be a superuser. The same is already ensured during CREATE PUBLICATION. Author: Vignesh C Reviewed-by: Nathan Bossart, Greg Nancarrow, Michael Paquier, Haiying Tang Discussion: https://postgr.es/m/CALDaNm0E5U-RqxFuFrkZrQeG7ae5trGa=xs=iRtPPHULtT4zOw@mail.gmail.com --- src/test/regress/expected/publication.out | 15 +++++++++++++++ src/test/regress/sql/publication.sql | 15 +++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'src/test') diff --git a/src/test/regress/expected/publication.out b/src/test/regress/expected/publication.out index a2115c1c606..c096fbdac58 100644 --- a/src/test/regress/expected/publication.out +++ b/src/test/regress/expected/publication.out @@ -373,6 +373,21 @@ ALTER PUBLICATION testpub2 ADD TABLE testpub_tbl1; -- ok DROP PUBLICATION testpub2; DROP PUBLICATION testpub3; SET ROLE regress_publication_user; +CREATE ROLE regress_publication_user3; +GRANT regress_publication_user2 TO regress_publication_user3; +SET client_min_messages = 'ERROR'; +CREATE PUBLICATION testpub4 FOR ALL TABLES IN SCHEMA pub_test; +RESET client_min_messages; +ALTER PUBLICATION testpub4 OWNER TO regress_publication_user3; +SET ROLE regress_publication_user3; +-- fail - new owner must be superuser +ALTER PUBLICATION testpub4 owner to regress_publication_user2; -- fail +ERROR: permission denied to change owner of publication "testpub4" +HINT: The owner of a FOR ALL TABLES IN SCHEMA publication must be a superuser. +ALTER PUBLICATION testpub4 owner to regress_publication_user; -- ok +SET ROLE regress_publication_user; +DROP PUBLICATION testpub4; +DROP ROLE regress_publication_user3; REVOKE CREATE ON DATABASE regression FROM regress_publication_user2; DROP TABLE testpub_parted; DROP TABLE testpub_tbl1; diff --git a/src/test/regress/sql/publication.sql b/src/test/regress/sql/publication.sql index 2fe41b07ae2..06628825444 100644 --- a/src/test/regress/sql/publication.sql +++ b/src/test/regress/sql/publication.sql @@ -218,6 +218,21 @@ DROP PUBLICATION testpub2; DROP PUBLICATION testpub3; SET ROLE regress_publication_user; +CREATE ROLE regress_publication_user3; +GRANT regress_publication_user2 TO regress_publication_user3; +SET client_min_messages = 'ERROR'; +CREATE PUBLICATION testpub4 FOR ALL TABLES IN SCHEMA pub_test; +RESET client_min_messages; +ALTER PUBLICATION testpub4 OWNER TO regress_publication_user3; +SET ROLE regress_publication_user3; +-- fail - new owner must be superuser +ALTER PUBLICATION testpub4 owner to regress_publication_user2; -- fail +ALTER PUBLICATION testpub4 owner to regress_publication_user; -- ok + +SET ROLE regress_publication_user; +DROP PUBLICATION testpub4; +DROP ROLE regress_publication_user3; + REVOKE CREATE ON DATABASE regression FROM regress_publication_user2; DROP TABLE testpub_parted; -- cgit v1.2.3