Hide Forgot
php-5.3.3-3.el6.i686 configure php to use a php_error log : # grep ^error_log /etc/php.ini error_log = /var/log/php/php_error.log create a directory with proper context where "apache" user can create logs: # ls -ldZ /var/log/php drwxr-xr-x. apache apache system_u:object_r:httpd_log_t:s0 /var/log/php Observe selinux denials: # ausearch -m avc -ts yesterday|grep php type=AVC msg=audit(1319863436.083:82728): avc: denied { write } for pid=29674 comm="httpd" name="php_error.log" dev=xvdb1 ino=913991 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_log_t:s0 tclass=file type=AVC msg=audit(1319870381.008:83149): avc: denied { write } for pid=30018 comm="httpd" name="php_error.log" dev=xvdb1 ino=913991 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_log_t:s0 tclass=file type=AVC msg=audit(1319899384.744:84562): avc: denied { write } for pid=31215 comm="httpd" name="php_error.log" dev=xvdb1 ino=913991 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_log_t:s0 tclass=file type=AVC msg=audit(1319902586.284:84713): avc: denied { write } for pid=30018 comm="httpd" name="php_error.log" dev=xvdb1 ino=913991 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_log_t:s0 tclass=file type=AVC msg=audit(1319902721.801:84722): avc: denied { write } for pid=30020 comm="httpd" name="php_error.log" dev=xvdb1 ino=913991 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_log_t:s0 tclass=file type=AVC msg=audit(1319918163.076:85505): avc: denied { write } for pid=2771 comm="httpd" name="php_error.log" dev=xvdb1 ino=913991 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_log_t:s0 tclass=file Selinux is not at fault - logs need to be opened in "append" mode.
This request was evaluated by Red Hat Product Management for inclusion in the current release of Red Hat Enterprise Linux. Because the affected component is not scheduled to be updated in the current release, Red Hat is unfortunately unable to address this request at this time. Red Hat invites you to ask your support representative to propose this request, if appropriate and relevant, in the next release of Red Hat Enterprise Linux. If you would like it considered as an exception in the current release, please ask your support representative.
Please show the strace output for the failing system call to demonstrate why this isn't an error with the SELinux policy and/or labelling. The code looks correct, and the strace output looks correct here: [pid 4920] open("/var/log/php/error_log", O_WRONLY|O_CREAT|O_APPEND, 0644) = 17
Hmm, I am not sure how to catch, which httpd instance would accept my request . I thought audit log is very specific time->Mon Oct 31 19:10:37 2011 type=SYSCALL msg=audit(1320088237.077:102161): arch=40000003 syscall=33 success=yes exit=0 a0=33589a4 a1=2 a2=133fe58 a3=9 items=0 ppid=22179 pid=25069 auid=500 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsg id=48 tty=(none) ses=10084 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null) type=AVC msg=audit(1320088237.077:102161): avc: denied { write } for pid=25069 comm="httpd" name="php_error.log" dev=xvdb1 ino=913991 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_log_t:s 0 tclass=file command - httpd context - httpd_t target - file target context httpd_log_t denied { write} It matches the time log was updated: # ls -lZ /var/log/php/php_error.log -rw-r--r--. apache apache system_u:object_r:httpd_log_t:s0 /var/log/php/php_error.log # tail -1 /var/log/php/php_error.log [31-Oct-2011 19:10:37] WordPress database error Table 'wordpress.wp_categories' doesn't exist for query SELECT cat_ID FROM wp_categories WHERE category_nicename = 'user_interface' made by require, wp, WP->main, WP->query_posts, WP->build_query_string, apply_filters, call_user_func_array, cqs->custom_query_string, cqs->init, cqs->get_category, cqs->get_category_id
Sorry for the noise, I should have noticed it starts with WordPress it's their fault : $log_file = @ini_get('error_log'); if ( !empty($log_file) && ('syslog' != $log_file) && !@is_writable($log_file) ) $log_error = false; I bet it chokes when is trying to see if it's "writable" Sorry again.
OK, glad you tracked this down.