From 2aca94bfd3691c492ce4b6e7f1dd73342774fefd Mon Sep 17 00:00:00 2001 From: Jamie Strandboge Date: Tue, 6 Apr 2010 17:22:39 +0200 Subject: [PATCH] Add backingstore support to apparmor adjust virt-aa-helper to handle backing store * src/security/virt-aa-helper.c: look for backing store metadata for disk definitions. --- src/security/virt-aa-helper.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 787f2b0643..f9b7c370cd 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -36,6 +36,7 @@ #include "uuid.h" #include "hostusb.h" #include "pci.h" +#include "storage_file.h" static char *progname; @@ -809,6 +810,33 @@ get_files(vahControl * ctl) for (i = 0; i < ctl->def->ndisks; i++) if (ctl->def->disks[i] && ctl->def->disks[i]->src) { int ret; + const char *path; + + path = ctl->def->disks[i]->src; + do { + virStorageFileMetadata meta; + + memset(&meta, 0, sizeof(meta)); + + ret = virStorageFileGetMetadata(path, &meta); + + if (path != ctl->def->disks[i]->src) + VIR_FREE(path); + path = NULL; + + if (ret < 0) { + vah_warning("skipping backingStore check (open failed)"); + continue; + } + + if (meta.backingStore != NULL && + (ret = vah_add_file(&buf, meta.backingStore, "rw")) != 0) { + VIR_FREE(meta.backingStore); + goto clean; + } + + path = meta.backingStore; + } while (path != NULL); if (ctl->def->disks[i]->readonly) ret = vah_add_file(&buf, ctl->def->disks[i]->src, "r"); -- 2.47.2