如何在 CentOS 中删除 SELinux 模块?

Chl*_*loe 6 selinux centos centos6

我试过了,但它给出了一个错误。

# ls -l opendkim.pp
-rw-r--r--. 1 root root 1569 Jan  8 01:20 opendkim.pp

# ls -l /etc/selinux/targeted/modules/active/modules/opendkim.pp
-rw-r--r--. 1 root root 344 Jan  8 01:33 /etc/selinux/targeted/modules/active/modules/opendkim.pp

# semodule -r opendkim.pp
SELinux:  Could not load policy file /etc/selinux/targeted/policy/policy.24:  Invalid argument
/sbin/load_policy:  Can't load policy:  Invalid argument
libsemanage.semanage_reload_policy: load_policy returned error code 2.
SELinux:  Could not load policy file /etc/selinux/targeted/policy/policy.24:  Invalid argument
/sbin/load_policy:  Can't load policy:  Invalid argument
libsemanage.semanage_reload_policy: load_policy returned error code 2.
semodule:  Failed!

# ls -lZ /etc/selinux/targeted/policy/policy.24
-rw-r--r--. root root unconfined_u:object_r:semanage_store_t:s0 /etc/selinux/targeted/policy/policy.24
Run Code Online (Sandbox Code Playgroud)

为什么需要 5m+ 才能失败?

CentOS 6.8 版(最终版)

Mic*_*ton 11

semodule -r 需要模块名称,而不是文件名。

所以它会是这样的:

semodule -r opendkim
Run Code Online (Sandbox Code Playgroud)

或者你在定义模块时给模块起的任何名字。

  • 我发现我需要使用“semodule -X<priority> -r <modulename>”指定优先级,并且还需要在“-r”参数之前指定“-X”参数才能正常工作。要获取已安装模块的优先级,请尝试“semodule --list=full” (4认同)