Centos 6.5 auditd fails to start with service or /etc/init.d/audit start

Jepper asked:

Fail:

# service auditd start
Starting auditd:                                           [FAILED]

Fail:

# /etc/init.d/auditd start
Starting auditd:                                           [FAILED]

And frustatingly – works:

# bash /etc/init.d/auditd start
Starting auditd:                                           [  OK  ]

I’ve added something like echo 1 echo 2 in various place in bash /etc/init.d/auditd, so see what path the script takes, to no avail.

The command that is eventually run, and fails is

env -i PATH=/sbin:/usr/sbin:/bin:/usr/bin TERM=xterm /etc/init.d/auditd start

Why does adding bash make it work? Looking for troubleshooting ideas.

Based on Michaels suggestion to use run_init, I could get some meaningful debug out of bash:

# run_init bash -x /etc/init.d/auditd start
[...]
+ /bin/bash -c 'ulimit -S -c 0 >/dev/null 2>&1 ; auditd '
+ '[' 6 -eq 0 ']'
+ failure 'auditd startup'

In /var/log/messages I have

Dec  8 14:54:06 aws-sonar-01 kernel: type=1100 audit(1418050446.762:250): user pid=7196 uid=0 auid=500 ses=6 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:authentication acct="user" exe="/usr/sbin/run_init" hostname=? addr=? terminal=pts/0 res=success'
Dec  8 14:54:06 aws-sonar-01 kernel: type=1101 audit(1418050446.777:251): user pid=7196 uid=0 auid=500 ses=6 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:accounting acct="user" exe="/usr/sbin/run_init" hostname=? addr=? terminal=pts/0 res=success'
Dec  8 14:54:06 aws-sonar-01 kernel: type=1400 audit(1418050446.795:252): avc:  denied  { read } for  pid=7200 comm="auditd" name="audit" dev=xvda1 ino=393285 scontext=system_u:system_r:auditd_t:s0 tcontext=system_u:object_r:var_log_t:s0 tclass=lnk_file
Dec  8 14:54:06 aws-sonar-01 kernel: type=1300 audit(1418050446.795:252): arch=c000003e syscall=2 success=no exit=-13 a0=7fa0660a42a0 a1=90800 a2=4000 a3=19 items=0 ppid=7196 pid=7200 auid=500 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=6 comm="auditd" exe="/sbin/auditd" subj=system_u:system_r:auditd_t:s0 key=(null)
Dec  8 14:54:06 aws-sonar-01 auditd: Could not open dir /var/log/audit (Permission denied)
Dec  8 14:54:06 aws-sonar-01 auditd: The audit daemon is exiting.

I’ve tried to generate a policy using above as input

cat messages_above | grep awc | audit2allow -M audit
semodule -i audit.pp

Had a go at selinux policy creation – is this correct? Or missing anything?

semanage permissive -a auditd_t
service auditd start
tail -n 20 messages  |grep auditd | audit2allow -M auditd
semodule -i auditd.pp
semanage permissive -d auditd_t

Still same problem

My answer:


On EL (prior to 7) start services on an SELinux-enabled system with run_init to ensure that SELinux contexts and domain transitions are correct.

run_init service auditd start

Or just enable them to start at boot time, which is preferred.


Your log entries indicate that /var/log/audit has the wrong security context. To resolve this:

  1. Update your system. There are new SELinux policy packages which contain many fixes, as well as other updates you are behind on.
  2. Run restorecon -r -v /var/log/audit to fix the security contexts, or better, restorecon -r -v / to relabel the entire system (which fixes a lot of other potential issues as well).

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.