-- -- Setup -- CREATETABLE t1 (a int, b text); INSERTINTO t1 VALUES (1, 'aaa'), (2, 'bbb'), (3, 'ccc'); CREATETABLE t2 ASSELECT * FROM t1 WHERE a % 2 = 0;
CREATE FUNCTION f1 () RETURNS text AS'SELECT sepgsql_getcon()'
LANGUAGE sql;
CREATE FUNCTION f2 () RETURNS text AS'SELECT sepgsql_getcon()'
LANGUAGE sql;
SECURITY LABELON FUNCTION f2() IS'system_u:object_r:sepgsql_trusted_proc_exec_t:s0';
CREATE FUNCTION f3 () RETURNS text AS'BEGIN
RAISE EXCEPTION ''an exception from f3()''; RETURNNULL;
END;' LANGUAGE plpgsql;
SECURITY LABELON FUNCTION f3() IS'system_u:object_r:sepgsql_trusted_proc_exec_t:s0';
CREATE FUNCTION f4 () RETURNS text AS'SELECT sepgsql_getcon()'
LANGUAGE sql;
SECURITY LABELON FUNCTION f4() IS'system_u:object_r:sepgsql_nosuch_trusted_proc_exec_t:s0';
CREATE FUNCTION f5 (text) RETURNS bool AS'SELECT sepgsql_setcon($1)'
LANGUAGE sql;
SECURITY LABELON FUNCTION f5(text) IS'system_u:object_r:sepgsql_regtest_trusted_proc_exec_t:s0';
CREATETABLE foo_ptbl(o int, p text) PARTITION BY RANGE (o); CREATETABLE foo_ptbl_ones PARTITION OF foo_ptbl FORVALUESFROM ('0') TO ('10'); CREATETABLE foo_ptbl_tens PARTITION OF foo_ptbl FORVALUESFROM ('10') TO ('100');
CREATETABLE var_ptbl(q int, r text) PARTITION BY RANGE (q); CREATETABLE var_ptbl_ones PARTITION OF var_ptbl FORVALUESFROM ('0') TO ('10'); CREATETABLE var_ptbl_tens PARTITION OF var_ptbl FORVALUESFROM ('10') TO ('100');
-- -- Tests for default labeling behavior -- -- @SECURITY-CONTEXT=unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0 CREATETABLE t3 (s int, t text); INSERTINTO t3 VALUES (1, 'sss'), (2, 'ttt'), (3, 'uuu');
-- @SECURITY-CONTEXT=unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0 CREATETABLE tpart (o int, p text) PARTITION BY RANGE (o);
CREATETABLE tpart_ones PARTITION OF tpart FORVALUESFROM ('0') TO ('10'); -- @SECURITY-CONTEXT=unconfined_u:unconfined_r:sepgsql_regtest_dba_t:s0 CREATETABLE tpart_tens PARTITION OF tpart FORVALUESFROM ('10') TO ('100');
ROLLBACK TO SAVEPOINT svpt_1; SELECT sepgsql_getcon(); -- should be 's0:c0.c8' SELECT sepgsql_setcon('unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c6');
COMMIT; SELECT sepgsql_getcon(); -- should be 's0:c0.c6'
-- sepgsql_regtest_user_t is not available dynamic-transition, -- unless sepgsql_setcon() is called inside of trusted-procedure -- @SECURITY-CONTEXT=unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0:c0.c15
-- sepgsql_regtest_user_t has no permission to switch current label SELECT sepgsql_setcon('unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0'); -- failed SELECT sepgsql_getcon();
-- trusted procedure allows to switch, but unavailable to override MCS rules SELECT f5('unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0:c0.c7'); -- OK SELECT sepgsql_getcon();
BEGIN; SELECT f5('unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0:c0.c3'); -- OK SELECT sepgsql_getcon();
ABORT; SELECT sepgsql_getcon();
-- -- Test for simulation of typical connection pooling server -- -- @SECURITY-CONTEXT=unconfined_u:unconfined_r:sepgsql_regtest_pool_t:s0
-- we shouldn't allow to switch client label without trusted procedure SELECT sepgsql_setcon('unconfined_u:unconfined_r:sepgsql_regtest_foo_t:s0');
SELECT * FROM auth_tbl; -- failed, no permission to reference
-- switch to "foo" SELECT auth_func('foo', 'acbd18db4cc2f85cedef654fccc4a4d8');
SELECT sepgsql_getcon();
SELECT * FROM foo_tbl; -- OK SELECT * FROM foo_ptbl; -- OK
SELECT * FROM var_tbl; -- failed SELECT * FROM var_ptbl; -- failed
SELECT * FROM auth_tbl; -- failed
SELECT sepgsql_setcon(NULL); -- end of session SELECT sepgsql_getcon();
-- the pooler cannot touch these tables directly SELECT * FROM foo_tbl; -- failed SELECT * FROM foo_ptbl; -- failed
SELECT * FROM var_tbl; -- failed SELECT * FROM var_ptbl; -- failed
-- switch to "var" SELECT auth_func('var', 'b2145aac704ce76dbe1ac7adac535b23');
SELECT sepgsql_getcon();
SELECT * FROM foo_tbl; -- failed SELECT * FROM foo_ptbl; -- failed
SELECT * FROM var_tbl; -- OK SELECT * FROM var_ptbl; -- OK
SELECT * FROM auth_tbl; -- failed
SELECT sepgsql_setcon(NULL); -- end of session
-- misc checks SELECT auth_func('var', 'invalid credential'); -- not works SELECT sepgsql_getcon();
-- -- Clean up -- -- @SECURITY-CONTEXT=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 DROPTABLEIFEXISTS t1 CASCADE; DROPTABLEIFEXISTS t2 CASCADE; DROPTABLEIFEXISTS t3 CASCADE; DROPTABLEIFEXISTS t4 CASCADE; DROPTABLEIFEXISTS tpart CASCADE; DROP FUNCTION IFEXISTS f1() CASCADE; DROP FUNCTION IFEXISTS f2() CASCADE; DROP FUNCTION IFEXISTS f3() CASCADE; DROP FUNCTION IFEXISTS f4() CASCADE; DROP FUNCTION IFEXISTS f5(text) CASCADE;
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.