天天看點

SELinux

selinux

SElinux:Secure Enhanced Linux,工作于Linux核心中

DAC:自主通路控制

MAC;強制通路控制

SElinux兩種工作級别:

strict:每個程序都受到selinux控制;

targeted:僅有限個程序受到selinux控制;

隻監控容易被入侵的程序;

subject operation object

subject:程序

object:程序,檔案

檔案:open,read,write,close,chown,chmod

subject:domain

object:type

SElinux為每個檔案提供了安全标簽,也為程序提供了安全标簽;

user:role:type

user:SElinux的user

role:角色

type:類型

SELinux規則庫:

規則:哪種域能通路那種或哪些類型的内檔案

配置SELinux

SELinux是否啟動:

給檔案重新打标:

設定某些布爾型開關:getsebool -a

SELinux的狀态:

enforcing:強制,每個受限的程序必須受限;

permissive:啟用,每個受限的程序違規操作不會被禁止,但會被記錄到審計日志中。

disabled:關閉;

如果目前系統是disabled,如果啟用為enforcing或者permissive必須重新開機

getenforce:檢視目前狀态

setenforce:設定狀态

0:設定為permissive

1:設定為enforcing

此設定:重新開機系統後無效。

配置檔案:/etc/sysconfig/selinx, /etc/selinux/config

給檔案重新打标;

chcon 

chcon [OPTION]... CONTEXT FILE...

chcon  [OPTION]...  [-u  USER]  [-r  ROLE] [-l RANGE] [-t

TYPE] FILE...

chcon [OPTION]... --reference=RFILE FILE...

-R 遞歸打标

chcon -t user_tmp_t home.txt

還原檔案的預設标簽:

restorecon

restorecon home.txt

布爾設定:

getsebool -a

getsebool httpd_can_sendmail

setsebool httpd_can_sendmail on/1 

setsebool httpd_can_sendmail off/0

setsebool -P httpd_can_sendmail on/1-P永久有效

cat /var/log/audit/audit.log selinux警告日志

     本文轉自阿倫艾弗森 51CTO部落格,原文連結http://blog.51cto.com/perper/1953683:,如需轉載請自行聯系原作者

繼續閱讀