簡體   English   中英

SELinux的CentOS Java應用程序錯誤

[英]CentOS Java application error with SELinux


我有一個托管Drupal 7網站的CentOS盒子。 我試圖在其上運行一個名為Tika的Java應用程序,以使用Apache Solr搜索為文件編制索引。

僅在啟用SELinux時,我一直遇到問題:

extract using tika: OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00007f1ed9000000, 2555904, 1) failed; error='Permission denied' (errno=13)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 2555904 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /tmp/jvm-2356/hs_error.log

如果禁用selinux,則不會發生這種情況。 如果我從SSH運行命令,則可以正常工作-但不能在瀏覽器中運行。 這是它正在運行的命令:

java '-Dfile.encoding=UTF8' -cp '/var/www/drupal/sites/all/modules/contrib/apachesolr_attachments/tika' -jar '/var/www/drupal/sites/all/modules/contrib/apachesolr_attachments/tika/tika-app-1.11.jar' -t '/var/www/drupal/sites/all/modules/contrib/apachesolr_attachments/tests/test-tika.pdf'

這是來自SELinux的日志,位於/var/log/audit/audit.log:

type=AVC msg=audit(1454636072.494:3351): avc:  denied  { execmem } for  pid=11285 comm="java" scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:system_r:httpd_t:s0 tclass=process
type=SYSCALL msg=audit(1454636072.494:3351): arch=c000003e syscall=9 success=no exit=-13 a0=7fdfe5000000 a1=270000 a2=7 a3=32 items=0 ppid=2377 pid=11285 auid=506 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=1 comm="java" exe="/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.95.x86_64/jre/bin/java" subj=unconfined_u:system_r:httpd_t:s0 key=(null)

有啟用SELinux的運行方法嗎? 我不知道Tika的策略名稱(或者我應該使用Java嗎?),所以我不確定從這里去哪里...

這對我有用...我在/var/apache-tika/tika-app-1.14.jar中有tika

setsebool -P httpd_execmem 1
chcon -t httpd_exec_t /var/apache-tika/tika-app-1.14.jar

使用sealert工具( https://wiki.centos.org/HowTos/SELinux )幫助跟蹤正確的selinux類型。

您所有的上下文消息都引用httpd_t ,所以我會運行

/usr/sbin/getsebool -a | grep httpd

並嘗試啟用顯示為off屬性。 自從我在CentOS上運行了一個數據庫支持的網站(Drupal,WordPress等)以來已經有一段時間了,但是正如我回想的那樣,必須啟用這兩個功能:

httpd_can_network_connect
httpd_can_network_connect_db

要啟用具有持久性的屬性,請運行

setsebool -P httpd_can_network_connect on

等等

您要查找的布爾值是:

httpd_execmem

httpd_read_user_content

怎么找:

audit2why -i /var/log/audit/audit.log會告訴您這一點。

軟件包的一部分: policycoreutils-python-utils

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM