Index: trunk/Makefile.in
===================================================================
--- trunk/Makefile.in	(revision 256)
+++ trunk/Makefile.in	(revision 257)
@@ -1184,6 +1184,8 @@
 	@$(MAKE) CUTEST='-DSH_CUTEST=1' intcutest
 
-intcutest: internal.h $(OBJECTS) $(CUTEST_OBJECTS) sh_tiger_i.o $(srcsrc)/make-tests.sh
-	cd $(srcsrc)/ && ./make-tests.sh >CuTestMain.c
+$(srcsrc)/CuTestMain.c: $(SOURCES) $(CUTEST_SOURCES) $(srcsrc)/make-tests.sh
+	cd $(srcsrc)/ && ./make-tests.sh >CuTestMain.c;
+
+intcutest: internal.h $(OBJECTS) $(CUTEST_OBJECTS) sh_tiger_i.o $(srcsrc)/CuTestMain.c
 	@$(COMPILE) -o CuTestMain.o -c $(srcsrc)/CuTestMain.c; \
 	$(COMPILE) -o CuTest.o -c $(srcsrc)/CuTest.c; \
Index: trunk/configure.ac
===================================================================
--- trunk/configure.ac	(revision 256)
+++ trunk/configure.ac	(revision 257)
@@ -12,5 +12,5 @@
 dnl start
 dnl
-AM_INIT_AUTOMAKE(samhain, 2.5.10)
+AM_INIT_AUTOMAKE(samhain, 2.6.0)
 AC_DEFINE([SAMHAIN], 1, [Application is samhain])
 AC_CANONICAL_HOST
Index: trunk/docs/Changelog
===================================================================
--- trunk/docs/Changelog	(revision 256)
+++ trunk/docs/Changelog	(revision 257)
@@ -1,3 +1,5 @@
 2.6.0:
+	* fix bug with parallel compilation of cutest in Makefile 
+	* sh_mem.c: fix deadlock in debug-only code
 	* Evaluate glob patterns for each run of file check
 	* Add compile option to disable compiling with SSP
Index: trunk/src/sh_cat.c
===================================================================
--- trunk/src/sh_cat.c	(revision 256)
+++ trunk/src/sh_cat.c	(revision 257)
@@ -260,5 +260,5 @@
   { MSG_MSTAMP,      SH_ERR_STAMP,   STAMP, N_("msg=\"Memory used:  max.=%lu, current=%lu\"")},
   { MSG_MSTAMP2,     SH_ERR_STAMP,   STAMP, N_("msg=\"Blocks: %d allocated, %d freed, %d maximum\"")},
-  { MSG_E_MNULL,     SH_ERR_ERR,     ERR,   N_("msg=\"Dereferenced NULL pointer\" source_file=\"%s\" source_line=\"%d\"")},
+  { MSG_E_MNULL,     SH_ERR_ERR,     ERR,   N_("msg=\"Dereferenced NULL pointer allocated in %s, line %d\" source_file=\"%s\" source_line=\"%d\"")},
   { MSG_E_MMEM,      SH_ERR_ERR,     ERR,   N_("msg=\"Out of memory\" source_file=\"%s\" source_line=\"%d\"")},
   { MSG_E_MREC,      SH_ERR_ERR,     ERR,   N_("msg=\"Free() on unrecorded block\" source_file=\"%s\" source_line=\"%d\"")},
