File 0033-qga-unlink-just-created-guest-file-.patch of Package qemu.openSUSE_12.2_Update

From 8a5a569a54354210207e70eb01ae5070cc0df75b Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <lersek@redhat.com>
Date: Wed, 8 May 2013 17:31:36 +0200
Subject: [PATCH] qga: unlink just created guest-file if fchmod() or fdopen()
 fails on it
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We shouldn't allow guest filesystem pollution on error paths.

Suggested-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
(cherry picked from commit 2b720018060179b394f8ce736983373ab80dd37c)

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 qga/commands-posix.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 47bbad2..5bdb522 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -235,6 +235,9 @@ safe_open_or_create(const char *path, const char *mode, Error **err)
             }
 
             close(fd);
+            if (oflag & O_CREAT) {
+                unlink(path);
+            }
         }
     }
 
openSUSE Build Service is sponsored by