1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +00:00

security: apparmor: Pass virStorageSource to add_file_path

The virStorageSource must have everything it needs

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2019-10-08 11:53:21 -04:00
parent 488fce1220
commit 7c0bf48bc9

View File

@ -911,20 +911,19 @@ file_iterate_pci_cb(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
} }
static int static int
add_file_path(virDomainDiskDefPtr disk, add_file_path(virStorageSourcePtr src,
const char *path,
size_t depth, size_t depth,
virBufferPtr buf) virBufferPtr buf)
{ {
int ret; int ret;
if (depth == 0) { if (depth == 0) {
if (disk->src->readonly) if (src->readonly)
ret = vah_add_file(buf, path, "rk"); ret = vah_add_file(buf, src->path, "rk");
else else
ret = vah_add_file(buf, path, "rwk"); ret = vah_add_file(buf, src->path, "rwk");
} else { } else {
ret = vah_add_file(buf, path, "rk"); ret = vah_add_file(buf, src->path, "rk");
} }
if (ret != 0) if (ret != 0)
@ -945,7 +944,7 @@ disk_add_files(virDomainDiskDefPtr disk,
/* execute the callback only for local storage */ /* execute the callback only for local storage */
if (virStorageSourceIsLocalStorage(tmp) && if (virStorageSourceIsLocalStorage(tmp) &&
tmp->path) { tmp->path) {
if (add_file_path(disk, tmp->path, depth, buf) < 0) if (add_file_path(tmp, depth, buf) < 0)
return -1; return -1;
} }