Index: /trunk/configure.ac
===================================================================
--- /trunk/configure.ac	(revision 58)
+++ /trunk/configure.ac	(revision 59)
@@ -13,5 +13,5 @@
 dnl start
 dnl
-AM_INIT_AUTOMAKE(samhain, 2.2.3)
+AM_INIT_AUTOMAKE(samhain, 2.2.4)
 AC_CANONICAL_HOST
 
Index: /trunk/docs/Changelog
===================================================================
--- /trunk/docs/Changelog	(revision 58)
+++ /trunk/docs/Changelog	(revision 59)
@@ -1,3 +1,8 @@
 2.2.4:
+	* fixed sh_unix.c: bug in database init if GrowingLogFiles used
+	  with signed database (reported by Timothy Stotts)
+	* bug in manual fixed (incorrect documentation of --enable-user,
+	  noticed by M. Brown)
+	* rc.subr compatible init script for FreeBSD/NetBSD
 	* improve routine to find rpm after build
 	* add netbsd rc file from Brian Seklecki (taken from pkgsrc-wip)
@@ -5,5 +10,5 @@
 	* fix bug with SuidExclude (files in directory were still checked)
 
-2.2.3:
+2.2.3 (31-07-2006):
 	* fix samhainadmin.pl: check for gpg-agent running if use-agent is set
 	  (ticket #28 by anonymous)
Index: /trunk/init/samhain.startFreeBSD.in
===================================================================
--- /trunk/init/samhain.startFreeBSD.in	(revision 58)
+++ /trunk/init/samhain.startFreeBSD.in	(revision 59)
@@ -1,95 +1,44 @@
-#! /bin/sh -
+#!/bin/sh
+
+# PROVIDE: @install_name@
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name="@install_name@"
+rcvar=`set_rcvar`
+
+pidfile="@mylockfile@"
+
+# there are no required_files in general,
+# as they might be downloaded from the server
 #
-#    initialization/shutdown script for @install_name@ package
+# required_files="@myconffile@ @mydatafile@"
 
-prefix="@prefix@"
-exec_prefix="@exec_prefix@"
+extra_commands="reload"
+stop_postcmd="remove_stale_files"
 
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-DAEMON=@sbindir@/@install_name@
-NAME=@install_name@
-pidfile=@mylockfile@
+command="@sbindir@/@install_name@"
 
-test -f $DAEMON || exit 0
-
-safe_pidof () {
-    pidval=0
-    if [ -f $pidfile ] ; then
-       pidval=`cat $pidfile | awk '{ print $1 }'`
-       echo "${pidval}" | grep ['[^0123456789]'] >/dev/null 2>&1 && pidval=0
-    fi
-    echo $pidval
-    if [ x"$pidval" = x0 ] ; then
-	return 1
-    else
-	return 0
-    fi
+is_set()
+{
+    eval "[ -n \"\${$1+X}\" ]"
 }
 
-log_stat_msg () {
-case "$1" in
-	0)
-	echo "Service $NAME: Running";
-	break;
-	;;
-	1)
-	echo "Service $NAME: Stopped and @mylockfile@ pid file exists";
-	break;
-	;;
-	3)
-	echo "Service $NAME: Stopped";
-	break;
-	;;
-	*)
-	echo "Service $NAME: Status unknown";
-	break;
-	;;
-esac
+remove_stale_files()
+{
+    if test -f @mylockfile@; then
+	/bin/rm -f @mylockfile@
+    fi
+    /bin/rm -f @mylockdir@/${name}.sock
 }
 
