I get the following when trying to allow httpd to write to application specific directories.

[xxx MISP]# chcon -t httpd_sys_rw_content_t /var/www/MISP/app/files
chcon: can't apply partial context to unlabeled file ‘/var/www/MISP/app/files’
  • What does ls -lZ var/www/MISP/app/files return? – Raman Sailopal Apr 18 '18 at 14:00
  • -rw-r----- root apache ? empty drwxr-x--- root apache ? feed-metadata drwxr-x--- root apache ? misp-galaxy drwxr-x--- root apache ? misp-objects drwxr-x--- root apache ? scripts drwxr-x--- root apache ? taxonomies drwxr-x--- apache apache ? terms drwxr-x--- root apache ? warninglists – user286785 Apr 18 '18 at 14:10
  • Yes, but what are the selinux contexts associated with the listing (hence the -Z flag) – Raman Sailopal Apr 18 '18 at 14:14
  • I used the Z flag, but it didn't pull back anything additional. – user286785 Apr 18 '18 at 14:35
  • 1
    Do you actually have selinux enabled and running on the system? – Raman Sailopal Apr 18 '18 at 15:00

You need to add some rule with semanage for your app/files directory, and then apply with restorecon -Rv.

See detailed explanations in this article (especially section about using httpd_sys_rw_content_t): Configuring SELinux Policies for Apache Web Servers


According other threads here on Unix Stackexchange: "chcon: can't apply partial context to unlabeled file '/usr/sbin/xrdp'" or "chcon: can't apply partial context to unlabeled file while installing nagios with SELinux", it seems that it is necessary to label the files using semanage and if there is SELinux in enforcing mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.