Book Image

SELinux Cookbook

By : Sven Vermeulen
Book Image

SELinux Cookbook

By: Sven Vermeulen

Overview of this book

Table of Contents (17 chapters)
SELinux Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using custom content types


Next up is to create our own set of content types for a web application that does not have a policy associated with it yet. We will use DokuWiki (available at https://www.dokuwiki.org) as an example.

Getting ready

Install DokuWiki either through the Linux distributions' package manager or manually through a downloaded release from the main site. In this example, we assume that DokuWiki is installed at /srv/web/dokuwiki/.

How to do it…

To use custom web content types, follow the next set of steps:

  1. Create a policy called mydokuwiki.te with the following content:

    apache_content_template(dokuwiki)
  2. Add a file context definition file called mydokuwiki.fc, which contains the following code:

    /srv/web/dokuwiki/lib/plugins(/.*)?  gen_context(system_u:object_r:httpd_dokuwiki_rw_content_t,s0)
    /srv/web/dokuwiki/conf(/.*)?  gen_context(system_u:object_r:httpd_dokuwiki_rw_content_t,s0)
    /srv/web/dokuwiki/data(/.*)?  gen_context(system_u:object_r:httpd_dokuwiki_rw_content_t,s0)
    /srv/web...