2015-07-14 22:20:27 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# auditd This starts and stops auditd
|
|
|
|
#
|
|
|
|
# description: This starts the Linux Auditing System Daemon,
|
|
|
|
# which collects security related events in a dedicated
|
|
|
|
# audit log. If this daemon is turned off, audit events
|
|
|
|
# will be sent to syslog.
|
|
|
|
#
|
|
|
|
|
|
|
|
NAME=auditd
|
|
|
|
DAEMON=/usr/sbin/${NAME}
|
|
|
|
CONFIG=/etc/audit/auditd.conf
|
|
|
|
PIDFILE=/var/run/${NAME}.pid
|
|
|
|
|
|
|
|
start(){
|
2015-10-03 23:29:57 +02:00
|
|
|
printf "Starting ${NAME}: "
|
2015-07-14 22:20:27 +02:00
|
|
|
|
|
|
|
# Create dir to store log files in if one doesn't exist. Create
|
|
|
|
# the directory with SELinux permissions if possible
|
|
|
|
command -v matchpathcon >/dev/null 2>&1
|
|
|
|
if [ $? = 0 ]; then
|
|
|
|
mkdir -p /var/log/audit -Z `matchpathcon -n /var/log/audit`
|
|
|
|
else
|
|
|
|
mkdir -p /var/log/audit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Run audit daemon executable
|
|
|
|
start-stop-daemon -S -q -p ${PIDFILE} --exec ${DAEMON}
|
|
|
|
|
|
|
|
if [ $? = 0 ]; then
|
|
|
|
# Load the default rules
|
|
|
|
test -f /etc/audit/rules.d/audit.rules && /usr/sbin/auditctl -R /etc/audit/rules.d/audit.rules >/dev/null
|
|
|
|
echo "OK"
|
|
|
|
else
|
|
|
|
echo "FAIL"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
stop(){
|
2015-10-03 23:29:57 +02:00
|
|
|
printf "Stopping ${NAME}: "
|
2015-07-14 22:20:27 +02:00
|
|
|
|
|
|
|
start-stop-daemon -K -q -p ${PIDFILE}
|
|
|
|
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
|
|
|
}
|
|
|
|
|
|
|
|
reload(){
|
2015-10-03 23:29:57 +02:00
|
|
|
printf "Reloading ${NAME} configuration: "
|
2015-07-14 22:20:27 +02:00
|
|
|
start-stop-daemon --stop -s 1 -p ${PIDFILE} 1>/dev/null
|
|
|
|
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
|
|
|
}
|
|
|
|
|
|
|
|
rotate(){
|
2015-10-03 23:29:57 +02:00
|
|
|
printf "Rotating ${NAME} logs: "
|
2015-07-14 22:20:27 +02:00
|
|
|
start-stop-daemon --stop -s 10 -p ${PIDFILE} 1>/dev/null
|
|
|
|
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
reload)
|
|
|
|
reload
|
|
|
|
;;
|
|
|
|
rotate)
|
|
|
|
rotate
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 {start|stop|restart|reload|rotate}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|