S02auditd 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/sh
  2. #
  3. # auditd This starts and stops auditd
  4. #
  5. # description: This starts the Linux Auditing System Daemon,
  6. # which collects security related events in a dedicated
  7. # audit log. If this daemon is turned off, audit events
  8. # will be sent to syslog.
  9. #
  10. NAME=auditd
  11. DAEMON=/usr/sbin/${NAME}
  12. CONFIG=/etc/audit/auditd.conf
  13. PIDFILE=/var/run/${NAME}.pid
  14. start(){
  15. printf "Starting ${NAME}: "
  16. # Create dir to store log files in if one doesn't exist. Create
  17. # the directory with SELinux permissions if possible
  18. command -v matchpathcon >/dev/null 2>&1
  19. if [ $? = 0 ]; then
  20. mkdir -p /var/log/audit -Z `matchpathcon -n /var/log/audit`
  21. else
  22. mkdir -p /var/log/audit
  23. fi
  24. # Run audit daemon executable
  25. start-stop-daemon -S -q -p ${PIDFILE} --exec ${DAEMON}
  26. if [ $? = 0 ]; then
  27. # Load the default rules
  28. test -f /etc/audit/rules.d/audit.rules && /usr/sbin/auditctl -R /etc/audit/rules.d/audit.rules >/dev/null
  29. echo "OK"
  30. else
  31. echo "FAIL"
  32. fi
  33. }
  34. stop(){
  35. printf "Stopping ${NAME}: "
  36. start-stop-daemon -K -q -p ${PIDFILE}
  37. [ $? = 0 ] && echo "OK" || echo "FAIL"
  38. }
  39. reload(){
  40. printf "Reloading ${NAME} configuration: "
  41. start-stop-daemon --stop -s 1 -p ${PIDFILE} 1>/dev/null
  42. [ $? = 0 ] && echo "OK" || echo "FAIL"
  43. }
  44. rotate(){
  45. printf "Rotating ${NAME} logs: "
  46. start-stop-daemon --stop -s 10 -p ${PIDFILE} 1>/dev/null
  47. [ $? = 0 ] && echo "OK" || echo "FAIL"
  48. }
  49. case "$1" in
  50. start)
  51. start
  52. ;;
  53. stop)
  54. stop
  55. ;;
  56. restart)
  57. stop
  58. start
  59. ;;
  60. reload)
  61. reload
  62. ;;
  63. rotate)
  64. rotate
  65. ;;
  66. *)
  67. echo "Usage: $0 {start|stop|restart|reload|rotate}"
  68. exit 1
  69. ;;
  70. esac