Fixed bug where selecting Command Expansion from Configuration CGI page would display commands instead

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2621 5f96b256-904b-4d8d-8c98-d829582c6739
Updated CGI utility functions to support UTF-8 characters

Specifically the escape_string() function in cgiutils.c was updated. 
In order to support this we needed to set the encoding which is set 
using setlocale(). 

Because setlocale() specifies both the language and the encoding, 
the function that reads the CGI variables now calls a function to 
parse the HTTP_ACCEPT_LANGUAGE variable and attempt to set the 
locale based on the user's preferred language and locality.

This wasn't really necessary because all we really needed was to 
set the encoding to UTF-8, but it may be useful in the future and 
is less ethnocentric than just blindly setting the locale to 
en_US.utf8. :-)



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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2625 5f96b256-904b-4d8d-8c98-d829582c6739
runcmd: Fix quoting issues when running commands

The important part of this patch is one line that makes sure that if
we're in single quoted mode, we should ignore '\' as an escape
character.

Without this, foo\\bar was interprented exactly the same as 'foo\\bar'.
With it, the former is executed as one backslash, the latter as two.

There's is also a new test-runcmd, with a small set of test cases for
the command quoter.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2627 5f96b256-904b-4d8d-8c98-d829582c6739
checks: Check command output does not show up pre-escaped

Why would you think it did?

Since we assumed that check output was escaped, we tried to unescape
it, and that becomes highly weird.

So, this bug meant that, unless a command is quoted (which, as shown in
the parent commit, you couldn't do), if you're trying to test quoting by
writing a check command that echoes your input, you needed four
backslashes in your input to get one in your output. Trying to read the
quad-escaped commands in the input, in turn, quickly makes a user want
to escape from this application.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2628 5f96b256-904b-4d8d-8c98-d829582c6739
base/nebmods: Log module loading errors to stdout

It's really, really tiresome to watch logs for module errors
when Nagios just keeps rolling on in case it can't load one or
more modules. This patch makes sure at least errors are printed
to stdout as well.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2629 5f96b256-904b-4d8d-8c98-d829582c6739
lib/worker: Add spawn_named_helper()

Setting argv[0] to some arbitrary name causes that arbitrary name
to show up as the process "title" (same as name, really) in most
programs, such as pidof, ps and top.

We don't use that feature yet, but when we get asked to spawn
particular workers (which will most likely happen "any day now")
it's nifty to be able to separate the workers from each other so
while also grouping them together. This patch makes that possible
without changing the current behaviour at all.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2630 5f96b256-904b-4d8d-8c98-d829582c6739
Forward patch of fix for bug #403

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2632 5f96b256-904b-4d8d-8c98-d829582c6739
Updated html_encode() to correctly encode characters outside the ASCII character set

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2633 5f96b256-904b-4d8d-8c98-d829582c6739
lib/test-bitmap: Properly start and set colors for tests

It's pretty and makes output consistent, so let's do it.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2634 5f96b256-904b-4d8d-8c98-d829582c6739
lib/t-utils: Add t_reset()

It makes sense to reset test scores here and there, so let's make
it easy to do that.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2635 5f96b256-904b-4d8d-8c98-d829582c6739
lib/test-dkhash: Reset test results between tests

Otherwise output appears to be lying, which is kinda bad.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2636 5f96b256-904b-4d8d-8c98-d829582c6739
lib/runcmd: Detect backticked subcommands inside double quotes

Shell substitutes it, so we must detect it.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2637 5f96b256-904b-4d8d-8c98-d829582c6739
lib/runcmd: Detect $() type subcommands as well as backtick ones

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2638 5f96b256-904b-4d8d-8c98-d829582c6739
lib/runcmd: Detect shell variables

We can't really interpolate them properly, so it's an error if we
find any.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2639 5f96b256-904b-4d8d-8c98-d829582c6739
lib/runcmd: Detect closing parentheses as CMD_HAS_PAREN too

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2640 5f96b256-904b-4d8d-8c98-d829582c6739
lib/test-runcmd: Make test-failures cause "build" failures

This makes these tests infinitely more useful from buildbots and
whatnot.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2641 5f96b256-904b-4d8d-8c98-d829582c6739
lib/test-runcmd: Add anomaly detection tests

These are the tests responsible for the earlier flurry of commits.
Since they've already proven useful, we keep them around in an
easily runnable state.

While at it, rename "runcmd test" to "exec output comparison".

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2642 5f96b256-904b-4d8d-8c98-d829582c6739
lib/test-runcmd: Add argument-splitting tests

This is just an embryo (or zygote, even) of a real testsuite for
argument splitting, but since tests tend to get written when
there's a comfortable framework to put them in, I expect more
will come in case bugs are found in this area.

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

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