2011-01-24 09:44:48 +08:00
|
|
|
--
|
|
|
|
-- Regression Tests for Label Management
|
|
|
|
--
|
|
|
|
--
|
|
|
|
-- Setup
|
|
|
|
--
|
|
|
|
CREATE TABLE t1 (a int, b text);
|
|
|
|
INSERT INTO t1 VALUES (1, 'aaa'), (2, 'bbb'), (3, 'ccc');
|
2021-01-28 21:01:41 +08:00
|
|
|
CREATE TABLE t2 AS SELECT * FROM t1 WHERE a % 2 = 0;
|
2011-01-24 09:44:48 +08:00
|
|
|
CREATE FUNCTION f1 () RETURNS text
|
|
|
|
AS 'SELECT sepgsql_getcon()'
|
|
|
|
LANGUAGE sql;
|
|
|
|
CREATE FUNCTION f2 () RETURNS text
|
|
|
|
AS 'SELECT sepgsql_getcon()'
|
|
|
|
LANGUAGE sql;
|
|
|
|
SECURITY LABEL ON 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()'';
|
|
|
|
RETURN NULL;
|
|
|
|
END;' LANGUAGE plpgsql;
|
|
|
|
SECURITY LABEL ON FUNCTION f3()
|
|
|
|
IS 'system_u:object_r:sepgsql_trusted_proc_exec_t:s0';
|
2011-04-05 01:25:42 +08:00
|
|
|
CREATE FUNCTION f4 () RETURNS text
|
|
|
|
AS 'SELECT sepgsql_getcon()'
|
|
|
|
LANGUAGE sql;
|
|
|
|
SECURITY LABEL ON FUNCTION f4()
|
2012-03-16 04:08:40 +08:00
|
|
|
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 LABEL ON FUNCTION f5(text)
|
|
|
|
IS 'system_u:object_r:sepgsql_regtest_trusted_proc_exec_t:s0';
|
|
|
|
CREATE TABLE auth_tbl(uname text, credential text, label text);
|
|
|
|
INSERT INTO auth_tbl
|
|
|
|
VALUES ('foo', 'acbd18db4cc2f85cedef654fccc4a4d8', 'sepgsql_regtest_foo_t:s0'),
|
|
|
|
('var', 'b2145aac704ce76dbe1ac7adac535b23', 'sepgsql_regtest_var_t:s0'),
|
|
|
|
('baz', 'b2145aac704ce76dbe1ac7adac535b23', 'sepgsql_regtest_baz_t:s0');
|
|
|
|
SECURITY LABEL ON TABLE auth_tbl
|
|
|
|
IS 'system_u:object_r:sepgsql_secret_table_t:s0';
|
|
|
|
CREATE FUNCTION auth_func(text, text) RETURNS bool
|
|
|
|
LANGUAGE sql
|
|
|
|
AS 'SELECT sepgsql_setcon(regexp_replace(sepgsql_getcon(), ''_r:.*$'', ''_r:'' || label))
|
|
|
|
FROM auth_tbl WHERE uname = $1 AND credential = $2';
|
|
|
|
SECURITY LABEL ON FUNCTION auth_func(text,text)
|
2011-04-05 01:25:42 +08:00
|
|
|
IS 'system_u:object_r:sepgsql_regtest_trusted_proc_exec_t:s0';
|
2012-03-16 04:08:40 +08:00
|
|
|
CREATE TABLE foo_tbl(a int, b text);
|
|
|
|
INSERT INTO foo_tbl VALUES (1, 'aaa'), (2,'bbb'), (3,'ccc'), (4,'ddd');
|
|
|
|
SECURITY LABEL ON TABLE foo_tbl
|
|
|
|
IS 'system_u:object_r:sepgsql_regtest_foo_table_t:s0';
|
|
|
|
CREATE TABLE var_tbl(x int, y text);
|
|
|
|
INSERT INTO var_tbl VALUES (2,'xxx'), (3,'yyy'), (4,'zzz'), (5,'xyz');
|
|
|
|
SECURITY LABEL ON TABLE var_tbl
|
|
|
|
IS 'system_u:object_r:sepgsql_regtest_var_table_t:s0';
|
2017-04-10 05:01:58 +08:00
|
|
|
CREATE TABLE foo_ptbl(o int, p text) PARTITION BY RANGE (o);
|
|
|
|
CREATE TABLE foo_ptbl_ones PARTITION OF foo_ptbl FOR VALUES FROM ('0') TO ('10');
|
|
|
|
CREATE TABLE foo_ptbl_tens PARTITION OF foo_ptbl FOR VALUES FROM ('10') TO ('100');
|
|
|
|
INSERT INTO foo_ptbl VALUES (0, 'aaa'), (9,'bbb'), (10,'ccc'), (99,'ddd');
|
|
|
|
SECURITY LABEL ON TABLE foo_ptbl
|
|
|
|
IS 'system_u:object_r:sepgsql_regtest_foo_table_t:s0';
|
|
|
|
CREATE TABLE var_ptbl(q int, r text) PARTITION BY RANGE (q);
|
|
|
|
CREATE TABLE var_ptbl_ones PARTITION OF var_ptbl FOR VALUES FROM ('0') TO ('10');
|
|
|
|
CREATE TABLE var_ptbl_tens PARTITION OF var_ptbl FOR VALUES FROM ('10') TO ('100');
|
|
|
|
INSERT INTO var_ptbl VALUES (0,'xxx'), (9,'yyy'), (10,'zzz'), (99,'xyz');
|
|
|
|
SECURITY LABEL ON TABLE var_ptbl
|
|
|
|
IS 'system_u:object_r:sepgsql_regtest_var_table_t:s0';
|
2011-01-24 09:44:48 +08:00
|
|
|
--
|
|
|
|
-- Tests for default labeling behavior
|
|
|
|
--
|
|
|
|
SELECT sepgsql_getcon(); -- confirm client privilege
|
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
CREATE TABLE t3 (s int, t text);
|
|
|
|
INSERT INTO t3 VALUES (1, 'sss'), (2, 'ttt'), (3, 'uuu');
|
2013-03-29 03:38:35 +08:00
|
|
|
SELECT sepgsql_getcon(); -- confirm client privilege
|
|
|
|
sepgsql_getcon
|
|
|
|
----------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_dba_t:s0
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
CREATE TABLE t4 (m int, n text);
|
|
|
|
INSERT INTO t4 VALUES (1,'mmm'), (2,'nnn'), (3,'ooo');
|
2017-04-10 05:01:58 +08:00
|
|
|
SELECT sepgsql_getcon(); -- confirm client privilege
|
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
CREATE TABLE tpart (o int, p text) PARTITION BY RANGE (o);
|
|
|
|
CREATE TABLE tpart_ones PARTITION OF tpart FOR VALUES FROM ('0') TO ('10');
|
|
|
|
SELECT sepgsql_getcon(); -- confirm client privilege
|
|
|
|
sepgsql_getcon
|
|
|
|
----------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_dba_t:s0
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
CREATE TABLE tpart_tens PARTITION OF tpart FOR VALUES FROM ('10') TO ('100');
|
|
|
|
INSERT INTO tpart VALUES (0, 'aaa');
|
|
|
|
INSERT INTO tpart VALUES (9, 'bbb');
|
|
|
|
INSERT INTO tpart VALUES (99, 'ccc');
|
2011-01-24 09:44:48 +08:00
|
|
|
SELECT objtype, objname, label FROM pg_seclabels
|
2017-04-10 05:01:58 +08:00
|
|
|
WHERE provider = 'selinux' AND objtype = 'table' AND objname in ('t1', 't2', 't3',
|
|
|
|
'tpart',
|
|
|
|
'tpart_ones',
|
|
|
|
'tpart_tens')
|
2017-04-10 06:59:02 +08:00
|
|
|
ORDER BY objname COLLATE "C" ASC;
|
2017-04-10 05:01:58 +08:00
|
|
|
objtype | objname | label
|
|
|
|
---------+------------+-----------------------------------------------
|
|
|
|
table | t1 | unconfined_u:object_r:sepgsql_table_t:s0
|
|
|
|
table | t2 | unconfined_u:object_r:sepgsql_table_t:s0
|
|
|
|
table | t3 | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
table | tpart | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
table | tpart_ones | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
table | tpart_tens | unconfined_u:object_r:sepgsql_table_t:s0
|
|
|
|
(6 rows)
|
2011-01-24 09:44:48 +08:00
|
|
|
|
2013-03-29 03:38:35 +08:00
|
|
|
SELECT objtype, objname, label FROM pg_seclabels
|
2017-04-10 05:01:58 +08:00
|
|
|
WHERE provider = 'selinux' AND objtype = 'column' AND (objname like 't3.%'
|
|
|
|
OR objname like 't4.%'
|
|
|
|
OR objname like 'tpart.%'
|
|
|
|
OR objname like 'tpart_ones.%'
|
|
|
|
OR objname like 'tpart_tens.%')
|
2017-04-10 06:59:02 +08:00
|
|
|
ORDER BY objname COLLATE "C" ASC;
|
2017-04-10 05:01:58 +08:00
|
|
|
objtype | objname | label
|
|
|
|
---------+---------------------+-----------------------------------------------
|
|
|
|
column | t3.cmax | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | t3.cmin | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | t3.ctid | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | t3.s | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | t3.t | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | t3.tableoid | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | t3.xmax | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | t3.xmin | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | t4.cmax | unconfined_u:object_r:sepgsql_sysobj_t:s0
|
|
|
|
column | t4.cmin | unconfined_u:object_r:sepgsql_sysobj_t:s0
|
|
|
|
column | t4.ctid | unconfined_u:object_r:sepgsql_sysobj_t:s0
|
|
|
|
column | t4.m | unconfined_u:object_r:sepgsql_table_t:s0
|
|
|
|
column | t4.n | unconfined_u:object_r:sepgsql_table_t:s0
|
|
|
|
column | t4.tableoid | unconfined_u:object_r:sepgsql_sysobj_t:s0
|
|
|
|
column | t4.xmax | unconfined_u:object_r:sepgsql_sysobj_t:s0
|
|
|
|
column | t4.xmin | unconfined_u:object_r:sepgsql_sysobj_t:s0
|
|
|
|
column | tpart.cmax | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | tpart.cmin | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | tpart.ctid | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | tpart.o | unconfined_u:object_r:user_sepgsql_table_t:s0
|
2017-04-10 06:59:02 +08:00
|
|
|
column | tpart.p | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | tpart.tableoid | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | tpart.xmax | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | tpart.xmin | unconfined_u:object_r:user_sepgsql_table_t:s0
|
2017-04-10 05:01:58 +08:00
|
|
|
column | tpart_ones.cmax | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | tpart_ones.cmin | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | tpart_ones.ctid | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | tpart_ones.o | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | tpart_ones.p | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | tpart_ones.tableoid | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | tpart_ones.xmax | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | tpart_ones.xmin | unconfined_u:object_r:user_sepgsql_table_t:s0
|
|
|
|
column | tpart_tens.cmax | unconfined_u:object_r:sepgsql_sysobj_t:s0
|
|
|
|
column | tpart_tens.cmin | unconfined_u:object_r:sepgsql_sysobj_t:s0
|
|
|
|
column | tpart_tens.ctid | unconfined_u:object_r:sepgsql_sysobj_t:s0
|
|
|
|
column | tpart_tens.o | unconfined_u:object_r:sepgsql_table_t:s0
|
|
|
|
column | tpart_tens.p | unconfined_u:object_r:sepgsql_table_t:s0
|
|
|
|
column | tpart_tens.tableoid | unconfined_u:object_r:sepgsql_sysobj_t:s0
|
|
|
|
column | tpart_tens.xmax | unconfined_u:object_r:sepgsql_sysobj_t:s0
|
|
|
|
column | tpart_tens.xmin | unconfined_u:object_r:sepgsql_sysobj_t:s0
|
|
|
|
(40 rows)
|
2013-03-29 03:38:35 +08:00
|
|
|
|
2011-01-24 09:44:48 +08:00
|
|
|
--
|
|
|
|
-- Tests for SECURITY LABEL
|
|
|
|
--
|
|
|
|
SELECT sepgsql_getcon(); -- confirm client privilege
|
|
|
|
sepgsql_getcon
|
|
|
|
----------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_dba_t:s0
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SECURITY LABEL ON TABLE t1
|
|
|
|
IS 'system_u:object_r:sepgsql_ro_table_t:s0'; -- ok
|
|
|
|
SECURITY LABEL ON TABLE t2
|
2011-02-03 12:39:43 +08:00
|
|
|
IS 'invalid security context'; -- be failed
|
|
|
|
ERROR: SELinux: invalid security label: "invalid security context"
|
2011-01-24 09:44:48 +08:00
|
|
|
SECURITY LABEL ON COLUMN t2
|
|
|
|
IS 'system_u:object_r:sepgsql_ro_table_t:s0'; -- be failed
|
2012-05-22 23:19:33 +08:00
|
|
|
ERROR: column name must be qualified
|
2011-01-24 09:44:48 +08:00
|
|
|
SECURITY LABEL ON COLUMN t2.b
|
|
|
|
IS 'system_u:object_r:sepgsql_ro_table_t:s0'; -- ok
|
2017-04-10 05:01:58 +08:00
|
|
|
SECURITY LABEL ON TABLE tpart
|
|
|
|
IS 'system_u:object_r:sepgsql_ro_table_t:s0'; -- ok
|
|
|
|
SECURITY LABEL ON TABLE tpart
|
|
|
|
IS 'invalid security context'; -- failed
|
|
|
|
ERROR: SELinux: invalid security label: "invalid security context"
|
|
|
|
SECURITY LABEL ON COLUMN tpart
|
|
|
|
IS 'system_u:object_r:sepgsql_ro_table_t:s0'; -- failed
|
|
|
|
ERROR: column name must be qualified
|
|
|
|
SECURITY LABEL ON COLUMN tpart.o
|
|
|
|
IS 'system_u:object_r:sepgsql_ro_table_t:s0'; -- ok
|
2011-01-24 09:44:48 +08:00
|
|
|
--
|
|
|
|
-- Tests for Trusted Procedures
|
|
|
|
--
|
|
|
|
SELECT sepgsql_getcon(); -- confirm client privilege
|
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0
|
|
|
|
(1 row)
|
|
|
|
|
2013-04-12 20:55:56 +08:00
|
|
|
SET sepgsql.debug_audit = true;
|
|
|
|
SET client_min_messages = log;
|
2011-01-24 09:44:48 +08:00
|
|
|
SELECT f1(); -- normal procedure
|
2013-04-17 21:52:25 +08:00
|
|
|
LOG: SELinux: allowed { execute } scontext=unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0 tcontext=unconfined_u:object_r:sepgsql_proc_exec_t:s0 tclass=db_procedure name="public.f1()"
|
|
|
|
LOG: SELinux: allowed { execute } scontext=unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0 tcontext=system_u:object_r:sepgsql_proc_exec_t:s0 tclass=db_procedure name="pg_catalog.sepgsql_getcon()"
|
2011-01-24 09:44:48 +08:00
|
|
|
f1
|
|
|
|
-----------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT f2(); -- trusted procedure
|
2013-04-17 21:52:25 +08:00
|
|
|
LOG: SELinux: allowed { execute } scontext=unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0 tcontext=system_u:object_r:sepgsql_trusted_proc_exec_t:s0 tclass=db_procedure name="public.f2()"
|
2013-04-12 20:55:56 +08:00
|
|
|
LOG: SELinux: allowed { entrypoint } scontext=unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0 tcontext=system_u:object_r:sepgsql_trusted_proc_exec_t:s0 tclass=db_procedure name="function f2()"
|
|
|
|
LOG: SELinux: allowed { transition } scontext=unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0 tcontext=unconfined_u:unconfined_r:sepgsql_trusted_proc_t:s0 tclass=process
|
2013-04-17 21:52:25 +08:00
|
|
|
LOG: SELinux: allowed { execute } scontext=unconfined_u:unconfined_r:sepgsql_trusted_proc_t:s0 tcontext=system_u:object_r:sepgsql_proc_exec_t:s0 tclass=db_procedure name="pg_catalog.sepgsql_getcon()"
|
2011-01-24 09:44:48 +08:00
|
|
|
f2
|
|
|
|
-----------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_trusted_proc_t:s0
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT f3(); -- trusted procedure that raises an error
|
2013-04-17 21:52:25 +08:00
|
|
|
LOG: SELinux: allowed { execute } scontext=unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0 tcontext=system_u:object_r:sepgsql_trusted_proc_exec_t:s0 tclass=db_procedure name="public.f3()"
|
2013-04-12 20:55:56 +08:00
|
|
|
LOG: SELinux: allowed { entrypoint } scontext=unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0 tcontext=system_u:object_r:sepgsql_trusted_proc_exec_t:s0 tclass=db_procedure name="function f3()"
|
|
|
|
LOG: SELinux: allowed { transition } scontext=unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0 tcontext=unconfined_u:unconfined_r:sepgsql_trusted_proc_t:s0 tclass=process
|
2011-01-24 09:44:48 +08:00
|
|
|
ERROR: an exception from f3()
|
2015-09-07 02:25:36 +08:00
|
|
|
CONTEXT: PL/pgSQL function f3() line 2 at RAISE
|
2011-04-05 01:25:42 +08:00
|
|
|
SELECT f4(); -- failed on domain transition
|
2013-04-17 21:52:25 +08:00
|
|
|
LOG: SELinux: allowed { execute } scontext=unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0 tcontext=system_u:object_r:sepgsql_nosuch_trusted_proc_exec_t:s0 tclass=db_procedure name="public.f4()"
|
2013-04-12 20:55:56 +08:00
|
|
|
LOG: SELinux: allowed { entrypoint } scontext=unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0 tcontext=system_u:object_r:sepgsql_nosuch_trusted_proc_exec_t:s0 tclass=db_procedure name="function f4()"
|
|
|
|
LOG: SELinux: denied { transition } scontext=unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0 tcontext=unconfined_u:unconfined_r:sepgsql_regtest_nosuch_t:s0 tclass=process
|
2011-04-05 01:25:42 +08:00
|
|
|
ERROR: SELinux: security policy violation
|
2011-01-24 09:44:48 +08:00
|
|
|
SELECT sepgsql_getcon(); -- client's label must be restored
|
2013-04-17 21:52:25 +08:00
|
|
|
LOG: SELinux: allowed { execute } scontext=unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0 tcontext=system_u:object_r:sepgsql_proc_exec_t:s0 tclass=db_procedure name="pg_catalog.sepgsql_getcon()"
|
2011-01-24 09:44:48 +08:00
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0
|
|
|
|
(1 row)
|
|
|
|
|
2012-03-16 04:08:40 +08:00
|
|
|
--
|
|
|
|
-- Test for Dynamic Domain Transition
|
|
|
|
--
|
|
|
|
-- validation of transaction aware dynamic-transition
|
|
|
|
SELECT sepgsql_getcon(); -- confirm client privilege
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c25
|
2012-03-16 04:08:40 +08:00
|
|
|
(1 row)
|
|
|
|
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
SELECT sepgsql_setcon('unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c15');
|
2012-03-16 04:08:40 +08:00
|
|
|
sepgsql_setcon
|
|
|
|
----------------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT sepgsql_getcon();
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c15
|
2012-03-16 04:08:40 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT sepgsql_setcon(NULL); -- failed to reset
|
|
|
|
ERROR: SELinux: security policy violation
|
|
|
|
SELECT sepgsql_getcon();
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c15
|
2012-03-16 04:08:40 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
BEGIN;
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
SELECT sepgsql_setcon('unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c12');
|
2012-03-16 04:08:40 +08:00
|
|
|
sepgsql_setcon
|
|
|
|
----------------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT sepgsql_getcon();
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c12
|
2012-03-16 04:08:40 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SAVEPOINT svpt_1;
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
SELECT sepgsql_setcon('unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c9');
|
2012-03-16 04:08:40 +08:00
|
|
|
sepgsql_setcon
|
|
|
|
----------------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT sepgsql_getcon();
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
sepgsql_getcon
|
|
|
|
----------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c9
|
2012-03-16 04:08:40 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SAVEPOINT svpt_2;
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
SELECT sepgsql_setcon('unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c6');
|
2012-03-16 04:08:40 +08:00
|
|
|
sepgsql_setcon
|
|
|
|
----------------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT sepgsql_getcon();
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
sepgsql_getcon
|
|
|
|
----------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c6
|
2012-03-16 04:08:40 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SAVEPOINT svpt_3;
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
SELECT sepgsql_setcon('unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c3');
|
2012-03-16 04:08:40 +08:00
|
|
|
sepgsql_setcon
|
|
|
|
----------------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT sepgsql_getcon();
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
sepgsql_getcon
|
|
|
|
----------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c3
|
2012-03-16 04:08:40 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
ROLLBACK TO SAVEPOINT svpt_2;
|
|
|
|
SELECT sepgsql_getcon(); -- should be 's0:c0.c9'
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
sepgsql_getcon
|
|
|
|
----------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c9
|
2012-03-16 04:08:40 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
ROLLBACK TO SAVEPOINT svpt_1;
|
|
|
|
SELECT sepgsql_getcon(); -- should be 's0:c0.c12'
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c12
|
2012-03-16 04:08:40 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
ABORT;
|
|
|
|
SELECT sepgsql_getcon(); -- should be 's0:c0.c15'
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c15
|
2012-03-16 04:08:40 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
BEGIN;
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
SELECT sepgsql_setcon('unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c8');
|
2012-03-16 04:08:40 +08:00
|
|
|
sepgsql_setcon
|
|
|
|
----------------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT sepgsql_getcon();
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
sepgsql_getcon
|
|
|
|
----------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c8
|
2012-03-16 04:08:40 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SAVEPOINT svpt_1;
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
SELECT sepgsql_setcon('unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c4');
|
2012-03-16 04:08:40 +08:00
|
|
|
sepgsql_setcon
|
|
|
|
----------------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT sepgsql_getcon();
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
sepgsql_getcon
|
|
|
|
----------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c4
|
2012-03-16 04:08:40 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
ROLLBACK TO SAVEPOINT svpt_1;
|
|
|
|
SELECT sepgsql_getcon(); -- should be 's0:c0.c8'
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
sepgsql_getcon
|
|
|
|
----------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c8
|
2012-03-16 04:08:40 +08:00
|
|
|
(1 row)
|
|
|
|
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
SELECT sepgsql_setcon('unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c6');
|
2012-03-16 04:08:40 +08:00
|
|
|
sepgsql_setcon
|
|
|
|
----------------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
COMMIT;
|
|
|
|
SELECT sepgsql_getcon(); -- should be 's0:c0.c6'
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
sepgsql_getcon
|
|
|
|
----------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0:c0.c6
|
2012-03-16 04:08:40 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
-- sepgsql_regtest_user_t is not available dynamic-transition,
|
|
|
|
-- unless sepgsql_setcon() is called inside of trusted-procedure
|
|
|
|
SELECT sepgsql_getcon(); -- confirm client privilege
|
|
|
|
sepgsql_getcon
|
|
|
|
------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0:c0.c15
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
-- sepgsql_regtest_user_t has no permission to switch current label
|
|
|
|
SELECT sepgsql_setcon('unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0'); -- failed
|
|
|
|
ERROR: SELinux: security policy violation
|
|
|
|
SELECT sepgsql_getcon();
|
|
|
|
sepgsql_getcon
|
|
|
|
------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0:c0.c15
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
-- 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
|
|
|
|
f5
|
|
|
|
----
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT sepgsql_getcon();
|
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0:c0.c7
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT f5('unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0:c0.c31'); -- Failed
|
|
|
|
ERROR: SELinux: security policy violation
|
|
|
|
CONTEXT: SQL function "f5" statement 1
|
|
|
|
SELECT sepgsql_getcon();
|
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0:c0.c7
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT f5(NULL); -- Failed
|
|
|
|
ERROR: SELinux: security policy violation
|
|
|
|
CONTEXT: SQL function "f5" statement 1
|
|
|
|
SELECT sepgsql_getcon();
|
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0:c0.c7
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
BEGIN;
|
|
|
|
SELECT f5('unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0:c0.c3'); -- OK
|
|
|
|
f5
|
|
|
|
----
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT sepgsql_getcon();
|
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0:c0.c3
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
ABORT;
|
|
|
|
SELECT sepgsql_getcon();
|
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_user_t:s0:c0.c7
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Test for simulation of typical connection pooling server
|
|
|
|
--
|
|
|
|
SELECT sepgsql_getcon(); -- confirm client privilege
|
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_pool_t:s0
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
-- we shouldn't allow to switch client label without trusted procedure
|
|
|
|
SELECT sepgsql_setcon('unconfined_u:unconfined_r:sepgsql_regtest_foo_t:s0');
|
|
|
|
ERROR: SELinux: security policy violation
|
|
|
|
SELECT * FROM auth_tbl; -- failed, no permission to reference
|
|
|
|
ERROR: SELinux: security policy violation
|
|
|
|
-- switch to "foo"
|
|
|
|
SELECT auth_func('foo', 'acbd18db4cc2f85cedef654fccc4a4d8');
|
|
|
|
auth_func
|
|
|
|
-----------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT sepgsql_getcon();
|
|
|
|
sepgsql_getcon
|
|
|
|
----------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_foo_t:s0
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT * FROM foo_tbl; -- OK
|
|
|
|
a | b
|
|
|
|
---+-----
|
|
|
|
1 | aaa
|
|
|
|
2 | bbb
|
|
|
|
3 | ccc
|
|
|
|
4 | ddd
|
|
|
|
(4 rows)
|
|
|
|
|
2017-04-10 05:01:58 +08:00
|
|
|
SELECT * FROM foo_ptbl; -- OK
|
|
|
|
o | p
|
|
|
|
----+-----
|
|
|
|
0 | aaa
|
|
|
|
9 | bbb
|
|
|
|
10 | ccc
|
|
|
|
99 | ddd
|
|
|
|
(4 rows)
|
|
|
|
|
2012-03-16 04:08:40 +08:00
|
|
|
SELECT * FROM var_tbl; -- failed
|
|
|
|
ERROR: SELinux: security policy violation
|
2017-04-10 05:01:58 +08:00
|
|
|
SELECT * FROM var_ptbl; -- failed
|
|
|
|
ERROR: SELinux: security policy violation
|
2012-03-16 04:08:40 +08:00
|
|
|
SELECT * FROM auth_tbl; -- failed
|
|
|
|
ERROR: SELinux: security policy violation
|
|
|
|
SELECT sepgsql_setcon(NULL); -- end of session
|
|
|
|
sepgsql_setcon
|
|
|
|
----------------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT sepgsql_getcon();
|
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_pool_t:s0
|
|
|
|
(1 row)
|
|
|
|
|
2017-02-06 18:04:04 +08:00
|
|
|
-- the pooler cannot touch these tables directly
|
2012-03-16 04:08:40 +08:00
|
|
|
SELECT * FROM foo_tbl; -- failed
|
|
|
|
ERROR: SELinux: security policy violation
|
2017-04-10 05:01:58 +08:00
|
|
|
SELECT * FROM foo_ptbl; -- failed
|
|
|
|
ERROR: SELinux: security policy violation
|
2012-03-16 04:08:40 +08:00
|
|
|
SELECT * FROM var_tbl; -- failed
|
|
|
|
ERROR: SELinux: security policy violation
|
2017-04-10 05:01:58 +08:00
|
|
|
SELECT * FROM var_ptbl; -- failed
|
|
|
|
ERROR: SELinux: security policy violation
|
2012-03-16 04:08:40 +08:00
|
|
|
-- switch to "var"
|
|
|
|
SELECT auth_func('var', 'b2145aac704ce76dbe1ac7adac535b23');
|
|
|
|
auth_func
|
|
|
|
-----------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT sepgsql_getcon();
|
|
|
|
sepgsql_getcon
|
|
|
|
----------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_var_t:s0
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT * FROM foo_tbl; -- failed
|
|
|
|
ERROR: SELinux: security policy violation
|
2017-04-10 05:01:58 +08:00
|
|
|
SELECT * FROM foo_ptbl; -- failed
|
|
|
|
ERROR: SELinux: security policy violation
|
2012-03-16 04:08:40 +08:00
|
|
|
SELECT * FROM var_tbl; -- OK
|
|
|
|
x | y
|
|
|
|
---+-----
|
|
|
|
2 | xxx
|
|
|
|
3 | yyy
|
|
|
|
4 | zzz
|
|
|
|
5 | xyz
|
|
|
|
(4 rows)
|
|
|
|
|
2017-04-10 05:01:58 +08:00
|
|
|
SELECT * FROM var_ptbl; -- OK
|
|
|
|
q | r
|
|
|
|
----+-----
|
|
|
|
0 | xxx
|
|
|
|
9 | yyy
|
|
|
|
10 | zzz
|
|
|
|
99 | xyz
|
|
|
|
(4 rows)
|
|
|
|
|
2012-03-16 04:08:40 +08:00
|
|
|
SELECT * FROM auth_tbl; -- failed
|
|
|
|
ERROR: SELinux: security policy violation
|
|
|
|
SELECT sepgsql_setcon(NULL); -- end of session
|
|
|
|
sepgsql_setcon
|
|
|
|
----------------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
-- misc checks
|
|
|
|
SELECT auth_func('var', 'invalid credential'); -- not works
|
|
|
|
auth_func
|
|
|
|
-----------
|
|
|
|
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT sepgsql_getcon();
|
|
|
|
sepgsql_getcon
|
|
|
|
-----------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_pool_t:s0
|
|
|
|
(1 row)
|
|
|
|
|
2011-01-24 09:44:48 +08:00
|
|
|
--
|
|
|
|
-- Clean up
|
|
|
|
--
|
|
|
|
SELECT sepgsql_getcon(); -- confirm client privilege
|
Fix sepgsql regression tests.
The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.
The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.
Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.
Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.
2015-08-31 02:09:05 +08:00
|
|
|
sepgsql_getcon
|
|
|
|
---------------------------------------------------------------------
|
|
|
|
unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255
|
2011-01-24 09:44:48 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS t1 CASCADE;
|
|
|
|
DROP TABLE IF EXISTS t2 CASCADE;
|
|
|
|
DROP TABLE IF EXISTS t3 CASCADE;
|
2013-03-29 03:38:35 +08:00
|
|
|
DROP TABLE IF EXISTS t4 CASCADE;
|
2017-04-10 05:01:58 +08:00
|
|
|
DROP TABLE IF EXISTS tpart CASCADE;
|
2011-01-24 09:44:48 +08:00
|
|
|
DROP FUNCTION IF EXISTS f1() CASCADE;
|
|
|
|
DROP FUNCTION IF EXISTS f2() CASCADE;
|
|
|
|
DROP FUNCTION IF EXISTS f3() CASCADE;
|
2011-04-05 01:25:42 +08:00
|
|
|
DROP FUNCTION IF EXISTS f4() CASCADE;
|
2012-03-16 04:08:40 +08:00
|
|
|
DROP FUNCTION IF EXISTS f5(text) CASCADE;
|