Forward patch of fix for bug #369

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2608 5f96b256-904b-4d8d-8c98-d829582c6739
dkhash: memory leak and possible loss of objects in dkhash_remove

Pointer to previous in dkhash_remove was only set for first element
in a given bucket. So when finding for example third object for
removal, setting prev->next=obj->next looses the reference to the
old prev->next, which is the second object in the list.

This can be tested by creating a hash map of one bucket (practically
a linked list), and fill and remove all, both forward and backward.
Such tests are also added with this patch.

Signed-off-by: Max Sikström <msikstrom@op5.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2612 5f96b256-904b-4d8d-8c98-d829582c6739
Add Max Sikström to THANKS-file

298 people on it now. Pretty damn impressive, tbh :)

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2613 5f96b256-904b-4d8d-8c98-d829582c6739
Add Dan Wittenberg and Mark Frost to THANKS

For invaluable testing, numerous bugreports and being generally
cool guys.

And now that we're 300, I just have to say;

This...

is!

SPAARTAA!!!!!!

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2614 5f96b256-904b-4d8d-8c98-d829582c6739
lib/dkhash: *really* fix memory leak and possible loss of objects

The previous fixes to dkhash_remove() were mangled beyond usefulness
from the original patch by yours truly. This additional patch fixes
it while retaining the nagios codestyle intact.

Mea culpa.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2615 5f96b256-904b-4d8d-8c98-d829582c6739
core: Fix logfile permissions, attila style

In the case where we're started as root, there are issues in the
configuration and we have no logfile, such as when a user first
installs Nagios and fires it up via the init-script through a
reboot, we will fail to open the logfile after having dropped
root privilegs.

With this patch, we chown the logfile and debug logfile to the
destination user just before we call setgid() and setuid(),
which is the hardcore way of making sure we can always write
to our logfile.

In the case where we're running as a non-root user, the call
is never made and we rely on the check to see if we can open
the logfile after privileges are dropped for proper logging.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2618 5f96b256-904b-4d8d-8c98-d829582c6739
base/nagios: Stop truncating nagios.log when doing sanity checks

That means we aren't allowed to try to open the logfiles with
"w" when checking if we *can* open it, since that truncates the
file.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2619 5f96b256-904b-4d8d-8c98-d829582c6739
downtime: Fix crash when using distributable downtime commands

The function that implements the distributable downtime commands kept a
pointer to the next downtime, which is a rubbish idea when the
unschedule_downtime deletes any triggered_by downtimes, and scheduled
downtimes triggered by this one typically start at the first element
right after this one.

To get nagios to crash using the old code, get a configuration with a
few hosts, make all of them depend on one single host, schedule and
propagate a triggered host downtime on the parent, and then unschedule
the downtime on the parent using, for example,
DEL_DOWNTIME_BY_HOST_NAME.

This prevents the crash by first locating any matching downtimes and
copying the information about the downtime type and id to a separate
downtime list, and only then try to unschedule anything. This might lead
to unschedule_downtime having to look for downtimes that no longer
exist, which is slow, but it should only really happen for
DEL_DOWNTIME_BY_START_TIME_COMMENT. I can see no easy way around this
without breaking API and/or ABI.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2620 5f96b256-904b-4d8d-8c98-d829582c6739