当一个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用户角色间的切换。
阅读(4729) | 评论(0) | 转发(0) |