Backport fixes to race conditions and file permissions in
file editing.

Previously the original was removed and then the edited file was
renamed, leaving a small timeframe where the file did not exist, which
can lead to bad situations. Fixed by leaving the file in place until
rename is called, which is atomic on all POSIX platforms.

Also make sure all permissions, including ACLs and SELinux security
contexts, are preserved when making a copy of the original file.

Fixes issue 2545.

Conflicts:
	cf-agent/files_operators.c
	cf-agent/files_operators.h
	src/acl.h

(cherry picked from commit a3f1a964ad5e079f8abc419bb9e0489aa8c62f7a)
(cherry picked from commit 908fb187191b41df44bdfb7d092a429cded06436)
(cherry picked from commit 76d895609ea7dee55502139acf52b1b141ca9b10)
Merge pull request #701 from kacfengine/3.4.x-backports

Backport fixes to race conditions and file permissions in
Call tchdboptimize only in 1% of the OpenTokyoDatabase() calls

Even though we call non-reentrant rand() from multiple thread contexts,
there is no harm done even if bad random numbers are returned.
(cherry picked from commit 3d95e9226cd0a38d077333d0cdec4ae85d6a0d0d)

Conflicts:
	libpromises/dbm_tokyocab.c
Changing lsdir to consistently return an slist

This is a backport of 6807e0dda5bd265c9bbee631fffb2ec0aa68adaa to the
3.4.x branch.
Switching to new use of CF_NULL_VALUE as requested.
Merge pull request #777 from werkt/3.4.x-lsdir-slist

Changing lsdir to consistently return an slist
Fix for acceptance test failure

I tried to cherry-pick the fix from master but there were too many conflicts.
So I just back ported the fix.
Pre-release version bump
Post-release version bump
Merge remote-tracking branch 'GitHub_orig/3.4.x' into cfengine3