cf-serverd: free getaddrinfo() result, on error of OpenReceiverChannel()

getaddrinfo() may allocate the 'result' struct even in cases where it
will return an error. Take care to free memory, although we would exit
the server process anyway.
cf-serverd: getaddrinfo() will use a numeric port, no lookup

This `AI_NUMERICSERV` flag avoids looking up the "services" table for
a string port resolution, according to the manual.
cf-serverd: getaddrinfo() will NOT set "errno" upon failure

It has its own `gai_strerror()` function to resolve its (reentrant)
result code.
cf-serverd: fix typo for addrinfo constant

As spotted by Dimitrios Apostolou
Fix subindexing for maparray function

Close #5452
Redmine #5557: Fix files promises having wrong status report.

In functions where we invoke sub promises, we need to start with the
assumption that the promise will be skipped, instead of it being a
kept promise. The reason is that the skipped status has the lowest
priority, so if we end up skipping a promise, the status will still be
kept if that's what we started with.
Merge pull request #1668 from kacfengine/files_compliance

Redmine #5557: Fix files promises having wrong status report.
Correctly report repaired compliance for commands promises.

For compliance, commands promises are interpreted to have been KEPT
for 0 returns status, and NOTKEPT for non-zero. In order to maintain
compatibility with repaired classes set via body classes, a REPAIRED
state from VerifyCommandRetcode is overwritten with KEPT.

If the body classes also defines return codes for which the compliance
should be REPAIRED, then honour this and don't overwrite with KEPT.

Fixes: #5489
Merge pull request #1669 from vohi/commands_compliance

Correctly report repaired compliance for commands promises.
Merge pull request #1231 from xrg/fix-getaddrinfo

Fix getaddrinfo() usage
Redmine #5621: Fix failing safe_open in create race.

On single core systems with certain kernel versions (CentOS), the
ordering of open calls is deterministic, and if two threads try to
open the same file with O_CREAT, one will fail because the other
thread creates it at the same moment.

This is actually the very thing that safe_open was designed to protect
against, but since it can happen even in daily operation when there is
no foul play, we need to be a bit more tolerant. So if we find that we
have hit a race condition, instead of failing immediately, retry the
operation to see if we hit the race condition again. Only after a few
attempts do we give up.

This changes the expected result of one of the unit tests from
safe_open returning -1, to returning a file descriptor.
Add an additional test for opening a dangling symlink, not just creating
Fix possible file open race condition on platforms without openat().

When opening a relative path, the first path component opened is the
current directory. However, this is opened using normal open(). This
is fine on most platforms, but on those where we emulate openat(), we
do not protect the open() call using the lock inside generic_at.c,
which means we can potentially be in a different directory at the time
of the call.

The fix is to switch to openat() with the AT_FDCWD flag, so that we
run the emulation code with the lock also for the first file open.
Remove AI_NUMERICSERV from getaddrinfo() call.

On Windows, although defined, it is not supported by Microsoft's
network stack.
Rename internal test hook to make it clear that it itself isn't a test
Merge pull request #1670 from kacfengine/safe_open_fixes

Redmine #5621: Safe open fixes
Attempt expansion of naked nested scalars in ExpandListEntry

Close #5480
libcfnet/tls_client.c: mention 3.5.x protocol incompatibility
Merge pull request #1671 from tzz/tls-mention-3.5.x

libcfnet/tls_client.c: mention 3.5.x protocol incompatibility
Redmine#5486: disable db_test and db_concurrent_test temporarily