Subversion Repositories configs

Rev

Rev 3 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 - 1
#!/bin/bash
2
#
3
# auditd        This starts and stops auditd
4
#
5
# chkconfig: 2345 11 88
6
# description: This starts the Linux Auditing System Daemon, \
7
#              which collects security related events in a dedicated \
8
#              audit log. If this daemon is turned off, audit events \
9
#              will be sent to syslog.
10
#
11
# processname: /sbin/auditd
12
# config: /etc/sysconfig/auditd
13
# config: /etc/audit/auditd.conf
14
# pidfile: /var/run/auditd.pid
15
#
16
# Return values according to LSB for all commands but status:
17
# 0 - success
18
# 1 - generic or unspecified error
19
# 2 - invalid or excess argument(s)
20
# 3 - unimplemented feature (e.g. "reload")
21
# 4 - insufficient privilege
22
# 5 - program is not installed
23
# 6 - program is not configured
24
# 7 - program is not running
25
#
26
 
27
 
28
PATH=/sbin:/bin:/usr/bin:/usr/sbin
29
prog="auditd"
30
 
31
# Source function library.
32
. /etc/init.d/functions
33
 
34
# Allow anyone to run status
35
if [ "$1" = "status" ] ; then
36
	status $prog
37
	RETVAL=$?
38
	exit $RETVAL
39
fi
40
 
41
# Check that we are root ... so non-root users stop here
42
test $EUID = 0  ||  exit 4
43
 
44
# Check config
45
test -f /etc/sysconfig/auditd && . /etc/sysconfig/auditd
46
 
47
RETVAL=0
48
 
49
start(){
50
	test -x /sbin/auditd  || exit 5
51
	test -f /etc/audit/auditd.conf  || exit 6
52
 
53
	echo -n $"Starting $prog: "
54
 
55
# Localization for auditd is controlled in /etc/synconfig/auditd
56
	if [ -z "$AUDITD_LANG" -o "$AUDITD_LANG" = "none" -o "$AUDITD_LANG" = "NONE" ]; then
57
		unset LANG LC_TIME LC_ALL LC_MESSAGES LC_NUMERIC LC_MONETARY LC_COLLATE
58
	else
59
		LANG="$AUDITD_LANG"
60
		LC_TIME="$AUDITD_LANG"
61
		LC_ALL="$AUDITD_LANG"
62
		LC_MESSAGES="$AUDITD_LANG"
63
		LC_NUMERIC="$AUDITD_LANG"
64
		LC_MONETARY="$AUDITD_LANG"
65
		LC_COLLATE="$AUDITD_LANG"
66
		export LANG LC_TIME LC_ALL LC_MESSAGES LC_NUMERIC LC_MONETARY LC_COLLATE
67
	fi
68
	unset HOME MAIL USER USERNAME
69
	daemon $prog "$EXTRAOPTIONS"
70
	RETVAL=$?
71
	echo
72
	if test $RETVAL = 0 ; then
73
		touch /var/lock/subsys/auditd
8 - 74
		# Prepare the default rules
75
		if test x"$USE_AUGENRULES" != "x" ; then
76
			if test "`echo $USE_AUGENRULES | tr 'NO' 'no'`" != "no"
77
			then
78
				test -d /etc/audit/rules.d && /sbin/augenrules
79
			fi
80
		fi
3 - 81
		# Load the default rules
82
		test -f /etc/audit/audit.rules && /sbin/auditctl -R /etc/audit/audit.rules >/dev/null
83
	fi
84
	return $RETVAL
85
}
86
 
87
stop(){
88
	echo -n $"Stopping $prog: "
89
	killproc $prog
90
	RETVAL=$?
91
	echo
92
	rm -f /var/lock/subsys/auditd
93
	# Remove watches so shutdown works cleanly
94
	if test x"$AUDITD_CLEAN_STOP" != "x" ; then
95
		if test "`echo $AUDITD_CLEAN_STOP | tr 'NO' 'no'`" != "no"
96
		then
97
			/sbin/auditctl -D >/dev/null
98
		fi
99
	fi
100
	if test x"$AUDITD_STOP_DISABLE" != "x" ; then
101
		if test "`echo $AUDITD_STOP_DISABLE | tr 'NO' 'no'`" != "no"
102
		then
103
			/sbin/auditctl -e 0 >/dev/null
104
		fi
105
	fi
106
	return $RETVAL
107
}
108
 
109
reload(){
110
	test -f /etc/audit/auditd.conf  || exit 6
111
	echo -n $"Reloading configuration: "
112
	killproc $prog -HUP
113
	RETVAL=$?
114
	echo
115
	return $RETVAL
116
}
117
 
118
rotate(){
119
	echo -n $"Rotating logs: "
120
	killproc $prog -USR1
121
	RETVAL=$?
122
	echo
123
	return $RETVAL
124
}
125
 
126
resume(){
127
	echo -n $"Resuming logging: "
128
	killproc $prog -USR2
129
	RETVAL=$?
130
	echo
131
	return $RETVAL
132
}
133
 
134
restart(){
135
	test -f /etc/audit/auditd.conf  || exit 6
136
	stop
137
	start
138
}
139
 
140
condrestart(){
141
	[ -e /var/lock/subsys/auditd ] && restart
142
	return 0
143
}
144
 
145
 
146
# See how we were called.
147
case "$1" in
148
    start)
149
	start
150
	;;
151
    stop)
152
	stop
153
	;;
154
    restart)
155
	restart
156
	;;
157
    reload|force-reload)
158
	reload
159
	;;
160
    rotate)
161
	rotate
162
	;;
163
    resume)
164
	resume
165
	;;
166
    condrestart|try-restart)
167
	condrestart
168
	;;
169
    *)
170
	echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|rotate|resume}"
171
	RETVAL=3
172
esac
173
 
174
exit $RETVAL
175