Don't ignore path resolution errors when cleaning ".." from paths.

The clean_dotdots_from_path() function was ignoring path resolution
errors when calling sb_path_resolution() function.
The reason for that was that clean_dotdots_from_path() function
was returning void and had no way to report failure to the caller.

This change makes clean_dotdots_from_path() return int to report errors.
Zero result means that there was no error.
Otherwise, errno code is returned.

All calling functions were modified to use this error code
and report errors to their respective callers.

Signed-off-by: Oleg Girko <oleg.girko@jolla.com>
Don't ignore path mapping error in preparation for exec.

This change adds check for path mapping error in prepare_exec().
Result of path mapping makes no sense if mapping failed.
In this case, returning error immediately is more reasonable
than trying to perform further steps, like inspecting binary file,
which should fail anyway, but possibly with misleading errno.

Signed-off-by: Oleg Girko <oleg.girko@jolla.com>
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).

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>