]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu: Don't unconditionally delete file in qemuOpenFileAs
authorJohn Ferlan <jferlan@redhat.com>
Wed, 28 Jan 2015 18:14:38 +0000 (13:14 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 29 Jan 2015 20:37:34 +0000 (15:37 -0500)
commit7879d031974417e767c2b6e198493289abffabdf
treec7f98296c1065889ce449a5d67bdb63396bce774
parent29946e3e53c6719a99b476dbab56b49d3d94f1ca
qemu: Don't unconditionally delete file in qemuOpenFileAs

https://bugzilla.redhat.com/show_bug.cgi?id=1158034

If we're expecting to create a file somewhere and that fails for some
reason during qemuOpenFileAs, then we unlink the path we're attempting
to create leaving no way to determine what the "existing" privileges,
protections, or labels are that caused the failure (open, change owner
and group, change mode, etc.).

Furthermore, if we fall into the path where we'll be opening / creating
the file using VIR_FILE_OPEN_FORK, we need to first unlink/delete the file
we created in the first path; otherwise, the attempt by the child process
to open as some specific user:group may fail because the file was already
created using nfsnobody:nfsnobody. Again, if we didn't create the file we
don't want to blindly delete what already exists. Thus, a second reason for
the original check to set need_unlink to false when we find the file with
CREAT set, but already existing.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_driver.c