Blame SOURCES/libvirt-storage_file-create-Create-new-images-with-write-permission-bit.patch

a41c76
From 1624090a014019ac1b61dc62557b829426068835 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <1624090a014019ac1b61dc62557b829426068835@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Tue, 12 May 2020 17:24:08 +0200
a41c76
Subject: [PATCH] storage_file: create: Create new images with write permission
a41c76
 bit
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
The 'Create' API of the two storage file backends is used only on
a41c76
code-paths where we need to format the image after creating an empty
a41c76
file. Since the DAC security driver only modifies the owner of the file
a41c76
and not the mode we need to create all files which are going to be
a41c76
formatted with the write bit set for the user.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit 20939b037c37789ddca54c18862fb45b4b41740f)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1832204
a41c76
Message-Id: <647821632e4b2822eceb81590459aafa2f88b6fb.1589296861.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
---
a41c76
 src/storage/storage_file_fs.c      | 6 +-----
a41c76
 src/storage/storage_file_gluster.c | 6 +-----
a41c76
 2 files changed, 2 insertions(+), 10 deletions(-)
a41c76
a41c76
diff --git a/src/storage/storage_file_fs.c b/src/storage/storage_file_fs.c
a41c76
index 8817970f44..1629c3d877 100644
a41c76
--- a/src/storage/storage_file_fs.c
a41c76
+++ b/src/storage/storage_file_fs.c
a41c76
@@ -83,13 +83,9 @@ virStorageFileBackendFileInit(virStorageSourcePtr src)
a41c76
 static int
a41c76
 virStorageFileBackendFileCreate(virStorageSourcePtr src)
a41c76
 {
a41c76
-    mode_t mode = S_IRUSR;
a41c76
     VIR_AUTOCLOSE fd = -1;
a41c76
 
a41c76
-    if (!src->readonly)
a41c76
-        mode |= S_IWUSR;
a41c76
-
a41c76
-    if ((fd = virFileOpenAs(src->path, O_WRONLY | O_TRUNC | O_CREAT, mode,
a41c76
+    if ((fd = virFileOpenAs(src->path, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR,
a41c76
                             src->drv->uid, src->drv->gid, 0)) < 0) {
a41c76
         errno = -fd;
a41c76
         return -1;
a41c76
diff --git a/src/storage/storage_file_gluster.c b/src/storage/storage_file_gluster.c
a41c76
index f389a94437..608f93d2f6 100644
a41c76
--- a/src/storage/storage_file_gluster.c
a41c76
+++ b/src/storage/storage_file_gluster.c
a41c76
@@ -152,13 +152,9 @@ virStorageFileBackendGlusterCreate(virStorageSourcePtr src)
a41c76
 {
a41c76
     virStorageFileBackendGlusterPrivPtr priv = src->drv->priv;
a41c76
     glfs_fd_t *fd = NULL;
a41c76
-    mode_t mode = S_IRUSR;
a41c76
-
a41c76
-    if (!src->readonly)
a41c76
-        mode |= S_IWUSR;
a41c76
 
a41c76
     if (!(fd = glfs_creat(priv->vol, src->path,
a41c76
-                          O_CREAT | O_TRUNC | O_WRONLY, mode)))
a41c76
+                          O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR)))
a41c76
         return -1;
a41c76
 
a41c76
     ignore_value(glfs_close(fd));
a41c76
-- 
a41c76
2.26.2
a41c76