We are switching from a rhel7 webserver to Ubuntu 18.04. We currently have SELinux with file context set. We typically use this command in our rhel7 box:
chcon -R -t httpd_sys_rw_content_t /var/www/html/
I am trying to get file context setup in our Ubuntu server for AppArmor. When I run the above command in Ubuntu I get:
chcon: can't apply partial context to unlabeled file 'filename'
I have read MANY things online, and all I get is I need to change the context to unconfined_u:object_r:httpd_sys_content_t:s0, or many variations of that, but I ALWAYS get the same result. I have even switched to SELinux and got the same result too.
This is my last blocker for getting this project completed and I have spent HOURS on this one issue. Maybe I have the whole idea of AppArmor wrong, but file context should still apply - right? How can I apply the context properly?
www-data
, so the files need to be accessible to that user. See https://askubuntu.com/questions/46331/how-to-avoid-using-sudo-when-working-in-var-www for hints – Panther Jun 15 '18 at 15:48ls -Z
. I guess there won't be any label (that's why that error message). Also just to verify if selinux is setup and enforcing, see if you get proper feedback withgetenforce
&sestatus
commands. Also try to stop apparmour before enabling selinux. If everything looks good then you can try running these for persistent changes.sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html(/.*)?"
and thensudo restorecon -Rv /var/www/html
– SarkarG Jun 16 '18 at 13:47