I roughly followed these instructions: http://library.linode.com/web-applications/analytics/webalizer/centos-5 to install and configure webalizer to run on several VirtualHosts. Unfortunately when i try and run:

webalizer -n site.net -o /var/www/webalizer /etc/httpd/logs/site.net-apache_log

I get:

Error: Can't open log file /etc/httpd/logs/site.net-apache_log

But after running:

echo 0 > /selinux/enforce

It works.

How can i tell selinux to allow webalizer to run?


[root@web-01 logs]# ls -lZ
-rw-r--r--. root root unconfined_u:object_r:httpd_log_t:s0 access_log
-rw-r--r--. root root unconfined_u:object_r:httpd_log_t:s0 error_log
-rw-r--r--. root root unconfined_u:object_r:httpd_log_t:s0 tt.net-access_log
-rw-r--r--. root root unconfined_u:object_r:httpd_log_t:s0 tt.net-error_log
-rw-r--r--. root root unconfined_u:object_r:httpd_log_t:s0 ck.tt.net-access_log
-rw-r--r--. root root unconfined_u:object_r:httpd_log_t:s0 ck.tt.net-error_log


[root@web-01 ~]# service --status-all
auditd (pid  1132) is running...

[root@web-01 ~]# /opt/webalizerScript.sh 
Error: Can't open log file /etc/httpd/logs/tt.net-access_log
Error: Can't open log file /etc/httpd/logs/ck.tt.net-access_log

[root@web-01 ~]# audit2allow -w -a
<no matches>
  • What user is webalizer running as, and what's the output of ls -lZ on the log files? (Please add this to the question.) – James O'Gorman Aug 27 '12 at 21:01
  • i've added the output of ls -lZ. webalizer runs via cron- my linux knowledge isn't great- but i think that means it runs as root? – Lee Tickett Aug 27 '12 at 21:05

Use audit2allow to determine why webalizer was blocked and to build a local SELinux policy module to allow webalizer to access the necessary files.

Red Hat's SELinux Troubleshooting Guide has detailed steps on this process.

| improve this answer | |
  • there are no entries in /var/log/audit/audit.log, the command audit2allow doesn't exist & yum install audit2allow says there is no package available. Any ideas? – Lee Tickett Aug 28 '12 at 9:06
  • Install them? yum install audit policycoreutils-python – Michael Hampton Aug 28 '12 at 9:08
  • policycoreutils-python fixed the missing audit2allow but no entries appear when webalizer runs/fails? – Lee Tickett Aug 28 '12 at 9:19
  • You didn't have the auditd service running. Start it and try again from the beginning. – Michael Hampton Aug 28 '12 at 9:25
  • added to my original question. i retried the troublesome command with auditd running- still nothing :( thanks for keeping trying- appreciate it – Lee Tickett Aug 28 '12 at 9:29

I encountered the same problem to run webalizer on a log I created by combining 2 httpd logs (access_log and ssl_acces_log concatened and sorted by date). It was perfectly running with either of the 2 files, but with the combination of both, i got the "Can't open log file" mesasge.

There was no trace of any error in the audit.log, as for Lee.

However, by executing this command:

chcon --type=httpd_log_t /var/log/combined-httpd.log

webalizer was finally authorized to read the file...

| improve this answer | |

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.