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
Revert "Redmine #5557: Fix promises wrongfully reported with kept status."

This reverts commit 1cb35d8c56a1effd081dc856b7ae2722ac4ed2a8.

The change, while in principle correct, break the test. Need to review
before letting this go in.
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
Remove AI_NUMERICSERV from getaddrinfo() call.

On Windows, although defined, it is not supported by Microsoft's
network stack.
new autoconf option to make state directory configurable: --with-statedir=<directory>
make use of preprocessor macros for static known_dirs.c functions
rename MAX_WORKDIR_LENGTH macro to generic MAX_DIR_LENGTH
add GetStateDir() and supporting functions
use GetStateDir() and replace hardcoded state/ paths
libpromises/generic_agent.c: chmod and chown internal directories only when needed.

Avoids gratuitous chmod and chown calls on internal directories by examining
the populated stat struct after stat(). Important for devices backed by flash
in order to avoid wanton wearing of the storage medium.
new $(sys.statedir) special variable
move embedded databases exclusive to state/ directory