Example install snapd-selinux error:
sudo yum install snapd-selinux
You get error:
cannot stat ‘/etc/selinux/targeted/contexts/files/file_contexts’: No such file or directory
Solution 1:
Step 1: Check installed packages selinux
[root@tutorialspots ~]# yum list installed|grep selinux libselinux.i686 2.5-15.el7 @base libselinux.x86_64 2.5-15.el7 @base libselinux-devel.x86_64 2.5-15.el7 @base libselinux-python.x86_64 2.5-15.el7 @base libselinux-utils.x86_64 2.5-15.el7 @base selinux-policy.noarch 3.13.1-268.el7_9.2 @updates selinux-policy-minimum.noarch 3.13.1-268.el7_9.2 @updates
Step 2: remove selinux-policy-minimum
[root@tutorialspots ~]# yum remove selinux-policy-minimum Loaded plugins: fastestmirror Resolving Dependencies --> Running transaction check ---> Package selinux-policy-minimum.noarch 0:3.13.1-268.el7_9.2 will be erased --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Removing: selinux-policy-minimum noarch 3.13.1-268.el7_9.2 @updates 16 M Transaction Summary ================================================================================ Remove 1 Package Installed size: 16 M Is this ok [y/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : selinux-policy-minimum-3.13.1-268.el7_9.2.noarch 1/1 warning: Failed to open SELinux handle. warning: /etc/selinux/minimum/seusers saved as /etc/selinux/minimum/seusers.rpmsave Verifying : selinux-policy-minimum-3.13.1-268.el7_9.2.noarch 1/1 Removed: selinux-policy-minimum.noarch 0:3.13.1-268.el7_9.2 Complete!
Step 3: install selinux-policy-targeted
[root@tutorialspots ~]# yum install selinux-policy-targeted Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: la.mirrors.clouvider.net * epel: linux.domainesia.com * extras: mirrors.sonic.net * remi-safe: mirrors.thzhost.com * rpmforge: mirror.poliwangi.ac.id * updates: repo1.sea.innoscale.net http://yum.mariadb.org/10.0/centos7-amd64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. To address this issue please refer to the below wiki article https://wiki.centos.org/yum-errors If above article doesn't help to resolve this issue please use https://bugs.centos.org/. Resolving Dependencies --> Running transaction check ---> Package selinux-policy-targeted.noarch 0:3.13.1-268.el7_9.2 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: selinux-policy-targeted noarch 3.13.1-268.el7_9.2 updates 7.0 M Transaction Summary ================================================================================ Install 1 Package Total download size: 7.0 M Installed size: 19 M Is this ok [y/d/N]: y Downloading packages: selinux-policy-targeted-3.13.1-268.el7_9.2.noarch.rpm | 7.0 MB 00:02 Running transaction check Running transaction test Transaction test succeeded Running transaction warning: Failed to open SELinux handle. Installing : selinux-policy-targeted-3.13.1-268.el7_9.2.noarch 1/1 Verifying : selinux-policy-targeted-3.13.1-268.el7_9.2.noarch 1/1 Installed: selinux-policy-targeted.noarch 0:3.13.1-268.el7_9.2 Complete!
Solution 2:
Step 1: Edit file /etc/selinux/config
nano /etc/selinux/config
# 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 three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are pr$ # mls - Multi Level Security protection. SELINUXTYPE=targeted
Change SELINUXTYPE
to minimum
Step 2: Reboot.