首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >基于SELinux约束违反的SELinux运行码头

基于SELinux约束违反的SELinux运行码头
EN

Stack Overflow用户
提问于 2015-05-28 07:48:55
回答 1查看 2.1K关注 0票数 3

在Ubuntu14.04上,我使用SELinux运行Docker,如我所知,Docker将读取$Selinux-Root-Dir/default/contexts/lxc_contexts。但是我找不到这个文件,所以我创建了这个文件并放置了一些contents.following:

代码语言:javascript
运行
复制
process = "system_u:system_r:svirt_lxc_net_t:s0"
content = "system_u:object_r:virt_var_lib_t:s0"
file = "system_u:object_r:svirt_lxc_file_t:s0"
sandbox_kvm_process = "system_u:system_r:svirt_qemu_net_t:s0"
sandbox_lxc_process = "system_u:system_r:svirt_lxc_net_t:s0"

然后我使用Selinux的许可模式( docker -dD --selinux-enabled=falsedocker run -it --rm ubuntu /bin/bash )运行Docker

最后,我想使用audit2allow生成一个*.te和*.pp文件,我执行cat /var/log/audit/audit.log | audit2allow -M container,但是它是compilation failed: container.te:41:ERROR 'syntax error' at token 'mlsconstrain' on line 41: #Constraint rule: mlsconstrain chr_file { create relabelto } ((h1 dom h2 -Fail-) and (l2 eq h2) ); Constraint DENIED /usr/bin/checkmodule: error(s) encountered while parsing configuration /usr/bin/checkmodule: loading policy configuration from container.te

我禁止container.te,它的内容是:#!!!! This avc is a constraint violation. You would need to modify the attributes of either the source or target types to allow this access. #Constraint rule: mlsconstrain chr_file { create relabelto } ((h1 dom h2 -Fail-) and (l2 eq h2) ); Constraint DENIED mlsconstrain chr_file { relabelfrom } ((h1 dom h2 -Fail-) ); Constraint DENIED .... # Possible cause is the source level (s0) and target level (s0:c96,c879) are different. --我猜这个对接器是用s0运行的,但是它想要将对接者的rootfs文件系统重新命名为(s0:c96,c879) --这个错误就发生了。

所以我的问题是:

类型是否为容器错误?如何关闭此约束或如何解决此问题?

EN

回答 1

Stack Overflow用户

发布于 2015-06-04 11:44:18

我不知道您的container.te文件的第41行。一般来说,“语法错误”表示缺少selinux类型或未知的selinux接口,这意味着问题在不同的地方。

但我注意到了一些事情:

  • Daemon必须与--selinux-enabled=true一起运行以支持SELinux
  • 要创建一个新的selinux策略模块,您需要所有这些文件:.te、.fc和.if。有关最小Debian -to策略的示例,请参阅SELinux。
  • 通过使用cat /var/log/audit/audit.log | audit2allow -M container,您可以在所有记录在案的行上工作。最好只将所需的行复制到新文件中。
  • s0是级别而不是标签。而“重标”则意味着改变类型。见标记文件
  • 在运行时,SELinux (不是码头本身)将重新命名停靠守护进程类型(docker_t)和正在运行的容器(svirt_lxc_net_t)。
  • 默认情况下,Docker将文件类别(即s0:c96,c879)更改为将正在运行的容器彼此分开。

默认情况下,Ubuntu是与AppArmor一起预装的,如果您想使用SELinux,则必须先删除/禁用Ubuntu。Ubuntu和Debian不为SELinux提供Docker策略。

可能的解决办法:

  • 在Ubuntu中使用AppArmor (但我不知道是否有现成的Docker配置文件)。
  • 在Ubuntu上为SELinux构建自己的Docker策略。请参阅码头SELinux策略,但是有许多依赖项,即svirt_lxc_net_t来自virt.te
  • 使用Fedora,它将与SELinux和Docker开箱即用,包括上述文件lxc_contexts
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30500346

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档