Hi On Thu, Apr 1, 2021 at 3:30 PM Dave Page <dp...@pgadmin.org> wrote:
> > > On Thu, Apr 1, 2021 at 3:23 PM Tom Lane <t...@sss.pgh.pa.us> wrote: > >> Andrew Dunstan <and...@dunslane.net> writes: >> > On 4/1/21 8:32 AM, Dave Page wrote: >> >> It seems to me that sepgsql should also log the denial, but flag that >> >> permissive mode is on. >> >> > +1 for doing what selinux does if possible. >> >> +1. If selinux itself is doing that, it's hard to see a reason why >> we should not; and I concur that the info is useful. >> > > Thanks both. I'll take a look at the code and see if I can whip up a patch > (it'll be a week or so as I'm taking some time off for Easter). > Attached is a patch to clean this up. It will log denials as such regardless of whether or not either selinux or sepgsql is in permissive mode. When either is in permissive mode, it'll add " permissive=1" to the end of the log messages. e.g. Regular user in permissive mode, with a restricted table column: 2021-04-14 13:20:30.401 BST [23073] LOG: SELinux: allowed { select } scontext=user_u:user_r:user_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_table name="public.tb_users" permissive=1 2021-04-14 13:20:30.401 BST [23073] STATEMENT: SELECT * FROM tb_users; 2021-04-14 13:20:30.401 BST [23073] LOG: SELinux: allowed { select } scontext=user_u:user_r:user_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="column uid of table tb_users" permissive=1 2021-04-14 13:20:30.401 BST [23073] STATEMENT: SELECT * FROM tb_users; 2021-04-14 13:20:30.401 BST [23073] LOG: SELinux: allowed { select } scontext=user_u:user_r:user_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="column name of table tb_users" permissive=1 2021-04-14 13:20:30.401 BST [23073] STATEMENT: SELECT * FROM tb_users; 2021-04-14 13:20:30.401 BST [23073] LOG: SELinux: allowed { select } scontext=user_u:user_r:user_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="column mail of table tb_users" permissive=1 2021-04-14 13:20:30.401 BST [23073] STATEMENT: SELECT * FROM tb_users; 2021-04-14 13:20:30.401 BST [23073] LOG: SELinux: allowed { select } scontext=user_u:user_r:user_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="column address of table tb_users" permissive=1 2021-04-14 13:20:30.401 BST [23073] STATEMENT: SELECT * FROM tb_users; 2021-04-14 13:20:30.401 BST [23073] LOG: SELinux: allowed { select } scontext=user_u:user_r:user_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="column salt of table tb_users" permissive=1 2021-04-14 13:20:30.401 BST [23073] STATEMENT: SELECT * FROM tb_users; 2021-04-14 13:20:30.401 BST [23073] LOG: SELinux: denied { select } scontext=user_u:user_r:user_t:s0 tcontext=system_u:object_r:sepgsql_secret_table_t:s0 tclass=db_column name="column phash of table tb_users" permissive=1 2021-04-14 13:20:30.401 BST [23073] STATEMENT: SELECT * FROM tb_users; The same user/table, but in enforcing mode: 2021-04-14 13:17:21.645 BST [22974] LOG: SELinux: allowed { search } scontext=user_u:user_r:user_t:s0 tcontext=system_u:object_r:sepgsql_schema_t:s0 tclass=db_schema name="public" at character 15 2021-04-14 13:17:21.645 BST [22974] STATEMENT: SELECT * FROM tb_users; 2021-04-14 13:17:21.646 BST [22974] LOG: SELinux: allowed { select } scontext=user_u:user_r:user_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_table name="public.tb_users" 2021-04-14 13:17:21.646 BST [22974] STATEMENT: SELECT * FROM tb_users; 2021-04-14 13:17:21.646 BST [22974] LOG: SELinux: allowed { select } scontext=user_u:user_r:user_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="column uid of table tb_users" 2021-04-14 13:17:21.646 BST [22974] STATEMENT: SELECT * FROM tb_users; 2021-04-14 13:17:21.646 BST [22974] LOG: SELinux: allowed { select } scontext=user_u:user_r:user_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="column name of table tb_users" 2021-04-14 13:17:21.646 BST [22974] STATEMENT: SELECT * FROM tb_users; 2021-04-14 13:17:21.646 BST [22974] LOG: SELinux: allowed { select } scontext=user_u:user_r:user_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="column mail of table tb_users" 2021-04-14 13:17:21.646 BST [22974] STATEMENT: SELECT * FROM tb_users; 2021-04-14 13:17:21.646 BST [22974] LOG: SELinux: allowed { select } scontext=user_u:user_r:user_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="column address of table tb_users" 2021-04-14 13:17:21.646 BST [22974] STATEMENT: SELECT * FROM tb_users; 2021-04-14 13:17:21.646 BST [22974] LOG: SELinux: allowed { select } scontext=user_u:user_r:user_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="column salt of table tb_users" 2021-04-14 13:17:21.646 BST [22974] STATEMENT: SELECT * FROM tb_users; 2021-04-14 13:17:21.646 BST [22974] LOG: SELinux: denied { select } scontext=user_u:user_r:user_t:s0 tcontext=system_u:object_r:sepgsql_secret_table_t:s0 tclass=db_column name="column phash of table tb_users" 2021-04-14 13:17:21.646 BST [22974] STATEMENT: SELECT * FROM tb_users; 2021-04-14 13:17:21.646 BST [22974] ERROR: SELinux: security policy violation -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EDB: http://www.enterprisedb.com
sepgsql_permissive_logging.diff
Description: Binary data