priority between file context rules

Vidalie Hervé herve.vidalie at worldline.com
Tue Dec 3 15:50:50 UTC 2013


Hello,

I am trying to label httpd files on a server running multiple instances of httpd.

        /WEBS/client_name/service_name/ contains configuration files, documents to serve, …
        /WEBLOGS/client_name/service_name/ contains httpd logs
        /WEBDATA/client_name/service_name/ contains datas

This is my goal:
        /WEBS/ httpd_sys_content_t
        /WEBS/lost\+found(/.*)? lost_found_t
        /WEBS/client_name/ httpd_sys_content_t
        /WEBS/client_name/service_name/ httpd_sys_content_t

        /WEBS/client_name/service_name/bin/ and his content httpd_sys_content_t
        /WEBS/client_name/service_name/conf/ and his content httpd_sys_content_t httpd_config_t
        /WEBS/client_name/service_name/docs/ and his content httpd_sys_content_t
        /WEBS/client_name/service_name/init/ and his content httpd_sys_content_t
        /WEBS/client_name/service_name/logs/ ->/WEBLOGS /client_name/service_name/  httpd_log_t (might be wrong)
        / WEBLOGS /client_name/service_name/readme/ and his content httpd_sys_content_t

        /WEBDATA / httpd_sys_content_t
        /WEBDATA /lost\+found(/.*)? lost_found_t
        /WEBDATA /client_name/ httpd_sys_content_t
        /WEBDATA /client_name/service_name/ and his content httpd_sys_rw_content_t

        /WEBLOGS / httpd_sys_content_t
        /WEBLOGS /lost\+found(/.*)? lost_found_t
        /WEBLOGS /client_name/ httpd_sys_content_t
        /WEBLOGS /client_name/service_name/ httpd_sys_content_t
        /WEBLOGS /client_name/service_name/* httpd_log_t

Would this labeling be correct?

I already tried to do run the following commands :
        semanage fcontext -a -t httpd_sys_content_t '/WEBS(/.*)'
        semanage fcontext -a -t httpd_sys_content_t '/WEBDATA(/.*)'
        semanage fcontext -a -t httpd_log_t '/WEBLOGS(/.*)'
        semanage fcontext -a -t lost_found_t '/WEBS/lost\+found(/.*)?'
        semanage fcontext -a -t lost_found_t '/WEBLOGS/lost\+found(/.*)?'
        semanage fcontext -a -t lost_found_t '/WEBDATA/lost\+found(/.*)?'
        semanage fcontext -a -t httpd_config_t '/WEBS/[^/]+/[^/]+/conf(/.*)?'
        semanage fcontext -a -t httpd_log_t '/WEBS/[^/]+/[^/]+/logs'
        restorecon -Rv /WEB*

Encountered problems :
        Already discussed : httpd_log_t is not enough to httpd to create new log files -> to be replaced with  httpd_sys_rw_content_t
        New files (for example logs) are not correctly labeled (they are labeled like the folder)


I would like to create a policy package file to define add this file context mappings. How to add mapping rules and rules for automatically labeling created files?

Another question:
Where can I find the source of the policy I use ? (selinux-policy-targeted-3.7.19-195.el6_4.18.noarch)

Regards,

Hervé Vidalie

-----Message d'origine-----
De : Daniel J Walsh [mailto:dwalsh at redhat.com]
Envoyé : mercredi 20 novembre 2013 20:39
À : Vidalie Hervé; Bruno Wolff III
Cc : selinux at lists.fedoraproject.org
Objet : Re: priority between file context rules


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/20/2013 04:34 AM, Vidalie Hervé wrote:
> Thank you for your clarification.
>
> How to modify current policy to add default context to some paths
> without using semanage fcontext -a? Where can I find sources of the policy I use?
> (I am using selinux-policy-targeted-3.7.19-195.el6_4.18.noarch)
>
> Regards,
>
> Hervé

There are two ways of adding file context mappings, either add them to a policy package (pp) file and install them, or use semanage fcontext.

If you use a policy package the labeling will work with the existing labeling, while semanage fcontext -a will take precedence.

semanage fcontext -a -e /var/www /WWW

Might also be usefull for saying labels under one directory should be like labels under a different directory.

What labeling are you trying to setup?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlKND7kACgkQrlYvE4MpobM0DgCdHsMcsHuA0xSd+JIFg2r0vXFt
xD8An1ycos+X9O3xpdPjLUekDoAwbAqY
=7f4o
-----END PGP SIGNATURE-----


Ce message et les pièces jointes sont confidentiels et réservés à l'usage exclusif de ses destinataires. Il peut également être protégé par le secret professionnel. Si vous recevez ce message par erreur, merci d'en avertir immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant être assurée sur Internet, la responsabilité de Worldline ne pourra être recherchée quant au contenu de ce message. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne saurait être recherchée pour tout dommage résultant d'un virus transmis.

This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Worldline liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.


More information about the selinux mailing list