Use virStorageFileAccess() to to check wether the file is accessible in
the main part of the metadata crawler.
---
 src/storage/storage_driver.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index f2c548d..cf969c8 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -3076,13 +3076,6 @@ virFindBackingFile(const char *start, const char *path,
         goto cleanup;
     }

-    if (virFileAccessibleAs(combined, F_OK, geteuid(), getegid()) < 0) {
-        virReportSystemError(errno,
-                             _("Cannot access backing file '%s'"),
-                             combined);
-        goto cleanup;
-    }
-
     if (!(*canonical = canonicalize_file_name(combined))) {
         virReportSystemError(errno,
                              _("Can't canonicalize path '%s'"), path);
@@ -3124,6 +3117,13 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
     if (virStorageFileInitAs(src, uid, gid) < 0)
         return -1;

+    if (virStorageFileAccess(src, F_OK) < 0) {
+        virReportSystemError(errno,
+                             _("Cannot access backing file %s"),
+                             src->path);
+        goto cleanup;
+    }
+
     if (!(uniqueName = virStorageFileGetUniqueIdentifier(src)))
         goto cleanup;

-- 
1.9.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to