I’m trying to make selinux permissive for one of the process (drbd) in Almalinux 8.8 and I’m facing the below python issue while using semanage command,
[root@dnd-st-6-0-0-28-lt-ha1 admin]# semanage permissive -a drbd_t
Traceback (most recent call last):
File “/sbin/semanage”, line 1000, in
do_parser()
File “/sbin/semanage”, line 970, in do_parser
commandParser = createCommandParser()
File “/sbin/semanage”, line 900, in createCommandParser
import seobject
File “/usr/lib/python3.6/site-packages/seobject.py”, line 33, in
import sepolicy
File “/usr/lib/python3.6/site-packages/sepolicy/init.py”, line 7, in
import setools
File “/usr/lib64/python3.6/site-packages/setools/init.py”, line 24, in version = pkg_resources.get_distribution(“setools”).version
AttributeError: module ‘pkg_resources’ has no attribute ‘get_distribution’
[admin@dnd-st-6-0-0-28-lt-ha1 ~]$ cat /etc/release
AlmaLinux release 8.8 (Sapphire Caracal)
Derived from Red Hat Enterprise Linux 8.8 (Source)
AlmaLinux release 8.8 (Sapphire Caracal)
NAME=“AlmaLinux”
VERSION=“8.8 (Sapphire Caracal)”
ID=“almalinux”
ID_LIKE=“rhel centos fedora”
VERSION_ID=“8.8”
PLATFORM_ID=“platform:el8”
PRETTY_NAME=“AlmaLinux 8.8 (Sapphire Caracal)”
ANSI_COLOR=“0;34”
LOGO=“fedora-logo-icon”
CPE_NAME=“cpe:/o:almalinux:almalinux:8::baseos”
HOME_URL=“https://almalinux.org/”
I don’t have even the /usr/lib/python3.6/site-packages/sepolicy/init.py … Wait! It is /usr/lib/python3.6/site-packages/sepolicy/__init__.py but your post shows that as bold.
The sepolicy/__init__.py is in python3-policycoreutils too, and the
The setools/__init__.py is in python3-setools.
My /usr/lib/python3.6/site-packages/pkg_resources/__init__.py defines function get_distribution(dist).
[AL8 ~]# semanage permissive --add drbd_t
[AL8 ~]# semanage permissive --list
Builtin Permissive Types
Customized Permissive Types
drbd_t
[AL8 ~]# semanage permissive --delete drbd_t
libsemanage.semanage_direct_remove_key: Removing last permissive_drbd_t module (no other permissive_drbd_t module exists at another priority).
[AL8 ~]# semanage permissive --list
[AL8 ~]#
The pkg_resources is in package platform-python-setuptools. Is that ok/up to date?
[root@test admin]# ls -l /usr/lib/python3.6/site-packages/pkg_resources/init.py /usr/lib/python3.6/site-packages/pkg_resources/_vendor/init.py
ls: cannot access ‘/usr/lib/python3.6/site-packages/pkg_resources/init.py’: No such file or directory
ls: cannot access ‘/usr/lib/python3.6/site-packages/pkg_resources/_vendor/init.py’: No such file or directory
[root@test admin]#
Reinstalling platform-python-setuptools-39.2.0-7.el8.noarch solves the problem. I will further look into it.