Subversion Repositories configs

Rev

Go to most recent revision | Details | 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
74
		# Load the default rules
75
		test -f /etc/audit/audit.rules && /sbin/auditctl -R /etc/audit/audit.rules >/dev/null
76
	fi
77
	return $RETVAL
78
}
79
 
80
stop(){
81
	echo -n $"Stopping $prog: "
82
	killproc $prog
83
	RETVAL=$?
84
	echo
85
	rm -f /var/lock/subsys/auditd
86
	# Remove watches so shutdown works cleanly
87
	if test x"$AUDITD_CLEAN_STOP" != "x" ; then
88
		if test "`echo $AUDITD_CLEAN_STOP | tr 'NO' 'no'`" != "no"
89
		then
90
			/sbin/auditctl -D >/dev/null
91
		fi
92
	fi
93
	if test x"$AUDITD_STOP_DISABLE" != "x" ; then
94
		if test "`echo $AUDITD_STOP_DISABLE | tr 'NO' 'no'`" != "no"
95
		then
96
			/sbin/auditctl -e 0 >/dev/null
97
		fi
98
	fi
99
	return $RETVAL
100
}
101
 
102
reload(){
103
	test -f /etc/audit/auditd.conf  || exit 6
104
	echo -n $"Reloading configuration: "
105
	killproc $prog -HUP
106
	RETVAL=$?
107
	echo
108
	return $RETVAL
109
}
110
 
111
rotate(){
112
	echo -n $"Rotating logs: "
113
	killproc $prog -USR1
114
	RETVAL=$?
115
	echo
116
	return $RETVAL
117
}
118
 
119
resume(){
120
	echo -n $"Resuming logging: "
121
	killproc $prog -USR2
122
	RETVAL=$?
123
	echo
124
	return $RETVAL
125
}
126
 
127
restart(){
128
	test -f /etc/audit/auditd.conf  || exit 6
129
	stop
130
	start
131
}
132
 
133
condrestart(){
134
	[ -e /var/lock/subsys/auditd ] && restart
135
	return 0
136
}
137
 
138
 
139
# See how we were called.
140
case "$1" in
141
    start)
142
	start
143
	;;
144
    stop)
145
	stop
146
	;;
147
    restart)
148
	restart
149
	;;
150
    reload|force-reload)
151
	reload
152
	;;
153
    rotate)
154
	rotate
155
	;;
156
    resume)
157
	resume
158
	;;
159
    condrestart|try-restart)
160
	condrestart
161
	;;
162
    *)
163
	echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|rotate|resume}"
164
	RETVAL=3
165
esac
166
 
167
exit $RETVAL
168