I am using RHEL 6.1 and I would like to configure SELinux to authorize httpd to read all files in some folders (My goal is to make log files available via web access).
- Is this possible without listing explicitely all files ?
- Is this possible without disabling SELinux for httpd ?
I need solution which could be made persistent.
Thanks by advance.
You can set up a rule to allow
httpd_t
to read the type of file your logfiles are labeled with.For example, if I want
httpd_t
to be able to readyour_log_file_type_t
, you create a policy module like this (out of the back of my head). Call it apache_read_logs.te and put it in an empty directory:This allows
httpd_t
to read files labeledyour_log_file_type_t
and search through directories labeledyour_log_dir_type_t
. It uses macros for brevity. You can see how the macros look by downloading and examining the reference policy tarball.Then, from the directory you created the file in, you run, as root:
This assumes you have selinux-policy-devel and policycoreutils installed. Test this on a non-crucial machine first! I wrote this blind and haven't tested it myself!