Index: trunk/src/sh_log_check.c
===================================================================
--- trunk/src/sh_log_check.c	(revision 256)
+++ trunk/src/sh_log_check.c	(revision 257)
@@ -811,4 +811,8 @@
 int sh_log_check_init (struct mod_type * arg)
 {
+#if !defined(HAVE_PTHREAD)
+  (void) arg;
+#endif
+
   if (ShLogmonActive == S_FALSE)
     return SH_MOD_FAILED;
Index: trunk/src/sh_mem.c
===================================================================
--- trunk/src/sh_mem.c	(revision 256)
+++ trunk/src/sh_mem.c	(revision 257)
@@ -112,11 +112,14 @@
 #endif
 
+static void ** sh_mem_merr_1;
+
 void sh_mem_stat ()
 {
   memlist_t   * this;
-
+  memlist_t   * merrlist = NULL;
 
   SL_ENTER(_("sh_mem_stat"));
 
+  sh_mem_merr_1 = (void **) &merrlist;
 
   if (Alloc_Count == Free_Count) 
@@ -139,19 +142,40 @@
   while (this != NULL) 
     {
+      memlist_t   * merr = (memlist_t *) malloc (sizeof(memlist_t));
+
+      memcpy(merr, this, sizeof(memlist_t));
+      merr->next = merrlist;
+      merrlist   = merr;
+
+      this = this->next;
+    }
+
+  SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
+
+  while (merrlist != NULL) 
+    {
+      memlist_t   * tmp = merrlist;
+      merrlist = merrlist->next;
+      
       sh_error_handle (SH_ERR_WARN, FIL__, __LINE__, 0, MSG_E_NOTFREE,
-		       this->size, this->file, this->line);
-      this = this->next;
-    }
-
-  SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
+		       tmp->size, tmp->file, tmp->line);
+      free(tmp);
+    }
+
   SL_RET0(_("sh_mem_stat"));
 }
 
+static void ** sh_mem_merr_2;
+
 void sh_mem_check ()
 {
   memlist_t * this;
+  memlist_t * merrlist = NULL;
+  memlist_t * merr;
   long        nerr = 0;
 
   SL_ENTER(_("sh_mem_check"));
+
+  sh_mem_merr_2 = (void **) &merrlist;
 
   sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_MSTAMP,
@@ -167,5 +191,11 @@
       if ( this->address == NULL )
 	{
-	  sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MNULL);
+	  merr = (memlist_t *) malloc (sizeof(memlist_t));
+
+	  memcpy(merr, this, sizeof(memlist_t));
+	  merr->size = 2;
+
+	  merr->next = merrlist;
+	  merrlist   = merr;
 	  ++nerr;
 	}
@@ -174,12 +204,22 @@
 	  if ( this->address[this->size]        != CHECKBYTE )
 	    {
-	      sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MOVER,
-			       this->file, this->line, FIL__, __LINE__);
+	      merr = (memlist_t *) malloc (sizeof(memlist_t));
+	      
+	      memcpy(merr, this, sizeof(memlist_t));
+	      merr->size = 1;
+	      
+	      merr->next = merrlist;
+	      merrlist   = merr;
 	      ++nerr;
 	    }
 	  if ( this->real_address[SH_MEMMULT-1] != CHECKBYTE )
 	    {
-	      sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MUNDER,
-			       this->file, this->line, FIL__, __LINE__);
+	      merr = (memlist_t *) malloc (sizeof(memlist_t));
+	      
+	      memcpy(merr, this, sizeof(memlist_t));
+	      merr->size = 0;
+	      
+	      merr->next = merrlist;
+	      merrlist   = merr;
 	      ++nerr;
 	    }
@@ -190,4 +230,22 @@
 
   SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
+
+  while (merrlist != NULL) 
+    {
+      memlist_t   * tmp = merrlist;
+      merrlist = merrlist->next;
+      
+      if (tmp->size == 2)
+	  sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MNULL,
+			   tmp->file, tmp->line, FIL__, __LINE__);
+      if (tmp->size == 1)
+	  sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MOVER,
+			   tmp->file, tmp->line, FIL__, __LINE__);
+      else
+	  sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MUNDER,
+			   tmp->file, tmp->line, FIL__, __LINE__);
+      free(tmp);
+    }
+
   SL_RET0(_("sh_mem_check"));
 }
@@ -203,4 +261,5 @@
   SH_MUTEX_RECURSIVE_INIT(mutex_mem);
   SH_MUTEX_RECURSIVE_LOCK(mutex_mem);
