复习之selinux的管理

一、什么是selinux?

SELinux,Security Enhanced Linux 的缩写,也就是安全强化的 Linux,是由美国国家安全局(NSA)联合其他安全机构(比如 SCC 公司)共同开发的,旨在增强传统 Linux 操作系统的安全性,解决传统 Linux 系统中自主访问控制(DAC)系统中的各种权限问题(如 root 权限过高等)。

下面举例了解下selinux:

1. selinux关闭时

  • 移动/mnt/里面的文件到ftp的默认发布目录中可以被访问
  • ls -Z 访问文件属性时显示?
  • 匿名用户可以上传文件(前提是配置文件设定权限)

首先查看selinux的状态

[root@ftp ~]# getenforce 
Disabled

在/mnt/建立新文件,并且移动他到ftp的默认发布目录/var/ftp,当匿名用户登录时可以访问该文件!

[root@ftp ~]# touch /mnt/westodfile1
[root@ftp ~]# mv /mnt/westodfile1 /var/ftp/
[root@ftp ~]# lftp 172.25.254.100
lftp 172.25.254.100:~> ls
drwxrwxr-x    3 0        50             49 Aug 02 05:51 pub
-rw-r--r--    1 0        0               0 Aug 02 13:05 westodfile1
lftp 172.25.254.100:/> 

ls -Z 访问文件属性时显示?

[root@ftp ~]# ls -Z /var/ftp
? pub  ? westodfile1
[root@ftp ~]# 

在配置文件中设定匿名用户可以上传文件!

重启服务后,匿名用户上传文件成功!

[root@ftp ~]# vim /etc/vsftpd/vsftpd.conf 
[root@ftp ~]# systemctl restart vsftpd.service 
[root@ftp ~]# lftp 172.25.254.100
lftp 172.25.254.100:~> ls
drwxrwxr-x    3 0        50             49 Aug 02 05:51 pub
-rw-r--r--    1 0        0               0 Aug 02 13:05 westodfile1
lftp 172.25.254.100:/> cd pub/
lftp 172.25.254.100:/pub> ls
-rw-r--r--    1 1000     50       16043547 Aug 02 05:53 bigfile
-rw-r--r--    1 1000     50           2761 Aug 02 05:02 passwd
drwx------    2 14       50              6 Aug 01 11:30 westos
lftp 172.25.254.100:/pub> put /etc/inittab 
490 bytes transferred
lftp 172.25.254.100:/pub> ls
-rw-r--r--    1 1000     50       16043547 Aug 02 05:53 bigfile
-rw-r--r--    1 1000     50            490 Aug 02 13:12 inittab
-rw-r--r--    1 1000     50           2761 Aug 02 05:02 passwd
drwx------    2 14       50              6 Aug 01 11:30 westos
lftp 172.25.254.100:/pub> quit

2. selinu开启时

  • vim  /etc/sysconfig/selinux : 修改selinux状态
  • 重复以上实验,比较结果!

首先修改selinux状态!修改完成一定要重启系统,否则不识别!重启比较慢,等待一下。。。

[root@ftp ~]# vim /etc/sysconfig/selinux 
[root@ftp ~]# cat /etc/sysconfig/selinux 

# 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 - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


[root@ftp ~]# reboot

重启成功后,再次重复上面的实验!首先查看selinux的状态!此时时开启的!

[root@ftp ~]# getenforce 
Enforcing

再次新建文件移动到ftp的默认发布目录,看看可以访问玛?发现不能访问了!

[root@ftp ~]# touch /mnt/westosfile2
[root@ftp ~]# mv /mnt/westosfile2 /var/ftp/
[root@ftp ~]# lftp 172.25.254.100
lftp 172.25.254.100:~> ls
drwxrwxr-x    3 0        50             64 Aug 02 13:12 pub
-rw-r--r--    1 0        0               0 Aug 02 13:05 westodfile1
lftp 172.25.254.100:/> quit

利用ls -Z 访问文件属性显示。。。

[root@ftp ~]# ls -Z /var/ftp
system_u:object_r:public_content_t:s0 pub
system_u:object_r:public_content_t:s0 westodfile1
       unconfined_u:object_r:mnt_t:s0 westosfile2
