【问题标题】:CentOS Java application error with SELinuxSELinux 的 CentOS Java 应用程序错误
【发布时间】:2016-05-14 16:27:11
【问题描述】:


我有一个托管 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 吗?)所以我不确定从这里去哪里......

【问题讨论】:

    标签: java drupal solr centos selinux


    【解决方案1】:

    这对我有用... 我在 /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 类型。

    【讨论】:

    • 不起作用,导致500错误没有任何日志输出
    • 按照 Josh C 设置 setsebool -P httpd_execmem 1 在 Fedora 28 / Tika 1.13 SELinux 内存不足问题上为我工作
    【解决方案2】:

    你所有的上下文消息都引用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
    

    等等

    【讨论】:

      【解决方案3】:

      您要查找的布尔值是:

      httpd_execmem
      
      httpd_read_user_content
      

      如何找到:

      audit2why -i /var/log/audit/audit.log 会告诉你这个。

      部分包:policycoreutils-python-utils

      【讨论】:

        猜你喜欢
        • 2018-12-30
        • 1970-01-01
        • 1970-01-01
        • 2014-11-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多