bug in finding a contact

This forum is intended for the discussion of Nagios Core development. Feature requests, patches, bug fixes, and all types of development-related discussions are welcome!

NOTE: The SourceForge.net nagios-devel mailing list has been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

bug in finding a contact

Postby eponymousalias » Tue Jun 27, 2017 11:11 pm

The following bug (with the fix shown here) appears
in the find_contact_by_name_or_alias() routine in
Nagios 4.3.2 and various earlier releases:

Code: Select all
nagios-4.3.2/base % diff -u notifications.c.orig notifications.c
--- notifications.c.orig        2017-05-09 10:03:31.000000000 -0700
+++ notifications.c     2017-06-27 20:41:48.332519925 -0700
@@ -36,7 +36,7 @@
        contact *c = NULL;

-       if (!name || !(c = find_contact(name)))
+       if (!name || (c = find_contact(name)))
                return c;
        for (c = contact_list; c; c = c->next)
                if (!strcmp(c->alias, name))

With the present code, the contact is pretty much guaranteed not to
be found. If the correct contact name is given, it will be ignored.
And the alias is not likely to be identical to the name, so that will
be ignored as well. The corrected code recognizes when find_contact()
has found the desired contact, and returns that result.

I don't know how much of a difference fixing this will make, considering
for instance that on line 958 of base/checks.c, the service_notification()
routine is called with a NULL third parameter (for the not_author
argument of that routine). But perhaps there are other calls where it
might matter, or perhaps (I haven't checked any of this) that call might
now be modified to specify some particular author for the notification.
Posts: 8
Joined: Mon Mar 07, 2016 5:38 am

Re: bug in finding a contact

Postby bheden » Wed Jun 28, 2017 12:58 pm

Can you create a Pull Request on GitHub and I'll merge it in?

As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Nagios Enterprises
Product Development Manager
User avatar
Product Development Manager
Posts: 166
Joined: Thu Feb 13, 2014 9:50 am
Location: Nagios Enterprises

Re: bug in finding a contact

Postby eponymousalias » Thu Jun 29, 2017 5:08 pm

I'm not a github guy, so I won't do a pull request. But it's just a one-character change (eliminate a single bang character); you can handle that easily enough.

More important is testing the change, to prove that it's worthwhile and that it actually changes the existing behavior as desired. I forgot to mention in the original post where the effect of this bug shows up. If the contact cannot be found, the $NOTIFICATIONAUTHORNAME$ and $NOTIFICATIONAUTHORALIAS$ macros do not get expanded when they should be. We've seen that happen in particular during an acknowledgement notification. So this bug does have an externally observable effect.
Posts: 8
Joined: Mon Mar 07, 2016 5:38 am

Re: bug in finding a contact

Postby dwhitfield » Fri Jun 30, 2017 11:53 am

The developers are aware of the issue. Did you have anything else you wanted to add, or should I go ahead and lock the thread?

Thanks again for posting the fix!
Former Nagios Staff
Posts: 4569
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN

Re: bug in finding a contact

Postby eponymousalias » Fri Jun 30, 2017 9:14 pm

No, there's nothing more to add.
Posts: 8
Joined: Mon Mar 07, 2016 5:38 am

Re: bug in finding a contact

Postby tmcdonald » Wed Jul 05, 2017 9:42 am

I'll be closing this thread now, but feel free to open another if you need anything in the future!
Former Nagios employee
Posts: 9118
Joined: Mon Sep 23, 2013 8:40 am

Return to Nagios Core Development

Who is online

Users browsing this forum: No registered users and 5 guests