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

70 lines
2.6 KiB
Diff
Raw Normal View History

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