|
|
404507 |
From ef9bacb8ce672161449683f748d4df76c4b78a54 Mon Sep 17 00:00:00 2001
|
|
|
404507 |
Message-Id: <ef9bacb8ce672161449683f748d4df76c4b78a54@dist-git>
|
|
|
404507 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
404507 |
Date: Thu, 7 Dec 2017 13:45:50 +0100
|
|
|
404507 |
Subject: [PATCH] storage: Don't dereference driver object if virStorageSource
|
|
|
404507 |
is not initialized
|
|
|
404507 |
|
|
|
404507 |
virStorageFileReportBrokenChain uses data from the driver private data
|
|
|
404507 |
pointer to print the user and group. This would lead to a crash in call
|
|
|
404507 |
paths where we did not initialize the storage backend as recently added
|
|
|
404507 |
in commit 24e47ee2b93 to qemuDomainDetermineDiskChain.
|
|
|
404507 |
|
|
|
404507 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1522682
|
|
|
404507 |
(cherry picked from commit 2d07f1f0ebd44b0348daa61afa0de34f3f838c22)
|
|
|
404507 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
404507 |
---
|
|
|
404507 |
src/storage/storage_source.c | 36 +++++++++++++++++++++++++-----------
|
|
|
404507 |
1 file changed, 25 insertions(+), 11 deletions(-)
|
|
|
404507 |
|
|
|
404507 |
diff --git a/src/storage/storage_source.c b/src/storage/storage_source.c
|
|
|
404507 |
index 469d3a00bc..aaec988e9a 100644
|
|
|
404507 |
--- a/src/storage/storage_source.c
|
|
|
404507 |
+++ b/src/storage/storage_source.c
|
|
|
404507 |
@@ -404,19 +404,33 @@ virStorageFileReportBrokenChain(int errcode,
|
|
|
404507 |
virStorageSourcePtr src,
|
|
|
404507 |
virStorageSourcePtr parent)
|
|
|
404507 |
{
|
|
|
404507 |
- unsigned int access_user = src->drv->uid;
|
|
|
404507 |
- unsigned int access_group = src->drv->gid;
|
|
|
404507 |
|
|
|
404507 |
- if (src == parent) {
|
|
|
404507 |
- virReportSystemError(errcode,
|
|
|
404507 |
- _("Cannot access storage file '%s' "
|
|
|
404507 |
- "(as uid:%u, gid:%u)"),
|
|
|
404507 |
- src->path, access_user, access_group);
|
|
|
404507 |
+ if (src->drv) {
|
|
|
404507 |
+ unsigned int access_user = src->drv->uid;
|
|
|
404507 |
+ unsigned int access_group = src->drv->gid;
|
|
|
404507 |
+
|
|
|
404507 |
+ if (src == parent) {
|
|
|
404507 |
+ virReportSystemError(errcode,
|
|
|
404507 |
+ _("Cannot access storage file '%s' "
|
|
|
404507 |
+ "(as uid:%u, gid:%u)"),
|
|
|
404507 |
+ src->path, access_user, access_group);
|
|
|
404507 |
+ } else {
|
|
|
404507 |
+ virReportSystemError(errcode,
|
|
|
404507 |
+ _("Cannot access backing file '%s' "
|
|
|
404507 |
+ "of storage file '%s' (as uid:%u, gid:%u)"),
|
|
|
404507 |
+ src->path, parent->path, access_user, access_group);
|
|
|
404507 |
+ }
|
|
|
404507 |
} else {
|
|
|
404507 |
- virReportSystemError(errcode,
|
|
|
404507 |
- _("Cannot access backing file '%s' "
|
|
|
404507 |
- "of storage file '%s' (as uid:%u, gid:%u)"),
|
|
|
404507 |
- src->path, parent->path, access_user, access_group);
|
|
|
404507 |
+ if (src == parent) {
|
|
|
404507 |
+ virReportSystemError(errcode,
|
|
|
404507 |
+ _("Cannot access storage file '%s'"),
|
|
|
404507 |
+ src->path);
|
|
|
404507 |
+ } else {
|
|
|
404507 |
+ virReportSystemError(errcode,
|
|
|
404507 |
+ _("Cannot access backing file '%s' "
|
|
|
404507 |
+ "of storage file '%s'"),
|
|
|
404507 |
+ src->path, parent->path);
|
|
|
404507 |
+ }
|
|
|
404507 |
}
|
|
|
404507 |
}
|
|
|
404507 |
|
|
|
404507 |
--
|
|
|
404507 |
2.15.1
|
|
|
404507 |
|