-case "$1" in
-  start)
-	#
-	# Remove a stale lockfile, if found
-	#
-	if test -f @mylockfile@; then
-	    rm -f @mylockfile@
-	fi
-        /bin/rm -f @mylockdir@/${NAME}.sock
-        $DAEMON -D && echo -n " $NAME"
-        ;;
-  stop)
-        PID=`safe_pidof`
-	if test "x$PID" != x0
-	then
-		kill $PID && echo -n " $NAME"
-        fi
-        ;;
-  reload|force-reload)
-        PID=`safe_pidof`
-        if test "x$PID" != x0
-        then
-		echo " Reloading $NAME configuration file."
-                kill -s HUP $PID && echo -n " $NAME"
-	else
-		echo " Cannot determine PID of process $NAME."
-		exit 1
-        fi
-        ;;
-  restart)
-	$0 stop
-        sleep 3
-        $0 start
-        ;;
-    status)
-        $DAEMON  status
-	ERRNUM=$?
-	log_stat_msg ${ERRNUM}
-	exit ${ERRNUM}
-        ;;
-  *)
-        echo " Usage: $0 {start|stop|restart|reload|force-reload}" >&2
-        exit 1
-        ;;
-esac
+load_rc_config "$name"
 
+if ! is_set ${rcvar}; then 
+    eval "${rcvar}=YES"
+fi
+
+run_rc_command "$1"
+
Index: /trunk/init/samhain.startLinux.in
===================================================================
--- /trunk/init/samhain.startLinux.in	(revision 58)
+++ /trunk/init/samhain.startLinux.in	(revision 59)
@@ -63,5 +63,5 @@
 fi
 
