Chinaunix首页 | 论坛 | 博客
  • 博客访问: 237234
  • 博文数量: 41
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 441
  • 用 户 组: 普通用户
  • 注册时间: 2015-04-11 11:05
个人简介

123

文章分类

全部博文(41)

文章存档

2019年(2)

2018年(3)

2017年(2)

2016年(11)

2015年(23)

我的朋友

分类: LINUX

2016-01-10 12:49:55

当一个SELinux用户关联有多个角色时,可以使用newrole进行角色切换。下面,以一个statff_u SELinux用户的角色切换进行演示。
1、查看staff_u用户关联的角色:
root@localhost yuanzhufu]# semanage user -l

                标记中        MLS/       MLS/                          
SELinux 用户      前缀         MCS 级别     MCS 范围                         SELinux 角色

guest_u         user       s0         s0                             guest_r
root            user       s0         s0-s0:c0.c1023                 staff_r sysadm_r system_r unconfined_r
staff_u         user       s0         s0-s0:c0.c1023                 staff_r sysadm_r system_r unconfined_r
sysadm_u        user       s0         s0-s0:c0.c1023                 sysadm_r
system_u        user       s0         s0-s0:c0.c1023                 system_r unconfined_r
unconfined_u    user       s0         s0-s0:c0.c1023                 system_r unconfined_r
user_u          user       s0         s0                             user_r
xguest_u        user       s0         s0                             xguest_r
由以上可知,staff_u SELinux用户关联的角色是staff_r sysadm_r system_r unconfined_r。
2、staff_u是不能使用su切换到root用户的。
[yuanzhufu@localhost ~]$ id -Z
staff_u:staff_r:staff_t:s0-s0:c0.c1023
[yuanzhufu@localhost ~]$ su
密码:
su: 鉴定故障
[yuanzhufu@localhost ~]$
3、将staff_u的角色切换到unconfined_r:
[yuanzhufu@localhost ~]$ id -Z
staff_u:staff_r:staff_t:s0-s0:c0.c1023
[yuanzhufu@localhost ~]$ newrole -r unconfined_r
密码:
[yuanzhufu@localhost ~]$ id -Z
staff_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[yuanzhufu@localhost ~]$
4、su切换到root:
[yuanzhufu@localhost ~]$ id -Z
staff_u:staff_r:staff_t:s0-s0:c0.c1023
[yuanzhufu@localhost ~]$ newrole -r unconfined_r
密码:
[yuanzhufu@localhost ~]$ id -Z
staff_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[yuanzhufu@localhost ~]$ su
密码:
[root@localhost yuanzhufu]# id -Z
staff_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[root@localhost yuanzhufu]#
5、小结
newrole命令可进行SELinux用户角色间的切换。
阅读(4505) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~