7a3408
From daa456afc0c24778737ead358c30c042634c421b Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <daa456afc0c24778737ead358c30c042634c421b@dist-git>
7a3408
From: John Ferlan <jferlan@redhat.com>
7a3408
Date: Wed, 2 Sep 2015 09:55:14 -0400
7a3408
Subject: [PATCH] storage: Correct the 'mode' check
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1253609
7a3408
7a3408
Commit id '7c2d65dde2' changed the default value of mode to be -1 if not
7a3408
supplied in the XML, which should cause creation of the volume using the
7a3408
default mode of VIR_STORAGE_DEFAULT_VOL_PERM_MODE; however, the check
7a3408
made was whether mode was '0' or not to use default or provided value.
7a3408
7a3408
This patch fixes the issue to check if the 'mode' was provided in the XML
7a3408
and use that value.
7a3408
7a3408
(cherry picked from commit 691dd388aee99f8b06177540303b690586d5f5b3)
7a3408
Signed-off-by: John Ferlan <jferlan@redhat.com>
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/storage/storage_backend.c | 8 +++++---
7a3408
 1 file changed, 5 insertions(+), 3 deletions(-)
7a3408
7a3408
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
7a3408
index ce59f63..c07b58c 100644
7a3408
--- a/src/storage/storage_backend.c
7a3408
+++ b/src/storage/storage_backend.c
7a3408
@@ -479,6 +479,7 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
7a3408
     int fd = -1;
7a3408
     int operation_flags;
7a3408
     bool reflink_copy = false;
7a3408
+    mode_t open_mode = VIR_STORAGE_DEFAULT_VOL_PERM_MODE;
7a3408
 
7a3408
     virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA |
7a3408
                   VIR_STORAGE_VOL_CREATE_REFLINK,
7a3408
@@ -511,11 +512,12 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
7a3408
     if (pool->def->type == VIR_STORAGE_POOL_NETFS)
7a3408
         operation_flags |= VIR_FILE_OPEN_FORK;
7a3408
 
7a3408
+    if (vol->target.perms->mode != (mode_t) -1)
7a3408
+        open_mode = vol->target.perms->mode;
7a3408
+
7a3408
     if ((fd = virFileOpenAs(vol->target.path,
7a3408
                             O_RDWR | O_CREAT | O_EXCL,
7a3408
-                            (vol->target.perms->mode ?
7a3408
-                             VIR_STORAGE_DEFAULT_VOL_PERM_MODE :
7a3408
-                             vol->target.perms->mode),
7a3408
+                            open_mode,
7a3408
                             vol->target.perms->uid,
7a3408
                             vol->target.perms->gid,
7a3408
                             operation_flags)) < 0) {
7a3408
-- 
7a3408
2.5.1
7a3408