Merge pull request #1106 from kacfengine/3.5.x

[3.5.x] Be a bit more descriptive about package promise changes.
Implemented safe_open() in order to avoid symlink race conditions.

It makes sure that we do not follow unsafe symlinks, that is a link
that belongs to a user, but has a target owned by a different user.
It does this in a way that avoids race conditions (between testing if
a file is a link, and opening that file, there is a small window of
opportunity).

Also implements safe_chdir(), to also safeguard chdir() operations.

Fixes issue #3693.
(cherry picked from commit 995b9d18d750713cd40ce0203550a45646a53cd0)

Conflicts:

	cf-agent/files_editline.c
	cf-agent/verify_files.c
	cf-agent/verify_packages.c
	cf-execd/cf-execd-runner.c
	cf-key/cf-key-functions.c
	cf-serverd/server_common.c
	configure.ac
	libcfnet/client_code.c
	libpromises/cf3lex.l
	libpromises/env_context.c
	libpromises/parser.c
	libpromises/pipes_unix.c
	libpromises/sysinfo.c
	libpromises/verify_reports.c
	libutils/hashes.c
	tests/unit/Makefile.am
Merge pull request #1116 from kacfengine/safe_open_3.5.x

[3.5.x] Implemented safe_open() in order to avoid symlink race conditions.
Work around fdopendir() missing on some platforms.
(cherry picked from commit 19be8b73b5ee94b890ca09ccf7346ea923b36c1c)
Merge pull request #1118 from kacfengine/safe_open_3.5.x

[3.5.x] Work around fdopendir() missing on some platforms.
Add missing header.
Merge pull request #1122 from kacfengine/safe_open_3.5.x

Add missing header.
Don't use O_DIRECTORY flag, which is Linux specific.

Directories will fail when we try to chdir into them anyway, so all
we lose is the early warning.
(cherry picked from commit fd0488f19bc8325bbb51171dd6fc69b074d2b51c)
Switch back to test folder after each test.

Otherwise the test framework may try to write into the wrong
directory.
(cherry picked from commit 7828a2ad7a4efb1799b8c9208c33e03f3af83aea)
Merge pull request #1124 from kacfengine/safe_open_3.5.x

[3.5.x] Some fixes for the safe_open() function.
Don't use GetErrorStrFromCode(), which is not defined in 3.5.x.
Merge pull request #1126 from kacfengine/safe_open_3.5.x

[3.5.x] Don't use GetErrorStrFromCode(), which is not defined in 3.5.x.
Pre-release version bump
va_arg is not well-defined for shorter-than-int arguments

Use int instead of mode_t, as the latter is either int or short
(cherry picked from commit e471bfd58655521fbb5474b49ec85ece174eeee7)
Add missing platform header for HP-UX.

The code compiles without it, but gets the wrong definition of stat
on HP-UX
(cherry picked from commit 6f2025af92da86c70af6e0d67bf6faa187838233)