[root@ftp ~]# 

此时配置文件允许匿名用户上传文件

 但是匿名用户却无法上传文件!

[root@ftp ~]# lftp 172.25.254.100
lftp 172.25.254.100:~> ls
drwxrwxr-x    3 0        50             64 Aug 02 13:12 pub
-rw-r--r--    1 0        0               0 Aug 02 13:05 westodfile1
lftp 172.25.254.100:/> cd pub/
lftp 172.25.254.100:/pub> ls
-rw-r--r--    1 1000     50       16043547 Aug 02 05:53 bigfile
-rw-r--r--    1 1000     50            490 Aug 02 13:12 inittab
-rw-r--r--    1 1000     50           2761 Aug 02 05:02 passwd
drwx------    2 14       50              6 Aug 01 11:30 westos
lftp 172.25.254.100:/pub> put /etc/group
put: /etc/group: Access failed: 553 Could not create file. (group)
lftp 172.25.254.100:/pub> quit
[root@ftp ~]# 

以上对比可知,selinux可以提高系统的安全性!

二、selinux的状态及管理

1.selinux的状态

  • enforcing :selinux开机设定为强制状态此状态为selinux开启
  • permissive :selinux开机设定为警告状态此状态为selinux开启
  • disabled:selinux关闭

enforcing 和 permissive状态都是开启状态,有什么不同呢?

enforcing:  不符合条件一定不能被允许,并会收到警告信息
permissive: 不符合条件被允许,并会收到警告信息

2. selinux状态的查看

  • getenforce
  • cat /etc/sysconfig/delinux
  • cat  /etc/selinux/config

[root@ftp ~]# geten
getenforce  getent      
[root@ftp ~]# getenforce 
Enforcing
[root@ftp ~]# cat /etc/sysconfig/selinux 

# 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 - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

3.selinux状态的转换

(1)开启和关闭状态之间的转换

selinux从开启状态变为关闭状态或者从关闭状态转换为开启状态,必须要重启!

 (2)开启状态之间的转换

enforceing 和 permissive状态之间的转换可以用

  • setenforce 0/1 进行转换
  • setenforce  0 : 转换到permissive状态
  • setenforce 1 :转换到enforcing状态
[root@ftp ~]# getenforce 
Enforcing
[root@ftp ~]# setenforce 0
[root@ftp ~]# getenforce 
Permissive
[root@ftp ~]# setenforce 1
[root@ftp ~]# getenforce 
Enforcing
[root@ftp ~]# 

(3)开机时想转换状态

当正在开机时,想转换状态

  • “e" 编辑输入 selinux=0/1 
  • selinux=0 : disabled状态
  • selinux=1:enforcing状态

初始时enforcing状态

重启后

想改变状态

[root@ftp ~]# getenforce 
Enforcing
[root@ftp ~]# reboot
Connection to 172.25.254.100 closed by remote host.
Connection to 172.25.254.100 closed.
[root@node73 Desktop]# ssh -l root 172.25.254.100
root@172.25.254.100's password: 
Activate the web console with: systemctl enable --now cockpit.socket

This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register

Last login: Sat Aug  5 10:30:45 2023 from 172.25.254.73
[root@ftp ~]# getenforce 
Disabled

在开机界面编辑 selinux=0 可以改成enforcing状态

开启,selinux状态转换成了disabled状态!

三、selinux的安全上下文

SELinux 管理过程中,进程是否可以正确地访问文件资源,取决于它们的安全上下文。进程和文件都有自己的安全上下文,SELinux 会为进程和文件添加安全信息标签,比如 SELinux 用户、角色、类型、类别等,当运行 SELinux 后,所有这些信息都将作为访问控制的依据。

1. selinux安全上下文的查看方法

ps:首先要开启selinux!!!

  • ls   -Z :查看文件的安全上下文
  • ls  -Zd  :查看目录的安全上下文
  • ps   auxZ  :查看进程的安全上下文
