45c1ca
From a2214c5257d3bd7b086ce04aca1648e8ff05ee96 Mon Sep 17 00:00:00 2001
45c1ca
Message-Id: <a2214c5257d3bd7b086ce04aca1648e8ff05ee96.1368567003.git.crobinso@redhat.com>
45c1ca
From: "Daniel P. Berrange" <berrange@redhat.com>
45c1ca
Date: Fri, 10 May 2013 14:45:05 +0100
45c1ca
Subject: [PATCH] Fix iohelper usage with streams opened for read
45c1ca
45c1ca
In b2878ed860ceceec3cd6481424fed0b543b687cd we added the O_NOCTTY
45c1ca
flag when opening files in the stream code. Unfortunately a later
45c1ca
piece of code was comparing the flags == O_RDONLY, without masking
45c1ca
out the non-access mode flags. This broke the iohelper when used
45c1ca
with streams for read, since it caused us to attach the stream
45c1ca
output pipe to the stream input FD instead of output FD :-(
45c1ca
45c1ca
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
45c1ca
---
45c1ca
 src/fdstream.c | 2 +-
45c1ca
 1 file changed, 1 insertion(+), 1 deletion(-)
45c1ca
45c1ca
diff --git a/src/fdstream.c b/src/fdstream.c
45c1ca
index 6f8ce53..a9a4851 100644
45c1ca
--- a/src/fdstream.c
45c1ca
+++ b/src/fdstream.c
45c1ca
@@ -641,7 +641,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
45c1ca
         virCommandTransferFD(cmd, fd);
45c1ca
         virCommandAddArgFormat(cmd, "%d", fd);
45c1ca
 
45c1ca
-        if (oflags == O_RDONLY) {
45c1ca
+        if ((oflags & O_ACCMODE) == O_RDONLY) {
45c1ca
             childfd = fds[1];
45c1ca
             fd = fds[0];
45c1ca
             virCommandSetOutputFD(cmd, &childfd);
45c1ca
-- 
45c1ca
1.8.2.1
45c1ca