当前位置: 首页 > news >正文

复习之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 westodfile1unconfined_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.socketThis system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --registerLast 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 -Zsystem_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 Videossystem_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有排错功能是因为有软件:

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

相关文章:

复习之selinux的管理

一、什么是selinux? SELinux&#xff0c;Security Enhanced Linux 的缩写&#xff0c;也就是安全强化的 Linux&#xff0c;是由美国国家安全局&#xff08;NSA&#xff09;联合其他安全机构&#xff08;比如 SCC 公司&#xff09;共同开发的&#xff0c;旨在增强传统 Linux 操…...

无涯教程-Lua - 文件I/O

I/O库用于在Lua中读取和处理文件。 Lua中有两种文件操作&#xff0c;即隐式(Implicit)和显式(Explicit)操作。 对于以下示例&#xff0c;无涯教程将使用例文件test.lua&#xff0c;如下所示。 -- sample test.lua -- sample2 test.lua 一个简单的文件打开操作使用以下语句。…...

java+ssm民宿酒店客房推荐预订系统_2k78b--论文

摘 要 互联网日益成熟&#xff0c;走进千家万户&#xff0c;改变多个行业传统的工作方式。民宿推荐管理以用户需求为基础&#xff0c;借由发展迅猛的互联网平台实现民宿推荐管理的信息化&#xff0c;简化旧时民宿推荐管理所需的纸质记录这一繁杂过程&#xff0c;从而大幅提高民…...

Docker实战-关于Docker镜像的相关操作(一)

导语   镜像&#xff0c;Docker中三大核心概念之一&#xff0c;并且在运行Docker容器之前需要本地存储对应的镜像。那么下面我们就来介绍一下在Docker中如何使用镜像。 如何获取镜像&#xff1f; 镜像作为容器运行的前提条件&#xff0c;在Docker Hub上提供了各种各样的开放的…...

Jenkins Gerrit Trigger实践

1.创建Gerrit Trigger 2.jenkins master节点生成gerrit用户的密钥 这里的用户名得写登录gerrit后个人信息中的 Username 3.gerrit 配置刚刚jenkins生成密钥的公钥 4.gerrit 用户加入群组 不加这个群组&#xff0c;下一步测试就会报错“User aeshare has no capability conn…...

Xcode protobuf2.5添加arm64编译器补丁生成静态库

项目需求&#xff0c;protobuf源码编成静态库使用 但是&#xff0c;github上的protobuf源码没有对应arm64的编译器定义&#xff0c;编译出来的静态库使用时报错。 下面的连接是arm64编译器代码补丁包&#xff0c;把编译器代码放到src/google/protobuf/stubs/atomicops_intern…...

计算机毕设 深度学习疫情社交安全距离检测算法 - python opencv cnn

文章目录 0 前言1 课题背景2 实现效果3 相关技术3.1 YOLOV43.2 基于 DeepSort 算法的行人跟踪 4 最后 0 前言 &#x1f525; 这两年开始毕业设计和毕业答辩的要求和难度不断提升&#xff0c;传统的毕设题目缺少创新和亮点&#xff0c;往往达不到毕业答辩的要求&#xff0c;这两…...

四数之和——力扣18