[root@ftp ~]# ls -Z
    system_u:object_r:admin_home_t:s0 anaconda-ks.cfg           system_u:object_r:admin_home_t:s0 passwd
unconfined_u:object_r:admin_home_t:s0 Desktop               unconfined_u:object_r:admin_home_t:s0 Pictures
unconfined_u:object_r:admin_home_t:s0 Documents             unconfined_u:object_r:admin_home_t:s0 Public
unconfined_u:object_r:admin_home_t:s0 Downloads             unconfined_u:object_r:admin_home_t:s0 Templates
unconfined_u:object_r:admin_home_t:s0 fstab                 unconfined_u:object_r:admin_home_t:s0 Videos
    system_u:object_r:admin_home_t:s0 initial-setup-ks.cfg  unconfined_u:object_r:admin_home_t:s0 westos.cfg
unconfined_u:object_r:admin_home_t:s0 Music
[root@ftp ~]# ls -Zd /var/www/html/
system_u:object_r:httpd_sys_content_t:s0 /var/www/html/
[root@ftp ~]# ps aux -Z
LABEL                           USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
system_u:system_r:init_t:s0     root           1  0.4  0.7 181872 13996 ?        Ss   18:06   0:01 /usr/lib/systemd/systemd --switched-root --syst
system_u:system_r:kernel_t:s0   root           2  0.0  0.0      0     0 ?        S    18:06   0:00 [kthreadd]
system_u:system_r:kernel_t:s0   root           3  0.0  0.0      0     0 ?        I<   18:06   0:00 [rcu_gp]
system_u:system_r:kernel_t:s0   root           4  0.0  0.0      0     0 ?        I<   18:06   0:00 [rcu_par_gp]
system_u:system_r:kernel_t:s0   root           5  0.0  0.0      0     0 ?        I    18:06   0:00 [kworker/0:0-events_power_efficient]
system_u:system_r:kernel_t:s0   root           6  0.0  0.0      0     0 ?        I<   18:06   0:00 [kworker/0:0H-kblockd]
system_u:system_r:kernel_t:s0   root           7  0.0  0.0      0     0 ?        I    18:06   0:00 [kworker/u4:0-events_unbound]

2. 安全上下文的组成

只要进程和文件的安全上下文匹配,该进程就可以访问该文件资源。

安全上下文看起来比较复杂,它使用“:”分隔为 4 个字段,其实共有 5 个字段,只是最后一个“类别”字段是可选的

  • system_u :  object_r : httpd_sys_content_t :  s0   /var/www/html/
  • 身份字段  :  角色    :        类型                      :灵敏度  [类别]  

(1)身份字段--user

用于标识该数据被哪个身份所拥有,相当于权限中的用户身份。常见的身份类型有以下 3 种:

  • 1.- root:表示安全上下文的身份是 root。
  • 2.- system_u:表示系统用户身份,其中“_u”代表 user。
  • 3.- user_u:表示与一般用户账号相关的身份,其中“_u”代表 user。

(2)角色--role

主要用来表示此数据是进程还是文件或目录。常见的角色有以下两种:

  • 1.- object_r:代表该数据是文件或目录,这里的“_r”代表 role。
  • 2.- system_r:代表该数据是进程,这里的“_r”代表 role。

(3)类型--type

类型字段是安全上下文中最重要的字段,进程是否可以访问文件,主要就是看进程的安全上下文类型字段是否和文件的安全上下文类型字段相匹配,如果匹配则可以访问

ps:类型字段在文件或目录的安全上下文中被称作类型(type),但是在进程的安全上下文中被称作域(domain)。也就是说,在主体(Subject)的安全上下文中,这个字段被称为域;在目标(Object)的安全上下文中,这个字段被称为类型。域和类型需要匹配(进程的类型要和文件的类型相匹配),才能正确访问。

 apache 进程的域是 httpd_t,/var/www/html/ 目录的类型是 httpd_sys_content_t,这个主体的安全上下文类型经过策略规则的比对,是和目标的安全上下文类型匹配的,所以 apache 进程可以访问 /var/www/html/ 目录。

(4) 灵敏度

