build: fix for compilers without -Wno-unused-result

Naemon and its lib - and thus also its misplaced lib tests - are built
with -Werror, and if the compiler doesn't like -Wno-unused-result, the
unused results will cause compilation errors.

Fix this by testing the results, as that could in fact prevent bugs.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
Remove global PROGRAM_VERSION symbol

autoconf (or is it automake?) provides us with a VERSION symbol which
does the same thing, so we don't need it.

If we do want the version in a module, we can still use
get_program_version to get it - though unlike the PROGRAM_VERSION
definition, this won't return the version of naemon that the module was
built against, but instead the version it's running against. Which is
probably going to be more useful, anyway.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
makefile: Make init script executable by default

Unexecutable scripts aren't really that useful as scripts.

Change-Id: I75466a83d582796d8e8274aabd9f7239d00a0c66
Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
configure: Give logrotate dir a default

Why would installing it into /naemon be a sane default?

Change-Id: I0b10a9fd36e6b61b7dd5edf99c20cee03462e325
Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
init: Specify variable the rest of the file uses

It's used indirectly all over, as it's used in the defaults for the
pidfiledir.

Change-Id: I3aec4fa8985c53c4c4724bb48bbef9896cf108ec
Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
configure: Use the specified user/group

Instead of defining that the user is always naemon, but there's also a
pretty, decorative --with flag where you can feed a username, not that
we'll care about it.

Change-Id: I643c4feedc4c6fa3872c378a895249f4a50a906a
Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
init: Use the configured user/group

Instead of a hardcoded one.

Change-Id: I4987456799bd6451eb00fe495c29c70f2ee789a5
Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
xodtemplate: Fix the regression in naemon bug #68

Fix it by once again completely ignoring the return value - this is what
nagios always did, and it worked splendidly.

Change-Id: Iaf7fbeb3c1cce73939188ea5e97769821882f4f9
Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
makefile.am: Don't pretend /var is the correct dir for non-config files

They should go into /var, yes, but in an appropriate subdirectory. Let's
go with /var/cache/naemon as that's where we currently store the pid
file.

You're telling me that's weird? Yes. Yes it is. But half the files
that uses this variable really are cache, while the other half is state,
and I don't care enough to separate them anymore.

Change-Id: Ifd1f6f147cc41e3d8a8ed22e528ccce1abe3dd03
Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
comments: Put back support for deleting host downtime comments

13d3a7d didn't just got rid of xcddefault.[ch], it also got rid of
the way that scheduled host downtimes are connected to their comments.
This puts that back into place, while also making me question the very
meaning of life.

Change-Id: I485a012281a58db099a7857d2492683a9327689a
Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
comments: Fix code for ensuring unique comment id

The code tried to ensure it wouldn't overwrite anything by always
looking up the next_comment_id, and if it existed due to weird reasons,
it would increase next_comment_id until it found a comment id that was
completely free.

The problem is, it only checked if there was a host comment when it was
adding a host comment, and only if there was a service comment when it
was adding a service comment. As host and service comments belong to the
same array, we need to check if either of the two comment types already
hold the next_comment_id slot, or else the two comment types will risk
overwriting each other's comments.

Change-Id: Id450e54d8f72dfdf9676250268b0ea659fc16a87
Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
Add main config include support

This works by you adding (probably) include_dir or (unlikely)
include_file into your nagios.cfg, and point it to a file where modules
can dump their config. If you use include_dir, make sure your config
files are called whatever.cfg, or naemon will proceed to ignore the
file - this lets a user dump, say, a README file into their config dir,
without naemon complaining that it's not a valid config file.

The settings in the subfile(s) are included as if the contents of the
subfile had been at the line that contains the include line, just like a
C preprocessor statement.

Perhaps unintuitively (or not, depending on what your intuition tells
you), all relative paths are relative to the main config file. While
it's not the case technically, you should pretend that naemon chdir()ed
into the directory where the main naemon.cfg file is located, and then
resolved all paths relative to the cwd.

In order for this to work with cfg_file and cfg_dir statements - which
used to be parsed by a separate nagios.cfg "parser" (because why
anything?), I've introduced two more globals. I feel very bad about
this.

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