]> xenbits.xensource.com Git - libvirt.git/commit
virfile: Adjust error path for virFileOpenForked
authorJohn Ferlan <jferlan@redhat.com>
Wed, 28 Jan 2015 17:34:54 +0000 (12:34 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 11 Feb 2015 12:28:58 +0000 (07:28 -0500)
commit92d9114eacddba08da6347aa0eb286948da49961
tree46728fb45020e42a2c701b8f596832804f719c24
parent45853b5289646dfcb8215d714df57f069811001c
virfile: Adjust error path for virFileOpenForked

Rather than have a dummy waitpid loop and return of the failure status
from recvfd, adjust the logic to save the recvfd error & fd and then
in priority order:

- if waitpid failed, use that errno value
- waitpid succeeded, but if the child exited abnormally, report failure
(use EACCES to report as return failure, since either EACCES or EPERM is
what caused us to fall into the fork+setuid path)
- waitpid succeeded, but if the child reported non-zero status, report
failure (use the errno value that the child encoded into exit status)
- waitpid succeeded, but if recvfd failed, report recvfd_errno
- waitpid and recvfd succeeded, use the fd

NOTE: Original logic to retry the open and force owner mode was
"documented" as only being attempted if we had already tried opening
with the fork+setuid, but checked flags vs. VIR_FILE_OPEN_NOFORK which
is counter to how we would get to that point. So that code was removed.
src/util/virfile.c