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.
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
fix db_concurrent_test
Test db->mc only once and store result on stack.

This reduces the possibility of race conditions in multi threaded
client code, where one thread opens a cursor while another thread
operates on the DB without cursors. In that case, db->mc changes
in the middle of the operation.

This is a quick workaround, the correct fix is to either remove this
optimization or protect the db structure with a mutex.
Merge pull request #1673 from vohi/mitigate_racecondition

Test db->mc only once and store result on stack.
Remove all transaction sharing code between cursor and regular updates.

Modifying the db structure makes the individual functions non-reentrant,
and can cause race conditions and data corruptions in multi threaded
programs, such as cf-serverd.
Merge pull request #1674 from vohi/mitigate_racecondition

Remove all transaction sharing code between cursor and regular updates.
Initialize the global transaction to null at initialization.

Otherwise, we have an uninitialized pointer in case of error.
Also abort the opening transaction in case of error.

No need to reset the pointer on the stack at end of function.
Disable irrelevant migration tests for LMDB builds.
Merge pull request #1675 from vohi/disable_migration_tests

Disable irrelevant migration tests for LMDB builds.
Try to simplify apoptosis/DeleteConnection locking mess.
Select() error code is no longer lost because of recv().
Merge pull request #1678 from jimis/select_error_lost

Select() error code is no longer lost because of recv().