Hi,

With my previous patch, the waiting time of the stop action is sometimes
insufficient. For information on my systems, the time has never exceeded
7 seconds.

The second patch (samhain-reindent.patch) is cleaning spaces/indent, if
you want it.

Regards,
diff -ru samhain-3.1.0-patched/debian/samhain.init samhain-3.1.0-patched2/debian/samhain.init
--- samhain-3.1.0-patched/debian/samhain.init	2016-02-13 11:10:20.747663920 +0100
+++ samhain-3.1.0-patched2/debian/samhain.init	2016-02-13 11:30:28.855246439 +0100
@@ -1,5 +1,5 @@
 #! /bin/sh
-# 
+#
 # Init.d file for Samhain, based on the example init.d file written by
 # Miquel van Smoorenburg and modified for Debian GNU/Linux by Ian Murdock
 #
@@ -30,87 +30,86 @@
 # Check if a daemon is running
 running()
 {
-# Check with pidfile first, if available
-    if [ -r "$PIDFILE" ] ; then
-	    pid=`cat $PIDFILE`
-# No pid, probably no daemon present
-	    if [ -n "$pid" ] ; then
-		    pidofproc -p $PIDFILE $DAEMON
-		    return $?
-	    fi
-    fi
-# Try to find the daemon by name
-    pidof $DAEMON >/dev/null 
-    return $?
+	# Check with pidfile first, if available
+	if [ -r "$PIDFILE" ] ; then
+		pid=`cat $PIDFILE`
+		# No pid, probably no daemon present
+		if [ -n "$pid" ] ; then
+			pidofproc -p $PIDFILE $DAEMON
+			return $?
+		fi
+	fi
+	# Try to find the daemon by name
+	pidof $DAEMON >/dev/null
+	return $?
 }
 
-# Initialize 
+# Initialize
 init_db()
 {
-# Initialize the database only if does not exist yet, abort if
-# it cannot be created
-     [  -f /var/lib/samhain/samhain_file ] && return
-     log_progress_msg "Creating integrity database (this can take some minutes)."
-     samhain -t init >/var/log/samhain/samhain-init.log 2>&1
-     if [  ! -f /var/lib/samhain/samhain_file ] ; then
-        log_failure_msg "Database could not be created. Review /var/log/samhain/samhain-init.log"
-        log_end_msg 1
-        exit 1
-    fi
-    log_progress_msg "Database created."
+	# Initialize the database only if does not exist yet, abort if
+	# it cannot be created
+	[ -f /var/lib/samhain/samhain_file ] && return
+	log_progress_msg "Creating integrity database (this can take some minutes)."
+	samhain -t init >/var/log/samhain/samhain-init.log 2>&1
+	if [ ! -f /var/lib/samhain/samhain_file ] ; then
+		log_failure_msg "Database could not be created. Review /var/log/samhain/samhain-init.log"
+		log_end_msg 1
+		exit 1
+	fi
+	log_progress_msg "Database created."
 }
 
 
 
 case "$1" in
-  start)
-        [ ! -e /var/run/${NAME} ] && mkdir -p /var/run/${NAME}
-        log_begin_msg "Starting $DESC: $NAME"
-        init_db
-        start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
-        log_end_msg $?
-        ;;
-  stop)
-        log_begin_msg "Stopping $DESC: $NAME"
-        start-stop-daemon --stop --quiet --retry 30 --oknodo --pidfile $PIDFILE  --name  $NAME 
-        log_end_msg $?
-        ;;
-  reload)
-  	log_begin_msg "Reloading $DESC configuration files: $NAME"
-	if running ; then
-		start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON
+	start)
+		[ ! -e /var/run/${NAME} ] && mkdir -p /var/run/${NAME}
+		log_begin_msg "Starting $DESC: $NAME"
+		init_db
+		start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
 		log_end_msg $?
-	else
-            	log_daemon_msg " ERROR: $DAEMON is not running."
-		log_end_msg 1
-	fi
-
-  	;;
-  restart|force-reload)
-        log_begin_msg "Restarting $DESC: $NAME"
-	if running; then
-	        start-stop-daemon --stop --quiet --retry 30 --oknodo --pidfile $PIDFILE  --name  $NAME 
-	fi
-        if  ! running  ; then
-            start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON
-            log_end_msg $?
-        else
-            log_daemon_msg " ERROR: $DAEMON did not die in the expected time, will not restart/force-reload"
-            log_end_msg 1
-        fi
-        ;;
-   status)
-	if [ -e $PIDFILE ] ; then
-	   	status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
-	else
-	   	status_of_proc $DAEMON $NAME && exit 0 || exit $?
-	fi
-        ;;
-  *)
-        N=/etc/init.d/${0##*/}
-        echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
-        exit 1
-        ;;
+	;;
+	stop)
+		log_begin_msg "Stopping $DESC: $NAME"
+		start-stop-daemon --stop --quiet --retry 30 --oknodo --pidfile $PIDFILE --name $NAME
+		log_end_msg $?
+	;;
+	reload)
+		log_begin_msg "Reloading $DESC configuration files: $NAME"
+		if running ; then
+			start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON
+			log_end_msg $?
+		else
+			log_daemon_msg " ERROR: $DAEMON is not running."
+			log_end_msg 1
+		fi
+	;;
+	restart|force-reload)
+		log_begin_msg "Restarting $DESC: $NAME"
+		if running; then
+			start-stop-daemon --stop --quiet --retry 30 --oknodo --pidfile $PIDFILE --name $NAME
+		fi
+		if ! running ; then
+			start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON
+			log_end_msg $?
+		else
+			log_daemon_msg " ERROR: $DAEMON did not die in the expected time, will not restart/force-reload"
+			log_end_msg 1
+		fi
+	;;
+	status)
+		if [ -e $PIDFILE ] ; then
+			status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
+		else
+			status_of_proc $DAEMON $NAME && exit 0 || exit $?
+		fi
+	;;
+	*)
+		N=/etc/init.d/${0##*/}
+		echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
+		exit 1
+	;;
 esac
 
 exit 0
diff -ru samhain-3.1.0/debian/samhain.init samhain-3.1.0-patched/debian/samhain.init
--- samhain-3.1.0/debian/samhain.init	2016-02-13 10:32:06.000000000 +0100
+++ samhain-3.1.0-patched/debian/samhain.init	2016-02-13 11:10:20.747663920 +0100
@@ -72,7 +72,7 @@
         ;;
   stop)
         log_begin_msg "Stopping $DESC: $NAME"
-        start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE  --name  $NAME 
+        start-stop-daemon --stop --quiet --retry 30 --oknodo --pidfile $PIDFILE  --name  $NAME 
         log_end_msg $?
         ;;
   reload)
@@ -89,11 +89,7 @@
   restart|force-reload)
         log_begin_msg "Restarting $DESC: $NAME"
 	if running; then
-	        start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE  --name  $NAME 
-	        for i in 1 2 3 ; do
-	            if ! running; then break ; fi
-	            sleep 1
-	        done
+	        start-stop-daemon --stop --quiet --retry 30 --oknodo --pidfile $PIDFILE  --name  $NAME 
 	fi
         if  ! running  ; then
             start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to