1. SELinux在Linux系统中的运行状态可以划分为如下3种运行模式(run modes)
- enforcing
默认模式,SELinux会根据安全策略对到达的访问请求进行检查。
- permissive
SELinux假装在进行安全策略的检查,甚至会将access denial写入日志文件,但实际不会拒绝任何访问请求。
这种模式适合开发调试阶段。
- disabled
强烈不建议这种模式。
SELinux不会进行任何检查,甚至不会对系统对象设置SELinux context。
2. 查看SELinux的运行状态
可以通过GUI工具system-config-selinux(需要安装policycoreutils-gui软件包),也可以通过sestatus命令。
[root@myhost ~]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 31
3. 设置Linux中的SELinux运行模式
1)系统启动时,参数enforcing=0或enforcing=1
2) 修改/etc/selinux/config配置文件
SELINUX=permissive
或
SELINUX=enforcing
3) 运行时命令
setenforce Enforcing等价于setenforce 1
setenforce Permissive等价于setenforce 0
4) 运行时GUI工具system-config-selinux(需要安装policycoreutils-gui软件包)
此外,还可以结合SELinux context临时改变某个系统服务的模式,我们将在SELinux context中详细介绍。
4. SELinux的安全策略类型
- targeted
默认策略类型,采用mcs级别的安全策略。将系统进程分为两大类,一类运行在confined域,任何访问请求都受到SELinux的限制,被称为targets;另一类运行在unconfined域,不受SELinux的约束。
所有位于confined域的进程都受到SELinux的限制。
- minimum
是targeted子集,只有指定的confined域的进程都受到SELinux的限制。
- mls
SELinux默认采用targeted策略,被targeted的进程运行在受限的domain,没有被targeted的进程运行在不受限的domain。
而在mls策略中,所有进程都被划分为细粒度的安全domain,受mls策略的限制。如果mls策略还采用了Bell And LaPadula模型,则所有进程还进一步受到数据的安全级别的限制。
配置SELinux的安全策略类型,可以直接修改/etc/selinux/config配置文件:
SELINUXTYPE=targeted
参考链接:
http://selinuxproject.org/
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/selinux_users_and_administrators_guide/index
https://wiki.centos.org/HowTos/SELinux
https://www.nginx.com/blog/using-nginx-plus-with-selinux/