sasl: Fixed compilation warning from commit 25264131e2

Added forward declaration of digestdata to overcome the following
compilation warning:

warning: 'struct digestdata' declared inside parameter list

Additionally made the ntlmdata forward declaration dependent on
USE_NTLM similar to how digestdata and kerberosdata are.
tests: fix memleak in server/resolve.c

This makes LeakSanitizer happy.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
tests: fix hostname faker

I noticed that a patched cmake build would pass tests with a fake local
hostname, but the autotools build skips them:

    got unexpected host name back, LD_PRELOAD failed

It turns out that -fvisibility=hidden hides the symbol, and since the
tests are not part of libcurl, it fails too. Just remove the LIBCURL
guard.

Broken since cURL 7.30 (commit 83a42ee20ea7fc25abb61c0b7ef56ebe712d7093,
"curl.h: stricter CURL_EXTERN linkage decorations logic").

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
cmake: fix HAVE_GETHOSTNAME definition

Otherwise Curl_gethostname always fails. Windows has gethostname
since Vista according to
http://msdn.microsoft.com/en-us/library/ms738527%28VS.85%29.aspx, but
accordings to byte_bucket's VC 2005 documentation, it is available even
in Windows 95. (possibly after installing a Platform SDK, the
Windows Server 2003 SP1 Platform SDK should be sufficient).

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
cmake: build libhostname for test suite

Used by some test cases via LD_PRELOAD in order to fake the host name.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
tests: use single quotes for some tests

This prepares for a future patch where commands are not executed by a
shell anymore, but by perl. In the future, Text::ParseWords will be used
to convert a command to an array.

According to 2.2.3 Double-Quotes, chapter Shell Command Language of
The Base Specifications Issue 6 (IEEE Std 1003.1 2004), double quotes
should not touch characters other than

    $ ` " \ <newline>

Unfortunately, perls Text::ParseWords does not handle this correctly,
removing the slash for everything else. Avoid this incompatibility by
using single quotes instead.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
tests/test22: expand a backtick command

This is the only user of the backtick operator in the command. As the
commands will soon not be executed by a shell anymore (but by perl),
replace the command with its output.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
runtests.pl: safer system() calls

Command invocation via runclient() (which calls system()) using a string
invokes the shell. This has the problem that tests which load
libhostname.so via LD_PRELOAD break when the library cannot be loaded
into the shell (when cURL is built with AddressSanitizer for example).

Fix this issue by making runclient() accept the command as array
which causes a bypass of sh. Replace system() by IPC::Run to allow
I/O redirection. Note that sh is only bypassed if curl is a binary as is
the case with cmake or with the curl binary installed via `make
install`. This patch does not fix the issue with the libtool wrapper of
autotools.

precheck is now also wrapped into runclient rather than using backticks
to take advantage of the sh bypass.

Implementation details: as runclient has become more sophisticated and
can also return stdout, get rid of runclientoutput.

Note for the curious: previously a gdb invocation would feed stdin via
'set args <input'. This only works because the command is interpreted as
a shell command. After this patch stdin is fed directly.

Detection of the `valgrind --tool` option was previously done by
invoking grep. Remove this use of grep. While at it, remove
`valgrind --version` invocation to determine whether `--log-file`
should be used instead of `--logfile`. Parse this information directly
from `valgrind --help` which was executed earlier.

As for differences in log file, these are just whitespace (trailing
space for `curl --version` command, spaces after redirection operator)
and quoting (quotes typically get stripped).

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
runtests.pl: simplify command environment handling

Rather than saving valid environment variables for restoration later,
use 'local' to limit the environment changes to the block executing
a command.

Rationale: LD_PRELOAD may not work with all executables. Previously
it would break on the shell when compiled with AddressSanitizer
(-fsanitize=address), but that is avoided by not executing string
commands anymore. gdb would still be executed with LD_PRELOAD though,
so setting $ENV in this way was not sustainable.

After this patch, environment variables are passed to executions of
precheck (for chkhostname), command (for curl) and postcheck (for
symmetry with precheck, it does not actually use it).

Note that this autotools with AddressSanitizer enabled is still
incompatible with this mode of execution as 'curl' is a libtool wrapper.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
symbol-scan.pl: do not require autotools

Makes test1119 pass when building with cmake.

configurehelp.pm is generated by configure (autotools). As cmake does
not provide a separate variable for the C preprocessor, default to cpp.
Before commit ef24ecde68a5f577a7f0f423a767620f09a0ab16 ("symbol-scan:
use configure script knowledge about how to run the C preprocessor"),
this tool would also use 'cpp'.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>