Skip to content

Commit 86f89b4

Browse files
committed
Fix avc denials but pcp plugin still not working
1 parent 64a695d commit 86f89b4

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

grafana.fc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#/var/lib/grafana/plugins(/.*)? gen_context(system_u:object_r:grafana_plugin_t,s0)
1717

18+
/var/lib/grafana/plugins/performancecopilot-pcp-app -- gen_context(system_u:object_r:grafana_pcp_plugin_exec_t,s0)
19+
1820
/usr/share/grafana/bin/grafana -- gen_context(system_u:object_r:grafana_exec_t,s0)
1921
/usr/share/grafana/bin/grafana-cli -- gen_context(system_u:object_r:grafana_exec_t,s0)
2022
/usr/share/grafana/bin/grafana-server -- gen_context(system_u:object_r:grafana_exec_t,s0)

grafana.if

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,55 @@ interface(`grafana_admin',`
139139
systemd_read_fifo_file_passwd_run($1)
140140
')
141141
')
142+
143+
########################################
144+
## <summary>
145+
## Execute the grafana unconfined plugins with
146+
## a domain transition.
147+
## </summary>
148+
## <param name="domain">
149+
## <summary>
150+
## Domain allowed access.
151+
## </summary>
152+
## </param>
153+
#
154+
interface(`grafana_domtrans_unconfined_plugins',`
155+
gen_require(`
156+
type grafana_unconfined_plugin_t;
157+
type grafana_unconfined_plugin_exec_t;
158+
')
159+
160+
domtrans_pattern($1, grafana_unconfined_plugin_exec_t, grafana_unconfined_plugin_t)
161+
')
162+
163+
########################################
164+
## <summary>
165+
## Create a set of derived types for various
166+
## grafana plugins,
167+
## </summary>
168+
## <param name="plugins_group_name">
169+
## <summary>
170+
## The name to be used for deriving type names.
171+
## </summary>
172+
## </param>
173+
#
174+
template(`grafana_plugin_template',`
175+
gen_require(`
176+
attribute grafana_plugin_domain;
177+
type grafana_t;
178+
')
179+
180+
type grafana_$1_plugin_t, grafana_plugin_domain;
181+
type grafana_$1_plugin_exec_t;
182+
application_domain(grafana_$1_plugin_t, grafana_$1_plugin_exec_t)
183+
role system_r types grafana_$1_plugin_t;
184+
185+
domtrans_pattern(grafana_t, grafana_$1_plugin_exec_t, grafana_$1_plugin_t)
186+
allow grafana_t grafana_$1_plugin_exec_t:file ioctl;
187+
188+
# needed by command.cfg
189+
domtrans_pattern(grafana_t, grafana_$1_plugin_exec_t, grafana_$1_plugin_t)
190+
191+
kernel_read_system_state(grafana_$1_plugin_t)
192+
193+
')

grafana.te

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ gen_tunable(grafana_can_tcp_connect_mysql_port, false)
3434
## </desc>
3535
gen_tunable(grafana_can_tcp_connect_prometheus_port, false)
3636

37+
attribute grafana_plugin_domain;
3738

3839
type grafana_t;
3940
type grafana_exec_t;
@@ -67,6 +68,27 @@ files_type(grafana_var_lib_t)
6768
type grafana_port_t;
6869
corenet_port(grafana_port_t)
6970

71+
grafana_plugin_template(pcp)
72+
73+
######################################
74+
#
75+
# Common plugin domain local policy
76+
#
77+
78+
allow grafana_plugin_domain self:fifo_file rw_fifo_file_perms;
79+
80+
allow grafana_t grafana_plugin_domain:process signal_perms;
81+
allow grafana_plugin_domain grafana_t:process signal_perms;
82+
83+
corecmd_exec_bin(grafana_plugin_domain)
84+
85+
dev_read_urand(grafana_plugin_domain)
86+
dev_read_rand(grafana_plugin_domain)
87+
dev_read_sysfs(grafana_plugin_domain)
88+
89+
userdom_use_inherited_user_ptys(grafana_plugin_domain)
90+
userdom_use_inherited_user_ttys(grafana_plugin_domain)
91+
7092
########################################
7193
#
7294
# grafana local policy
@@ -77,6 +99,14 @@ allow grafana_t self:unix_dgram_socket create_socket_perms;
7799

78100
allow grafana_t grafana_port_t:tcp_socket { name_bind name_connect };
79101

102+
#allow grafana_t grafana_exec_t:file execute_no_trans;
103+
allow grafana_t self:unix_stream_socket connectto;
104+
105+
allow grafana_t grafana_var_lib_t:file { execute execute_no_trans };
106+
allow grafana_t grafana_var_lib_t:file map;
107+
108+
allow init_t grafana_tmp_t:sock_file unlink;
109+
80110
manage_dirs_pattern(grafana_t, grafana_conf_t, grafana_conf_t)
81111
manage_files_pattern(grafana_t, grafana_conf_t, grafana_conf_t)
82112

0 commit comments

Comments
 (0)