Index: trunk/src/samhain.c
===================================================================
--- trunk/src/samhain.c	(revision 84)
+++ trunk/src/samhain.c	(revision 86)
@@ -1443,5 +1443,6 @@
 
 #if (defined(WITH_GPG) || defined(WITH_PGP))
-  /* do nothing -- we exit earlier if error */
+  /* log startup */
+  sh_gpg_log_startup ();
 #else
   sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_START_1H,
@@ -1465,5 +1466,6 @@
     {
 #if (defined(WITH_GPG) || defined(WITH_PGP))
-      /* do nothing -- we exit earlier if error */
+      /* log startup */
+      sh_gpg_log_startup ();
 #else
       sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_START_2H,
@@ -1476,5 +1478,6 @@
     {
 #if (defined(WITH_GPG) || defined(WITH_PGP))
-      /* do nothing -- we exit earlier if error */
+      /* log startup */
+      sh_gpg_log_startup ();
 #else
       sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_START_1H,
Index: trunk/src/sh_error.c
===================================================================
--- trunk/src/sh_error.c	(revision 84)
+++ trunk/src/sh_error.c	(revision 86)
@@ -110,4 +110,7 @@
 int  OnlyStderr    = S_TRUE; 
 
+/* --- Enable facilities not safe for closeall(). --- 
+ */
+int  enableUnsafe  = S_FALSE;
 
 /*********************************************
@@ -145,4 +148,10 @@
 {
   OnlyStderr    = flag;
+  return;
+}
+
+void sh_error_enable_unsafe (int flag)
+{
+  enableUnsafe    = flag;
   return;
 }
@@ -1026,5 +1035,5 @@
   /* Full logging enabled.
    */
-  if (OnlyStderr == BAD)  /* full error logging enabled */
+  if (OnlyStderr == S_FALSE)  /* full error logging enabled */
     {
 
@@ -1083,5 +1092,5 @@
 	  class != AUD)
 	{
-	  if (database_block == 0)
+	  if (database_block == 0 && enableUnsafe == S_TRUE)
 	    {
 	      /* truncates; query_max is 16k
@@ -1209,5 +1218,5 @@
 	  )
 	{
-	  if (prelude_block == 0)
+	  if (prelude_block == 0 && enableUnsafe == S_TRUE)
 	    {
 	      /* will truncate to 998 bytes 
Index: trunk/src/sh_gpg.c
===================================================================
--- trunk/src/sh_gpg.c	(revision 84)
+++ trunk/src/sh_gpg.c	(revision 86)
@@ -115,4 +115,5 @@
 
 #ifdef GPG_HASH
+
 static int sh_gpg_checksum (SL_TICKET checkfd, int flag)
 {
@@ -202,4 +203,39 @@
 }
 #endif
+
+struct startup_info {
+  long   line;
+  char * program;
+  long   uid;
+  char * path;
+  char * key_uid;
+  char * key_id;
+};
+
+static struct startup_info startInfo = { 0, NULL, 0, NULL, NULL, NULL };
+
+void sh_gpg_log_startup ()
+{
+  if (startInfo.program != NULL)
+    {
+      sh_error_handle ((-1), FIL__, startInfo.line, 0, MSG_START_GH,
+		       startInfo.program, startInfo.uid,
+		       startInfo.path,
+		       startInfo.key_uid, startInfo.key_id);
+    }
+  return;
+}
+
+static void sh_gpg_fill_startup (long line, char * program, long uid, char * path, 
+				 char * key_uid, char * key_id)
+{
+  startInfo.line    = line;
+  startInfo.program = sh_util_strdup(program);
+  startInfo.uid     = uid;
+  startInfo.path    = sh_util_strdup(path);
+  startInfo.key_uid = sh_util_strdup(key_uid);
+  startInfo.key_id  = sh_util_strdup(key_id);
+  return;
+}
 
 static FILE * sh_gpg_popen (sh_gpg_popen_t  *source, int fd, 
@@ -968,5 +1004,6 @@
 	    {
 	      tmp  = sh_util_safe_name(gp.conf_id);
-	      sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_START_GH,
+	      sh_gpg_fill_startup (
+				   /* sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_START_GH, */
 			       sh.prg_name, sh.real.uid,
 			       (sh.flag.hidefile == S_TRUE) ? 
@@ -995,5 +1032,6 @@
 	{
 	  tmp = sh_util_safe_name(gp.conf_id);
-	  sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_START_GH,
+	  sh_gpg_fill_startup (__LINE__,
+	  /* sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_START_GH, */
 			   sh.prg_name, sh.real.uid,
 			   (sh.flag.hidefile == S_TRUE) ? 
Index: trunk/src/sh_prelude.c
===================================================================
--- trunk/src/sh_prelude.c	(revision 84)
+++ trunk/src/sh_prelude.c	(revision 86)
@@ -967,5 +967,8 @@
 }
 
-
+/* Allow initialization of prelude; to be called
+ * after forking the daemon. Delays heartbeat
+ * start after config read until it is safe.
+ */
 void sh_prelude_reset(void)
 {
Index: trunk/src/sh_unix.c
===================================================================
--- trunk/src/sh_unix.c	(revision 84)
+++ trunk/src/sh_unix.c	(revision 86)
@@ -1880,4 +1880,5 @@
 	}
 
+      sh_error_enable_unsafe (S_TRUE);
 #if defined(HAVE_LIBPRELUDE)
       sh_prelude_reset ();
@@ -1913,4 +1914,5 @@
     {
       sh_unix_closeall(3, -1);  /* if not daemon */
+      sh_error_enable_unsafe (S_TRUE);
 #if defined(HAVE_LIBPRELUDE)
       sh_prelude_reset ();
