CentOS上的安全防护软件Selinux详解

2020-01-30 17:34:03刘景俊

}@font-face {

 font-family: “Calibri”;

}@font-face {

 font-family: “@宋体”;

}p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0cm 0cm 0.0001pt; text-align: justify; font-size: 10.5pt; font-family: “Calibri”,”sans-serif”; }.MsoChpDefault { font-family: “Calibri”,”sans-serif”; }div.WordSection1 {  } 

selinux策略

对象(object):所有可以读取的对象,包括文件、目录和进程,端口等

主体:进程称为主题(subject)

selinux中对所有的文件都赋予一个type的文件类型标签,对于所有的进程也赋予各自的一个domain标签。domain标签能够执行的操作由安全策略里定义

当一个subject视图访问一个object,kernel中的粗略执行服务器将检查AVC,在AVC中,subject和object的权限被缓存,查找应用+文件的安全环境,然后根据查询结果允许或拒绝访问

安全策略:定义主体读取对象的规则数据库,规则中记录了那个类型的主体使用了那个方法读取哪一个对象是允许还是拒绝的,并且定义了那种行为是允许或拒绝

设置selinux

配置selinux

selinux是否启用

给文件重新打安全标签

给端口设置安全标签

设定某些操作的布尔型开关

selinux的日志管理

selinux的状态

enforcing:强制,每个受限的进程都必然受限

permissive:允许;每个受限的进程违规操作不会被禁止,但会被记录与审计日志

disabled:禁用,允许任何操作

getenforce:获取selinux当前状态

sestatus:查看selinux状态

setenforce  0|1

         0:设置为permissive

         1:设置为enforcing

配置文件

/etc/sysconfig/selinux链接文件链接到/etc/selinux/config

/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 – SELinux is fully disabled.

SELINUX=enforcing

# SELINUXTYPE= type of policy in use. Possible values are:

#       targeted – Only targeted network daemons are protected.

#       strict – Full SELinux protection.

SELINUXTYPE=targeted

SELINUX=enforcing 设置selinux的状态

SELINUXTYPE=targeted 设置selinux的工作类型

设置selinux也可以在开机的时候设定,在/boot/grub/grub.conf文件内核那一行后面设定selinux的状态selinux=0|1,只要配置文件或内核设定为禁用,最后selinux的状态为禁用