码迷,mamicode.com
首页 > 系统相关 > 详细

SELinux 与强制访问控制系统

时间:2014-04-30 02:57:31      阅读:783      评论:0      收藏:0      [点我收藏+]

标签:tar   c   strong   t   get   ble   int   set   文件   cti   type   

SELinux 全称 Security Enhanced Linux (安全强化 Linux),是 MAC (Mandatory Access Control,强制访问控制系统)的一个实现,目的在于明确的指明某个进程可以访问哪些资源(文件、网络端口等)。
强制访问控制系统的用途在于增强系统抵御 0-Day 攻击(利用尚未公开的漏洞实现的攻击行为)的能力。所以它不是网络防火墙或 ACL 的替代品,在用途上也不重复。
举例来说,系统上的 Apache 被发现存在一个漏洞,使得某远程用户可以访问系统上的敏感文件(比如 /etc/passwd 来获得系统已存在用户),而修复该安全漏洞的 Apache 更新补丁尚未释出。此时 SELinux 可以起到弥补该漏洞的缓和方案。因为 /etc/passwd 不具有 Apache 的访问标签,所以 Apache 对于 /etc/passwd 的访问会被 SELinux 阻止。
相比其他强制性访问控制系统,SELinux 有如下优势:

了解和配置 SELinux
1. 获取当前 SELinux 运行状态
getenforce
可能返回结果有三种:Enforcing、Permissive 和 Disabled。Disabled 代表 SELinux 被禁用,Permissive 代表仅记录安全警告但不阻止可疑行为,Enforcing 代表记录警告且阻止可疑行为。
目前常见发行版中,RHEL 和 Fedora 默认设置为 Enforcing,其余的如 openSUSE 等为 Permissive。
2. 改变 SELinux 运行状态
setenforce [ Enforcing | Permissive | 1 | 0 ]
该命令可以立刻改变 SELinux 运行状态,在 Enforcing 和 Permissive 之间切换,结果保持至关机。一个典型的用途是看看到底是不是 SELinux 导致某个服务或者程序无法运行。若是在 setenforce 0 之后服务或者程序依然无法运行,那么就可以肯定不是 SELinux 导致的。
若是想要永久变更系统 SELinux 运行环境,可以通过更改配置文件 /etc/sysconfig/selinux 实现。注意当从 Disabled 切换到 Permissive 或者 Enforcing 模式后需要重启计算机并为整个文件系统重新创建安全标签(touch /.autorelabel && reboot)。

3. SELinux 运行策略
配置文件 /etc/sysconfig/selinux 还包含了 SELinux 运行策略的信息,通过改变变量 SELINUXTYPE 的值实现,该值有三种可能:targeted 代表仅针对预制的几种网络服务和访问请求使用 SELinux 保护,strict 代表所有网络服务和访问请求都要经过 SELinux。mls指 Multi Level Security protection。

RHEL 和 Fedora 默认设置为 targeted,包含了对几乎所有常见网络服务的 SELinux 策略配置,已经默认安装并且可以无需修改直接使用。

vi /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. #在RHEL 6.0中value值为mls(非strict) - Multi Level Security protection.
SELINUXTYPE=targeted

SELinux 与强制访问控制系统,布布扣,bubuko.com

SELinux 与强制访问控制系统

标签:tar   c   strong   t   get   ble   int   set   文件   cti   type   

原文地址:http://www.cnblogs.com/rusking/p/3695861.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!