
On 10/24/2011 04:23 AM, Michal Privoznik wrote:
This function checks if a given path is accessible under given uid and gid. --- src/util/util.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/util/util.h | 3 ++ 2 files changed, 75 insertions(+), 0 deletions(-)
+ + if (pid) { /* parent */ + if (virPidWait(pid,&status)< 0) { + /* virPidWait() already + * reported error */ + return -1; + } + + return -(status& 0xFF);
Per the method docs, I think this has to be: errno = status; return -1;
+ } + + /* child. + * Return positive value here. Parent + * will change it to negative one. */ + + if (forkRet< 0) { + ret = 1;
ret = errno;
+ goto childerror; + } + + if (virSetUIDGID(uid, gid)< 0) { + ret = 1;
ret = errno;
+ goto childerror; + } + + if (access(path, mode)< 0) + ret = 1;
ret = errno;
+ +childerror: + if ((ret& 0xFF) != ret) { + VIR_WARN("unable to pass desired return value %d", ret); + ret = 0xFF; + } + + _exit(ret);
That way, your exit status is 0 on success, and an errno value on error. ACK - I'm comfortable with you making those changes and pushing, without having to see v7. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org