[root@trouble policy]# 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
[root@trouble policy]# getenforce
Enforcing
[root@trouble policy]# setenforce 0
[root@trouble policy]# getenforce
Permissive
[root@trouble policy]# setenforce 1
[root@trouble policy]# getenforce
Enforcing
[root@trouble ~]# getsebool -a|grep ftpd
ftpd_anon_write --> on
ftpd_connect_all_unreserved --> off
ftpd_connect_db --> off
ftpd_full_access --> off
ftpd_use_cifs --> off
ftpd_use_fusefs --> off
ftpd_use_nfs --> off
ftpd_use_passive_mode --> off
[root@trouble ~]# setsebool ftpd_anon_write=off
[root@trouble ~]# getsebool ftpd_anon_write
ftpd_anon_write --> off
[root@trouble test]# ls -Z
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 a
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 b
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 c
[root@trouble test]# seinfo -t|grep httpd_sys
httpd_sys_content_t
httpd_sys_htaccess_t
httpd_sys_ra_content_t
httpd_sys_rw_content_t
httpd_sys_script_t
httpd_sys_script_exec_t
[root@trouble test]# chcon -t httpd_sys_rw_content_t b
[root@trouble test]# ls -Z
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 a
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 b
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 c
[root@trouble test]# restorecon -Rv ../test
restorecon reset /root/test/b context unconfined_u:object_r:httpd_sys_rw_content_t:s0->unconfined_u:object_r:admin_home_t:s0
[root@trouble test]# ls -Z
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 a
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 b
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 c
[root@trouble test]# semanage fcontext --add -t httpd_sys_rw_content_t '/root/test(/.*)?'
[root@trouble test]# semanage fcontext -l |grep /root/test
/root/test(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0
[root@trouble test]# ls -Z
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 a
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 b
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 c
[root@trouble test]# restorecon -Rv /root
restorecon reset /root/test context unconfined_u:object_r:admin_home_t:s0->unconfined_u:object_r:httpd_sys_rw_content_t:s0
restorecon reset /root/test/a context unconfined_u:object_r:admin_home_t:s0->unconfined_u:object_r:httpd_sys_rw_content_t:s0
restorecon reset /root/test/b context unconfined_u:object_r:admin_home_t:s0->unconfined_u:object_r:httpd_sys_rw_content_t:s0
restorecon reset /root/test/c context unconfined_u:object_r:admin_home_t:s0->unconfined_u:object_r:httpd_sys_rw_content_t:s0
[root@trouble test]# ls -Z
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 a
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 b
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 c
[root@trouble test]# semanage fcontext --delete '/root/test(/.*)?'
[root@trouble test]# semanage fcontext -l |grep /root/test
[root@trouble test]# restorecon -Rv /root
restorecon reset /root/test context unconfined_u:object_r:httpd_sys_rw_content_t:s0->unconfined_u:object_r:admin_home_t:s0
restorecon reset /root/test/a context unconfined_u:object_r:httpd_sys_rw_content_t:s0->unconfined_u:object_r:admin_home_t:s0
restorecon reset /root/test/b context unconfined_u:object_r:httpd_sys_rw_content_t:s0->unconfined_u:object_r:admin_home_t:s0
restorecon reset /root/test/c context unconfined_u:object_r:httpd_sys_rw_content_t:s0->unconfined_u:object_r:admin_home_t:s0
[root@trouble test]# ls -Z
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 a
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 b
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 c
[root@trouble test]# chcon -t httpd_sys_rw_content_t b
[root@trouble test]# ls -Z
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 a
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 b
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 c
[root@trouble test]# restorecon -Rv /root
restorecon reset /root/test/b context unconfined_u:object_r:httpd_sys_rw_content_t:s0->unconfined_u:object_r:admin_home_t:s0
[root@trouble test]# ls -Z
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 a
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 b
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 c
'IT > LINUX' 카테고리의 다른 글
[EX342] trouble shooting [protective MBR recover] (0) | 2020.12.27 |
---|---|
[EX342] trouble shooting[MBR, GPT] (0) | 2020.12.27 |
[EX342] trouble shooting [selinux] (0) | 2020.12.24 |
[RHCA] 그냥 따고 싶어졌어. (4) | 2020.12.23 |
[ansible] become 에 대하여 (0) | 2020.12.22 |