Blame SOURCES/0046-v2v-vddk-Check-if-nbdkit-supports-selinux-label-befo.patch

151578
From bf7dba21337b2671f877f4e37e5eb031b26fc6e2 Mon Sep 17 00:00:00 2001
151578
From: "Richard W.M. Jones" <rjones@redhat.com>
151578
Date: Tue, 17 Oct 2017 10:43:30 +0100
151578
Subject: [PATCH] v2v: vddk: Check if nbdkit supports --selinux-label before
151578
 using.
151578
151578
Give a better error message if not.
151578
151578
Thanks: Ming Xie.
151578
(cherry picked from commit 59b4c4779f7dac645c794393d91c46467afab91c)
151578
---
151578
 v2v/input_libvirt_vddk.ml | 16 ++++++++++++++++
151578
 1 file changed, 16 insertions(+)
151578
151578
diff --git a/v2v/input_libvirt_vddk.ml b/v2v/input_libvirt_vddk.ml
151578
index b322a9c49..f0b150efa 100644
151578
--- a/v2v/input_libvirt_vddk.ml
151578
+++ b/v2v/input_libvirt_vddk.ml
151578
@@ -101,6 +101,20 @@ See also \"INPUT FROM VDDK\" in the virt-v2v(1) manual.") library_path
151578
       error (f_"You must pass the ‘--vddk-thumbprint’ option with the SSL thumbprint of the VMware server.  To find the thumbprint, see the nbdkit-vddk-plugin(1) manual.  See also \"INPUT FROM VDDK\" in the virt-v2v(1) manual.")
151578
   in
151578
 
151578
+  (* Check that nbdkit was compiled with SELinux support (for the
151578
+   * --selinux-label option).
151578
+   *)
151578
+  let error_unless_nbdkit_compiled_with_selinux () =
151578
+    let lines = external_command "nbdkit --dump-config" in
151578
+    (* In nbdkit <= 1.1.15 the selinux attribute was not present
151578
+     * at all in --dump-config output so there was no way to tell.
151578
+     * Ignore this case because there will be an error later when
151578
+     * we try to use the --selinux-label parameter.
151578
+     *)
151578
+    if List.mem "selinux=no" (List.map String.trim lines) then
151578
+      error (f_"nbdkit was compiled without SELinux support.  You will have to recompile nbdkit with libselinux-devel installed, or else set SELinux to Permissive mode while doing the conversion.")
151578
+  in
151578
+
151578
   (* List of passthrough parameters. *)
151578
   let vddk_passthrus =
151578
     [ "config",      (fun { vddk_config }      -> vddk_config);
151578
@@ -135,6 +149,8 @@ object
151578
     error_unless_nbdkit_working ();
151578
     error_unless_nbdkit_vddk_working ();
151578
     error_unless_thumbprint ();
151578
+    if have_selinux then
151578
+      error_unless_nbdkit_compiled_with_selinux ();
151578
 
151578
     (* Get the libvirt XML.  This also checks (as a side-effect)
151578
      * that the domain is not running.  (RHBZ#1138586)
151578
-- 
151578
2.14.3
151578