简体   繁体   English

SELinux 和 Java

[英]SELinux and Java

Are there any best practices to handle Java applications with SELinux?是否有使用 SELinux 处理 Java 应用程序的最佳实践? Is it able to configure SELinux for each Java App or can only the VM be handled because it makes the finale system calls?是否能够为每个 Java 应用程序配置 SELinux,或者只能处理 VM,因为它进行最终系统调用?

If you are asking will Java and SELinux work it depends on how the policy is defined.如果你问 Java 和 SELinux 是否工作,这取决于策略是如何定义的。 You will be mostly concerned with what domain the java process is running in, how it got to that domain and what that domain is allowed to do.您将主要关注 java 进程在哪个域中运行、它如何到达该域以及允许该域执行的操作。

A domain is just an SELinux context to see what context/domain a process is running as try the -Z option for ps (ie ps -Z).域只是一个 SELinux 上下文,用于查看进程正在运行的上下文/域,因为尝试 ps 的 -Z 选项(即 ps -Z)。 Likewise for seeing the context of files try the -Z option for ls (ie ls -Z)同样,要查看文件的上下文,请尝试 ls 的 -Z 选项(即 ls -Z)

You would be interested in looking at the SELinux policy source or using an analysis tool like sesearch or apol (from setools) to see what policy allows and how java got into a particular domain.您可能有兴趣查看 SELinux 策略源或使用像 sesearch 或 apol(来自 setools)这样的分析工具来查看策略允许什么以及 java 是如何进入特定域的。

From there you would care about fixing/writing the policy which can be an involved process but tools have been written such as SLIDE (eclipse plugin), seedit (though I have no experience with this one) for example.从那里你会关心修复/编写策略,这可能是一个涉及的过程,但是已经编写了工具,例如 SLIDE(eclipse 插件)、seedit(尽管我没有这方面的经验)。

You can have any number of JVM and any number of versions of JVM as well.您可以拥有任意数量的 JVM 以及任意数量的 JVM 版本。 You can configure them all independently if you wish.如果您愿意,您可以独立配置它们。

I would suggest keeping the number of JVMs to around the number of cores you have or less.我建议将 JVM 的数量保持在您拥有的内核数量附近或更少。 If you start having hundreds of JVMs it can be difficult to manage and configure.如果您开始拥有数百个 JVM,则可能难以管理和配置。

It's not just the executables you have to worry about, its all the files it touches.您需要担心的不仅仅是可执行文件,还有它接触到的所有文件。 This is the REAL power behind SElinux.这是 SElinux 背后的真正力量。 I oppose turning off this valuable tool.我反对关闭这个有价值的工具。 What I have discerned from Redhat's Dan Walsh is that the unconfined_u is going to disappear.我从 Redhat 的 Dan Walsh 那里了解到,unconfined_u 将会消失。 Well, that means you have to realign the data files including those in.eclipse in your home directory.好吧,这意味着您必须重新对齐数据文件,包括主目录中的 .eclipse 中的数据文件。 I have reduced my main login to staff_u, where I have sudo access but have changed the fcontext to /HOME_DIR/.eclipse(/.*)+ to staff_java_t我已将我的主登录减少到 staff_u,在那里我有 sudo 访问权限,但已将 fcontext 更改为 /HOME_DIR/.eclipse(/.*)+ 到 staff_java_t

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM