]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: Switch metadata crawler to use storage driver file access check
authorPeter Krempa <pkrempa@redhat.com>
Mon, 28 Apr 2014 06:44:42 +0000 (08:44 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Jun 2014 07:27:23 +0000 (09:27 +0200)
Use virStorageFileAccess() to to check whether the file is accessible in
the main part of the metadata crawler.

src/storage/storage_driver.c

index b074047570317a7fcae87bd208a2ff037a8062f1..787171df30a415560d5097398d6abe29bdcc0895 100644 (file)
@@ -3103,13 +3103,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);
@@ -3151,6 +3144,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;