灵敏度一般是用 s0、s1、s2 来命名的,数字代表灵敏度的分级。数值越大,代表灵敏度越高。

(5)类别

类别字段不是必须有的

3. selinux安全上下文的修改

  • chcon:临时修改
  • semanage :永久修改

(1)临时修改--chcon

  •  chcon    [选项]     文件或目录
  • -R: 递归,当前目录和目录下的所有子文件同时设置;
    -t: 修改安全上下文的类型字段,最常用;
    -u: 修改安全上下文的身份字段;
    -r: 修改安全上下文的角色字段;

-------------------------------------------------------实验----------------------------------------------------------------------

在apache的默认发布目录中 写入test page

[root@ftp html]# echo "test page" >> /var/www/html/index.html

上下文匹配的情况下,打开浏览器,可以看见以下界面!

 此时,修改默认目录的安全上下文,与httpd进程的上下文不再匹配

[root@ftp html]# ps auxZ | grep httpd
system_u:system_r:httpd_t:s0    root        1078  0.0  0.6 281404 11464 ?        Ss   18:06   0:00 /usr/sbin/httpd -DFOREGROUND
system_u:system_r:httpd_t:s0    apache      1200  0.0  0.4 294140  8524 ?        S    18:06   0:00 /usr/sbin/httpd -DFOREGROUND
system_u:system_r:httpd_t:s0    apache      1201  0.0  1.0 1941840 20412 ?       Sl   18:06   0:00 /usr/sbin/httpd -DFOREGROUND
system_u:system_r:httpd_t:s0    apache      1205  0.0  0.6 1810712 12244 ?       Sl   18:06   0:00 /usr/sbin/httpd -DFOREGROUND
system_u:system_r:httpd_t:s0    apache      1206  0.0  0.8 1810712 16332 ?       Sl   18:06   0:00 /usr/sbin/httpd -DFOREGROUND
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 root 2550 0.0  0.0 12108 1100 pts/0 S+ 18:36   0:00 grep --color=auto httpd
[root@ftp html]# chcon -t var_t /var/www/html/index.html 
[root@ftp html]# ls -Z /var/www/html/index.html 
unconfined_u:object_r:var_t:s0 /var/www/html/index.html
[root@ftp html]# 

再次打浏览器,进入默认发布目录,发现无法访问!

这是因为 安全上下文不匹配!当然,我们可以通过 chcon 命令修改回来就可以修复。不过,我们还有一个命令 restorecon,这个命令的作用就是把文件的安全上下文恢复成默认的安全上下文。SELinux 的安全上下文设定非常完善,所以使用 restorecon 命令就可以修复安全上下文不匹配所引起的问题。

(2)恢复默认上下文--restorecon

  •  restorecon    [选项】     文件或目录

  • -R:递归.当前目录和目录下所有的子文件同时恢复;
    -V:把恢复过程显示到屏幕上;

恢复目录的默认上下文!!

[root@ftp html]# restorecon -Rv /var/www/html/index.html 
Relabeled /var/www/html/index.html from unconfined_u:object_r:var_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
[root@ftp html]# ls -Z /var/www/html/index.html 
unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/index.html

再次通过浏览器访问!!再次访问成功,因为此时安全上下文已经匹配!

 (3) 修改默认安全上下文--semanage

  • semanage  fcontent   -l  : 查看内核的安全上下文
  • semanage   fcontext   -a   -t    public_content_t    '/westosdir(/.*)?'  : 修改目录的安全上下文
  • restorecon   -RvvF   /westosdir/ :刷新,修改目录当前的安全上下文
  • semanage   fcontext   -d   -t    public_content_t    '/westosdir(/.*)?'  : 删除目录的安全上下文

----------------------------------------------------------------实验--------------------------------------------------------

[root@ftp ~]# semanage fcontext -l

查看内核的安全上下文,建立目录westosdir

修改默认上下文

修改后,还没有改变,因为只是修改了默认上下文,没有修改目前的安全上下文!

因此要刷新,修改目前的安全上下文

 修改完成后,默认上下文已经改变,再次查看内核的安全上下文,/wesosdir存在!

 如果不想要这个上下文,可以删除!删除后依旧要刷新!

root@ftp ~]# semanage fcontext -d -t public_content_t '/westosdir(/.*)?'
[root@ftp ~]# ls -Zd /westosdir/
system_u:object_r:public_content_t:s0 /westosdir/
[root@ftp ~]# restorecon -RvvF /westosdir/
Relabeled /westosdir from system_u:object_r:public_content_t:s0 to system_u:object_r:default_t:s0
[root@ftp ~]# ls -Zd /westosdir/
system_u:object_r:default_t:s0 /westosdir/

