mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-26 14:37:18 +02:00
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.
73 lines
5.3 KiB
Plaintext
73 lines
5.3 KiB
Plaintext
--
|
|
-- Regression Test for Misc Permission Checks
|
|
--
|
|
LOAD '$libdir/sepgsql'; -- failed
|
|
ERROR: SELinux: LOAD is not permitted
|
|
--
|
|
-- Permissions to execute functions
|
|
--
|
|
CREATE TABLE t1 (x int, y text);
|
|
INSERT INTO t1 (SELECT x, md5(x::text) FROM generate_series(1,100) x);
|
|
SET sepgsql.debug_audit = on;
|
|
SET client_min_messages = log;
|
|
-- regular function and operators
|
|
SELECT * FROM t1 WHERE x > 50 AND y like '%64%';
|
|
LOG: SELinux: allowed { select } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_table name="public.t1"
|
|
LOG: SELinux: allowed { select } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="table t1 column x"
|
|
LOG: SELinux: allowed { select } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="table t1 column y"
|
|
LOG: SELinux: allowed { execute } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=system_u:object_r:sepgsql_proc_exec_t:s0 tclass=db_procedure name="pg_catalog.int4gt(integer,integer)"
|
|
LOG: SELinux: allowed { execute } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=system_u:object_r:sepgsql_proc_exec_t:s0 tclass=db_procedure name="pg_catalog.textlike(pg_catalog.text,pg_catalog.text)"
|
|
x | y
|
|
-----+----------------------------------
|
|
77 | 28dd2c7955ce926456240b2ff0100bde
|
|
89 | 7647966b7343c29048673252e490f736
|
|
90 | 8613985ec49eb8f757ae6439e879bb2a
|
|
91 | 54229abfcfa5649e7003b83dd4755294
|
|
99 | ac627ab1ccbdb62ec96e702f07f6425b
|
|
100 | f899139df5e1059396431415e770c6dd
|
|
(6 rows)
|
|
|
|
-- aggregate function
|
|
SELECT MIN(x), AVG(x) FROM t1;
|
|
LOG: SELinux: allowed { select } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_table name="public.t1"
|
|
LOG: SELinux: allowed { select } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="table t1 column x"
|
|
LOG: SELinux: allowed { execute } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=system_u:object_r:sepgsql_proc_exec_t:s0 tclass=db_procedure name="pg_catalog.avg(integer)"
|
|
LOG: SELinux: allowed { execute } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=system_u:object_r:sepgsql_proc_exec_t:s0 tclass=db_procedure name="pg_catalog.int4_avg_accum(bigint[],integer)"
|
|
LOG: SELinux: allowed { execute } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=system_u:object_r:sepgsql_proc_exec_t:s0 tclass=db_procedure name="pg_catalog.int8_avg(bigint[])"
|
|
LOG: SELinux: allowed { execute } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=system_u:object_r:sepgsql_proc_exec_t:s0 tclass=db_procedure name="pg_catalog.min(integer)"
|
|
LOG: SELinux: allowed { execute } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=system_u:object_r:sepgsql_proc_exec_t:s0 tclass=db_procedure name="pg_catalog.int4smaller(integer,integer)"
|
|
min | avg
|
|
-----+---------------------
|
|
1 | 50.5000000000000000
|
|
(1 row)
|
|
|
|
-- window function
|
|
SELECT row_number() OVER (order by x), * FROM t1 WHERE y like '%86%';
|
|
LOG: SELinux: allowed { select } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_table name="public.t1"
|
|
LOG: SELinux: allowed { select } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="table t1 column x"
|
|
LOG: SELinux: allowed { select } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="table t1 column y"
|
|
LOG: SELinux: allowed { execute } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=system_u:object_r:sepgsql_proc_exec_t:s0 tclass=db_procedure name="pg_catalog.row_number()"
|
|
LOG: SELinux: allowed { execute } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0-s0:c0.c255 tcontext=system_u:object_r:sepgsql_proc_exec_t:s0 tclass=db_procedure name="pg_catalog.textlike(pg_catalog.text,pg_catalog.text)"
|
|
row_number | x | y
|
|
------------+----+----------------------------------
|
|
1 | 2 | c81e728d9d4c2f636f067f89cc14862c
|
|
2 | 17 | 70efdf2ec9b086079795c442636b55fb
|
|
3 | 22 | b6d767d2f8ed5d21a44b0e5886680cb9
|
|
4 | 27 | 02e74f10e0327ad868d138f2b4fdd6f0
|
|
5 | 33 | 182be0c5cdcd5072bb1864cdee4d3d6e
|
|
6 | 43 | 17e62166fc8586dfa4d1bc0e1742c08b
|
|
7 | 54 | a684eceee76fc522773286a895bc8436
|
|
8 | 73 | d2ddea18f00665ce8623e36bd4e3c7c5
|
|
9 | 76 | fbd7939d674997cdb4692d34de8633c4
|
|
10 | 89 | 7647966b7343c29048673252e490f736
|
|
11 | 90 | 8613985ec49eb8f757ae6439e879bb2a
|
|
12 | 94 | f4b9ec30ad9f68f89b29639786cb62ef
|
|
(12 rows)
|
|
|
|
RESET sepgsql.debug_audit;
|
|
RESET client_min_messages;
|
|
--
|
|
-- Cleanup
|
|
--
|
|
DROP TABLE IF EXISTS t1 CASCADE;
|