在Ubuntu14.04上,我使用SELinux运行Docker,如我所知,Docker将读取$Selinux-Root-Dir/default/contexts/lxc_contexts。但是我找不到这个文件,所以我创建了这个文件并放置了一些contents.following:
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=false
和docker 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) --这个错误就发生了。
所以我的问题是:
类型是否为容器错误?如何关闭此约束或如何解决此问题?
发布于 2015-06-04 11:44:18
我不知道您的container.te文件的第41行。一般来说,“语法错误”表示缺少selinux类型或未知的selinux接口,这意味着问题在不同的地方。
但我注意到了一些事情:
--selinux-enabled=true
一起运行以支持SELinuxcat /var/log/audit/audit.log | audit2allow -M container
,您可以在所有记录在案的行上工作。最好只将所需的行复制到新文件中。s0
是级别而不是标签。而“重标”则意味着改变类型。见标记文件。默认情况下,Ubuntu是与AppArmor一起预装的,如果您想使用SELinux,则必须先删除/禁用Ubuntu。Ubuntu和Debian不为SELinux提供Docker策略。
可能的解决办法:
https://stackoverflow.com/questions/30500346
复制相似问题