在SELinux的文件夹标签的types字段中允许多种types

我是一个Ubuntu / Debian的人,但是我在安装Ubuntu软件的时候遇到了麻烦,所以我去了CentOS 5.6。

我还在一家小型networking开发公司,我们需要通过samba / smb共享我们的testing服务器的html / httpd文件,但也允许apache来承载它们。

所以我想知道如果我可以将我们的文件设置为桑巴和httpdtypes?

就像是,

/usr/sbin/semanage fcontext -a -t samba_share_t,httpd_sys_content_t "/var/www/html(/.*)?" 

否则,我将不得不把SELinux变成宽容模式,这不是我想要做的。

我只是意识到我完全误解了你的问题:)

如果你想允许Samba读取/var/www/html ,这是httpd_sys_content_t ,你应该没有问题。 我不是桑巴专家,但afaik桑巴运行在smbd_t域,所以你应该没事的:

  # sesearch -s smbd_t --allow | grep httpd_sys_content allow smbd_t httpd_sys_content_t : file { ioctl read getattr lock }; allow smbd_t httpd_sys_content_t : file { ioctl read write create getattr setattr lock append unlink link rename }; allow smbd_t httpd_sys_content_t : file { ioctl read write create getattr setattr lock append unlink link rename }; allow smbd_t httpd_sys_content_t : dir { ioctl read getattr lock search }; allow smbd_t httpd_sys_content_t : dir { ioctl read write create getattr setattr lock unlink link rename add_name remove_name reparent search rmdir }; allow smbd_t httpd_sys_content_t : dir { ioctl read write create getattr setattr lock unlink link rename add_name remove_name reparent search rmdir }; 

这就是说Samba允许读取httpd_sys_content_t目录和文件。 /var/www/html httpd_sys_content_t 。 你已经尝试过了吗?

 SHARING FILES If you want to share files with multiple domains (Apache, FTP, rsync, Samba), you can set a file context of public_content_t and public_content_rw_t. These context allow any of the above domains to read the content. If you want a particular domain to write to the public_con‐ tent_rw_t domain, you must set the appropriate boolean. allow_DOMAIN_anon_write. So for samba you would execute: setsebool -P allow_smbd_anon_write=1 

例如:

 semanage fcontext -a -t public_content_rw_t '/var/www/html(/.*)?' restorecon -R /var/www/html setsebool -P allow_smbd_anon_write 1 

而对于httpd:

 setsebool -P allow_httpd_anon_write=1 

请参阅: http : //fedoraproject.org/wiki/SELinux/apache