Index: /trunk/Makefile.in
===================================================================
--- /trunk/Makefile.in	(revision 24)
+++ /trunk/Makefile.in	(revision 25)
@@ -1091,4 +1091,5 @@
 CUTEST_SOURCES = $(srcsrc)/cutest_sh_tools.c \
 		$(srcsrc)/cutest_sh_utils.c \
+		$(srcsrc)/cutest_sh_unix.c \
 		$(srcsrc)/cutest_slib.c \
 		$(srcsrc)/cutest_zAVLTree.c \
@@ -1097,4 +1098,5 @@
 CUTEST_OBJECTS = cutest_sh_tools.o \
 	cutest_sh_utils.o \
+	cutest_sh_unix.o \
 	cutest_slib.o \
 	cutest_zAVLTree.o \
Index: /trunk/docs/Changelog
===================================================================
--- /trunk/docs/Changelog	(revision 24)
+++ /trunk/docs/Changelog	(revision 25)
@@ -1,11 +1,8 @@
 2.2.0:
+	* patch by Yoann Vandoorselaere for sh_prelude.c
 	* allow --longopt arg as well as --longopt=arg
-	* fix minor problem with dead clienbt detection (problem reported
-	  by M. Kustosik)
 	* verify checksum of growing log files
 	* rewrite of the test suite
 	* added a bit of unit testing
-	* improved the windows howto according to suggestions by 
-	  Jorge Morgado
 	* minor optimizations in various places
 	* optimized implementation of tiger checksum algorithm
@@ -20,4 +17,14 @@
 	* slib.c: remove fcntl's from sl_read_timeout (caller sets O_NONBLOCK),
 	  add function sl_read_timeout_prep
+
+2.1.3 (13-03-2006):
+	* fix compile problem in slib.c (reported by Lawrence Bowie)
+        * fix bug with combination of one-shot update mode and file check 
+	  schedule (reportedby Dan Track)
+	* improved the windows howto according to suggestions by 
+	  Jorge Morgado
+	* fix samhain_hide kernel module for new linux kernel versions
+	* fix minor problem with dead client detection (problem reported
+	  by Michal Kustosik)
 
 2.1.2 (10-01-2006):
Index: /trunk/dsys/comDOWNLOAD
===================================================================
--- /trunk/dsys/comDOWNLOAD	(revision 24)
+++ /trunk/dsys/comDOWNLOAD	(revision 25)
@@ -111,5 +111,5 @@
     if test -z "$command"
     then
-	printFATAL "No wget, curl, lynx, links, lwp-request, fetch in your \$PATH, cannot download"
+	printFATAL "No wget, curl, lynx, links, lwp-request, fetch, fget in your \$PATH, cannot download"
     fi
 
Index: /trunk/include/samhain.h
===================================================================
--- /trunk/include/samhain.h	(revision 24)
+++ /trunk/include/samhain.h	(revision 25)
@@ -301,9 +301,13 @@
 int safe_fatal  (int signal, int method, char * details, char *f, int l);
 
