From: Peter Krempa <[email protected]>

External inactive snapshots are created by invoking 'qemu-img' which
creates the file. Currently qemu-img creates image with mode 644 based
on default umask as libvirt doesn't set any.

Having a world-readable image is obviously wrong so set the umask to
0066 to have the file readable only by the owner.

Resolves: https://bugs.debian.org/1120119
Signed-off-by: Peter Krempa <[email protected]>
---
 src/qemu/qemu_snapshot.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index d4994dd54e..6868910d9a 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -228,6 +228,9 @@ qemuSnapshotCreateQcow2Files(virDomainDef *def,
                                          NULL)))
             return -1;

+        /* ensure that new files are only readable by the user */
+        virCommandSetUmask(cmd, 0066);
+
         /* adds cmd line arg: 
backing_fmt=format,backing_file=/path/to/backing/file */
         virBufferAsprintf(&buf, "backing_fmt=%s,backing_file=",
                           
virStorageFileFormatTypeToString(defdisk->src->format));
-- 
2.51.1

Reply via email to