When cfagent - inside IDClasses() - sees that the /etc/vmware directory exists, it assumes that the host is a VMware server, defines the VMware class and calls VM_version(). This function tries to open /etc/issue and define classes based on its contents.

However, if /etc/issue is an empty file, cfagent will hang forever. A glance at line 1212 of misc.c reveals why:

    do
       {
       fgets(buffer,sizeof(buffer), fp);
       Chop(buffer);
       len = strlen(buffer);
       }
    while (len == 0);

This patch fixes the bug by exiting the loop when the return value of fgets() is NULL, which the manpage states will be the case on read error or at EOF.
--- cfengine-2.2.1/src/misc.c.orig	2007-09-13 15:48:36.755966000 +0100
+++ cfengine-2.2.1/src/misc.c	2007-09-14 09:42:57.503740000 +0100
@@ -1211,11 +1211,11 @@
 
 do
    {
-   fgets(buffer,sizeof(buffer), fp);
+   sp = fgets(buffer,sizeof(buffer), fp);
    Chop(buffer);
    len = strlen(buffer);
    }
-while (len == 0);
+while (sp != NULL);
 
 AddClassToHeap(CanonifyName(buffer));
 
_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine

Reply via email to