-#define SH_VAL_EQ(a,b) \
+#define SH_VALIDATE_EQ(a,b) \
      do { \
          if ((a) != (b)) safe_fatal(0, 0, #a " != " #b, FIL__, __LINE__);\
      } while (0)
 
+#define SH_VALIDATE_NE(a,b) \
+     do { \
+         if ((a) == (b)) safe_fatal(0, 0, #a " == " #b, FIL__, __LINE__);\
+     } while (0)
 
 #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK)
Index: /trunk/include/sh_unix.h
===================================================================
--- /trunk/include/sh_unix.h	(revision 24)
+++ /trunk/include/sh_unix.h	(revision 25)
@@ -141,4 +141,7 @@
 int sh_unix_munlock(void * addr, size_t len);
 int sh_unix_count_mlock();
+/* public for unit tests */
+int sh_unix_pagesize();
+unsigned long sh_unix_lookup_page(void * in_addr, size_t len, int * num_pages);
 
 /* chroot directory
Index: /trunk/src/samhain.c
===================================================================
--- /trunk/src/samhain.c	(revision 24)
+++ /trunk/src/samhain.c	(revision 25)
@@ -1795,5 +1795,7 @@
       /* see whether its time to check files
        */
-      if      (sh.flag.checkSum == SH_CHECK_INIT)
+      if      (sh.flag.checkSum == SH_CHECK_INIT ||
+	       (sh.flag.checkSum == SH_CHECK_CHECK &&
+		(sh.flag.isdaemon == S_FALSE && sh.flag.loop == S_FALSE)))
 	{
 	  flag_check_1 = 1;
Index: /trunk/src/sh_html.c
===================================================================
--- /trunk/src/sh_html.c	(revision 24)
+++ /trunk/src/sh_html.c	(revision 25)
@@ -313,5 +313,5 @@
 	  sl_strlcat(&entry_orig[entry_size], line, line_size + 1);
 	  entry_size += add_size;
-	  SH_VAL_EQ(entry_orig[entry_size], '\0');
+	  SH_VALIDATE_EQ(entry_orig[entry_size], '\0');
 	}
       sl_close(fd);
Index: /trunk/src/sh_unix.c
===================================================================
--- /trunk/src/sh_unix.c	(revision 24)
+++ /trunk/src/sh_unix.c	(revision 25)
@@ -4024,5 +4024,5 @@
     {
 #ifdef WITH_TPT
-      sl_snprintf(str, 128, _("file: %s line: %d page: %d"), 
+      sl_snprintf(str, sizeof(str), _("file: %s line: %d page: %d"), 
 		  page_list->file, page_list->line, i+1);
       sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, i, MSG_E_SUBGEN,
@@ -4032,5 +4032,5 @@
       ++i;
     }
-  sl_snprintf(str, 128, _("%d pages locked"), i);
+  sl_snprintf(str, sizeof(str), _("%d pages locked"), i);
   sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, i, MSG_E_SUBGEN,
 		  str, _("sh_unix_count_mlock"));
Index: /trunk/src/sh_utils.c
===================================================================
--- /trunk/src/sh_utils.c	(revision 24)
+++ /trunk/src/sh_utils.c	(revision 25)
@@ -205,10 +205,10 @@
   SL_ENTER(_("sh_util_strdup"));
 
-  if (str != NULL)
-    {
-      len = sl_strlen(str);
-      p   = SH_ALLOC (len + 1);
-      (void) sl_strlcpy (p, str, len+1);
-    }
+  SH_VALIDATE_NE(str, NULL);
+
+  len = sl_strlen(str);
+  p   = SH_ALLOC (len + 1);
+  (void) sl_strlcpy (p, str, len+1);
+
   SL_RETURN( p, _("sh_util_strdup"));
 }
@@ -224,7 +224,5 @@
   ret = *str;
 
-  if (ret == NULL) {
-    SL_RETURN(ret, _("sh_util_strsep"));
-  }
+  SH_VALIDATE_NE(ret, NULL);
 
   for (c = *str; *c != '\0'; c++) {
Index: /trunk/src/slib.c
===================================================================
--- /trunk/src/slib.c	(revision 24)
+++ /trunk/src/slib.c	(revision 25)
@@ -577,5 +577,5 @@
 
 #if !defined(HOST_IS_I86SOLARIS)
-#if !defined (_GNU_SOURCE)
+#if !defined (_GNU_SOURCE) && !defined(__linux__)
 /* flawfinder: ignore */
 extern int vsnprintf ( char *str, size_t n,
Index: /trunk/test/testrun_1.sh
===================================================================
--- /trunk/test/testrun_1.sh	(revision 24)
+++ /trunk/test/testrun_1.sh	(revision 25)
@@ -22,5 +22,5 @@
 testrun1_setup=0
 
-MAXTEST=10; export MAXTEST
+MAXTEST=11; export MAXTEST
 
 test_dirs () {
@@ -46,4 +46,47 @@
 	fi
     done
+}
+
+# 
+# combine file check schedule with one-shot mode 
+# 
+TESTPOLICY_11="
+[ReadOnly]
+dir=99${BASE}
+"
+
+mod_testdata_11 () {
+    sleep 1
+    echo "foobar" >"${BASE}/c/x"; # bad
+    chmod 0555  "${BASE}/a/y";    # bad
+    ORIGINAL='SetFilecheckTime=60'
+    REPLACEMENT='FileCheckScheduleOne = 6 12 * * *'
+    ex $RCFILE <<EOF
+:%s/${ORIGINAL}/${REPLACEMENT}/g
+:wq
+EOF
+}
+
+chk_testdata_11 () {
+    # CDIRS="a b c a/a a/b a/c a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c";
+    tmp=`grep CRIT $LOGFILE | wc -l`
+    if [ $tmp -ne 2 ]; then
+	[ -z "$verbose" ] || log_msg_fail "policy count";
+	return 1
+    fi
+    egrep "CRIT.*POLICY \[ReadOnly\] C-------TS.*${BASE}/c/x" $LOGFILE >/dev/null 2>&1
+    if [ $? -ne 0 ]; then
+	[ -z "$verbose" ] || log_msg_fail "${BASE}/c/x";
+	return 1
+    fi
+    egrep "CRIT.*POLICY \[ReadOnly\] -----M--T-.*${BASE}/a/y" $LOGFILE >/dev/null 2>&1
+    if [ $? -ne 0 ]; then
+	[ -z "$verbose" ] || log_msg_fail "${BASE}/a/y";
+	return 1
+    fi
+    CDIRS="a a/a a/b a/c c b a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c";
+    NDIRS="";
+    test_dirs;
+    return $?
 }
 
Index: /trunk/test/testrun_2a.sh
===================================================================
--- /trunk/test/testrun_2a.sh	(revision 24)
+++ /trunk/test/testrun_2a.sh	(revision 25)
@@ -140,4 +140,6 @@
 	rm -f ./rc.${SH_LOCALHOST}
 	rm -f ./file.${SH_LOCALHOST}
+	rm -f  "./rc.${ALTHOST}"
+	rm -f  "./file.${ALTHOST}"
 
 	cp ${SCRIPTDIR}/testrc_2.in testrc_2
@@ -196,5 +198,5 @@
 }
 
-MAXTEST=1; export MAXTEST
+MAXTEST=5; export MAXTEST
 
 testrun2a ()
@@ -209,5 +211,4 @@
     #
     testrun2a_internal
-    #
     do_test_1_a
     if [ $? -eq 0 ]; then
@@ -215,4 +216,51 @@
     else
 	[ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client download+logging";
+    fi
+    #
+    SERVER_BUILDOPTS_ORIG="${SERVER_BUILDOPTS}"
+    CLIENT_BUILDOPTS_ORIG="${CLIENT_BUILDOPTS}"
+    #
+    SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --disable-srp"
+    CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --disable-srp"
+    #
+    testrun2a_internal
+    do_test_1_a
+    if [ $? -eq 0 ]; then
+	[ -z "$quiet" ] && log_ok   2 ${MAXTEST} "SRP disabled";
+    else
+	[ -z "$quiet" ] && log_fail 2 ${MAXTEST} "SRP disabled";
+    fi
+    #
+    SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --disable-encrypt"
+    CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --disable-encrypt"
+    #
+    testrun2a_internal
+    do_test_1_a
+    if [ $? -eq 0 ]; then
+	[ -z "$quiet" ] && log_ok   3 ${MAXTEST} "Encryption disabled";
+    else
+	[ -z "$quiet" ] && log_fail 3 ${MAXTEST} "Encryption disabled";
+    fi
+    #
+    SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --enable-encrypt=1"
+    CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --enable-encrypt=1"
+    #
+    testrun2a_internal
+    do_test_1_a
+    if [ $? -eq 0 ]; then
+	[ -z "$quiet" ] && log_ok   4 ${MAXTEST} "Encryption (v1)";
+    else
+	[ -z "$quiet" ] && log_fail 4 ${MAXTEST} "Encryption (v1)";
+    fi
+    #
+    SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG}"
+    CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --enable-encrypt=1"
+    #
+    testrun2a_internal
+    do_test_1_a
+    if [ $? -eq 0 ]; then
+	[ -z "$quiet" ] && log_ok   5 ${MAXTEST} "Encryption backward compat";
+    else
+	[ -z "$quiet" ] && log_fail 5 ${MAXTEST} "Encryption backward compat";
     fi
     #
