About SELinux file contexts
Throughout this chapter, we will be using a web-based application deployment as an example: DokuWiki. This is a popular PHP wiki that uses files rather than a database as its backend system and is easy to install and manage.
Getting context information
Let's assume that the DokuWiki application is hosted at /srv/web/localhost/htdocs/dokuwiki
and stores its wiki pages (user content) in subdirectories of the data/
directory. This can be accomplished by downloading the latest DokuWiki tarball from the project site and extracting it in this location. Some distributions might have a different location for the DokuWiki application (such as /var/lib/dokuwiki
) which is correctly labeled already. The example here generally follows the same labeling regardless of the distribution, allowing us to show various context related actions.
The contexts of files can easily be acquired using the -Z
option of the ls
command. Most utilities that are able to provide feedback on contexts...