diff -up psad-2.1.3/init-scripts/psad-init.fedora.init psad-2.1.3/init-scripts/psad-init.fedora
--- psad-2.1.3/init-scripts/psad-init.fedora.init 2005-06-14 03:00:35.000000000 +0200
+++ psad-2.1.3/init-scripts/psad-init.fedora 2008-08-14 13:33:22.000000000 +0200
@@ -4,14 +4,40 @@
#
# Starts the psad daemon
#
-# chkconfig: 345 95 5
+# chkconfig: - 95 5
# description: The Port Scan Attack Detector (psad)
# processname: psad
+#
+# Return values according to LSB for all commands but status:
+# 0 - success
+# 1 - generic or unspecified error
+# 2 - invalid or excess argument(s)
+# 3 - unimplemented feature (e.g. "reload")
+# 4 - insufficient privilege
+# 5 - program is not installed
+# 6 - program is not configured
+# 7 - program is not running
+#
+
+PATH=/sbin:/bin:/usr/bin:/usr/sbin
+prog="psad"
# Source function library.
. /etc/init.d/functions
-test -x /usr/sbin/psad || exit 0
+# Allow anyone to run status
+if [ "$1" = "status" ] ; then
+ if [ -f /var/run/psad/kmsgsd.pid ]; then
+ status /usr/sbin/kmsgsd
+ fi
+ status /usr/sbin/psadwatchd
+ status /usr/sbin/psad
+ RETVAL=$?
+ exit $RETVAL
+fi
+
+# Check that we are root ... so non-root users stop here
+test $EUID = 0 || exit 4
RETVAL=0
@@ -19,16 +45,34 @@ RETVAL=0
# See how we were called.
#
-prog="psad"
start() {
+ echo -n $"Starting $prog: "
+ test -x /usr/sbin/psad || exit 5
+ test -f /etc/psad/psad.conf || exit 6
+
# Check if psad is already running
if [ ! -f /var/lock/subsys/psad ]; then
- echo -n $"Starting $prog: "
+ # Create empty fwdata file if it doesn't exist
+ /bin/touch /var/log/psad/fwdata
+ chown root.root /var/log/psad/fwdata
+ chmod 0600 /var/log/psad/fwdata
+ # Create fifo if it doesn't exist
+ if [ ! -p /var/lib/psad/psadfifo ]; then
+ [ -e /var/lib/psad/psadfifo ] && \
+ /bin/rm -f /var/lib/psad/psadfifo
+ /bin/mknod -m 600 /var/lib/psad/psadfifo p
+ fi
+ chown root.root /var/lib/psad/psadfifo
+ chmod 0600 /var/lib/psad/psadfifo
+
+ unset HOME MAIL USER USERNAME
daemon /usr/sbin/psad
RETVAL=$?
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/psad
echo
+ if test $RETVAL = 0 ; then
+ touch /var/lock/subsys/psad
+ fi
fi
return $RETVAL
}
@@ -53,17 +97,10 @@ restart() {
}
reload() {
+ test -f /etc/psad/psad.conf || exit 6
restart
}
-status_psad() {
- if [ -f /var/run/psad/kmsgsd.pid ]; then
- status /usr/sbin/kmsgsd
- fi
- status /usr/sbin/psadwatchd
- status /usr/sbin/psad
-}
-
case "$1" in
start)
start
@@ -79,13 +116,9 @@ condrestart)
restart
fi
;;
-status)
- status_psad
- ;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
- exit 1
+ RETVAL=3
esac
-exit $?
exit $RETVAL