mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Update sepgsql to add mandatory access control for TRUNCATE
Use SELinux "db_table: { truncate }" to check if permission is granted to TRUNCATE. Update example SELinux policy to grant needed permission for TRUNCATE. Add new regression test to demonstrate a positive and negative cases. Test will only be run if the loaded SELinux policy has the "db_table: { truncate }" permission. Makes use of recent commit which added object TRUNCATE hook. Patch by Yuli Khodorkovskiy with minor editorialization by me. Not back-patched because the object TRUNCATE hook was not. Author: Yuli Khodorkovskiy Reviewed-by: Joe Conway Discussion: https://postgr.es/m/CAFL5wJcomybj1Xdw7qWmPJRpGuFukKgNrDb6uVBaCMgYS9dkaA%40mail.gmail.com
This commit is contained in:
24
contrib/sepgsql/sql/truncate.sql
Normal file
24
contrib/sepgsql/sql/truncate.sql
Normal file
@ -0,0 +1,24 @@
|
||||
--
|
||||
-- Regression Test for TRUNCATE
|
||||
--
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
CREATE TABLE julio_claudians (name text, birth_date date);
|
||||
SECURITY LABEL ON TABLE julio_claudians IS 'system_u:object_r:sepgsql_regtest_foo_table_t:s0';
|
||||
INSERT INTO julio_claudians VALUES ('Augustus', 'September 23, 63 BC'), ('Tiberius', 'November 16, 42 BC'), ('Caligula', 'August 31, 0012'), ('Claudius', 'August 1, 0010'), ('Nero', 'December 15, 0037');
|
||||
|
||||
CREATE TABLE flavians (name text, birth_date date);
|
||||
SECURITY LABEL ON TABLE flavians IS 'system_u:object_r:sepgsql_table_t:s0';
|
||||
|
||||
INSERT INTO flavians VALUES ('Vespasian', 'November 17, 0009'), ('Titus', 'December 30, 0039'), ('Domitian', 'October 24, 0051');
|
||||
|
||||
SELECT * from julio_claudians;
|
||||
SELECT * from flavians;
|
||||
|
||||
TRUNCATE TABLE julio_claudians; -- ok
|
||||
TRUNCATE TABLE flavians; -- failed
|
||||
|
||||
SELECT * from julio_claudians;
|
||||
SELECT * from flavians;
|
Reference in New Issue
Block a user