======基本Selinux未完成....====== * selinux是當年美國國家安全局專門為Linux量身定制的安群機制[[wp>selinux|wiki_selinux]]。目前Selinux以kernel為基楚的方式,已整合到Linux kernel 2.6.x。 * selinux主要以MAC(Mandatory Access Control)委任式存取控制系統的每個程序。Selinux管理程序方式,是依照SELINUX規則來限定程序存取範圍,其中規則以安全本文(SELINUX Context)為重要。 ======如何讓Linux支援selinux====== * 修改/etc/selinux/config#vim /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=enforcing --->enforcing 有支援selinux --->disabled 關閉 selinux --->permissive 有支援selinux,但不阻擋,只有顯示訊息在log檔中/var/log/messages # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted 修改此設定檔完後,要重新開機才會生效 #reboot * 透過指令方式做管理#sestatus SELinux status: enabled SELinuxfs mount: /selinux Current mode: enforcing Mode from config file: enforcing Policy version: 24 Policy from config file: targeted -------------------------------------------- #顯示Current mode:enforcing 表示目前有支援selinux #setenforce 0 有支援selinux,但不阻擋。即為permissive #setenforce 1 有支援selinux ======基本設定selinux規則====== * 基本SELINUX指令#ll -dZ /var/www/html/ drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /var/www/html/ #ls -lZ /tmp/host -rw-r--r--. root root unconfined_u:object_r:user_tmp_t:s0 /tmp/host 可以看到不同的檔案被SELINUX 標示Security Content就不一樣 /var/www/html/ :httpd_sys_content_t /tmp/host :user_tmp_t 若要設定/tmp/host與/var/www/html/一樣的Security Content #chcon -t httpd_sys_content_t /tmp/host #ls -lZ /tmp/host -rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 /tmp/host * SELINUX Booleans除了selinux context 規則外,還有需多以細項規則 off及on來限制。 ex:Apache Web有一項個人用戶網站;以自己的家目錄當個人網站(http:www.xxxx.com/~ali/), 但是SELINUX開啟時,就會把這項功能oFF掉,因此就要動用到SELINUX Boleans 取得家目錄selinux booleans#getsebool -a|grep -i httpd|grep -i home httpd_enable_homedirs --> off 設定selinux Booleans off為 on#setsebool -P httpd_enable_homedirs=on =====好用的SELINUX 管理程式(semanage)===== * 安裝policycoreutils-python這個套件yum install policycoreutils-python ======參考資料====== - [[http://linux.vbird.org/linux_basic/0440processcontrol.php#selinux|鳥歌_SELINUX初探]] - [[http://www.dotblogs.com.tw/billy3321/archive/2008/10/23/5761.aspx|雨倉的SELINUX初探心得]]