Index: /trunk/config.h.in
===================================================================
--- /trunk/config.h.in	(revision 490)
+++ /trunk/config.h.in	(revision 491)
@@ -540,4 +540,7 @@
 /* Define to 1 if you have the <fnmatch.h> header file. */
 #undef HAVE_FNMATCH_H
+
+/* Define to 1 if you have the `fpurge' function. */
+#undef HAVE_FPURGE
 
 /* Define to 1 if you have the `getaddrinfo' function. */
Index: /trunk/configure.ac
===================================================================
--- /trunk/configure.ac	(revision 490)
+++ /trunk/configure.ac	(revision 491)
@@ -12,5 +12,5 @@
 dnl start
 dnl
-AM_INIT_AUTOMAKE(samhain, 4.1.0)
+AM_INIT_AUTOMAKE(samhain, 4.1.1)
 AC_DEFINE([SAMHAIN], 1, [Application is samhain])
 AC_CANONICAL_HOST
@@ -378,5 +378,5 @@
 dnl *****************************************
 AC_FUNC_STRFTIME
-AC_CHECK_FUNCS(memcmp memcpy memmove memset getpwent endpwent \
+AC_CHECK_FUNCS(memcmp memcpy memmove memset getpwent endpwent fpurge \
 	gettimeofday strlcat strlcpy strstr strchr strerror strsignal \
 	seteuid setreuid setresuid lstat getwd getcwd ptrace \
Index: /trunk/docs/Changelog
===================================================================
--- /trunk/docs/Changelog	(revision 490)
+++ /trunk/docs/Changelog	(revision 491)
@@ -1,2 +1,8 @@
+4.1.1:
+	* fix problem with baseline update on FreeBSD and probably other
+	non-GNU/Linux systems (reported by L.Vasiliev)
+	* fix bad check_libwrap() call in sh_xfer_server.c
+	(reported by L.Vasiliev)
+
 4.1.0:
 	* fix quirks with Linux audit support
Index: /trunk/src/sh_dbIO.c
===================================================================
--- /trunk/src/sh_dbIO.c	(revision 490)
+++ /trunk/src/sh_dbIO.c	(revision 491)
@@ -156,5 +156,5 @@
 {
   FILE * fdp;
-
+  
   SL_ENTER(_("sh_dbIO_setdataent_old"));
 
@@ -163,4 +163,7 @@
   if (0 != seek_sof(fdp, line, size, file))
     SL_RETURN( SL_EREAD, _("sh_dbIO_setdataent_old"));
+
+  lseek(fileno(fdp), ftello(fdp), SEEK_SET);
+
   if (0 != ftruncate(fileno(fdp), ftello(fdp)))
     {
@@ -406,5 +409,5 @@
        _("There is a record with a bad version number in the file signature database: %s\n"),
        (NULL == filepath) ? _("(null)") : filepath);
-  sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGPATH,
+  sh_error_handle((-1), file, line, 0, MSG_E_SUBGPATH,
 		  _("Record with bad version number in file signature database"), 
 		  _("sh_dbIO_getdataent"),
@@ -1331,7 +1334,34 @@
   if (pushdata_stdout == S_FALSE)
     {
-      sl_write           (fd,        p, sizeof(sh_filestore_t));
-      sl_write_line_fast (fd, fullpath, sl_strlen(fullpath));
-      sl_write_line_fast (fd,    lpath, sl_strlen(lpath));
+      if (SL_ENONE != sl_write (fd,        p, sizeof(sh_filestore_t)))
+	{
+	  char * tmp = sh_util_safe_name(fullpath);
+	  sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGPATH,
+			  _("Failed to write record to baseline database"),
+			  _("write_record"),
+			  tmp);
+	  SH_FREE(tmp);
+	  aud_exit(FIL__, __LINE__,  EXIT_FAILURE );
+	}
+      if (SL_ENONE != sl_write_line_fast (fd, fullpath, sl_strlen(fullpath)))
+	{
+	  char * tmp = sh_util_safe_name(fullpath);
+	  sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGPATH,
+			  _("Failed to write path to baseline database"),
+			  _("write_record"),
+			  tmp);
+	  SH_FREE(tmp);
+	  aud_exit(FIL__, __LINE__,  EXIT_FAILURE );
+	}
+      if (SL_ENONE != sl_write_line_fast (fd,    lpath, sl_strlen(lpath)))
+	{
+	  char * tmp = sh_util_safe_name(fullpath);
+	  sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGPATH,
+			  _("Failed to write lpath to baseline database"),
+			  _("write_record"),
+			  tmp);
+	  SH_FREE(tmp);
+	  aud_exit(FIL__, __LINE__,  EXIT_FAILURE );
+	}
       if (attr_string)
 	sl_write_line_fast (fd, attr_string, sl_strlen(attr_string));
Index: /trunk/src/sh_extern.c
===================================================================
--- /trunk/src/sh_extern.c	(revision 490)
+++ /trunk/src/sh_extern.c	(revision 491)
@@ -978,4 +978,7 @@
     */
    new_act.sa_handler = SIG_IGN;
+   new_act.sa_flags   = 0;
+   sigemptyset( &new_act.sa_mask );
+   
    (void) retry_sigaction (FIL__, __LINE__, SIGPIPE, &new_act, &old_act);
    
Index: /trunk/src/sh_sub.c
===================================================================
--- /trunk/src/sh_sub.c	(revision 490)
+++ /trunk/src/sh_sub.c	(revision 491)
@@ -184,5 +184,8 @@
 	   */
 	  act.sa_handler = SIG_DFL;
-	  for (i = 0; i < NSIG; ++i)
+	  act.sa_flags   = 0;
+	  sigemptyset( &act.sa_mask );
+	  
+	  for (i = 1; i < NSIG; ++i)
 	    sigaction(i, &act, NULL);
 	  SH_SETSIGMASK(SIG_UNBLOCK, &signal_set_new, NULL);
Index: /trunk/src/sh_xfer_server.c
===================================================================
--- /trunk/src/sh_xfer_server.c	(revision 490)
+++ /trunk/src/sh_xfer_server.c	(revision 491)
@@ -2858,5 +2858,5 @@
 
 #ifdef SH_USE_LIBWRAP
-  if (check_libwrap(rc) < 0)
+  if (check_libwrap(rc, newconn) < 0)
     SL_RETURN( (-1), _("sh_xfer_accept"));
 #endif
Index: /trunk/test/testhash.sh
===================================================================
--- /trunk/test/testhash.sh	(revision 490)
+++ /trunk/test/testhash.sh	(revision 491)
@@ -63,5 +63,5 @@
 	fi
 	#
-	${TOP_SRCDIR}/configure --enable-debug=gdb --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-db-reload '--enable-login-watch' '--enable-mounts-check' ${C_LOGFILE} '--enable-port-check' '--enable-message-queue'
+	${TOP_SRCDIR}/configure --enable-debug=gdb --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-db-reload '--enable-login-watch' '--enable-mounts-check' ${C_LOGFILE} '--enable-port-check' '--enable-message-queue' '--enable-suidcheck' '--disable-dnmalloc'
 	#
 	fail=0