文章目录 题目描述双指针法题目描述 双指针法 class Solution {public:vector<vector<int>>...

Serializable 和 Externalizable区别?

Serializable接口 java.io.Serializable 接口没有方法或字段&#xff0c;仅用于标识可序列化的语义。 public interface Serializable { }可序列化类的所有子类型本身都是可序列化的。在进行序列化操作时&#xff0c;会判断要被序列化的类是否是Enum、Array和 Serializable类…...

2023 电赛 E 题 K210 方案--K210实现矩形识别

相关库介绍 sensor&#xff08;摄像头&#xff09; sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(10) reset()&#xff1a;重置并初始化单目摄像头 set_pixformat()&#xff1a;设置摄像头输出格式&#xff0c…...

【雕爷学编程】MicroPython动手做(29)——物联网之SIoT 2

知识点&#xff1a;什么是掌控板&#xff1f; 掌控板是一块普及STEAM创客教育、人工智能教育、机器人编程教育的开源智能硬件。它集成ESP-32高性能双核芯片&#xff0c;支持WiFi和蓝牙双模通信&#xff0c;可作为物联网节点&#xff0c;实现物联网应用。同时掌控板上集成了OLED…...

chapter13:springboot与任务

Spring Boot与任务视频 1. 异步任务 使用注解 Async 开启一个异步线程任务&#xff0c; 需要在主启动类上添加注解EnableAsync开启异步配置&#xff1b; Service public class AsyncService {Asyncpublic void hello() {try {Thread.sleep(3000);} catch (InterruptedExcept…...

(十一)大数据实战——hadoop高可用之HDFS手动模式高可用

前言 本节内容我们介绍一下hadoop在手动模式下如何实现HDFS的高可用&#xff0c;HDFS的高可用功能是通过配置多个 NameNodes(Active/Standby)实现在集群中对 NameNode 的热备来解决上述问题。如果出现故障&#xff0c;如机器崩溃或机器需要升级维护&#xff0c;这时可通过此种…...

problem(3):python IDE和python解释器

为什么写这篇文章呢&#xff1f;遇到了下面的问题&#xff0c;相同的解释器&#xff0c;如果运行angr库的代码&#xff0c;会出现 这样的情况&#xff0c;但是用spyder IDE 会显示正常&#xff0c;很奇怪 应该就是IDE的原因 IDE的循环导入问题 检查IDE配置&#xff1a; 如果可…...

【C语言进阶篇】模拟实现通讯录 (内附源码)

&#x1f3ac; 鸽芷咕&#xff1a;个人主页 &#x1f525; 个人专栏:《C语言初阶篇》 《C语言进阶篇》 ⛺️生活的理想&#xff0c;就是为了理想的生活! 文章目录 &#x1f4cb; 前言一 、 通讯录的简介1.1 联系人的类型定义1.2 通讯录的定义1.3 通讯录要实现的功能 二 、 如何…...

Python web实战之 Django 的模板语言详解

关键词&#xff1a; Python、web开发、Django、模板语言 概要 作为 Python Web 开发的框架之一&#xff0c;Django 提供了一套完整的 MVC 模式&#xff0c;其中的模板语言为开发者提供了强大的渲染和控制前端的能力。本文介绍 Django 的模板语言。 1. Django 模板语言入门 Dj…...

使用ChatGPT编写技术文档

技术文档对于任何项目都是至关重要的&#xff0c;因为它确保所有利益相关者都在同一层面上&#xff0c;并允许有效的沟通和协作。创建详细而准确的技术文档可能既耗时又具有挑战性&#xff0c;特别是对于那些不熟悉主题或缺乏强大写作技巧的人来说。ChatGPT 是一个强大的人工智…...

Java超级玛丽小游戏制作过程讲解 第四天 创建并完成常量类03

今天继续来完成常量类。 package com.sxt;import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List;public class StaticValue {//背景public static Buff…...

webpack基础知识八:说说如何借助webpack来优化前端性能?

一、背景 随着前端的项目逐渐扩大&#xff0c;必然会带来的一个问题就是性能 尤其在大型复杂的项目中&#xff0c;前端业务可能因为一个小小的数据依赖&#xff0c;导致整个页面卡顿甚至奔溃 一般项目在完成后&#xff0c;会通过webpack进行打包&#xff0c;利用webpack对前…...

JAVA SE -- 第十五天

&#xff08;全部来自“韩顺平教育”&#xff09; 多线程 一、线程相关概念 1、程序&#xff1a;是为完成特定任务、用某种语言编写的一组指令的集合。 2、进程&#xff1a;是指运行中的程序&#xff0c;如QQ&#xff0c;就启动了一个进程&#xff0c;操作系统就会为该进程…...

macOS 环境变量加载探究

使用 macOS 安装环境&#xff0c;见到过很数种环境变量配置方法&#xff0c;每次也都是按照别人的代码&#xff0c;人家配置在哪 我就配置在哪&#xff0c;其实不太清楚有什么区别&#xff0c;决定记录下。 本机 macOS 13.3&#xff0c;从 macOS Catalina(10.15) 开始&#xf…...

在程序中如何判断该线程的线程id(get_id())的返回值是一个无效值

std::thread::id() 是std::thread::id的默认构造函数&#xff0c;它会创建一个空的std::thread::id对象。一个空的std::thread::id对象代表一个无效的线程标识符。 可以通过 std::thread::id 的成员函数 std::thread::id::operator() 来判断一个 std::thread::id 是否是一个空值…...

ffmpeg-ffplay代码架构简述

全局变量 /* Minimum SDL audio buffer size, in samples. */ // 最小音频缓冲 #define SDL_AUDIO_MIN_BUFFER_SIZE 512 /* Calculate actual buffer size keeping in mind not cause too frequent audio callbacks */ // 计算实际音频缓冲大小&#xff0c;并不需要太频繁…...

⛳ 多线程面试-什么是多线程上下文切换?

目录 ⛳ 多线程面试&#xff0d;什么是多线程上下文切换&#xff1f;&#x1f381; Java中用到的线程调度算法是什么&#xff1f;&#x1f3a8; 什么是线程饥饿 &#xff1f;你对线程优先级的理解是什么&#xff1f; ⛳ 多线程面试&#xff0d;什么是多线程上下文切换&#xff…...

vb+SQL车辆管理系统设计与实现

摘 要 随着信息时代的到来,信息高速公路的兴起,全球信息化进入了一个新的发展时期。人们越来越认识到计算机强大的信息模块处理功能,使之成为信息产业的基础和支柱。 我国经济的快速发展,汽车已经成为人们不可缺少的交通工具。对于拥有大量车辆的机关企事业来说,车辆的…...

java的枚举类

枚举类的概念和使用 1.枚举类的理解&#xff1a;类的对象只有有限个&#xff0c;确定的。我们称此为枚举类。 2.当需要定义一组常量时&#xff0c;强烈建议使用枚举类。对象便是所指的常量。 3.如果枚举类中只有一个对象&#xff0c;则可以作为单例模式的实现方式。 定义枚举类…...

基于java早餐店点餐系统源码设计与实现

摘 要 多姿多彩的世界带来了美好的生活&#xff0c;行业的发展也是形形色色的离不开技术的发展。作为时代进步的发展方面&#xff0c;信息技术至始至终都是成就行业发展的重要秘密。不论何种行业&#xff0c;大到国家、企业&#xff0c;小到团体、个人都在多方位的结合信息化技…...

ODOO16如何处理采购运输正常损耗的成本价核算?

《会计准则》规定&#xff1a;商品流通企业在采购商品过程中发生的运输费、装卸费、运输途中的合理损耗都归为采购存货成本中。 例如&#xff1a;采购A产品1000个&#xff0c;单价10元/个&#xff0c;途中运输正常损耗率是5%&#xff0c;因此实际入库是950个&#xff0c;入库金…...

【数据预测】基于白鲸优化算法BWO的VMD-KELM光伏发电功率预测 短期功率预测【Matlab代码#54】

文章目录 【可更换其他算法&#xff0c;获取资源请见文章第6节&#xff1a;资源获取】1. 白鲸优化算法BWO2. 变分模态分解VMD3. 核极限学习机KELM4. 部分代码展示5. 仿真结果展示6. 资源获取 【可更换其他算法&#xff0c;获取资源请见文章第6节&#xff1a;资源获取】 1. 白鲸…...

函数式编程-将过程作为返回值的应用:分步过程

之前的文章提到函数式编程的一等函数&#xff08;First-class Function&#xff09;四个性质中有“可以将过程作为返回值”这一点&#xff0c;但这一点在实际使用中不如“将过程作为参数”&#xff08;高阶函数&#xff09;用得多。本文介绍一种这个性质用于分步函数的应用。 …...