io: Fix QIOChannelFile when creating and opening read-write
commit902f6e14fc68743ce24efb7d87dc3f8464a78bf3
authorRoss Lagerwall <ross.lagerwall@citrix.com>
Wed, 1 Nov 2017 14:25:24 +0000 (1 14:25 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 15 Feb 2018 16:54:57 +0000 (15 16:54 +0000)
tree7ad393040358740e78d39eeafa4b31996d7d2095
parenta46ded1de5cf0edd6c780e071ddafb92601070b5
io: Fix QIOChannelFile when creating and opening read-write

The code wrongly passes the mode to open() only if O_WRONLY is set.
Instead, the mode should be passed when O_CREAT is set (or O_TMPFILE on
Linux). Fix this by always passing the mode since open() will correctly
ignore the mode if it is not needed. Add a testcase which exercises this
bug and also change the existing testcase to check that the mode of the
created file is correct.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
include/io/channel-file.h
io/channel-file.c
tests/test-io-channel-file.c