]> xenbits.xensource.com Git - libvirt.git/commitdiff
security: Don't skip relabel for all chardevs
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 22 Jun 2017 11:51:58 +0000 (13:51 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 22 Jun 2017 12:28:15 +0000 (14:28 +0200)
Our commit e13e8808f9 was way too generic. Currently, virtlogd is
used only for chardevs type of file and nothing else. True, we
must not relabel the path in this case, but we have to in all
other cases. For instance, if you want to have a physical console
attached to your guest:

    <console type='dev'>
      <source path='/dev/ttyS0'/>
      <target type='virtio' port='1'/>
    </console>

Starting such domain fails because qemu doesn't have access to
/dev/ttyS0 because we haven't relabelled the path.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/security/security_dac.c
src/security/security_selinux.c

index 79941f480a39584d0c3e842d6ec305114538030b..ca7a6af6d46645852cf39ca3b2e5413f45114142 100644 (file)
@@ -1179,7 +1179,9 @@ virSecurityDACSetChardevLabel(virSecurityManagerPtr mgr,
     if (chr_seclabel && !chr_seclabel->relabel)
         return 0;
 
-    if (!chr_seclabel && chardevStdioLogd)
+    if (!chr_seclabel &&
+        dev_source->type == VIR_DOMAIN_CHR_TYPE_FILE &&
+        chardevStdioLogd)
         return 0;
 
     if (chr_seclabel && chr_seclabel->label) {
@@ -1261,7 +1263,9 @@ virSecurityDACRestoreChardevLabel(virSecurityManagerPtr mgr,
     if (chr_seclabel && !chr_seclabel->relabel)
         return 0;
 
-    if (!chr_seclabel && chardevStdioLogd)
+    if (!chr_seclabel &&
+        dev_source->type == VIR_DOMAIN_CHR_TYPE_FILE &&
+        chardevStdioLogd)
         return 0;
 
     switch ((virDomainChrType) dev_source->type) {
index 26137f6d8d39e44794fb030fa52fdbe4a1630c04..2e3082b7a8d77a241f0aa88d08e4b0e46a611a17 100644 (file)
@@ -2199,7 +2199,9 @@ virSecuritySELinuxSetChardevLabel(virSecurityManagerPtr mgr,
     if (chr_seclabel && !chr_seclabel->relabel)
         return 0;
 
-    if (!chr_seclabel && chardevStdioLogd)
+    if (!chr_seclabel &&
+        dev_source->type == VIR_DOMAIN_CHR_TYPE_FILE &&
+        chardevStdioLogd)
         return 0;
 
     if (chr_seclabel)
@@ -2274,7 +2276,9 @@ virSecuritySELinuxRestoreChardevLabel(virSecurityManagerPtr mgr,
     if (chr_seclabel && !chr_seclabel->relabel)
         return 0;
 
-    if (!chr_seclabel && chardevStdioLogd)
+    if (!chr_seclabel &&
+        dev_source->type == VIR_DOMAIN_CHR_TYPE_FILE &&
+        chardevStdioLogd)
         return 0;
 
     switch (dev_source->type) {