<br><font size=2 face="sans-serif">Greetings again,</font>
<br>
<br><font size=2 face="sans-serif">I couldn't let loose and started researching the problem - and finally found the bug ;)</font>
<br>
<br><font size=2 face="sans-serif">Nagios does indeed have a bug in config-file parsing when NSCORE is defined</font>
<br><font size=2 face="sans-serif">(which is actually always true afaik) and there is only ONE single object definition</font>
<br><font size=2 face="sans-serif">of any object (host, hostgroup, servicegroup, command, etc...)</font>
<br><font size=2 face="sans-serif">In the file common/objects.c the configs are read from the files, the corresponding</font>
<br><font size=2 face="sans-serif">objects created and added to the linked lists.</font>
<br>
<br><font size=2 face="sans-serif">At the end of each add_<some-structure>() function the adding to the linked list is incorrectly</font>
<br><font size=2 face="sans-serif">implemented.</font>
<br>
<br><font size=2 face="sans-serif">Example from objects.c  at the end of *add_host(...)</font>
<br><font size=2 face="sans-serif">(this code is true for every *add_<some-structure> in objects.c - just change the variable names)</font>
<br>
<br><font size=2 face="sans-serif">#ifdef NSCORE</font>
<br><font size=2 face="sans-serif">        /* hosts are sorted alphabetically for daemon, so add new items to tail of list */</font>
<br><font size=2 face="sans-serif">        if(host_list==NULL){</font>
<br><font size=2 face="sans-serif">                host_list=new_host;</font>
<br><font size=2 face="sans-serif">                host_list_tail=host_list;</font>
<br><font size=2 face="sans-serif">                }</font>
<br><font size=2 face="sans-serif">        host_list_tail->next=new_host;</font>
<br><font size=2 face="sans-serif">        host_list_tail=new_host;</font>
<br><font size=2 face="sans-serif">#else</font>
<br><font size=2 face="sans-serif">        /* hosts are sorted in reverse for CGIs, so add new items to head of list */</font>
<br><font size=2 face="sans-serif">        new_host->next=host_list;</font>
<br><font size=2 face="sans-serif">        host_list=new_host;</font>
<br><font size=2 face="sans-serif">#endif</font>
<br>
<br><font size=2 face="sans-serif">What happens is the following:</font>
<br>
<br><font size=2 face="sans-serif">1. host_list is NULL since it's the first entry the parser found so far.</font>
<br><font size=2 face="sans-serif">2. host_list and host_list_tail get initialized with the newly created object new_host, correct so far.</font>
<br>
<br><font size=2 face="sans-serif">But since the host_list just got initialiased the next steps don't make sense at all:</font>
<br><font size=2 face="sans-serif">(remember new_host and host_list are identical for the first parsed object!)</font>
<br>
<br><font size=2 face="sans-serif">3. new_host->next become host_list (aka. new_host)</font>
<br><font size=2 face="sans-serif">4 host_list (aka new_host) becomes new_host.</font>
<br>
<br><font size=2 face="sans-serif">Therefor host_list->next points to host_list again now.</font>
<br><font size=2 face="sans-serif">Voila, here we got the loop.</font>
<br><font size=2 face="sans-serif">host_list->next gets correctly overwritten when a second object is added and</font>
<br><font size=2 face="sans-serif">everything is fine, but if you only have a single definition of any kind of object -> BOOM!</font>
<br>
<br><font size=2 face="sans-serif">I provided a patch to fix the problem, encasing the last 2 statements in an else {} statement, so</font>
<br><font size=2 face="sans-serif">they don't get executed when the list just got initialised.</font>
<br>
<br><font size=2 face="sans-serif">have fun and merge it quickly ;)</font>
<br>
<br><font size=2 face="sans-serif">sash</font>
<br>
<br>
<br><font size=2 face="sans-serif">--------------------------------------------------<br>
Sascha Runschke<br>
Netzwerk Administration<br>
IT-Services<br>
<br>
ABIT AG<br>
Robert-Bosch-Str. 1<br>
40668 Meerbusch<br>
<br>
Tel.:+49 (0) 2150.9153.226<br>
mailto:SRunschke@abit.de<br>
<br>
http://www.abit.net<br>
http://www.abit-epos.net<br>
http://www.my-academy.net<br>
--------------------------------------------------<br>
Der Inhalt dieser Email sowie die Anhänge sind ausschließlich für den bezeichneten Adressaten bestimmt. Wenn Sie nicht der vorgesehene Adressat dieser Email oder dessen Vertreter sein sollten, so beachten Sie bitte, daß jede Form der Kenntnisnahme, Veröffentlichung,  Vervielfältigung oder Weitergabe des Inhalts dieser Email unzulässig ist. Wir möchten Sie außerdem darauf hinweisen, daß die Kommunikation per Email über das Internet unsicher ist, da fuer unberechtigte Dritte grundsätzlich die Möglichkeit der Kenntnisnahme und Manipulation besteht. Wenn Sie diese Nachricht versehentlich erhalten, informieren Sie bitte den Absender und löschen diese Nachricht mit den Anhängen. Herzlichen Dank<br>
<br>
The information and any attachments contained in this email are intended solely for the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any form of disclosure, reproduction, distribution or any action taken or refrained from in reliance on it, is prohibited and may be unlawful. We also like to inform you that communication via email over the internet is insecure because third parties may have the possibility to access and manipulate emails. If you have received the message in error, please advise the sender and delete the message and any attachments. Thank you very much.</font>