Page 1 of 1

Bug writing config files

Posted: Tue Jan 22, 2019 1:31 pm
by gzaloprgm
Hi
I've found a bug that affects the generation of certain config files. In my case it affected service groups, and caused some members of it to dissapear.

Steps to reproduce:
- Create host "host1"
- Create service with description "test100", add it to host1
- Create service with description "test10", add it to host1
- Create servicegroup, add both services to it.
- Press the "view config" button on the servicegroup (or apply config/write files)
- Inspect which members are included in the servicegroup. If the bug occurs, only one of the two services will appear as a member

Any naming of services that contains substrings might trigger the bug. For instance, calling services "Something" and "Something - extra" can trigger it. It is also dependent on the order in which they were created.

The bug seems to be caused by in includes/components/ccm/classes/config.class.php line 886:

Code: Select all

if (substr_count($value, $strHost.",".$strService) == 0) {
  $value .= $strHost.",".$strService.",";
}
As it can be seen, in order to avoid adding duplicated members to the member variable, it checks if the string "<hostName>,<serviceDescr>" exists in the string that contain the members that have already been added. This causes a bug if a service description is contained within another service description of the same host.

Thanks, Gonzalo

Re: Bug writing config files

Posted: Tue Jan 22, 2019 5:16 pm
by lmiltchev
I was able to recreate the problem, and filed an internal bug report (task_id=14007). Thank you for reporting this issue!