查看内核的安全上下文,已经不存在!

 四、SEBOOL

sebool  是selinux能对服务功能能够添加的开关

  • getsebool     -a |  grep  ftp :查看ftp的bool值
  • setsebool    -P    ftpd_anon_write    on:更改bool值

---------------------------------------实验-------------------------------------------------------

ftp默认配置目录中允许匿名用户上传文件

但实际不允许匿名用户上传文件

[root@ftp ~]# lftp 172.25.254.100
lftp 172.25.254.100:~> ls
drwxrwxr-x    3 0        50             64 Aug 02 13:12 pub
-rw-r--r--    1 0        0               0 Aug 02 13:05 westodfile1
-rw-r--r--    1 0        0               0 Aug 02 13:23 westosfile2
lftp 172.25.254.100:/> cd pub/
lftp 172.25.254.100:/pub> ls
-rw-r--r--    1 1000     50       16043547 Aug 02 05:53 bigfile
-rw-r--r--    1 1000     50            490 Aug 02 13:12 inittab
-rw-r--r--    1 1000     50           2761 Aug 02 05:02 passwd
drwx------    2 14       50              6 Aug 01 11:30 westos
lftp 172.25.254.100:/pub> put /etc/group
put: /etc/group: Access failed: 553 Could not create file. (group)
lftp 172.25.254.100:/pub> quit

这是因为selinux开启!!此时查看ftp的sebool值,发现匿名用户上传功能关闭!

[root@ftp ~]# getenforce 
Enforcing
[root@ftp ~]# getsebool -a | grep ftp
ftpd_anon_write --> off
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
httpd_can_connect_ftp --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off
tftp_home_dir --> off

更改sebool值

[root@ftp ~]# setsebool -P ftpd_anon_write on
[root@ftp ~]# getsebool -a | grep ftp
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
httpd_can_connect_ftp --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off
tftp_home_dir --> off

再次匿名上传文件,成功!!

<pre>[root@ftp ~]# lftp 172.25.254.100
lftp 172.25.254.100:~&gt; ls
drwxrwxr-x    3 0        50             64 Aug 02 13:12 <font color="#0087FF">pub</font>
-rw-r--r--    1 0        0               0 Aug 02 13:05 westodfile1
-rw-r--r--    1 0        0               0 Aug 02 13:23 westosfile2
lftp 172.25.254.100:/&gt; cd pub/
lftp 172.25.254.100:/pub&gt; ls
-rw-r--r--    1 1000     50       16043547 Aug 02 05:53 bigfile
-rw-r--r--    1 1000     50            490 Aug 02 13:12 inittab
-rw-r--r--    1 1000     50           2761 Aug 02 05:02 passwd
drwx------    2 14       50              6 Aug 01 11:30 <font color="#0087FF">westos</font>
lftp 172.25.254.100:/pub&gt; put /etc/group
1032 bytes transferred
lftp 172.25.254.100:/pub&gt; quit
</pre>

五、SEPORT

SEPORT是selinux对于服务端口的管理

  • semanage port -l | grep ssh:查看服务可用端口
  • semanage   port    -a    -t    ssh_port_t    -p   tcp   2222:添加服务端口
  • semanage   port    -d    -t    ssh_port_t    -p   tcp   2222:删除服务端口

---------------------------------------------------------实验------------------------------------------------------

首先设定selinux状态为permissive,然后修改ssh服务的默认端口号,重启服务,成功!

[root@ftp ~]# getenforce 
Enforcing
[root@ftp ~]# setenforce 0
[root@ftp ~]# getenforce 
Permissive
[root@ftp ~]# vim /etc/ssh/sshd_config 

