lib/nspath: Add leading slash when relative paths go to the root

When traversing backwards to or beyond the filesystem root, we used
to discard any and all slashes, which isn't very good. This patch
adds them back again, but only for backwards-traversing paths that
go to or beyond the filesystem root.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Try harder to make sense of the temp_path and temp_file

Since temp_path and temp_file are sort of cooperative, one can
override the other and it rarely makes sense to put tempfiles
in the same directory where one keeps the nagios.cfg file, we
special-case temp_file so it's relative to temp_path instead.

The change looks larger than it is, since we have to revamp the
ordering a bit in order to be able to use the temp_path directive
last seen in the config file and thus have to duplicate a bit of
error handling as well, but now a configuration such as

  temp_path=/usr/local/nagios/var
  temp_file=nagios.tmp

will cause temp_file to actually become
   temp_file=/usr/local/nagios/var/nagios.tmp

which makes sense and is less surprising than the alternative.

Also, since we do rely pretty hard on being able to generate temp
files, we make sure to have sensible fallbacks in case it's not
configured, with "nagios.tmp" being the standard base template for
the filename, and the environment variables TMPDIR and TMP setting
defaults for the temp directory, with "/tmp" as the ultimate
fallback.

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