Skip to content

Commit

Permalink
fix selinux policy
Browse files Browse the repository at this point in the history
  • Loading branch information
aphralG committed Nov 21, 2023
1 parent 89fc334 commit 671beca
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
4 changes: 2 additions & 2 deletions scripts/selinux/nginx_agent.fc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/usr/bin/nginx-agent -- gen_context(system_u:object_r:nginx_agent_exec_t,s0)
/etc/systemd/system/nginx-agent.service -- gen_context(system_u:object_r:nginx_agent_unit_file_t,s0)

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

/var/log/nginx-agent(/.*)? gen_context(system_u:object_r:nginx_agent_log_t,s0)
29 changes: 29 additions & 0 deletions scripts/selinux/nginx_agent.if
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,30 @@ interface(`nginx_agent_manage_log',`
manage_files_pattern($1, nginx_agent_log_t, nginx_agent_log_t)
manage_lnk_files_pattern($1, nginx_agent_log_t, nginx_agent_log_t)
')
########################################
## <summary>
## Execute nginx_agent server in the nginx_agent domain.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed to transition.
## </summary>
## </param>
#
interface(`nginx_agent_systemctl',`
gen_require(`
type nginx_agent_t;
type nginx_agent_unit_file_t;
')

systemd_exec_systemctl($1)
systemd_read_fifo_file_passwd_run($1)
allow $1 nginx_agent_unit_file_t:file read_file_perms;
allow $1 nginx_agent_unit_file_t:service manage_service_perms;

ps_process_pattern($1, nginx_agent_t)
')


########################################
## <summary>
Expand All @@ -119,6 +143,7 @@ interface(`nginx_agent_admin',`
gen_require(`
type nginx_agent_t;
type nginx_agent_log_t;
type nginx_agent_unit_file_t;
')

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

logging_search_logs($1)
admin_pattern($1, nginx_agent_log_t)

nginx_agent_systemctl($1)
admin_pattern($1, nginx_agent_unit_file_t)
allow $1 nginx_agent_unit_file_t:service all_service_perms;
optional_policy(`
systemd_passwd_agent_exec($1)
systemd_read_fifo_file_passwd_run($1)
Expand Down
Binary file modified scripts/selinux/nginx_agent.pp
Binary file not shown.
7 changes: 6 additions & 1 deletion scripts/selinux/nginx_agent.te
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ require {
type sssd_var_lib_t;
type net_conf_t;
type fixed_disk_device_t;
type nvme_device_t;
type udev_var_run_t;
}

allow nginx_agent_t bin_t:file { execute execute_no_trans };
Expand Down Expand Up @@ -142,4 +144,7 @@ allow nginx_agent_t sssd_public_t:dir search;
allow nginx_agent_t sssd_var_lib_t:dir search;
allow nginx_agent_t net_conf_t:file { getattr open read };
allow nginx_agent_t self:udp_socket { connect create getattr setopt };
allow nginx_agent_t fixed_disk_device_t:blk_file getattr;
allow nginx_agent_t fixed_disk_device_t:blk_file getattr;
allow nginx_agent_t nvme_device_t:blk_file getattr;
allow nginx_agent_t udev_var_run_t:dir search;
allow nginx_agent_t udev_var_run_t:file { getattr open read };

0 comments on commit 671beca

Please sign in to comment.