Index: trunk/src/samhain_setpwd.c
===================================================================
--- trunk/src/samhain_setpwd.c	(revision 211)
+++ trunk/src/samhain_setpwd.c	(revision 212)
@@ -252,26 +252,26 @@
   if (argc < 4) 
     {
-      fprintf (stderr, _("\nUsage: samhain_setpwd <filename> <suffix> "\
+      fprintf (stderr, "%s", _("\nUsage: samhain_setpwd <filename> <suffix> "\
 	       "<new_password>\n\n"));
-      fprintf (stderr, _("   This program is a utility that will:\n"));
-      fprintf (stderr, _("    - search in the binary executable <filename> "\
-	       "for samhain's\n"));
-      fprintf (stderr, _("      compiled-in default password,\n"));
-      fprintf (stderr, _("    - change it to <new_password>,\n"));
-      fprintf (stderr, _("    - and output the modified binary to "\
+      fprintf (stderr, "%s", _("   This program is a utility that will:\n"));
+      fprintf (stderr, "%s", _("    - search in the binary executable "\
+	       "<filename> for samhain's\n"));
+      fprintf (stderr, "%s", _("      compiled-in default password,\n"));
+      fprintf (stderr, "%s", _("    - change it to <new_password>,\n"));
+      fprintf (stderr, "%s", _("    - and output the modified binary to "\
 	       "<filename>.<suffix>\n\n"));
-      fprintf (stderr, _("   To allow for non-printable chars, "\
+      fprintf (stderr, "%s", _("   To allow for non-printable chars, "\
 			 "<new_password> must be\n")); 
-      fprintf (stderr, _("   a 16-digit hexadecimal "\
+      fprintf (stderr, "%s", _("   a 16-digit hexadecimal "\
 	       "number (only 0-9,A-F allowed in input),\n"));
-      fprintf (stderr, _("   thus corresponding"\
+      fprintf (stderr, "%s", _("   thus corresponding"\
 			 "   to an 8-byte password.\n\n"));
-      fprintf (stderr, _("   Example: 'samhain_setpwd samhain new "\
+      fprintf (stderr, "%s", _("   Example: 'samhain_setpwd samhain new "\
 	       "4142434445464748'\n"));
-      fprintf (stderr, _("   takes the file 'samhain', sets the password to "\
-	       "'ABCDEFGH'\n")); 
-      fprintf (stderr, _("   ('A' = 41 hex, 'B' = 42 hex, ...) "\
+      fprintf (stderr, "%s", _("   takes the file 'samhain', sets the "\
+	       "password to 'ABCDEFGH'\n")); 
+      fprintf (stderr, "%s", _("   ('A' = 41 hex, 'B' = 42 hex, ...) "\
 	       "and outputs the result\n"));
-      fprintf (stderr, _("   to 'samhain.new'.\n"));
+      fprintf (stderr, "%s", _("   to 'samhain.new'.\n"));
       return  EXIT_FAILURE;
     }
@@ -360,5 +360,5 @@
 	{
 	  suc = 1;
-	  fprintf (stdout, _("INFO   old password found\n"));
+	  fprintf (stdout, "%s", _("INFO   old password found\n"));
 	  fflush(stdout);
 	  for (i = 0; i < 8; ++i)
@@ -409,5 +409,5 @@
   if (suc == 1 && badcnt == 7)
     {
-      fprintf (stdout, _("INFO   finished\n"));
+      fprintf (stdout, "%s", _("INFO   finished\n"));
       close (newf);
       close (oldf);
@@ -419,6 +419,6 @@
   lseek (newf, 0, SEEK_SET);
 
-  fprintf (stdout, _("INFO   Not found in first pass.\n"));
-  fprintf (stdout, _("INFO   Second pass ..\n"));
+  fprintf (stdout, "%s", _("INFO   Not found in first pass.\n"));
+  fprintf (stdout, "%s", _("INFO   Second pass ..\n"));
 
   /* offset the start point
@@ -449,5 +449,5 @@
 	{
 	  suc = 1;
-	  fprintf (stdout, _("INFO   old password found\n"));
+	  fprintf (stdout, "%s", _("INFO   old password found\n"));
 	  for (i = 0; i < 8; ++i)
 	    {
@@ -497,5 +497,5 @@
   if (suc == 1 && badcnt == 7)
     {
-      fprintf (stdout, _("INFO   finished\n"));
+      fprintf (stdout, "%s", _("INFO   finished\n"));
       fflush(stdout);
       return 0;
@@ -504,9 +504,9 @@
   if (suc == 0 || badcnt < 7)
     {
-      fprintf (stdout, _("ERROR incomplete replacement\n"));
+      fprintf (stdout, "%s", _("ERROR incomplete replacement\n"));
     }
   else 
     {
-      fprintf (stdout, _("ERROR bad replacement\n"));
+      fprintf (stdout, "%s", _("ERROR bad replacement\n"));
     }
   fflush(stdout);
Index: trunk/src/samhain_stealth.c
===================================================================
--- trunk/src/samhain_stealth.c	(revision 211)
+++ trunk/src/samhain_stealth.c	(revision 212)
@@ -270,32 +270,35 @@
 static void usage ()
 {
-      fprintf(stdout, _("\nUsage:  samhain_stealth -i|s|g|o <where> "\
-			"[what]\n\n"));
-
-      fprintf(stdout, _("   -i info on PS image 'where'\n"));
-      fprintf(stdout, _("      (how much bytes can be hidden in it).\n"));
-      fprintf(stdout, _("   -s hide file 'what' in PS image 'where'\n"));
-      fprintf(stdout, _("   -g get hidden data from PS image 'where'\n"));
-      fprintf(stdout, _("      (output to stdout)\n"));
-      fprintf(stdout, _("   -o size of file 'where' = offset to "\
-			"end-of-file\n"));
-      fprintf(stdout, _("      (same as wc -c).\n\n"));
-      fprintf(stdout, _(" Example: let bar.ps be the ps file, and foo the config file\n"));
-      fprintf(stdout, _("   1) extract with: samhain_stealth -g bar.ps >foo\n"));
-      fprintf(stdout, _("   2) hide with:    samhain_stealth -s bar.ps foo\n\n"));
-
-      fprintf(stdout, _(" This program hides a file in an UNCOMPRESSED "\
-	      "postscript\n"));
-      fprintf(stdout, _(" image. To generate such an image, you may "\
-	      "use e.g.:\n"));
-      fprintf(stdout, _("   'convert +compress foo.jpg bar.ps'.\n"));
-      fprintf(stdout, _("   'gimp' apparently saves postscript uncompressed "\
-			"by default\n"));
-      fprintf(stdout, _("          (V 1.06 of the postscript plugin).\n"));
-      fprintf(stdout, _("   'xv' seems to save with run-length compression, "\
-	      "which is unsuitable.\n"));
-      fprintf(stdout, _(" The program does not check the compression type of "\
-	      "the PS file.\n"));
-      fprintf(stdout, _(" Just have a look at the result to check.\n"));
+      fprintf(stdout, "%s", _("\nUsage:  samhain_stealth -i|s|g|o <where> "\
+			      "[what]\n\n"));
+
+      fprintf(stdout, "%s", _("   -i info on PS image 'where'\n"));
+      fprintf(stdout, "%s", _("      (how much bytes can be hidden in it).\n"));
+      fprintf(stdout, "%s", _("   -s hide file 'what' in PS image 'where'\n"));
+      fprintf(stdout, "%s", _("   -g get hidden data from PS image 'where'\n"));
+      fprintf(stdout, "%s", _("      (output to stdout)\n"));
+      fprintf(stdout, "%s", _("   -o size of file 'where' = offset to "\
+			      "end-of-file\n"));
+      fprintf(stdout, "%s", _("      (same as wc -c).\n\n"));
+      fprintf(stdout, "%s", _(" Example: let bar.ps be the ps file, and"\
+			      "foo the config file\n"));
+      fprintf(stdout, "%s", _("   1) extract with: samhain_stealth "\
+			      "-g bar.ps >foo\n"));
+      fprintf(stdout, "%s", _("   2) hide with:    samhain_stealth "\
+			      "-s bar.ps foo\n\n"));
+
+      fprintf(stdout, "%s", _(" This program hides a file in an UNCOMPRESSED "\
+			      "postscript\n"));
+      fprintf(stdout, "%s", _(" image. To generate such an image, you may " \
+			      "use e.g.:\n"));
+      fprintf(stdout, "%s", _("   'convert +compress foo.jpg bar.ps'.\n"));
+      fprintf(stdout, "%s", _("   'gimp' apparently saves postscript "\
+			      "uncompressed by default\n"));
+      fprintf(stdout, "%s", _("         (V 1.06 of the postscript plugin).\n"));
+      fprintf(stdout, "%s", _("   'xv' seems to save with run-length "\
+			      "compression, which is unsuitable.\n"));
+      fprintf(stdout, "%s", _(" The program does not check the "\
+			      "compression type of the PS file.\n"));
+      fprintf(stdout, "%s", _(" Just have a look at the result to check.\n"));
       return;
 }
@@ -338,5 +341,6 @@
       if (fd == -1) 
 	{
-	  fprintf(stderr, _("Error: could not open() %s for reading\n"), argv[2]);
+	  fprintf(stderr, _("Error: could not open() %s for reading\n"), 
+		  argv[2]);
 	  return (1);
 	}
@@ -417,5 +421,5 @@
 	  return (1);
 	}
-      fprintf(stdout, _(" .. finished\n"));
+      fprintf(stdout, "%s", _(" .. finished\n"));
       return (0);
     }
@@ -458,4 +462,3 @@
   return (1);
 }
-  
-      
+
Index: trunk/src/sh_err_log.c
===================================================================
--- trunk/src/sh_err_log.c	(revision 211)
+++ trunk/src/sh_err_log.c	(revision 212)
@@ -665,5 +665,5 @@
 	  /* don't write second EOF mark
 	   */
-	  if (current->log_start != S_TRUE)
+	  if (current->log_start != S_TRUE && sh.flag.islocked == GOOD)
 	    {
 	      /* Don't use inet_peer == NULL, userwise a lock file will
Index: trunk/src/sh_extern.c
===================================================================
--- trunk/src/sh_extern.c	(revision 211)
+++ trunk/src/sh_extern.c	(revision 212)
@@ -31,6 +31,6 @@
  * for debugging
  */
-#if 1
-#define PDGBFILE "/home/rainer/PROJECTS/samhain/devel/pdbg."
+#if 0
+#define PDGBFILE "/pdbg."
 #endif
 
@@ -781,6 +781,4 @@
   struct  sigaction  new_act;
   struct  sigaction  old_act;
-  char  dir[SH_PATHBUF];
-  char * p;
   char * out = NULL;
   int    status;
@@ -1469,4 +1467,5 @@
   while (listval != NULL)
     {
+      PDBG_OPEN;
       PDBG(-2);
       if (t1 == listval->type[0] &&
Index: trunk/src/sh_hash.c
===================================================================
--- trunk/src/sh_hash.c	(revision 211)
+++ trunk/src/sh_hash.c	(revision 212)
@@ -1552,6 +1552,17 @@
 	      sh_error_handle((-1), FIL__, __LINE__, pushdata_fd, MSG_E_ACCESS,
 			      geteuid(), file_path('D', 'W'));
-	      SL_RET0(_("sh_hash_pushdata_int"));
+	      aud_exit(FIL__, __LINE__, EXIT_FAILURE);
 	    }
+
+	  if (SL_ISERROR(status = sl_lock (pushdata_fd)))
+	    {
+	      SH_FREE(fullpath);
+	      SH_FREE(linkpath);
+	      sh_error_handle((-1), FIL__, __LINE__, status, MSG_E_SUBGPATH,
+			      _("Failed to lock baseline database"), _("sh_hash_pushdata_int"),
+			      file_path('D', 'W'));
+	      aud_exit(FIL__, __LINE__, EXIT_FAILURE);
+	    }
+
 	  if ( SL_ISERROR(status = sl_forward(pushdata_fd))) 
 	    {
@@ -1559,7 +1570,7 @@
 	      SH_FREE(linkpath);
 	      sh_error_handle((-1), FIL__, __LINE__, status, MSG_E_SUBGPATH,
-			      _("Fast forward failed"), _("sh_hash_pushdata_int"),
+			      _("Failed to seek to end of baseline database"), _("sh_hash_pushdata_int"),
 			      file_path('D', 'W'));
-	      SL_RET0(_("sh_hash_pushdata_int"));
+	      aud_exit(FIL__, __LINE__, EXIT_FAILURE);
 	    }
 	}
@@ -1570,11 +1581,22 @@
 	{
 	  TPT((0, FIL__, __LINE__, _("msg=<Update.>\n")))
-	  if ( SL_ISERROR(pushdata_fd = sl_open_rdwr(file_path('D', 'W'), SL_YESPRIV))){
-	    SH_FREE(fullpath);
-	    SH_FREE(linkpath);
-	    sh_error_handle((-1), FIL__, __LINE__, pushdata_fd, MSG_E_ACCESS,
-			    geteuid(), file_path('D', 'W'));
-	    SL_RET0(_("sh_hash_pushdata_int"));
-	  }
+	    if ( SL_ISERROR(pushdata_fd = sl_open_rdwr(file_path('D', 'W'), SL_YESPRIV))){
+	      SH_FREE(fullpath);
+	      SH_FREE(linkpath);
+	      sh_error_handle((-1), FIL__, __LINE__, pushdata_fd, MSG_E_ACCESS,
+			      geteuid(), file_path('D', 'W'));
+	      aud_exit(FIL__, __LINE__, EXIT_FAILURE);
+	    }
+
+	  if (SL_ISERROR(status = sl_lock (pushdata_fd)))
+	    {
+	      SH_FREE(fullpath);
+	      SH_FREE(linkpath);
+	      sh_error_handle((-1), FIL__, __LINE__, status, MSG_E_SUBGPATH,
+			      _("Failed to lock baseline database"), _("sh_hash_pushdata_int"),
+			      file_path('D', 'W'));
+	      aud_exit(FIL__, __LINE__, EXIT_FAILURE);
+	    }
+
 	  line = SH_ALLOC(MAX_PATH_STORE+1);
 	  if (SL_ISERROR(sh_hash_setdataent_old (pushdata_fd, line, 
@@ -1585,5 +1607,5 @@
 	      SH_FREE(linkpath);
 	      SH_FREE(line);
-	      SL_RET0(_("sh_hash_pushdata_int"));
+	      aud_exit(FIL__, __LINE__, EXIT_FAILURE);
 	    }
 	  SH_FREE(line);
Index: trunk/src/sh_portcheck.c
===================================================================
--- trunk/src/sh_portcheck.c	(revision 211)
+++ trunk/src/sh_portcheck.c	(revision 212)
@@ -1218,8 +1218,13 @@
 /* Subroutine to add an interface
  */
+static void * sh_dummy_str    = NULL; /* fix clobbered by.. warning */
+
 static int sh_portchk_add_interface (const char * str)
 {
   struct in_addr   haddr;
   char errbuf[256];
+  char buf[64];
+
+  sh_dummy_str    = (void*) &str;
 
   if (iface_initialized == 0)
@@ -1229,18 +1234,33 @@
     }
 
-  if (0 == inet_aton(str, &haddr))
-    return -1;
-
-  if (iface_list.used == SH_IFACE_MAX)
-    return -1;
-
-  sl_snprintf(errbuf, sizeof(errbuf), _("interface: %s"), inet_ntoa(haddr));
-  SH_MUTEX_LOCK(mutex_thread_nolog);
-  sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, 0, MSG_E_SUBGEN, 
-		  errbuf, _("sh_portchk_add_interface"));
-  SH_MUTEX_UNLOCK(mutex_thread_nolog);
-
-  memcpy (&(iface_list.iface[iface_list.used].s_addr), &(haddr.s_addr), sizeof(in_addr_t));
-  ++iface_list.used;
+  do {
+
+    while (*str == ',' || *str == ' ' || *str == '\t') ++str;
+
+    if (*str)
+      {
+	unsigned int i = 0;
+	while (*str && i < (sizeof(buf)-1) && *str != ',' && *str != ' ' && *str != '\t')
+	  {
+	    buf[i] = *str; ++str; ++i;
+	  }
+	buf[i] = '\0';
+
+	if (0 == inet_aton(buf, &haddr))
+	  return -1;
+
+	if (iface_list.used == SH_IFACE_MAX)
+	  return -1;
+
+	sl_snprintf(errbuf, sizeof(errbuf), _("interface: %s"), inet_ntoa(haddr));
+	SH_MUTEX_LOCK(mutex_thread_nolog);
+	sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, 0, MSG_E_SUBGEN, 
+			errbuf, _("sh_portchk_add_interface"));
+	SH_MUTEX_UNLOCK(mutex_thread_nolog);
+	
+	memcpy (&(iface_list.iface[iface_list.used].s_addr), &(haddr.s_addr), sizeof(in_addr_t));
+	++iface_list.used;
+      }
+  } while (*str);
 
   return 0;
Index: trunk/src/slib.c
===================================================================
--- trunk/src/slib.c	(revision 211)
+++ trunk/src/slib.c	(revision 212)
@@ -2152,4 +2152,33 @@
 }
 
+int sl_lock (SL_TICKET ticket)
+{
+  int fd;
+  struct flock lock;
+  int retval;
+ 
+  SL_ENTER(_("sl_lock"));
+
+  if (SL_ISERROR(fd = get_the_fd (ticket)))
+    SL_IRETURN(fd, _("sl_lock"));
+
+  lock.l_type   = F_WRLCK;
+  lock.l_whence = SEEK_SET;
+  lock.l_start  = 0;
+  lock.l_len    = 0;
+
+  /* F_SETLK returns if the lock cannot be obtained */
+  do {
+    retval = fcntl(fd, F_SETLK, &lock);
+  } while (retval < 0 && errno == EINTR);
+
+  if (retval < 0 && errno == EBADF)
+    SL_IRETURN(SL_ETICKET, _("sl_lock"));
+  else if (retval < 0)
+    SL_IRETURN(SL_EBADFILE, _("sl_lock"));
+  else
+    SL_IRETURN(SL_ENONE, _("sl_lock"));
+ }
+ 
 int sl_close (SL_TICKET ticket) 
 {
