大网数据广告活动
服务器运维问答

SELinux create custom role

· 52CE 我爱测

I have a folder shared out via Samba, and a Docker container which I would like to give access to said folder by adding it as a volume to the Docker container (yes, I know that's not portable). SELinux blocks the container from a…

问题原文

原帖链接 · dghodgson · CC BY-SA 3.0

I have a folder shared out via Samba, and a Docker container which I would like to give access to said folder by adding it as a volume to the Docker container (yes, I know that's not portable).

SELinux blocks the container from accessing the folder since the folder and its contents are labeled as samba_share_t, not svirt_sandbox_file_t

I know that the smbd_t domain has access to a number of SELinux labels (e.g. httpd_sys_content_t, though sesearch -s smbd_t --allow provides a full list), but svirt_sandbox_file_t is not one of them.

I see a few ways around this problem:

  • Access the samba share from the container over the network (not desirable as that requires samba to be installed in the container, and there's network overhead)

  • Relabel the folder and its contents as svirt_sandbox_file_t (which prevents Samba from accessing the folder)

  • Relabel the folder and its contents as public_content_rw_t (but that also gives access to a number of other services which I don't want to have access to this folder)

  • Create a policy to give svirt_lxc_net_t access to the samba_share_t label (generated by audit2allow, but that gives any container access to any file/folder labeled as samba_share_t)

The other option I can think of is to create my own SELinux role with its own label that gives access only to Samba and svirt (which I haven't done before, but am willing to try).

Am I missing something here? Is there an easier way to do this?

已采纳解答

原帖链接 · rhatdan · CC BY-SA 3.0

I would go the route of adding the rule to allow samba to write to svirt_sandbox_file_t. Since you want samba to be allowed to upload content to the container. Is samba only needs to read the content, then just add the allow rules to make this happen.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-01-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。