]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
security: Skip labeling resources when seclabel defaults to none
authorJiri Denemark <jdenemar@redhat.com>
Wed, 25 Jul 2012 12:38:27 +0000 (14:38 +0200)
committerCole Robinson <crobinso@redhat.com>
Mon, 13 Aug 2012 01:15:46 +0000 (21:15 -0400)
If a domain is explicitly configured with <seclabel type="none"/> we
correctly ensure that no labeling will be done by setting
norelabel=true. However, if no seclabel element is present in domain XML
and hypervisor is configured not to confine domains by default, we only
set type to "none" without turning off relabeling. Thus if such a domain
is being started, security driver wants to relabel resources with
default label, which doesn't make any sense.

Moreover, with SELinux security driver, the generated image label lacks
"s0" sensitivity, which causes setfilecon() fail with EINVAL in
enforcing mode.
(cherry picked from commit ce53382ba28179d3a504b29b4f888b6e130d53f0)

src/security/security_manager.c

index 0a43458d7815011a5730f98d4fea65c320e7c443..8bf1fcc3427469e6cc3c5b6a9af71c879854d82d 100644 (file)
@@ -296,10 +296,12 @@ int virSecurityManagerGenLabel(virSecurityManagerPtr mgr,
                                virDomainDefPtr vm)
 {
     if (vm->seclabel.type == VIR_DOMAIN_SECLABEL_DEFAULT) {
-        if (mgr->defaultConfined)
+        if (mgr->defaultConfined) {
             vm->seclabel.type = VIR_DOMAIN_SECLABEL_DYNAMIC;
-        else
+        } else {
             vm->seclabel.type = VIR_DOMAIN_SECLABEL_NONE;
+            vm->seclabel.norelabel = true;
+        }
     }
 
     if ((vm->seclabel.type == VIR_DOMAIN_SECLABEL_NONE) &&