0

I have two files of interest in /var/www/html (in CentOS): index1.html, and index2.html.

index1.html was downloaded from a website and chowned to root and chmoded 0644. index2.html was created by root, and had the contents of index1.html copied into it. They have identical contents, and identical permissions. Apache will load index2.html, but will return a 403 Forbidden error for index1.html. If I swap the filenames, the permissions problem follows with the rename. What's going on?

[root@localhost html]# ls -al
total 52
drwxr-xr-x. 6 root root 4096 Jul  8 13:32 .
drwxr-xr-x. 6 root root 4096 Jul  8 12:59 ..
drw-r--r--. 2 root root 4096 Jun 26 12:14 css
-rw-r--r--. 1 root root 1558 Jul  8 11:42 dashboard.css
drw-r--r--. 2 root root 4096 Jun 26 12:14 fonts
-rw-r--r--. 1 root root 8744 Jul  8 13:12 index1.html
-rw-r--r--. 1 root root 8744 Jul  8 11:42 index2.html
drw-r--r--. 2 root root 4096 Jul  8 13:32 js
drw-r--r--. 4 root root 4096 Jun 21 18:39 PHP_Site
[root@localhost html]#

The rest of the files were downloaded and chowned/chmodded, and they also all return 403 errors. index2.html is the only file apache will load.

If I 'su apache' and cat the files, it can read all of them.

  • 1
    What does getfacl index*html tell you? – Janne Pikkarainen Jul 8 '14 at 17:59
  • Is SELinux enabled? – faker Jul 8 '14 at 18:00
  • getfacl returns identical results for both. I setenforce 0, so selinux should be off. But I see this in the error_log: [Tue Jul 08 12:52:37 2014] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0 – directedition Jul 8 '14 at 18:09
  • 1
    What is in the error log regarding the 403 error? – Michael Hampton Jul 8 '14 at 18:16
  • [error] [client ::1] (13)Permission denied: access to /index1.html denied – directedition Jul 8 '14 at 18:23
2

Try updating your file/folders context of your apache share.

# restorecon -R /var/www/html/

SELinux is useful, dont turn it off unless you have to.

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.