]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix iohelper usage with streams opened for read
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 10 May 2013 13:45:05 +0000 (14:45 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 10 May 2013 18:57:18 +0000 (19:57 +0100)
In b2878ed860ceceec3cd6481424fed0b543b687cd we added the O_NOCTTY
flag when opening files in the stream code. Unfortunately a later
piece of code was comparing the flags == O_RDONLY, without masking
out the non-access mode flags. This broke the iohelper when used
with streams for read, since it caused us to attach the stream
output pipe to the stream input FD instead of output FD :-(

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/fdstream.c

index 6f8ce530af52cdb80ba04b7439d8ca0d19c57ad6..a9a4851dd348665a4ca86f78ade2c114d18af8d2 100644 (file)
@@ -641,7 +641,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
         virCommandTransferFD(cmd, fd);
         virCommandAddArgFormat(cmd, "%d", fd);
 
-        if (oflags == O_RDONLY) {
+        if ((oflags & O_ACCMODE) == O_RDONLY) {
             childfd = fds[1];
             fd = fds[0];
             virCommandSetOutputFD(cmd, &childfd);