Blame SOURCES/0030-v2v-o-rhv-upload-make-oo-rhv-cafile-optional.patch

46b2f6
From 5ad1e7c160f5fe0d499d8d25116cb0e1692f1e93 Mon Sep 17 00:00:00 2001
46b2f6
From: Pino Toscano <ptoscano@redhat.com>
46b2f6
Date: Fri, 27 Sep 2019 13:56:42 +0200
46b2f6
Subject: [PATCH] v2v: -o rhv-upload: make -oo rhv-cafile optional
46b2f6
46b2f6
It makes little sense to require the oVirt certificate, especially when
46b2f6
the verification of the connection (-oo rhv-verifypeer) is disabled by
46b2f6
default.  The only work done with the certificate in that case is
46b2f6
checking that it is a valid certificate file.
46b2f6
46b2f6
Hence, make -oo rhv-cafile optional, requiring it only when
46b2f6
-oo rhv-verifypeer is enabled.
46b2f6
46b2f6
(cherry picked from commit 0a5eaad7db3c9b9a03fa88102a9e6142c855bfd1)
46b2f6
---
46b2f6
 v2v/output_rhv_upload.ml    | 16 +++++++++-------
46b2f6
 v2v/virt-v2v-output-rhv.pod |  2 ++
46b2f6
 2 files changed, 11 insertions(+), 7 deletions(-)
46b2f6
46b2f6
diff --git a/v2v/output_rhv_upload.ml b/v2v/output_rhv_upload.ml
46b2f6
index 206657a2b..2c8c18732 100644
46b2f6
--- a/v2v/output_rhv_upload.ml
46b2f6
+++ b/v2v/output_rhv_upload.ml
46b2f6
@@ -28,7 +28,7 @@ open Types
46b2f6
 open Utils
46b2f6
 
46b2f6
 type rhv_options = {
46b2f6
-  rhv_cafile : string;
46b2f6
+  rhv_cafile : string option;
46b2f6
   rhv_cluster : string option;
46b2f6
   rhv_direct : bool;
46b2f6
   rhv_verifypeer : bool;
46b2f6
@@ -76,15 +76,13 @@ let parse_output_options options =
46b2f6
        error (f_"-o rhv-upload: unknown output option ‘-oo %s’") k
46b2f6
   ) options;
46b2f6
 
46b2f6
-  let rhv_cafile =
46b2f6
-    match !rhv_cafile with
46b2f6
-    | Some s -> s
46b2f6
-    | None ->
46b2f6
-       error (f_"-o rhv-upload: must use ‘-oo rhv-cafile’ to supply the path to the oVirt or RHV user’s ‘ca.pem’ file") in
46b2f6
+  let rhv_cafile = !rhv_cafile in
46b2f6
   let rhv_cluster = !rhv_cluster in
46b2f6
   let rhv_direct = !rhv_direct in
46b2f6
   let rhv_verifypeer = !rhv_verifypeer in
46b2f6
   let rhv_disk_uuids = Option.map List.rev !rhv_disk_uuids in
46b2f6
+  if rhv_verifypeer && rhv_cafile = None then
46b2f6
+     error (f_"-o rhv-upload: must use ‘-oo rhv-cafile’ to supply the path to the oVirt or RHV user’s ‘ca.pem’ file");
46b2f6
 
46b2f6
   { rhv_cafile; rhv_cluster; rhv_direct; rhv_verifypeer; rhv_disk_uuids }
46b2f6
 
46b2f6
@@ -92,6 +90,10 @@ let nbdkit_python_plugin = Config.virt_v2v_nbdkit_python_plugin
46b2f6
 let pidfile_timeout = 30
46b2f6
 let finalization_timeout = 5*60
46b2f6
 
46b2f6
+let json_optstring = function
46b2f6
+  | Some s -> JSON.String s
46b2f6
+  | None -> JSON.Null
46b2f6
+
46b2f6
 class output_rhv_upload output_alloc output_conn
46b2f6
                         output_password output_storage
46b2f6
                         rhv_options =
46b2f6
@@ -200,7 +202,7 @@ See also the virt-v2v-output-rhv(1) manual.")
46b2f6
     "output_sparse", JSON.Bool (match output_alloc with
46b2f6
                                 | Sparse -> true
46b2f6
                                 | Preallocated -> false);
46b2f6
-    "rhv_cafile", JSON.String rhv_options.rhv_cafile;
46b2f6
+    "rhv_cafile", json_optstring rhv_options.rhv_cafile;
46b2f6
     "rhv_cluster",
46b2f6
       JSON.String (Option.default "Default" rhv_options.rhv_cluster);
46b2f6
     "rhv_direct", JSON.Bool rhv_options.rhv_direct;
46b2f6
diff --git a/v2v/virt-v2v-output-rhv.pod b/v2v/virt-v2v-output-rhv.pod
46b2f6
index e840ca78d..04a894268 100644
46b2f6
--- a/v2v/virt-v2v-output-rhv.pod
46b2f6
+++ b/v2v/virt-v2v-output-rhv.pod
46b2f6
@@ -101,6 +101,8 @@ The storage domain.
46b2f6
 The F<ca.pem> file (Certificate Authority), copied from
46b2f6
 F</etc/pki/ovirt-engine/ca.pem> on the oVirt engine.
46b2f6
 
46b2f6
+This option must be specified if I<-oo rhv-verifypeer> is enabled.
46b2f6
+
46b2f6
 =item I<-oo rhv-cluster=>C<CLUSTERNAME>
46b2f6
 
46b2f6
 Set the RHV Cluster Name.  If not given it uses C<Default>.
46b2f6
-- 
b155d0
2.26.2
46b2f6