]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage_file: create: Create new images with write permission bit
authorPeter Krempa <pkrempa@redhat.com>
Mon, 11 May 2020 13:38:28 +0000 (15:38 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 12 May 2020 04:56:09 +0000 (06:56 +0200)
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>
src/storage/storage_file_fs.c
src/storage/storage_file_gluster.c

index 0d3f134765e2c17939b6deec54d7bab66395f252..8aafd58992e58292be6f62997a48cf3e4dfbcf31 100644 (file)
@@ -84,13 +84,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;
index f389a944377b46eb2254fcf64c817688786b0ab1..608f93d2f6f04da1a16681d92fe13350ad618fc3 100644 (file)
@@ -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));