SELinux가 동일한 폴더에서 Apache와 Samba를 허용하도록하려면 어떻게해야합니까? 아파치가 / var / www에 액세스하도록 허용하고

구성에서 삼바와 아파치가 / var / www에 액세스하도록 허용하고 싶습니다. 삼바 액세스를 허용하는 컨텍스트를 설정할 수 있지만 httpd는 액세스 할 수 없습니다. setenforce를 0으로 사용하면 문제가 제거되므로 SELinux라는 것을 알고 있습니다.

또한 : 폴더의 컨텍스트를보고 폴더에 여러 컨텍스트를 가질 수있는 방법은 무엇입니까?

(CentOS)



답변

먼저 ls -Z를 사용하여 ls로 무언가의 컨텍스트를 볼 수 있습니다

[root@servername www]# ls -dZ /var/www
drwxr-xr-x  root root system_u:object_r:httpd_sys_content_t /var/www

둘째, Samba와 Apache가 동일한 디렉토리에 액세스 할 수 있도록하는 두 가지 옵션이 있습니다.

간단한 방법은 다음과 같이 어디서나 삼바 읽기 / 쓰기 액세스를 허용하는 것입니다.

setsebool -P samba_export_all_rw 1

간단하고 쉽고 SELinux의 이상한 속성을 엉망으로 만들지 않습니다.

Samba가 모든 디렉토리에 대한 전체 액세스 권한을 갖고 있고 / var / www 만 변경하려면 다음을 시도하십시오.

chcon -t public_content_rw_t /var/www
setsebool -P allow_smbd_anon_write 1
setsebool -P allow_httpd_anon_write 1

이를 통해 Samba와 Apache는 모두 public_content_rw_t 컨텍스트를 가진 디렉토리에 대한 쓰기 액세스를 허용합니다. chcon은 / var / www 만 수정하고 있습니다. / var / www에서 생성 된 새 디렉토리는 public_content_rw_t이지만 / var / www / html 또는 / var / www / manual과 같은 기존 디렉토리는 아닙니다. 모든 것을 변경하려면 chcon에 -R을 추가하십시오.

chcon -R -t public_content_rw_t /var/www

이 CentOS 위키 페이지 를 통해 다른 SELinux 부울에 대한 힌트를 얻을 수 있습니다 .


답변

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(/.*)?'
restorecon -R /var/www
setsebool -P allow_smbd_anon_write 1


답변