26 2使用 SELinux提升内核安全性 23安全上下文 Security Context a SELinux contexts have several fields: user, role, type, and security level a The Selinux type information is perhaps the most important when it comes to the SELinux policy, as the most common policy rule which defines the allowed interactions between processes and system resources uses SELinux types and not the full selinux context SELinux types end with t user: role: type: security level [ category I 用户:角色:类型:安全级别[:分类] 河南中医药大学/阮晓龙713938213680/http://inux.xg.hactcm.edu.cn/http://www.5lxueweb.cn
河南中医药大学 / 阮晓龙 / 13938213680 / http://linux.xg.hactcm.edu.cn / http://www.51xueweb.cn 2.使用SELinux提升内核安全性 SELinux contexts have several fields: user, role, type, and security level. ◼ The SELinux type information is perhaps the most important when it comes to the SELinux policy, as the most common policy rule which defines the allowed interactions between processes and system resources uses SELinux types and not the full SELinux context. ◼ SELinux types end with _t. user : role : type : security level [ : category ] 用户 : 角色 : 类型 : 安全级别 [ : 分类 ] 26 2.3 安全上下文 Security Context
27 2使用 SELinux提升内核安全性 23安全上下文 Security Context 安全上下文的组成元素 user: role: type: security level [ category 用户:角色:类型:安全级别[:分类] ■user:指定登录系统的用户类型,如userυ(普通用户登录系统后的预设)、 systenυ(开机过程中系统 进程的预设)、root(roo用户登录后的预设),多数本地进程都属于自由( unconfined u)进程。 roe:定义文件( object r)、进程和用户( system r)的角色,角色可以限制"type"的使用。 type:指定数据类型,规则中定乂何种进程类型访问何种文件对象目标的策略,都是基于ρe实现。 ■ security level:限制访问的需要,由规则定义的分层安全级别,每个对象均有且只有一个级别,总共分为0 ~15级(s0最低),目标策略默认使用等级为s0 category:可选字段,对于特定组织划分不同分层的分类,一个对象可以有多个分类。对于普通用户来讲, 该字段可以忽略。 河南中医药大学/阮晓龙713938213680/http://inux.xg.hactcm.edu.cn/http://www.5lxueweb.cn
河南中医药大学 / 阮晓龙 / 13938213680 / http://linux.xg.hactcm.edu.cn / http://www.51xueweb.cn 2.使用SELinux提升内核安全性 user : role : type : security level [ : category ] 用户 : 角色 : 类型 : 安全级别 [ : 分类 ] ◼ user:指定登录系统的用户类型,如user_u(普通用户登录系统后的预设)、system_u(开机过程中系统 进程的预设)、root(root用户登录后的预设),多数本地进程都属于自由(unconfined_u)进程。 ◼ role:定义文件(object_r)、进程和用户(system_r)的角色,角色可以限制“type”的使用。 ◼ type:指定数据类型,规则中定义何种进程类型访问何种文件对象目标的策略,都是基于type实现。 ◼ security level:限制访问的需要,由规则定义的分层安全级别,每个对象均有且只有一个级别,总共分为0 ~15级(s0最低),目标策略默认使用等级为s0。 ◼ category:可选字段,对于特定组织划分不同分层的分类,一个对象可以有多个分类。对于普通用户来讲, 该字段可以忽略。 27 2.3 安全上下文 Security Context 安全上下文的组成元素
28 2使用 SELinux提升内核安全性 23安全上下文 Security Context a Processes and files are labeled with an selinux context that contains additional information, such as an SELinux user, role, type, and, optionally, a level a When running SELinux, all of this information is used to make access control decisions u SELinux provides a combination of Role Based Access Control(RBAC), Type Enforcement (TE), and, optionally, Multi-Level Security(MLS) 口安全上下文信息附加在用户、文件和进程中,使用-Z选项查看。 查看文件的安全上下文信息:|s-z ■查看进程的安全上下文信息:ps-Z 查看用户的安全上下文信息:id-z 河南中医药大学/阮晓龙713938213680/http://inux.xg.hactcm.edu.cn/http://www.5lxueweb.cn
河南中医药大学 / 阮晓龙 / 13938213680 / http://linux.xg.hactcm.edu.cn / http://www.51xueweb.cn 2.使用SELinux提升内核安全性 Processes and files are labeled with an SELinux context that contains additional information, such as an SELinux user, role, type, and, optionally, a level. ◼ When running SELinux, all of this information is used to make access control decisions. ◼ SELinux provides a combination of RoleBased Access Control (RBAC), Type Enforcement (TE), and, optionally, Multi-Level Security (MLS). 安全上下文信息附加在用户、文件和进程中,使用-Z选项查看。 ◼ 查看文件的安全上下文信息:ls -Z ◼ 查看进程的安全上下文信息:ps -Z ◼ 查看用户的安全上下文信息:id -Z 28 2.3 安全上下文 Security Context
29 2使用 SELinux提升内核安全性 23安全上下文 Security Context 口配置 SELinux policy SELinux is in enforcing mode, the default policy is the targeted policy Change configuration defaults, such as ports, database locations, or file-system permissions for processes policycoreutils-python-utils package is installed 口配置工具 配置文件安全上下文: cheon ■恢复文件安全上下文为默认值: restorecon 查询/修改/增加删除文件的默认 SeLinux类型: semanage ■显示 SELinux规则: sento ■查询 SELinux规则: sesearch 河南中医药大学/阮晓龙713938213680/http://inux.xg.hactcm.edu.cn/http://www.5lxueweb.cn
河南中医药大学 / 阮晓龙 / 13938213680 / http://linux.xg.hactcm.edu.cn / http://www.51xueweb.cn 2.使用SELinux提升内核安全性 配置SELinux Policy ◼ SELinux is in enforcing mode, the default policy is the targeted policy. ◼ Change configuration defaults, such as ports, database locations, or file-system permissions for processes. ◼ The policycoreutils-python-utils package is installed. 配置工具 ◼ 配置文件安全上下文:chcon ◼ 恢复文件安全上下文为默认值:restorecon ◼ 查询/修改/增加/删除文件的默认SELinux类型:semanage ◼ 显示SELinux规则:seinfo ◼ 查询SELinux规则:sesearch 29 2.3 安全上下文 Security Context
30 2使用 SELinux提升内核安全性 2.4 Booleans a Booleans allow parts of SELinux policy to be changed at runtime, without any knowledge of SELinux policy writing 对 Security Context的修改需要一定的专业能力和丰富的经验 使用 Booleans可以更改安全规则的部分内容 修改 Booleans是 SELinux管理配置的常用操作 口 Booleans的管理工具 列出所有 Booleans: semanage boolean 查看 Boolean值: getseboo 表11-1-8 setsebool命令选项 ■配置 Boolean值: setsebool 可选项,永久保存该属性值设置结果,防止系统重新启动后属性值恢复 boolean 需要设置的安全策略属性值名称。同时设置多个策略属性时需将属性和值之问用“=” 号连接 on或1属性值。表示设置策略属性值状态为开启 value 或0属性值。表示设置策略属性值状态为关闭 河南中医药大学/阮晓龙713938213680/http://inux.xg.hactcm.edu.cn/http://www.5lxueweb.cn
河南中医药大学 / 阮晓龙 / 13938213680 / http://linux.xg.hactcm.edu.cn / http://www.51xueweb.cn 2.使用SELinux提升内核安全性 Booleans allow parts of SELinux policy to be changed at runtime, without any knowledge of SELinux policy writing. ◼ 对Security Context的修改需要一定的专业能力和丰富的经验 ◼ 使用Booleans可以更改安全规则的部分内容 ◼ 修改Booleans是SELinux管理配置的常用操作 Booleans的管理工具 ◼ 列出所有Booleans:semanage boolean -l ◼ 查看Boolean值:getsebool ◼ 配置Boolean值:setsebool 30 2.4 Booleans