specfile updates by Daniel Wittenberg

Patched-by: Daniel Wittenberg <dwittenberg2008@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2746 5f96b256-904b-4d8d-8c98-d829582c6739
lib/test-runcmd: Enumerate the anomaly testcases

It's silly not to, since searching for the right C representation
of a shell-escaped string is just retardedly annoying.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2747 5f96b256-904b-4d8d-8c98-d829582c6739
lib/runcmd: Handle escaped glyphs in double-quoted strings properly

Previously, an argument such as "\\Key\Lalafoo\\Value" would get
translated to "\KeyLalafoo\Value", which is not how the shell does
it.

With this patch we get the properly escaped string \Key\Lalafoo\Value,
which is the same as /bin/echo produces with the above quoting, and
is what Nagios 3 used to execute when given such a string.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2748 5f96b256-904b-4d8d-8c98-d829582c6739
lib/runcmd: Grok escaped shell variables inside double-quoted strings

Previously we'd raise a flag for this (or perhaps that was just
because the latest patch), but with this addendum we handle it
properly once again.

While at it, we add a test-case for it to make sure we avoid
regressions.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2749 5f96b256-904b-4d8d-8c98-d829582c6739
.gitignore lib/test-{fanout,nsutils} and lib/core

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2750 5f96b256-904b-4d8d-8c98-d829582c6739
core: Fix macro initialization during reloads

When we originally start, the statically defined macro_keys array
is initialized with all zeroes, like the rest of the .bss segment,
but when we get a reload signal, it appears it's sometimes changed,
which caused us to url-encode certain macros that really shouldn't
be url-encoded.

With this patch, we should be able to lay issue 407 to rest for
Nagios 4.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2751 5f96b256-904b-4d8d-8c98-d829582c6739
Forward patch of SVN revision 2752

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2753 5f96b256-904b-4d8d-8c98-d829582c6739
xod: Plug a memory leak in xdata/xodtemplate.c

On soft reloads, we used to leak the bitmaps we created to track
contacts, hosts and services. This patch adds the necessary calls
to get rid of it.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2755 5f96b256-904b-4d8d-8c98-d829582c6739
xod: Make sure we free servicedependency templates

Apparently we forgot to do that earlier. For host dependencies this
doesn't seem to be a problem.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2756 5f96b256-904b-4d8d-8c98-d829582c6739
core: Avoid strdup()'ing group member names

Since we know all string lists are duplicated to kingdom come when
we inherit variable values, read them from config and register
objects, we can at least avoid duplicating them once again here,
cutting down memory used by lots, and allocations even more (making
it far more pleasant to run large configurations through valgrind).

The user-visible feature here is that error messages for non-existant
objects listed as members of some particular group can contain the
location in the configuration where things went south, which is
particularly helpful for larger configurations.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2757 5f96b256-904b-4d8d-8c98-d829582c6739
core: Assign strings rather than copying them when registering objects

This means we avoid one layer of strdup(). Since everything is
already copied from config to pre-objects anyway, and then from
templates to pre-objects, we really needn't bother with it when
creating the real objects too.

This cuts down the number of memory allocations by quite a significant
amount. We still copy everything from services though, since those
are duplicated per-object, and releasing duplicated services would
otherwise lead to heap corruption on double-free when we exit or
reload.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2758 5f96b256-904b-4d8d-8c98-d829582c6739
core: Stop leaking neb-modules on reloads and shutdowns

Only 40-ish bytes per module, but it's good to get valgrind to
shut the hell up.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2759 5f96b256-904b-4d8d-8c98-d829582c6739
core: Make valgrind report leaked and reachable memory more accurately

Mostly for the --verify-config case though, where we have to free
the nebmod lists and some miscellaneous variables.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2760 5f96b256-904b-4d8d-8c98-d829582c6739
xod: Avoid printf() calls

Changing it to a logging call makes a lot more sense.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2761 5f96b256-904b-4d8d-8c98-d829582c6739
core: free() more variables when quitting

While we'd like to get "No leaks possible" from valgrind, we'll
have to settle for the memory my_strtok() allocates and keeps a
pointer to (for now anyways).

We also make sure to assign more of the "runtime constant" macros
from our global variables, to avoid tracking both of them for leaks.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2762 5f96b256-904b-4d8d-8c98-d829582c6739
xod: Launch a massive strike in the war against strdup()

We already get an allocated and duplicated buffer from mmap_fgets(),
so there's no need for us copy it again, and then once more to get
the value part of the variable in a separate string.

Instead, we avoid the two extra copies per object config entry and
simply modify the input in-place.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2763 5f96b256-904b-4d8d-8c98-d829582c6739
xod: Stop segfaulting on contactgroup config verification

Previously we used to segfault when we encountered a contactgroup
with both contacts and contactgroups as members. This patch fixes
that.

Patched-by: Jeff <iamirix@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
xod: Remove an unused varaible

Shush, gcc, shush...

Signed-off-by: Andreas Ericsson <ae@op5.se>
test: Make test_timeperiods functional

I intend to refactor the time periods, and need a bit of encouragement
from something that tells me that everything is OK.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
utils: Refactor get_next_valid_time

There were several problems with how it worked, when faced with
exceptions and exclusions together with regular logic - Jean Gabes had
contributed several examples to the test_timeperiod suite that were
marked as TODO, that now passes just fine.

This code wraps the old logic in a loop. Once an exclusion hits, we
start over with checking for exceptions or weekday rules. If any rule
moves the match to tomorrow, we start over checking for new exclusions,
exceptions and weekday rules. Before, we didn't start over from scratch,
only on the "level" we had already reached.

Given that your timeperiod is crazy enough, or you use an empty
timeperiod to mean 24x7, nagios might spend slightly more time than
before figuring out your next valid time. The first case didn't behave
correctly before, so that's not a problem. For the second case, nagios
will only run it once, realize the check can't be scheduled, and leave
it alone, so that shouldn't affect things in practice.

The net line reduction comes from introducing a new helper, as
get_next_valid_time and check_time_against_period were using exactly the
same code to find rules to match against.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>