Skip to main content
  1. Posts/

Creating Custom Policy Modules SELinux

·1 min·
centos linux centos
Table of Contents

Jika Anda mengaktifkan selinux pada server CentOS atau disto RHEL lain, maka sering terjadi akses pada service FTP atau Webserver dan lainnya mengalami masalah atau ditolak karena konfig permission pada selinux yang belum disesuaikan.

Contoh log dari tail -F /var/log/audit/audit.log | grep httpd

type=AVC msg=audit(1688415689.387:108): avc:  denied  { read } for  pid=1500 comm="httpd" name="public_html" dev="dm-0" ino=46140891 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_user_content_t:s0 tclass=dir permissive=0
type=SYSCALL msg=audit(1688415689.387:108): arch=c000003e syscall=257 success=no exit=-13 a0=ffffff9c a1=7f45b00053f0 a2=90800 a3=0 items=0 ppid=931 pid=1500 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)ARCH=x86_64 SYSCALL=openat AUID="unset" UID="apache" GID="apache" EUID="apache" SUID="apache" FSUID="apache" EGID="apache" SGID="apache" FSGID="apache"

Install utilitas SELinux
#

yum install policycoreutils-python-utils

Create policy
#

Pada log diatas ambil bagian httpd_t pada scontext lalu buat custom policy dengan perintah audit2allow

grep httpd_t /var/log/audit/audit.log  | audit2allow -M webserver
******************** IMPORTANT ***********************
To make this policy package active, execute:

semodule -i webserver.pp

Lalu load policy

semodule -i httpd.pp

Terkahir coba kembali akses webserver Anda.

Untuk menghapus policy

semanage module -r httpd

Related

Install Repo Raven di CentOS
·1 min
centos linux centos
Benchmark Network Throughput antar Host Linux
·1 min
linux linux
HTTP Benchmarking dengan wrk
·1 min
linux linux
Grub Error: you need to load kernel first
·1 min
linux linux
Linux Boot Error: Root does not exist
·1 min
linux linux
Securing Tmp Folder on Linux
·1 min
linux linux