SELinux: Could not downgrade policy file

简介: 在配置nfs服务器,设定selinux时,碰到了SELinux: Could not downgrade policy file的错误提示,下文是其解决方案。

在配置nfs服务器,设定selinux时,碰到了SELinux: Could not downgrade policy file的错误提示,下文是其解决方案。

一、故障现象

[root@system1 ~]# semanage fcontext -a -t 'public_content_t' '/protected(/.*)?'
SELinux: Could not downgrade policy file /etc/selinux/targeted/policy/policy.29, searching for an older version.
SELinux: Could not open policy file <= /etc/selinux/targeted/policy/policy.29: No such file or directory
/sbin/load_policy: Can't load policy: No such file or directory
libsemanage.semanage_reload_policy: load_policy returned error code 2.
SELinux: Could not downgrade policy file /etc/selinux/targeted/policy/policy.29, searching for an older version.
SELinux: Could not open policy file <= /etc/selinux/targeted/policy/policy.29: No such file or directory
/sbin/load_policy: Can't load policy: No such file or directory
libsemanage.semanage_reload_policy: load_policy returned error code 2.
ValueError: Could not commit semanage transaction

二、解决方案

从故障的提示来看,说不能够降级策略文件,以及找不到policy.29这个文件

[root@system1 ~]# more /etc/redhat-release
Red Hat Enterprise Linux Server release 7.0 (Maipo)
[root@system1 ~]# uname -r
3.10.0-123.el7.x86_64

###下面查看selinux配置,如下,为disabled状态

[root@system1 ~]# sestatus
SELinux status: disabled

[root@system1 ~]# getenforce
Disabled

[root@system1 ~]# rpm -q libsepol libsemanage libselinux
libsepol-2.1.9-3.el7.x86_64
libsemanage-2.1.10-16.el7.x86_64
libselinux-2.2.2-6.el7.x86_64

### 临时修改selinux 配置
[root@system1 ~]# setenforce 1 ###尝试设置为1,依旧提示关闭
setenforce: SELinux is disabled

[root@system1 ~]# getenforce
Disabled

### 查看enforce配置文件
[root@system1 ~]# more /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=permissive
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

### 手工修改配置文件

[root@system1 ~]# vi /etc/sysconfig/selinux

SELINUX=enforce

[root@system1 ~]# getenforce ###依旧为关闭
Disabled

###不知道什么原因导致配置修改无法生效,于是尝试重启Linux

[root@system1 ~]# reboot

### 再次修改和执行都OK
[root@system1 ~]# getenforce
Permissive
[root@system1 ~]#
[root@system1 ~]#
[root@system1 ~]# setenforce 1
[root@system1 ~]#
[root@system1 ~]# getenforce
Enforcing

### 再次执行semanage成功
[root@system1 ~]# semanage fcontext -a -t 'public_content_t' '/protected(/.*)?'
[root@system1 ~]#

这里写图片描述

DBA牛鹏社(SQL/NOSQL/LINUX)

目录
相关文章
|
2月前
|
canal Kubernetes Perl
Network Policy及应用
文章主要介绍了如何在Kubernetes中使用Network Policy进行网络策略配置,包括如何部署Calico网络模型来支持网络策略,以及如何通过设置不同的网络策略来控制不同命名空间下Pods之间的访问权限。
47 4
Network Policy及应用
|
5月前
|
网络安全
ssh: Could not resolve hostname centos02: Temporary failure in name resolution
ssh: Could not resolve hostname centos02: Temporary failure in name resolution
447 0
|
6月前
|
安全 网络安全 数据安全/隐私保护
/etc/ssh/sshd_config line 142: Deprecated option RSAAuthentication 是什么
【5月更文挑战第6天】/etc/ssh/sshd_config line 142: Deprecated option RSAAuthentication 是什么
1394 4
|
Linux 数据安全/隐私保护
sudo报错:no valid sudoers sources found, quitting
sudo报错:no valid sudoers sources found, quitting
272 0
|
Ubuntu Linux
No manual entry for ls解决办法
No manual entry for ls解决办法
|
Web App开发 JavaScript 安全
Please open the about:config page and disable the "security.fileuri.strict_origin_policy" option
Please open the about:config page and disable the "security.fileuri.strict_origin_policy" option
218 0
Please open the about:config page and disable the "security.fileuri.strict_origin_policy" option
configure: error: SELinux selected but libselinux not found
configure: error: SELinux selected but libselinux not found
109 0
|
安全 Linux
18.4 SELinux配置文件(/etc/selinux/config)
我们知道,SELinux 是预先配置的,可以在不进行任何手动配置的情况下使用 SELinux 功能。然而,一般来说,预先配置的 SELinux 设置很难满足所有的 Linux 系统安全需求。
608 0
18.4 SELinux配置文件(/etc/selinux/config)
|
Linux 数据安全/隐私保护
You (root) are not allowed to access to (crontab) because of pam configuration
巡检发现一台Linux服务器上的作业没有如期发送邮件,登录服务器检查后发现作业并没有执行,于是检查一下crontab的设置。结果发现如下错误:   [root@mylnx2 ~]# crontab -l   Authentication token is no longer valid; n...
3117 0