selinux/README.md
Install required SELinux development tools:
dnf upgrade && dnf install setools-console policycoreutils-python-utils selinux-policy-devel make
make -f /usr/share/selinux/devel/Makefile shadowsocks.pp
semodule -i shadowsocks.pp
semanage fcontext -a -t shadowsocks_exec_t "/usr/bin/ssservice"
semanage fcontext -a -t shadowsocks_conf_t "/etc/shadowsocks(/.*)?"
semanage fcontext -a -t shadowsocks_unit_file_t "/usr/lib/systemd/system/ss-server@.*\.service"
restorecon -v /etc/systemd/system/[email protected]
restorecon -R /usr/bin/ssservice /etc/shadowsocks
systemctl start ss-server@main
# Check that shadowsocks is running in the correct domain
ps -eZ | grep ssservice
# Should show: system_u:system_r:shadowsocks_t:s0 (not unconfined_service_t)
# View recent AVC denials
ausearch -m avc -ts recent | grep denied
# Generate additional policy rules if needed
ausearch -m avc -ts recent | grep shadowsocks | audit2allow
If you need to add more permissions:
# Edit shadowsocks.te file
# Recompile and update
make -f /usr/share/selinux/devel/Makefile shadowsocks.pp
semodule -u shadowsocks.pp
# Remove file contexts first
semanage fcontext -d "/usr/bin/ssservice"
semanage fcontext -d "/etc/shadowsocks(/.*)?"
semanage fcontext -d "/usr/lib/systemd/system/ss-server@.*\.service"
# Reset file labels
restorecon -F /usr/bin/ssservice
restorecon -RF /etc/shadowsocks
# Remove the policy module
semodule -r shadowsocks
This policy provides several security improvements over running shadowsocks as unconfined_service_t:
/etc/systemd/system and /usr/lib/systemd/system