Xymon Mailing List Archive search

building on Mandriva Corporate Server 4

list Henrik Størner
Wed, 22 Nov 2006 16:38:34 +0100
Message-Id: <user-29ec6a4044d7@xymon.invalid>

On Wed, Nov 22, 2006 at 06:54:18AM -0600, Daniel J McDonald wrote:
Now, reading through the strace, I think it is dying when
reading /etc/hobbit/hobbitlaunch.d/ There are no files there.  Let's see
what happens when I add one.  I'll make it blank for now....

[mcdonalddj at ldap ~]$ sudo touch /etc/hobbit/hobbitlaunch.d/00_test.cfg
[mcdonalddj at ldap ~]$ ls -l /etc/hobbit/hobbitlaunch.d/00_test.cfg
-rw-r--r--  1 root root 0 Nov 22
06:41 /etc/hobbit/hobbitlaunch.d/00_test.cfg

And let's start it up again....  Hey, it starts now!  Yeah!
OK, this patch should fix it.


Regards,
Henrik

-------------- next part --------------
--- lib/stackio.c	2006/07/20 16:06:41	1.20
+++ lib/stackio.c	2006/11/22 15:36:31
@@ -388,15 +388,17 @@
 
 	closedir(dirfd);
 
-	if (fnsz) qsort(fnames, fnsz, sizeof(char *), namecompare);
-	for (i=0; (i<fnsz); i++) {
-		htnames_t *newitem = malloc(sizeof(htnames_t));
-		newitem->name = fnames[i];
-		newitem->next = fnlist;
-		fnlist = newitem;
-	}
+	if (fnsz) {
+		qsort(fnames, fnsz, sizeof(char *), namecompare);
+		for (i=0; (i<fnsz); i++) {
+			htnames_t *newitem = malloc(sizeof(htnames_t));
+			newitem->name = fnames[i];
+			newitem->next = fnlist;
+			fnlist = newitem;
+		}
 
-	xfree(fnames);
+		xfree(fnames);
+	}
 }
 
 char *stackfgets(strbuffer_t *buffer, char *extraincl)
@@ -438,7 +440,7 @@
 				xfree(tmp->name); xfree(tmp);
 				return stackfgets(buffer, extraincl);
 			}
-			else {
+			else if (fnlist) {
 				htnames_t *tmp = fnlist;
 
 				errprintf("WARNING: Cannot open include file '%s', line was:%s\n", fnlist->name, buffer);
@@ -447,6 +449,11 @@
 				if (eol) *eol = '\n';
 				return result;
 			}
+			else {
+				/* Empty directory include - return a blank line */
+				*result = '\0'; 
+				return result;
+			}
 		}
 	}
 	else if (result == NULL) {