+
   the_realAddress = malloc(size + 2 * SH_MEMMULT);
   
@@ -258,4 +317,5 @@
 
 static void ** sh_mem_dummy_a;
+static void ** sh_mem_merr_3;
 
 void sh_mem_free (void * aa, char * file, int line)
@@ -263,4 +323,6 @@
   memlist_t * this;
   memlist_t * before;
+  memlist_t * merr;
+  memlist_t * merrlist = NULL;
   unsigned long        size   = 0;
   void      * a;
@@ -271,4 +333,5 @@
   a      = aa;
   sh_mem_dummy_a = &a;
+  sh_mem_merr_3  = (void **) &merrlist;
 
 
@@ -276,5 +339,5 @@
     {
       sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MNULL,
-		       file, line);
+		       file, line, FIL__, __LINE__);
       SL_RET0(_("sh_mem_free"));
     }
@@ -307,10 +370,23 @@
       if ( this->address[this->size]        != CHECKBYTE )
 	{
-	  sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MOVER,
-			   this->file, this->line, file, line);
+	  merr = (memlist_t *) malloc (sizeof(memlist_t));
+
+	  memcpy(merr, this, sizeof(memlist_t));
+	  merr->size = 1;
+
+	  merr->next = merrlist;
+	  merrlist = merr;
 	}
+
       if ( this->real_address[SH_MEMMULT-1] != CHECKBYTE )
-	sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MUNDER,
-			 this->file, this->line, file, line);
+	{
+	  merr = (memlist_t *) malloc (sizeof(memlist_t));
+
+	  memcpy(merr, this, sizeof(memlist_t));
+	  merr->size = 0;
+
+	  merr->next = merrlist;
+	  merrlist = merr;
+	}
 
       size = this->size;
@@ -325,4 +401,5 @@
   if (this)
     free(this);
+
   ++Free_Count;
   --Now_Alloc_Count;
@@ -332,7 +409,23 @@
   ; /* label at end of compound statement */
   SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
+
+  while (merrlist != NULL) 
+    {
+      memlist_t   * tmp = merrlist;
+      merrlist = merrlist->next;
+      
+      if (tmp->size == 1)
+	  sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MOVER,
+			   tmp->file, tmp->line, file, line);
+      else
+	  sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MUNDER,
+			   tmp->file, tmp->line, file, line);
+      free(tmp);
+    }
+
   if (flag != 0)
     sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MREC,
 		     file, line);
+
   SL_RET0(_("sh_mem_free"));
 }
Index: trunk/src/sh_portcheck.c
===================================================================
--- trunk/src/sh_portcheck.c	(revision 256)
+++ trunk/src/sh_portcheck.c	(revision 257)
@@ -1618,13 +1618,7 @@
   if (sh_portchk_active != S_FALSE)
     {
-#ifdef SL_DEBUG
-      sh_error_handle(SH_ERR_NOTICE, FIL__, __LINE__, 0, MSG_E_SUBGEN, 
-		      _("Checking for open ports"),
-		      _("sh_portchk_check"));
-#else
       sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, 0, MSG_E_SUBGEN, 
 		      _("Checking for open ports"),
 		      _("sh_portchk_check"));
-#endif
 
       sh_portchk_reset_lists();
