shell> curl http://localhost/test.html <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>403 Forbidden</title> </head><body> <h1>Forbidden</h1> <p>You don't have permission to access /test.html on this server.</p> </body></html>
shell> sealert -a /var/log/audit/audit.log Summary: SELinux is preventing /usr/sbin/httpd "getattr" access to /var/www/html/test.html. Detailed Description: SELinux denied access requested by httpd. /var/www/html/test.html may be a mislabeled. /var/www/html/test.html default SELinux type is httpd_sys_content_t, but its current type is admin_home_t. Changing this file back to the default type, may fix your problem. File contexts can be assigned to a file in the following ways. * Files created in a directory receive the file context of the parent directory by default. * The SELinux policy might override the default label inherited from the parent directory by specifying a process running in context A which creates a file in a directory labeled B will instead create the file with label C. An example of this would be the dhcp client running with the dhclient_t type and creating a file in the directory /etc. This file would normally receive the etc_t type due to parental inheritance but instead the file is labeled with the net_conf_t type because the SELinux policy specifies this. * Users can change the file context on a file using tools such as chcon, or restorecon. This file could have been mislabeled either by user error, or if an normally confined application was run under the wrong domain. However, this might also indicate a bug in SELinux because the file should not have been labeled with this type. If you believe this is a bug, please file a bug report against this package. Allowing Access: You can restore the default system context to this file by executing the restorecon command. restorecon '/var/www/html/test.html', if this file is a directory, you can recursively restore using restorecon -R '/var/www/html/test.html'. Fix Command: /sbin/restorecon '/var/www/html/test.html'
[iyunv@bia Desktop]# getsebool -a | grep http
allow_httpd_anon_write --> off
allow_httpd_mod_auth_ntlm_winbind --> off
allow_httpd_mod_auth_pam --> off
allow_httpd_sys_script_anon_write --> off
httpd_builtin_scripting --> on
httpd_can_check_spam --> off
httpd_can_network_connect --> off
httpd_can_network_connect_cobbler --> off
httpd_can_network_connect_db --> off
httpd_can_network_relay --> off
httpd_can_sendmail --> off
httpd_dbus_avahi --> on
httpd_enable_cgi --> on
httpd_enable_ftp_server --> off
httpd_enable_homedirs --> off
httpd_execmem --> off
httpd_read_user_content --> off
httpd_setrlimit --> off
httpd_ssi_exec --> off
httpd_tmp_exec --> off
httpd_tty_comm --> on
httpd_unified --> on
httpd_use_cifs --> off
httpd_use_gpg --> off
httpd_use_nfs --> off
Mar 31 13:46:15 localhost kernel: audit(1206942375.697:5719): avc: denied { append } for pid=32111 comm="vsftpd" name="test" dev=sda3 ino=19400200 scontext=root:system_r:ftpd_t:s0 tcontext=root:object_r:root_t:s0 tclass=file
SELinux ftp daemon policy is customizable based on least access required. So by default SElinux does not allow users to login and read their home directories.
If you are setting up this machine as a ftpd server and wish to allow users to access their home directorories, you need to set the ftp_home_dir boolean.
Disable selinux [iyunv@Jie ~]# vi /etc/sysconfig/selinux # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - SELinux is fully disabled. SELINUX=enforcing # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted
红帽企业 Linux 4 使用在 ext2/ext3 文件系统上的扩展属性来支持 SELinux。这就意味着,当一个文件被写到默认挂载的 ext2/ext3 文件系统中时,一个扩展的属性也会被写入。
当系统有 红帽企业 Linux 4 和 红帽企业 Linux 2.1 双重启动的时候,这就可能会产生一些问题。红帽企业 Linux2.1 内核不支持文件的扩展属性,当它遇到文件的扩展属性时,系统可能会崩溃。
有Linux桌面用户在安装了Redhat Enterprise Linux 4.0后,可能会需要关闭SELinux,正确的方法是:
修改/etc/selinux/config文件中的SELINUX="" 为 disabled ,然后重启。
By wangzhijun, # 24. January 2006, 04:09:06
1. Apache - Document root must be a directory 问题。有可能和这个问题并发的问题还有 403 Forbidden 禁止访问的问题。
现象描述:
不使用系统默认的 /var/www/html作为系统的Document Root,自己新建一个目录后修改 /etc/httpd/conf/httpd.conf 中的配置,然后重起Apache的Daemon,发现Apache无法起动,系统报错:
Document root must be a directory
但是,我们设置的DocumentRoot 的确是一个目录,而且apache用户具有可读权限。