cfengine/core — pull request #1116 by kacfengine (2013-11-26 07:57:12+00:00)
Title: [3.5.x] 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