mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Make inherited TRUNCATE perform access permission checks on parent table only.
Previously, TRUNCATE command through a parent table checked the permissions on not only the parent table but also the children tables inherited from it. This was a bug and inherited queries should perform access permission checks on the parent table only. This commit fixes that bug. Back-patch to all supported branches. Author: Amit Langote Reviewed-by: Fujii Masao Discussion: https://postgr.es/m/CAHGQGwFHdSvifhJE+-GSNqUHSfbiKxaeQQ7HGcYz6SC2n_oDcg@mail.gmail.com
This commit is contained in:
@ -695,6 +695,27 @@ SELECT tableoid FROM atestp2; -- ok
|
||||
----------
|
||||
(0 rows)
|
||||
|
||||
-- child's permissions do not apply when operating on parent
|
||||
SET SESSION AUTHORIZATION regress_priv_user1;
|
||||
REVOKE ALL ON atestc FROM regress_priv_user2;
|
||||
GRANT ALL ON atestp1 TO regress_priv_user2;
|
||||
SET SESSION AUTHORIZATION regress_priv_user2;
|
||||
SELECT f2 FROM atestp1; -- ok
|
||||
f2
|
||||
----
|
||||
(0 rows)
|
||||
|
||||
SELECT f2 FROM atestc; -- fail
|
||||
ERROR: permission denied for table atestc
|
||||
DELETE FROM atestp1; -- ok
|
||||
DELETE FROM atestc; -- fail
|
||||
ERROR: permission denied for table atestc
|
||||
UPDATE atestp1 SET f1 = 1; -- ok
|
||||
UPDATE atestc SET f1 = 1; -- fail
|
||||
ERROR: permission denied for table atestc
|
||||
TRUNCATE atestp1; -- ok
|
||||
TRUNCATE atestc; -- fail
|
||||
ERROR: permission denied for table atestc
|
||||
-- privileges on functions, languages
|
||||
-- switch to superuser
|
||||
\c -
|
||||
|
@ -446,6 +446,20 @@ SELECT fy FROM atestp2; -- ok
|
||||
SELECT atestp2 FROM atestp2; -- ok
|
||||
SELECT tableoid FROM atestp2; -- ok
|
||||
|
||||
-- child's permissions do not apply when operating on parent
|
||||
SET SESSION AUTHORIZATION regress_priv_user1;
|
||||
REVOKE ALL ON atestc FROM regress_priv_user2;
|
||||
GRANT ALL ON atestp1 TO regress_priv_user2;
|
||||
SET SESSION AUTHORIZATION regress_priv_user2;
|
||||
SELECT f2 FROM atestp1; -- ok
|
||||
SELECT f2 FROM atestc; -- fail
|
||||
DELETE FROM atestp1; -- ok
|
||||
DELETE FROM atestc; -- fail
|
||||
UPDATE atestp1 SET f1 = 1; -- ok
|
||||
UPDATE atestc SET f1 = 1; -- fail
|
||||
TRUNCATE atestp1; -- ok
|
||||
TRUNCATE atestc; -- fail
|
||||
|
||||
-- privileges on functions, languages
|
||||
|
||||
-- switch to superuser
|
||||
|
Reference in New Issue
Block a user