set selinux context

List existing:
ls -lZ /etc/zabbix
This can print:

-rw-r--r--. 1 root root unconfined_u:object_r:etc_t:s0 1401 Apr 15 05:25 another.conf
-rw-r--r--. 1 root root system_u:object_r:etc_t:s0     1401 Feb 24 06:54 zabbix_java_gateway.conf
-rw-r--r--. 1 root root system_u:object_r:etc_t:s0      770 Feb 24 06:54 zabbix_java_gateway_logback.xml
-rw-r--r--. 1 root root system_u:object_r:etc_t:s0      237 Feb 24 06:44 zabbix_java_gateway_openjdk11.env
Install context:
sudo chcon system_u:object_r:etc_t:s0 /etc/zabbix/another.conf
To make it persistent across relabels (like restorecon or policy reloads):
sudo semanage fcontext -a -t etc_t "/etc/zabbix/another.conf"
sudo restorecon -v /etc/zabbix/another.conf
To replicate context:
sudo chcon --reference=/etc/zabbix/zabbix_java_gateway.conf /etc/zabbix/another.conf

No comments: