19

我想知道这里的人们是否通常在默认情况下启用 SELinux 的安装中禁用它?如果是这样,你能解释为什么,它是什么样的系统,等等?

我想尽可能多地对此发表意见。

4

15 回答 15

13

三四年前我做到了,当时定义的政策有很多陷阱,制定政策太难了,我“没有时间”学习。当然,这是在非关键机器上进行的。

如今,为发布带有合理策略的发行版所做的所有工作,以及帮助您创建、修复和定义策略的现有工具教程,都没有理由禁用它。

于 2008-09-18T23:06:51.497 回答
8

I worked for a company last year where we were setting it enforcing with the 'targeted' policy enabled on CentOS 5.x systems. It did not interfere with any of the web application code our developers worked on because Apache was in the default policy. It did cause some challenges for software installed from non-Red Hat (or CentOS) packages, but we managed to get around that with the configuration management tool, Puppet.

We used Puppet's template feature to generate our policies. See SELinux Enhancements for Puppet, heading "Future stuff", item "Policy Generation".

Here's some basic steps from the way we implemented this. Note other than the audit2allow, this was all automated.

Generate an SELinux template file for some service named ${name}.

sudo audit2allow -m "${name}" -i /var/log/audit/audit.log > ${name}.te

Create a script, /etc/selinux/local/${name}-setup.sh

SOURCE=/etc/selinux/local
BUILD=/etc/selinux/local

/usr/bin/checkmodule -M -m -o ${BUILD}/${name}.mod ${SOURCE}/${name}.te
/usr/bin/semodule_package -o ${BUILD}/${name}.pp -m ${BUILD}/${name}.mod
/usr/sbin/semodule -i ${BUILD}/${name}.pp

/bin/rm ${BUILD}/${name}.mod ${BUILD}/${name}.pp

That said, most people are better off just disabling SELinux and hardening their system through other commonly accepted consensus based best practices such as The Center for Internet Security's Benchmarks (note they recommend SELinux :-)).

于 2008-09-19T00:12:52.320 回答
5

我公司做一个CMS/集成平台产品。我们的许多客户都有遗留的第 3 方系统,其中仍然有重要的操作数据,并且大多数人希望继续使用这些系统,因为它们可以正常工作。因此,我们通过多种方式挂钩我们的系统以提取数据以进行发布或报告等。在每台服务器上运行大量客户端特定的东西使得正确配置 SELinux 成为一项艰巨的,因此也是昂贵的任务。

许多客户最初想要最好的安全性,但是当他们听到我们的集成解决方案的成本估算时,“SELinux disabled”这个词往往很快就会出现在项目计划中。

真可惜,因为纵深防御是个好主意。不过, SELinux 从来都不是安全所必需的,这似乎是它的失败之处。当客户问“那么你能在没有 SELinux 的情况下确保它的安全吗?”,我们应该回答什么?“嗯……我们不确定”?

我们可以而且我们会,但是当地狱冻结,发现一些新的漏洞,更新没有及时出现,你的系统很不幸成为零基础...... SELinux 可能会拯救你的屁股。

但这是一个艰难的销售。

于 2008-09-19T15:02:59.520 回答
3

I used to work for a major computer manufacturer in 3rd level support for RedHat Linux (as well as two other flavors) running on that company's servers. In the vast majority of cases, we had SELinux turned off. My feeling is that if you REALLY NEED SeLinux, you KNOW that you need it and can state specifically why you need it. When you don't need it, or can't clearly articulate why, and it is enabled by default, you realize pretty quickly that it is a pain in the rear end. Go with your gut instinct.

于 2010-11-22T07:06:23.837 回答
2

我听说它正在好转,但我仍然禁用它。对于服务器,除非您是希望在多个本地用户之间实施细粒度访问级别控制的 ISP 或大型公司,否则它实际上没有任何意义。

在 Web 服务器上使用它时,我在 apache 权限方面遇到了很多问题。我必须不断地奔跑,

chcon -R -h -t httpd_sys_content_t /var/www/html 

添加新文件时更新 ACL。我确信这个问题现在已经解决了,但是,SELinux 仍然让您在标准网站部署中启用它所获得的有限回报非常痛苦。

于 2008-09-18T23:10:03.890 回答
2

可悲的是,我大部分时间也关闭了 SELinux,因为大量第三方应用程序,如 Oracle,在打开 SELinux 的情况下不能很好地工作和/或在运行 SELinux 的平台上不受支持。

请注意,Red Hat 自己的 Satellite 产品也要求您关闭 SELinux,这再次令人遗憾地说明了人们在支持 SELinux 的平台上运行复杂应用程序时遇到的困难。

对您可能有用也可能没用的使用提示:SELinux 可以在运行时通过使用 setenforce 来打开和关闭(使用 getenforce 检查当前状态)。restorecon 在 chcon 很麻烦但 ymmv 的情况下会很有帮助。

于 2008-11-12T15:41:06.500 回答
2

SELinux 需要用户注意和手动授予权限,只要(哦,好吧)您没有某事的权限。许多人发现它妨碍了它并将其关闭。

在最近的版本中,SELinux 对用户更加友好,甚至有人谈到取消关闭或隐藏它的可能性,以便只有知识渊博的用户知道如何操作 - 并且假设只有用户才是真正理解结果。

对于 SELinux,存在先有鸡还是先有蛋的问题:为了始终拥有它,作为用户的您需要向开发人员报告问题,以便他们改进它。但是用户不喜欢在它改进之前使用它,如果没有多少用户使用它,它不会得到改进。

因此,默认情况下它处于打开状态,希望大多数人会使用它足够长的时间来报告至少一些问题,然后再将其关闭。

最后,这是你的决定:你是在寻找一个短期的解决方案,还是对软件的长期改进,这将导致有一天不再需要问这样的问题。

于 2008-09-18T23:06:36.847 回答
1

I do not disable it, but there are some problems.

Some applications don't work particularly well with it.

For example, I believe I enabled smartd to try and keep track of my raid disks s.m.a.r.t. status, but selinux would get confused about the new /dev/sda* nodes created at boot (I think that's what the problem was)

You have to download the source to the rules to understand things.

Just check /var/log/messages for the "avc denied" messages and you can decode what is being denied.

google "selinux faq" and you'll find a fedora selinux faq that will tell you how to work through these problems.

于 2008-09-19T00:09:22.000 回答
1

我在这里没有太多贡献,但由于它没有得到答复,我想我会投入两分钱。

就个人而言,我在开发盒上以及在处理不重要的事情时禁用它。当我处理任何生产或需要更好的安全性时,我会保留它和/或花时间调整它以处理我需要的事情。

天气是否使用它真的取决于您的需求,但它的创建是有原因的,所以考虑使用它而不是总是关闭它。

于 2008-09-18T23:05:23.997 回答
1

我在我所有的 cPanel 盒子上都关闭了它,因为 cPanel 不会在它打开的情况下运行。

于 2011-08-10T04:08:09.443 回答
1

是的。脑残了 它可能会破坏几乎无法诊断的标准守护程序。它也可以关闭一扇门,但打开一扇窗户。也就是说,由于某种原因,在新安装的 CentOS 上,它阻止了 smbd 从“/etc/init.d/smb”开始。但它并没有阻止它在以“sh /etc/init.d/smb”或“smbd -D”调用时启动,或者将init.d/smb文件移动到另一个目录,它将从该目录启动smbd美好的。

因此,无论它认为它正在做什么来保护我们的系统——通过破坏它们——它甚至都没有始终如一地做。咨询了一些严肃的 CentOS 大师,他们也不了解其行为的不一致之处。它旨在让您感到安全。但这是安全的表象。它可以替代锁定系统安全性的实际工作。

于 2010-05-26T02:53:03.660 回答
0

我从未禁用 selinux,我的承包商必须使用它。而且,如果/何时,某些守护进程(顺便说一句,具有 OSS 许可证)没有安全策略,则必须编写一个(好的)安全策略。这不是因为我相信 selinux 在 Linux 上是一个无懈可击的 MAC——举例来说毫无用处——而是因为它无论如何都增强了操作系统的安全性。对于 web 应用程序,OSS 安全性更好的解决方案是 mod_security :所以我两者都使用。selinux 的大多数问题都出在很少或易于理解的文档上,尽管近年来情况有了很大改善。

于 2009-08-10T12:08:46.110 回答
0

我作为开发机器使用的 CENTOS 盒子打开了它,我把它关掉了。它阻止了我在测试我正在开发的网络应用程序时尝试做的一些事情。该系统(当然)位于防火墙后面,该防火墙完全阻止了来自我们 LAN 外部的访问,并且具有许多其他安全措施,因此即使关闭 SELinux,我也感到相当安全。

于 2010-05-26T03:00:54.517 回答
-1

在 Red-hat 下,您可以编辑/etc/sysconfig/selinux和设置SELINIX=disabled.

我认为在所有版本的 Linux 下,您都可以selinux=0 noselinux在 lilo.conf 或 grub.conf 中添加引导行。

于 2008-09-19T14:07:45.410 回答
-1

如果默认情况下它是打开的,我会一直打开它,直到它破坏某些东西然后关闭它。

就我个人而言,我认为它没有提供任何安全性,我不会为此烦恼。

于 2010-05-26T02:56:32.740 回答