Skip to content

Commit b887f38

Browse files
authored
fix selinux policy (#520)
1 parent 89fc334 commit b887f38

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

scripts/selinux/nginx_agent.fc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/usr/bin/nginx-agent -- gen_context(system_u:object_r:nginx_agent_exec_t,s0)
1+
/etc/systemd/system/nginx-agent.service -- gen_context(system_u:object_r:nginx_agent_unit_file_t,s0)
22

3-
/etc/nginx-agent(/.*)? -- gen_context(system_u:object_r:nginx_agent_config_t,s0)
3+
/usr/bin/nginx-agent -- gen_context(system_u:object_r:nginx_agent_exec_t,s0)
44

55
/var/log/nginx-agent(/.*)? gen_context(system_u:object_r:nginx_agent_log_t,s0)

scripts/selinux/nginx_agent.if

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,30 @@ interface(`nginx_agent_manage_log',`
9797
manage_files_pattern($1, nginx_agent_log_t, nginx_agent_log_t)
9898
manage_lnk_files_pattern($1, nginx_agent_log_t, nginx_agent_log_t)
9999
')
100+
########################################
101+
## <summary>
102+
## Execute nginx_agent server in the nginx_agent domain.
103+
## </summary>
104+
## <param name="domain">
105+
## <summary>
106+
## Domain allowed to transition.
107+
## </summary>
108+
## </param>
109+
#
110+
interface(`nginx_agent_systemctl',`
111+
gen_require(`
112+
type nginx_agent_t;
113+
type nginx_agent_unit_file_t;
114+
')
115+
116+
systemd_exec_systemctl($1)
117+
systemd_read_fifo_file_passwd_run($1)
118+
allow $1 nginx_agent_unit_file_t:file read_file_perms;
119+
allow $1 nginx_agent_unit_file_t:service manage_service_perms;
120+
121+
ps_process_pattern($1, nginx_agent_t)
122+
')
123+
100124

101125
########################################
102126
## <summary>
@@ -119,6 +143,7 @@ interface(`nginx_agent_admin',`
119143
gen_require(`
120144
type nginx_agent_t;
121145
type nginx_agent_log_t;
146+
type nginx_agent_unit_file_t;
122147
')
123148

124149
allow $1 nginx_agent_t:process { signal_perms };
@@ -130,6 +155,10 @@ interface(`nginx_agent_admin',`
130155

131156
logging_search_logs($1)
132157
admin_pattern($1, nginx_agent_log_t)
158+
159+
nginx_agent_systemctl($1)
160+
admin_pattern($1, nginx_agent_unit_file_t)
161+
allow $1 nginx_agent_unit_file_t:service all_service_perms;
133162
optional_policy(`
134163
systemd_passwd_agent_exec($1)
135164
systemd_read_fifo_file_passwd_run($1)

scripts/selinux/nginx_agent.pp

450 Bytes
Binary file not shown.

scripts/selinux/nginx_agent.te

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ require {
6363
type sssd_var_lib_t;
6464
type net_conf_t;
6565
type fixed_disk_device_t;
66+
type nvme_device_t;
67+
type udev_var_run_t;
6668
}
6769

6870
allow nginx_agent_t bin_t:file { execute execute_no_trans };
@@ -142,4 +144,7 @@ allow nginx_agent_t sssd_public_t:dir search;
142144
allow nginx_agent_t sssd_var_lib_t:dir search;
143145
allow nginx_agent_t net_conf_t:file { getattr open read };
144146
allow nginx_agent_t self:udp_socket { connect create getattr setopt };
145-
allow nginx_agent_t fixed_disk_device_t:blk_file getattr;
147+
allow nginx_agent_t fixed_disk_device_t:blk_file getattr;
148+
allow nginx_agent_t nvme_device_t:blk_file getattr;
149+
allow nginx_agent_t udev_var_run_t:dir search;
150+
allow nginx_agent_t udev_var_run_t:file { getattr open read };

0 commit comments

Comments
 (0)