-function debian_end ()
+debian_end()
 {
 	if [ $RETVAL -eq 0 ];
@@ -103,5 +103,5 @@
 
 # echo OK in green if is success, FAILED in red is failed
-function generic_end ()
+generic_end()
 {
 	if [ $RETVAL -eq 0 ];
Index: /trunk/init/samhain.startSolaris.in
===================================================================
--- /trunk/init/samhain.startSolaris.in	(revision 58)
+++ /trunk/init/samhain.startSolaris.in	(revision 59)
@@ -9,5 +9,5 @@
 
 
-log_stat_msg () {
+log_stat_msg() {
 case "$1" in
 	0)
Index: /trunk/samhain-install.sh.in
===================================================================
--- /trunk/samhain-install.sh.in	(revision 58)
+++ /trunk/samhain-install.sh.in	(revision 59)
@@ -672,5 +672,5 @@
        realname="$user"
        case "$platform" in
-           FreeBSD/* | NetBSD/* )
+           FreeBSD/* | NetBSD/* | OpenBSD/* )
               file=/etc/master.passwd
               entry="${user}:*:${uid}:${gid}::0:0:${realname}:${home}:${shell}"
@@ -785,11 +785,56 @@
 	;;
 
+    OpenBSD/*)
+	test -z "$verbose" || echo "  OpenBSD system detected"
+	grep '^## begin @install_name@' /etc/rc.local >/dev/null 2>&1
+	if [ $? -eq 0 ]; then
+	    RCLOCALTMP=`mktemp /etc/rc.local.XXXXXXXXXX` || exit 1
+	    sed "/^## begin @install_name@/,/^## end @install_name@/d" /etc/rc.local >$RCLOCALTMP || exit 1
+	    cat $RCLOCALTMP >/etc/rc.local || exit 1
+	    rm -f $RCLOCALTMP || exit 1
+	    if test x"$act" = xuboot; then
+		echo "  uninstalling from /etc/rc.local completed"
+	    fi
+	fi
+	if test x"$act" = xboot; then
+	    echo "## begin @install_name@"          >>/etc/rc.local || exit 1
+	    echo "if [ -x @sbindir@/@install_name@ ]; then" >>/etc/rc.local || exit 1
+	    echo "  @sbindir@/@install_name@ start" >>/etc/rc.local || exit 1
+	    echo "fi"                               >>/etc/rc.local || exit 1
+	    echo "## end @install_name@"            >>/etc/rc.local || exit 1
+	    echo "  installing to /etc/rc.local completed"
+	fi
+	exit 0
+	;;
+
+    NetBSD/*)
+	test -z "$verbose" || echo "  NetBSD system detected"
+	if test -f /etc/rc.subr; then
+	    DVER="FreeBSD"
+	    rc_main=${DESTDIR}/etc/rc.d
+	    rc_dirz=
+	    rc_inst="chmod 755 /etc/rc.d/@install_name@"
+	    rc_uinst="rm -f /etc/rc.d/@install_name@"
+	else
+	    echo "${0}: unsupported platform ${platform} (too old)"
+	    exit 1
+	fi
+	;;
+
     FreeBSD/* )
-	DVER="FreeBSD"
 	test -z "$verbose" || echo "  FreeBSD system detected"
-	rc_main=${DESTDIR}/usr/local/etc/rc.d
-	rc_dirz=
-	rc_inst="mv /usr/local/etc/rc.d/@install_name@ /usr/local/etc/rc.d/@install_name@.sh &&  chmod 755 /usr/local/etc/rc.d/@install_name@.sh"
-	rc_uinst="rm -f /usr/local/etc/rc.d/@install_name@.sh; echo You may want to remove ${rc_main} from local_startup in /etc/rc.conf; echo if it is empty"
+	if test -f /etc/rc.subr; then
+	    DVER="FreeBSD"
+	    rc_main=${DESTDIR}/etc/rc.d
+	    rc_dirz=
+	    rc_inst="chmod 755 /etc/rc.d/@install_name@"
+	    rc_uinst="rm -f /etc/rc.d/@install_name@"
+	else
+	    DVER="Solaris"
+	    rc_main=${DESTDIR}/usr/local/etc/rc.d
+	    rc_dirz=
+	    rc_inst="mv /usr/local/etc/rc.d/@install_name@ /usr/local/etc/rc.d/@install_name@.sh && chmod 755 /usr/local/etc/rc.d/@install_name@.sh"
+	    rc_uinst="rm -f /usr/local/etc/rc.d/@install_name@.sh"
+	fi
 	if test x"$act" = xboot
 	then
@@ -797,4 +842,5 @@
 		test x"$act" = xboot && mkdir ${rc_main}
 	    fi
+	    if test "x$DVER" = "xSolaris"; then
 	    (   . /etc/defaults/rc.conf
                 . /etc/rc.conf
@@ -814,8 +860,11 @@
                 fi
             )
-       fi
+	    fi
+	fi
 	;;
+
     SunOS/5.* )
 	DVER="Solaris"
+	DVER_REAL="Solaris"
 	test -z "$verbose" || echo "  Solaris system detected"
 	rc_dirz=
@@ -824,4 +873,5 @@
 	rc_uinst="rm -f ${DESTDIR}/etc/init.d/@install_name@; rm -f ${DESTDIR}/etc/rc0.d/K10@install_name@; rm -f ${DESTDIR}/etc/rc1.d/K10@install_name@; rm -f ${DESTDIR}/etc/rc3.d/S99@install_name@"
 	;;
+
     Linux/*)
 	rlv="2 3 4 5"
@@ -1005,5 +1055,5 @@
 		    ${mkinstalldirs} ${rc_main}
 		    #
-		    if test x"$DVER" = xSolaris; then
+		    if test x"${DVER_REAL}" = xSolaris; then
 			${mkinstalldirs} ${DESTDIR}/etc/rc0.d
 			${mkinstalldirs} ${DESTDIR}/etc/rc1.d
Index: /trunk/samhainrc.freebsd
===================================================================
--- /trunk/samhainrc.freebsd	(revision 58)
+++ /trunk/samhainrc.freebsd	(revision 59)
@@ -177,7 +177,4 @@
 #
 
-[ReadOnly]
-file = /var
-
 [Attributes]
 
Index: /trunk/samhainrc.netbsd
===================================================================
--- /trunk/samhainrc.netbsd	(revision 58)
+++ /trunk/samhainrc.netbsd	(revision 59)
@@ -774,7 +774,7 @@
 
 
-## The digest/checksum/hash algorithm
-#
-DigestAlgo = MD5
+## The digest/checksum/hash algorithm (default: TIGER192; others: MD5, SHA1)
+#
+# DigestAlgo = TIGER192
 
 
Index: /trunk/src/samhain.c
===================================================================
--- /trunk/src/samhain.c	(revision 58)
+++ /trunk/src/samhain.c	(revision 59)
@@ -652,4 +652,5 @@
   sh_files_delfilestack ();
   sh_hash_hashdelete();
+  sh_files_hle_reg (NULL);
 #endif
 #if defined(SH_WITH_SERVER)
@@ -1369,9 +1370,29 @@
     }
 
-  /* initialize signal handling etc
-   */
   if (sh.flag.isdaemon == S_TRUE)
     sh_error_only_stderr (BAD);
 
+  /* --- load database; checksum of database
+   */
+#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) 
+  TPT((0, FIL__, __LINE__, _("msg=<Get checksum of the database.>\n")))
+  if (sh.flag.checkSum == SH_CHECK_CHECK) 
+    {
+      if (0 != sl_strcmp(file_path('D', 'R'), _("REQ_FROM_SERVER")))
+	{
+	  (void) sl_strlcpy(sh.data.hash,
+			    sh_tiger_hash (file_path('D', 'R'), 
+					   TIGER_FILE, 0), 
+			    KEY_LEN+1);
+	}
+
+      /* this eventually fetches the file from server to get checksum
+       */
+      sh_hash_init ();
+    }
+#endif
+
+  /* --- initialize signal handling etc.; fork daemon
+   */
   if (sh_unix_init(sh.flag.isdaemon) == -1) 
     {
@@ -1409,28 +1430,4 @@
 #if defined(INET_SYSLOG) && defined(SH_WITH_SERVER)
   create_syslog_socket (S_FALSE);
-#endif
-
-
-  /* checksum of database
-   */
-#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) 
-  TPT((0, FIL__, __LINE__, _("msg=<Get checksum of the database.>\n")))
-  if (sh.flag.checkSum == SH_CHECK_CHECK) 
-    {
-      if (0 == sl_strcmp(file_path('D', 'R'), _("REQ_FROM_SERVER")))
-	{
-	  /* fetch the file from server to get checksum
-	   */
-	  sh_hash_init ();
-	  /* sh_hash_hashdelete (); */
-	}
-      else
-	{
-	  (void) sl_strlcpy(sh.data.hash,
-			    sh_tiger_hash (file_path('D', 'R'), 
-					   TIGER_FILE, 0), 
-			    KEY_LEN+1);
-	}
-    }
 #endif
 
Index: /trunk/src/sh_unix.c
===================================================================
--- /trunk/src/sh_unix.c	(revision 58)
+++ /trunk/src/sh_unix.c	(revision 59)
@@ -2843,9 +2843,16 @@
   SL_ENTER(_("sh_unix_checksum_size"));
 
-  /* lookup file in database */
-  status = sh_hash_get_it (filename, &tmpFile);
-  if (status != 0) {
-    goto out;
-  }
+  if (sh.flag.checkSum != SH_CHECK_INIT)
+    {
+      /* lookup file in database */
+      status = sh_hash_get_it (filename, &tmpFile);
+      if (status != 0) {
+	goto out;
+      }
+    }
+  else
+    {
+      tmpFile.size = fbuf->st_size;
+    }
 
   /* if last < current get checksum */
@@ -2853,7 +2860,7 @@
     {
       sl_strlcpy(fileHash,
-		sh_tiger_generic_hash (filename, TIGER_FD, tmpFile.size, 
-				       alert_timeout),
-		KEY_LEN+1);
+		 sh_tiger_generic_hash (filename, TIGER_FD, tmpFile.size, 
+					alert_timeout),
+		 KEY_LEN+1);
 
       /* return */