[root@ftp ~]# systemctl restart sshd
[root@ftp ~]# netstat -antlupe | grep sshd
tcp        0      0 0.0.0.0:2222            0.0.0.0:*               LISTEN      0          37626      2320/sshd           
tcp        0      0 172.25.254.100:22       172.25.254.73:59242     ESTABLISHED 0          34599      2152/sshd: root [pr 
tcp6       0      0 :::2222                 :::*                    LISTEN      0          37628      2320/sshd           

查看端口号,也可以使用!此时修改selinux的状态为enforcing,重启服务失败!

[root@ftp ~]# setenforce 1
[root@ftp ~]# getenforce 
Enforcing
[root@ftp ~]# systemctl restart sshd
Job for sshd.service failed because the control process exited with error code.
See "systemctl status sshd.service" and "journalctl -xe" for details.
[root@ftp ~]# netstat -antlupe | grep sshd
tcp        0      0 172.25.254.100:22       172.25.254.73:59242     ESTABLISHED 0          34599      2152/sshd: root [pr 

如果在enforcing状态下,想使用指定的端口号怎么办?可以使用semanage命添加指定端口!

[root@ftp ~]# netstat -antlupe | grep sshd
tcp        0      0 172.25.254.100:22       172.25.254.73:59242     ESTABLISHED 0          34599      2152/sshd: root [pr 
[root@ftp ~]# semanage port -a -t ssh_port_t -p tcp 2222
[root@ftp ~]# semanage -l | grep ssh
semanage: error: the following arguments are required: subcommand
[root@ftp ~]# semanage port -l | grep ssh
ssh_port_t                     tcp      2222, 22
[root@ftp ~]# netstat -antlupe | grep sshd
tcp        0      0 0.0.0.0:2222            0.0.0.0:*               LISTEN      0          40835      2436/sshd           
tcp        0      0 172.25.254.100:22       172.25.254.73:59242     ESTABLISHED 0          34599      2152/sshd: root [pr 
tcp6       0      0 :::2222                 :::*                    LISTEN      0          40837      2436/sshd           
[root@ftp ~]# systemctl restart sshd

添加成功,重启服务成功!当然也可删除该端口,删除后,2222端口不存在!!

[root@ftp ~]# semanage port -d -t ssh_port_t -p tcp 2222
[root@ftp ~]# semanage port -l | grep ssh
ssh_port_t                     tcp      22

六、selinux的排错解决方案

  • /var/log/audit/audit.log  :selinux警告信息
  • /var/log/messages:selinux问题解决方案
  • setroubleshoot-server :此软件功能是采集警告信息并分析得到解决方案存放到message中

--------------------------------------------------------实验------------------------------------------------------------------

首先建立新文件,移动该文件到ftp的发布目录

[root@ftp ~]# touch /mnt/westostest
[root@ftp ~]# mv /mnt/westostest /var/ftp
mv: overwrite '/var/ftp/westostest'? y

接着进入发布目录,发现没有看见该文件!

[root@ftp ~]# lftp 172.25.254.100
lftp 172.25.254.100:~> ls
drwxrwxr-x    3 0        50             77 Aug 05 12:04 pub
-rw-r--r--    1 0        0               0 Aug 02 13:05 westodfile1
-rw-r--r--    1 0        0               0 Aug 02 13:23 westosfile2
lftp 172.25.254.100:/> quit

进入/var/log/audit/audit.log ,查看警告信息

 但是没有解决方案,进入/var/log/messages查看解决方案

 运行该命令发现,有两个命令可以解决

 选择一个运行:

ps:/westostest 前面加上/var/ftp

[root@ftp ~]# /sbin/restorecon -v /var/ftp/westostest
Relabeled /var/ftp/westostest from unconfined_u:object_r:mnt_t:s0 to unconfined_u:object_r:public_content_t:s0

此时再次查看ftp默认目录,发现wesetostest文件已经出现!

 宗上,selinux有排错功能是因为有软件:

 如果没有解决方案可能是没有安装这个软件!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值