Index: trunk/src/sh_err_log.c
===================================================================
--- trunk/src/sh_err_log.c	(revision 409)
+++ trunk/src/sh_err_log.c	(revision 410)
@@ -1058,4 +1058,19 @@
 static char * gEfile = NULL;
 static int    gFail  = 0;
+static long   gGid   = 0;
+
+int sh_efile_group(const char * str)
+{
+  int  fail;
+  long gid = sh_group_to_gid(str, &fail);
+
+  if (fail < 0)
+    {
+      return -1;
+    }
+  gGid = gid;
+  return 0;
+}
+
 
 int sh_efile_path(const char * str) 
@@ -1148,4 +1163,24 @@
 	      fchmod (filed, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
 	      sl_close (fd);
+	    }
+	  else
+	    {
+	      static int nFail = 0;
+
+	      if (nFail == 0)
+		{
+		  char errmsg[1024];
+		  char * tmp  = sh_util_safe_name (lockfile);
+		  
+		  sl_snprintf(errmsg, sizeof(errmsg), 
+			      _("Error creating lockfile %s"),
+			      tmp);
+		  
+		  sh_error_handle (SH_ERR_ERR, FIL__, __LINE__, 
+				   0, MSG_E_SUBGEN,
+				   errmsg, _("sh_efile_lock"));
+		  ++nFail;
+		  SH_FREE(tmp);
+		}
 	    }
 	}
@@ -1191,4 +1226,5 @@
 void sh_efile_report()
 {
+  extern int get_the_fd (SL_TICKET ticket);
   SL_TICKET     fd;
   char         *efile;
@@ -1226,4 +1262,5 @@
 
 	      time_t now = time(NULL);
+	      int  filed = get_the_fd(fd);
 
 	      (void) sh_unix_time (now, tstamp, sizeof(tstamp));
@@ -1233,5 +1270,6 @@
 			  tstamp,
 			  (long long) now,
-			  tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5]);
+			  (long) tmp[0], (long) tmp[1], (long) tmp[2], 
+			  (long) tmp[3], (long) tmp[4], (long) tmp[5]);
 #else
 	      sl_snprintf(report, sizeof(report), 
@@ -1239,5 +1277,6 @@
 			  tstamp,
 			  (long) now,
-			  tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5]);
+			  (long) tmp[0], (long) tmp[1], (long) tmp[2], 
+			  (long) tmp[3], (long) tmp[4], (long) tmp[5]);
 #endif
 			  
@@ -1246,4 +1285,30 @@
 		status = sl_write (fd, report,  strlen(report));
 	      (void) sl_sync(fd);
+
+	      /* make group writeable, such that nagios can truncate */
+	      fchmod (filed, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
+	      status = fchown (filed, -1, gGid);
+	      if (status < 0)
+		{
+		  int  errnum = errno;
+		  static int nFail = 0;
+		  if (nFail == 0)
+		    {
+		      char errmsg[1024];
+		      char buf[256];
+		      char * tmp  = sh_util_safe_name (efile);
+
+		      sl_snprintf(errmsg, sizeof(errmsg), 
+				  _("Error changing group of %s to %ld: %s"),
+				  tmp, gGid, 
+				  sh_error_message (errnum, buf, sizeof(buf)));
+		      sh_error_handle (SH_ERR_ERR, FIL__, __LINE__, 
+				       errnum, MSG_E_SUBGEN,
+				       errmsg, _("sh_efile_report"));
+		      ++nFail;
+		      SH_FREE(tmp);
+		    }
+		}
+
 	      (void) sl_close(fd);
 	    }
Index: trunk/src/sh_readconf.c
===================================================================
--- trunk/src/sh_readconf.c	(revision 409)
+++ trunk/src/sh_readconf.c	(revision 410)
@@ -1218,4 +1218,6 @@
   { N_("setreportfile"),     SH_SECTION_MISC,  SH_SECTION_NONE, 
     sh_efile_path },
+  { N_("setreportgroup"),    SH_SECTION_MISC,  SH_SECTION_NONE, 
+    sh_efile_group },
 
 #ifdef WITH_MESSAGE_QUEUE
Index: trunk/src/sh_unix.c
===================================================================
--- trunk/src/sh_unix.c	(revision 409)
+++ trunk/src/sh_unix.c	(revision 410)
@@ -1000,4 +1000,63 @@
 }
 
+
+/* ---------------------------------------------------------------- */
+
+long sh_group_to_gid (const char * g, int * fail)
+{
+  struct group *           w;
+  gid_t                    gid  = 0;
+
+#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
+  struct group     grp;
+  char           * buffer;
+#endif
+
+  *fail = -1;
+
+  if (g)
+    {
+      size_t i;
+      size_t len = strlen(g);
+
+      *fail = 0;
+
+      for (i = 0; i < len; ++i)
+	{
+	  char c = g[i];
+
+	  if (!isdigit((int) c))
+	    goto is_a_name;
+	}
+      return atol(g);
+
+    is_a_name:
+
+#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
+      buffer = SH_ALLOC(SH_GRBUF_SIZE);
+      sh_getgrnam_r(g, &grp, buffer, SH_GRBUF_SIZE, &w);
+#else
+      w = sh_getgrnam(g);
+#endif
+
+      if (w == NULL)
+	{
+	  char * tmp = sh_util_strdup(g);
+	  sh_error_handle ((-1), FIL__, __LINE__, EINVAL, MSG_EINVALS, 
+			   _("sh_group_to_gid"), tmp);
+	  SH_FREE(tmp);
+	  *fail = -1;
+	}
+      else
+	{
+	  gid = w->gr_gid;
+	}
+#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
+      SH_FREE(buffer);
+#endif
+    }
+
+  return gid;
+}
 
 /* ---------------------------------------------------------------- */
