From a36d3b88d637c59d541aaa6c77ccf32f7a915826 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Mon, 7 Oct 2019 15:55:20 -0400 Subject: [PATCH] security: selinux: Add is_toplevel to SetImageLabelInternal This will simplify future patches and make the logic easier to follow Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik Signed-off-by: Cole Robinson --- src/security/security_selinux.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index fe65513317..f79d47ab15 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1826,6 +1826,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr, virSecurityDeviceLabelDefPtr parent_seclabel = NULL; char *use_label = NULL; bool remember; + bool is_toplevel = parent == src; int ret; if (!src->path || !virStorageSourceIsLocalStorage(src)) @@ -1847,7 +1848,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr, * but the top layer, or read only image, or disk explicitly * marked as shared. */ - remember = src == parent && !src->readonly && !src->shared; + remember = is_toplevel && !src->readonly && !src->shared; disk_seclabel = virStorageSourceGetSecurityLabelDef(src, SECURITY_SELINUX_NAME); @@ -1864,7 +1865,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr, return 0; use_label = parent_seclabel->label; - } else if (parent == src) { + } else if (is_toplevel) { if (src->shared) { use_label = data->file_context; } else if (src->readonly) {