大网数据广告活动
服务器运维问答

SELinux Blocks Tomcat 7 Service in RHEL 7 after Yum update

· 52CE 我爱测

I performed a Yum update and Tomcat's ability to access file has been broken. SEVERE: Failed to load keystore type JKS with path /var/websvr/certs/keyfile.jks due to /var/websvr/certs/keyfile.jks (Permission denied) java.io.FileN…

问题原文

原帖链接 · Roy Hinkley · CC BY-SA 3.0

I performed a Yum update and Tomcat's ability to access file has been broken.

SEVERE: Failed to load keystore type JKS with path /var/websvr/certs/keyfile.jks due to /var/websvr/certs/keyfile.jks (Permission denied)
java.io.FileNotFoundException: /var/websvr/certs/keyfile.jks (Permission denied)

Even though the tomcat user has ownership and full permissions of not only the file, but the entire directory

-rwxrwxrwx. 1 tomcat   tomcat 4829 Aug 19  2016 keyfile.jks

and I have verified that Tomcat is running under tomcat user. So, why is access still being prevented?

Red Hat Enterprise Linux Server release 7.4 (Maipo)

Edit

From A.B's comment - the /var/log/audit/audit.log :

type=AVC msg=audit(1511208892.087:392): avc:  denied  { read } for  pid=770 comm="java" name="keyfile.jks" dev="xvda2" ino=9641897 scontext=system_u:system_r:tomcat_t:s0 tcontext=unconfined_u:object_r:var_t:s0 tclass=file

So it appears this is SELinux related. I have tried to resolve, but posts like this one require a Red Hat subscription.

Using RH Doc for SELinux & Apache, in conjunction with RH SELinux Doc - I think to resolve this, the keyfile.jks file must be labelled with:

tomcat_t:tomcat_t:tomcat_sys_content_t:s0

which is read-only access for confined user tomcat_t in role tomcat_t. The file is currently labelled:

unconfined_u:object_r:var_t:s0

to get past additional SELinux file restrictions.

Any guidance is appreciated!

已采纳解答

原帖链接 · user9517 · CC BY-SA 3.0

If you want to label /var/websvr/certs/keyfile.jks with tomcat_sys_content_t then you can create a customer file context

semanage fcontext -a /var/websvr/certs/keyfile.jks -t tomcat_sys_content_t
restorecon /var/websvr/certs/keyfile.jks

If that doesn't work because tomcat_sys_content_t doesn't exist then substitute tomcat_t or possibly pki_tomcat_cert_t in the command above.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-11-17)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。