]> xenbits.xensource.com Git - libvirt.git/commitdiff
security: apparmor: Push virStorageSource checks to add_file_path
authorCole Robinson <crobinso@redhat.com>
Tue, 8 Oct 2019 15:55:24 +0000 (11:55 -0400)
committerCole Robinson <crobinso@redhat.com>
Wed, 9 Oct 2019 18:17:16 +0000 (14:17 -0400)
This mirrors the code layout in security_selinux.c. It will also make
it easier to share the checks for qcow2 external data_file support
eventually

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
src/security/virt-aa-helper.c

index 9f39eb2e2b66adfecee53d236c391fcac697c09f..20281c38b76d27fe0c5f8df086638b2ddf2712d1 100644 (file)
@@ -917,6 +917,10 @@ add_file_path(virStorageSourcePtr src,
 {
     int ret;
 
+    /* execute the callback only for local storage */
+    if (!src->path || !virStorageSourceIsLocalStorage(src))
+        return 0;
+
     if (depth == 0) {
         if (src->readonly)
             ret = vah_add_file(buf, src->path, "rk");
@@ -941,12 +945,8 @@ disk_add_files(virDomainDiskDefPtr disk,
     virStorageSourcePtr tmp;
 
     for (tmp = disk->src; virStorageSourceIsBacking(tmp); tmp = tmp->backingStore) {
-        /* execute the callback only for local storage */
-        if (virStorageSourceIsLocalStorage(tmp) &&
-            tmp->path) {
-            if (add_file_path(tmp, depth, buf) < 0)
-                return -1;
-        }
+        if (add_file_path(tmp, depth, buf) < 0)
+            return -1;
 
         depth++;
     }