security: selinux: break out SetImageLabelRelative

This will be used for recursing into externalDataStore

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2019-10-07 15:40:49 -04:00
parent bbdf85d63a
commit dbdf150b45

View File

@ -1921,15 +1921,16 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr,
static int
virSecuritySELinuxSetImageLabel(virSecurityManagerPtr mgr,
virDomainDefPtr def,
virStorageSourcePtr src,
virSecurityDomainImageLabelFlags flags)
virSecuritySELinuxSetImageLabelRelative(virSecurityManagerPtr mgr,
virDomainDefPtr def,
virStorageSourcePtr src,
virStorageSourcePtr parent,
virSecurityDomainImageLabelFlags flags)
{
virStorageSourcePtr n;
for (n = src; virStorageSourceIsBacking(n); n = n->backingStore) {
if (virSecuritySELinuxSetImageLabelInternal(mgr, def, n, src) < 0)
if (virSecuritySELinuxSetImageLabelInternal(mgr, def, n, parent) < 0)
return -1;
if (!(flags & VIR_SECURITY_DOMAIN_IMAGE_LABEL_BACKING_CHAIN))
@ -1940,6 +1941,15 @@ virSecuritySELinuxSetImageLabel(virSecurityManagerPtr mgr,
}
static int
virSecuritySELinuxSetImageLabel(virSecurityManagerPtr mgr,
virDomainDefPtr def,
virStorageSourcePtr src,
virSecurityDomainImageLabelFlags flags)
{
return virSecuritySELinuxSetImageLabelRelative(mgr, def, src, src, flags);
}
struct virSecuritySELinuxMoveImageMetadataData {
virSecurityManagerPtr mgr;
const char *src;