mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0012-Use-proper-label-for-nbdkit-sockets.patch

a034fe
From d161370dbc97786e05d476ccaed219fa14d7bf1b Mon Sep 17 00:00:00 2001
a034fe
From: Martin Kletzander <mkletzan@redhat.com>
a034fe
Date: Mon, 27 May 2019 13:30:05 +0200
a034fe
Subject: [PATCH] Use proper label for nbdkit sockets
a034fe
a034fe
While svirt_t can be used for sockets it does not always guarantee that it will
a034fe
be accessible from a virtual machine.  The VM might be running under svirt_tcg_t
a034fe
context which will need a svirt_tcg_t label on the socket in order to access it.
a034fe
a034fe
There is, however, another label, svirt_socket_t, which is accessible from
a034fe
virt_domain:
a034fe
a034fe
  # sesearch -A -s svirt_t -c unix_stream_socket -p connectto
a034fe
  ...
a034fe
  allow virt_domain svirt_socket_t:unix_stream_socket { ... connectto ... };
a034fe
  ...
a034fe
a034fe
And virt_domain is a type attribute of both svirt_t and svirt_tcg_t:
a034fe
a034fe
  # seinfo -x -a virt_domain
a034fe
  Type Attributes: 1
a034fe
     attribute virt_domain;
a034fe
          svirt_t
a034fe
          svirt_tcg_t
a034fe
a034fe
Resolves: https://bugzilla.redhat.com/1698437
a034fe
a034fe
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
a034fe
(cherry picked from commit c2918b8b74506523a723b804d452816a059c5e50)
a034fe
---
a034fe
 v2v/input_libvirt_vddk.ml | 2 +-
a034fe
 v2v/output_rhv_upload.ml  | 2 +-
a034fe
 2 files changed, 2 insertions(+), 2 deletions(-)
a034fe
a034fe
diff --git a/v2v/input_libvirt_vddk.ml b/v2v/input_libvirt_vddk.ml
a034fe
index 97c7cb532..567233d58 100644
a034fe
--- a/v2v/input_libvirt_vddk.ml
a034fe
+++ b/v2v/input_libvirt_vddk.ml
a034fe
@@ -290,7 +290,7 @@ object
a034fe
       add_arg "--newstyle";         (* use newstyle NBD protocol *)
a034fe
       add_arg "--exportname"; add_arg "/";
a034fe
       if have_selinux then (        (* label the socket so qemu can open it *)
a034fe
-        add_arg "--selinux-label"; add_arg "system_u:object_r:svirt_t:s0"
a034fe
+        add_arg "--selinux-label"; add_arg "system_u:object_r:svirt_socket_t:s0"
a034fe
       );
a034fe
 
a034fe
       (* Name of the plugin.  Everything following is a plugin parameter. *)
a034fe
diff --git a/v2v/output_rhv_upload.ml b/v2v/output_rhv_upload.ml
a034fe
index 77c39107e..c2a5c72c7 100644
a034fe
--- a/v2v/output_rhv_upload.ml
a034fe
+++ b/v2v/output_rhv_upload.ml
a034fe
@@ -217,7 +217,7 @@ See also the virt-v2v-output-rhv(1) manual.")
a034fe
     let args =
a034fe
       (* label the socket so qemu can open it *)
a034fe
       if have_selinux then
a034fe
-        args @ ["--selinux-label"; "system_u:object_r:svirt_t:s0"]
a034fe
+        args @ ["--selinux-label"; "system_u:object_r:svirt_socket_t:s0"]
a034fe
       else args in
a034fe
     args in
a034fe
 
a034fe
-- 
a034fe
2.21.0
a034fe