Fail path resolution early on symlink detection error.

This change makes path resolution return error if check
whether a path component is a symlink returns any error
except EINVAL (not a symlink).
Last component check is also allowed to fail
with ENOENT (file doesn't exist) unless it's required to exist
(last component before ".." is required to exist).

This is needed to make cleaning ".." components from path
fail on nonexistent files preceding ".." part.
For example, "/nonexistent/../bin" was resolving the same way as "/bin"
without this change, but it should fail instead.

See https://bugs.merproject.org/show_bug.cgi?id=834 for details.

Signed-off-by: Oleg Girko <oleg.girko@jolla.com>
Handle errno more carefully if path mapping failed preparing for exec.

Avoid possible errno overwriting when printing debug output.

Signed-off-by: Oleg Girko <oleg.girko@jolla.com>