Skip to content

Commit

Permalink
make cockpit definition optional
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Feb 7, 2024
1 parent ec6e5e0 commit 10266e3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
4 changes: 2 additions & 2 deletions foreman.fc
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@

# Foreman Remote Execution

/usr/sbin/foreman-cockpit-session gen_context(system_u:object_r:cockpit_session_exec_t,s0)
/usr/share/gems/gems/foreman_remote_execution-.*/extra/cockpit/foreman-cockpit-session -- gen_context(system_u:object_r:cockpit_session_exec_t,s0)
/usr/sbin/foreman-cockpit-session gen_context(system_u:object_r:foreman_cockpit_session_exec_t,s0)
/usr/share/gems/gems/foreman_remote_execution-.*/extra/cockpit/foreman-cockpit-session -- gen_context(system_u:object_r:foreman_cockpit_session_exec_t,s0)

# Foreman Hooks plugin

Expand Down
47 changes: 30 additions & 17 deletions foreman.te
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ require{
type bin_t;
type httpd_t;
type websm_port_t;
type cockpit_ws_t;
type cockpit_session_t;
type cockpit_session_exec_t;
type unconfined_service_t;
type http_cache_port_t;
type squid_port_t;
Expand Down Expand Up @@ -333,25 +330,41 @@ manage_dirs_pattern(foreman_rails_t, system_cronjob_tmp_t, system_cronjob_tmp_t)
# Remote Execution
#

# File /usr/sbin/foreman-cockpit-session is a symlink
read_lnk_files_pattern(cockpit_ws_t, cockpit_session_exec_t, cockpit_session_exec_t)
read_lnk_files_pattern(cockpit_session_t, cockpit_session_exec_t, cockpit_session_exec_t)
# this needs to exist even if cockpit policy doesn't
type foreman_cockpit_session_exec_t;

# Run /usr/bin/env and /usr/bin/ruby
corecmd_exec_bin(cockpit_ws_t)
kernel_read_system_state(cockpit_ws_t)
optional_policy(`
gen_require(`
type cockpit_ws_t;
type cockpit_session_t;
type cockpit_session_exec_t;
')

# foreman-cockpit-session needs to be labeled foreman_cockpit_session_exec_t,
# but we need to end up in cockpit_session_t
domtrans_pattern(cockpit_ws_t, foreman_cockpit_session_exec_t, cockpit_session_t)

# Connect to Foreman HTTP(s) port
corenet_tcp_connect_http_port(cockpit_session_t)
corenet_tcp_connect_http_port(cockpit_ws_t)
# File /usr/sbin/foreman-cockpit-session is a symlink
read_lnk_files_pattern(cockpit_ws_t, cockpit_session_exec_t, cockpit_session_exec_t)
read_lnk_files_pattern(cockpit_session_t, cockpit_session_exec_t, cockpit_session_exec_t)
read_lnk_files_pattern(cockpit_ws_t, foreman_cockpit_session_exec_t, foreman_cockpit_session_exec_t)
read_lnk_files_pattern(cockpit_session_t, foreman_cockpit_session_exec_t, foreman_cockpit_session_exec_t)

# Connect to remote Cockpit instance HTTPS port
corenet_tcp_connect_websm_port(cockpit_session_t)
corenet_tcp_connect_websm_port(cockpit_ws_t)
# Run /usr/bin/env and /usr/bin/ruby
corecmd_exec_bin(cockpit_ws_t)
kernel_read_system_state(cockpit_ws_t)

# Connect to Foreman Cockpit instance HTTPS port
corenet_tcp_connect_websm_port(httpd_t)
# Connect to Foreman HTTP(s) port
corenet_tcp_connect_http_port(cockpit_session_t)
corenet_tcp_connect_http_port(cockpit_ws_t)

# Connect to remote Cockpit instance HTTPS port
corenet_tcp_connect_websm_port(cockpit_session_t)
corenet_tcp_connect_websm_port(cockpit_ws_t)

# Connect to Foreman Cockpit instance HTTPS port
corenet_tcp_connect_websm_port(httpd_t)
')

#######################################
#
Expand Down

0 comments on commit 10266e3

Please sign in to comment.