Index: trunk/src/sh_processcheck.c
===================================================================
--- trunk/src/sh_processcheck.c	(revision 256)
+++ trunk/src/sh_processcheck.c	(revision 257)
@@ -1360,13 +1360,7 @@
     {
       SH_MUTEX_LOCK(mutex_thread_nolog);
-#ifdef SL_DEBUG
-      sh_error_handle(SH_ERR_NOTICE, FIL__, __LINE__, 0, MSG_PCK_CHECK, 
-		      (unsigned long) sh_prochk_minpid, 
-		      (unsigned long) (sh_prochk_maxpid-1));
-#else
       sh_error_handle((-1), FIL__, __LINE__, 0, MSG_PCK_CHECK, 
 		      (unsigned long) sh_prochk_minpid, 
 		      (unsigned long) (sh_prochk_maxpid-1));
-#endif
       SH_MUTEX_UNLOCK(mutex_thread_nolog);
 
Index: trunk/src/sh_suidchk.c
===================================================================
--- trunk/src/sh_suidchk.c	(revision 256)
+++ trunk/src/sh_suidchk.c	(revision 257)
@@ -1456,7 +1456,7 @@
 
   SH_MUTEX_LOCK(mutex_thread_nolog);
-  sh_error_handle (SH_ERR_NOTICE, FIL__, __LINE__, EINVAL, MSG_E_SUBGEN,
+  sh_error_handle (SH_ERR_INFO, FIL__, __LINE__, EINVAL, MSG_E_SUBGEN,
 		   _("Checking for SUID programs"),
-		   _("suidchk_check") );
+		   _("sh_suidchk_check") );
   SH_MUTEX_UNLOCK(mutex_thread_nolog);
 
Index: trunk/test/testcompile.sh
===================================================================
--- trunk/test/testcompile.sh	(revision 256)
+++ trunk/test/testcompile.sh	(revision 257)
@@ -179,5 +179,6 @@
 		echo getenv >> list_null_funcs_uniq;
 		cat $i | ./deference_check.pl |\
-                     egrep -v 'x_trustfile.c ... ... sl_trustfile';
+                     egrep -v 'x_trustfile.c ... ... sl_trustfile' | \
+		     egrep -v 'x_sh_mem.c ';
 		rm -f list_null_funcs_uniq;
 		# rm -f $i
@@ -262,4 +263,25 @@
 	numfail=0
 
+	
+	C_LOGFILE=""
+
+	ls /lib/libpcre* >/dev/null 2>&1
+	if [ $? -eq 0 ]; then
+	    C_LOGFILE=" --enable-logfile-monitor "
+	else
+	    ls /usr/lib/libpcre* >/dev/null 2>&1
+	    if [ $? -eq 0 ]; then
+		C_LOGFILE=" --enable-logfile-monitor "
+	    else
+		ls /usr/local/lib/libpcre* >/dev/null 2>&1
+		if [ $? -eq 0 ]; then
+		    C_LOGFILE=" --enable-logfile-monitor "
+		fi
+	    fi
+	fi
+	if [ x"${C_LOGFILE}" = x ]; then
+	    log_msg_ok  "Not testing  --enable-logfile-monitor";
+	fi
+
 	#
 	# test dnmalloc
@@ -319,5 +341,5 @@
 	[ -z "${SMATCH}" ] || { CC="${SAVE_CC}"; export CC; SMATCH=""; export SMATCH; }
 	#
-	${TOP_SRCDIR}/configure --quiet  --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test  --enable-static --enable-suidcheck --enable-process-check --enable-logfile-monitor > /dev/null 2>> test_log
+	${TOP_SRCDIR}/configure --quiet  --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test  --enable-static --enable-suidcheck --enable-process-check ${C_LOGFILE} > /dev/null 2>> test_log
 	#
 	let "num = num + 1" >/dev/null
@@ -429,5 +451,5 @@
 	fi
 	#
-	${TOP_SRCDIR}/configure --quiet  --prefix=$PW_DIR --enable-nocl="owl" --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test  --enable-logfile-monitor > /dev/null 2>> test_log   
+	${TOP_SRCDIR}/configure --quiet  --prefix=$PW_DIR --enable-nocl="owl" --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test ${C_LOGFILE} > /dev/null 2>> test_log   
 	#
 	let "num = num + 1" >/dev/null
@@ -670,5 +692,5 @@
 	[ -z "${SMATCH}" ] || { CC="${SAVE_CC}"; export CC; SMATCH=""; export SMATCH; }
 	#
-	${TOP_SRCDIR}/configure --quiet --enable-network=client  --enable-static --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test   --with-timeserver=127.0.0.1   --enable-logfile-monitor > /dev/null 2>> test_log   
+	${TOP_SRCDIR}/configure --quiet --enable-network=client  --enable-static --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test   --with-timeserver=127.0.0.1 ${C_LOGFILE} > /dev/null 2>> test_log   
 	#
 	let "num = num + 1" >/dev/null
@@ -726,5 +748,5 @@
 	    fi
 	    #
-	    ${TOP_SRCDIR}/configure --quiet --enable-network=client  --enable-srp --with-gpg=$GPG  --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test   --enable-logfile-monitor > /dev/null 2>> test_log   
+	    ${TOP_SRCDIR}/configure --quiet --enable-network=client  --enable-srp --with-gpg=$GPG  --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test ${C_LOGFILE} > /dev/null 2>> test_log   
 	    #
 	    let "num = num + 1" >/dev/null
@@ -790,5 +812,5 @@
 	fi
 	#
-	${TOP_SRCDIR}/configure --quiet --enable-network=client --enable-debug --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test   --enable-logfile-monitor > /dev/null 2>> test_log   
+	${TOP_SRCDIR}/configure --quiet --enable-network=client --enable-debug --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test ${C_LOGFILE} > /dev/null 2>> test_log   
 	#
 	let "num = num + 1" >/dev/null
Index: trunk/test/testhash.sh
===================================================================
--- trunk/test/testhash.sh	(revision 256)
+++ trunk/test/testhash.sh	(revision 257)
@@ -28,4 +28,25 @@
 {
 	log_start "HASH FUNCTION"
+
+	C_LOGFILE=""
+
+	ls /lib/libpcre* >/dev/null 2>&1
+	if [ $? -eq 0 ]; then
+	    C_LOGFILE=" --enable-logfile-monitor "
+	else
+	    ls /usr/lib/libpcre* >/dev/null 2>&1
+	    if [ $? -eq 0 ]; then
+		C_LOGFILE=" --enable-logfile-monitor "
+	    else
+		ls /usr/local/lib/libpcre* >/dev/null 2>&1
+		if [ $? -eq 0 ]; then
+		    C_LOGFILE=" --enable-logfile-monitor "
+		fi
+	    fi
+	fi
+	if [ x"${C_LOGFILE}" = x ]; then
+	    log_msg_ok  "Not testing  --enable-logfile-monitor";
+	fi
+
 	#
 	# test standalone compilation
@@ -37,5 +58,5 @@
 	fi
 	#
-	${TOP_SRCDIR}/configure --quiet $TRUST --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file --enable-debug '--enable-login-watch' '--enable-mounts-check' '--enable-logfile-monitor' '--enable-process-check' '--enable-port-check' '--enable-suidcheck' '--with-rnd=unix'
+	${TOP_SRCDIR}/configure --quiet $TRUST --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file --enable-debug '--enable-login-watch' '--enable-mounts-check' ${C_LOGFILE} '--enable-process-check' '--enable-port-check' '--enable-suidcheck' '--with-rnd=unix'
 	#
 	fail=0
Index: trunk/test/testrun_1.sh
===================================================================
--- trunk/test/testrun_1.sh	(revision 256)
+++ trunk/test/testrun_1.sh	(revision 257)
@@ -892,5 +892,5 @@
 	return 1
     fi
-    egrep "CRIT.*POLICY \[ReadOnly\] CL---M--TS.*${BASE}/b/l_x" $LOGFILE >/dev/null 2>&1
+    egrep "CRIT.*POLICY \[ReadOnly\] CL-.-M--TS.*${BASE}/b/l_x" $LOGFILE >/dev/null 2>&1
     if [ $? -ne 0 ]; then
 	[ -z "$verbose" ] || log_msg_fail "${BASE}/b/l_x";
