chcon:使用 SELinux 安装 nagios 时无法将部分上下文应用于未标记的文件

chcon:使用 SELinux 安装 nagios 时无法将部分上下文应用于未标记的文件

我正在 CentOS 上使用 SELINUX=enforcing 设置 Nagios 核心。

我试着跑

chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/

作为手册中建议的,但我收到此错误消息:

chcon: can't apply partial context to unlabeled file `cmd.cgi'
chcon: can't apply partial context to unlabeled file `trends.cgi'
chcon: can't apply partial context to unlabeled file `histogram.cgi'
chcon: can't apply partial context to unlabeled file `avail.cgi'
chcon: can't apply partial context to unlabeled file `history.cgi'
chcon: can't apply partial context to unlabeled file `status.cgi'
chcon: can't apply partial context to unlabeled file `tac.cgi'
chcon: can't apply partial context to unlabeled file `showlog.cgi'
chcon: can't apply partial context to unlabeled file `notifications.cgi'
chcon: can't apply partial context to unlabeled file `extinfo.cgi'
chcon: can't apply partial context to unlabeled file `statuswml.cgi'
chcon: can't apply partial context to unlabeled file `outages.cgi'
chcon: can't apply partial context to unlabeled file `statuswrl.cgi'
chcon: can't apply partial context to unlabeled file `statusmap.cgi'
chcon: can't apply partial context to unlabeled file `config.cgi'
chcon: can't apply partial context to unlabeled file `summary.cgi'

有什么想法如何避免这些错误?

答案1

您需要使用正确的 selinux 类型重新标记文件:

semanage fcontext -a -s system_u -t httpd_sys_script_exec_t /usr/local/nagios/sbin/*

答案2

10年前!你能解决问题吗?我也遇到了同样的问题,几乎翻遍了网上的所有内容。我的操作系统是Ubuntu。当我输入命令时ls -lZ,我意识到我的文件和目录都没有标签!所以,根据塞尔吉·洛马尔科夫回答,我安装了 semanage 并使用命令semange fcontext,我想在目录上创建一个标签。但我在解析时遇到了以下错误semanage configuration file: syntax error /n ValueError: Could not create semanage handle。我没有找到任何解决方案。

相关内容