Blame SOURCES/0007-v2v-Add-op-output-password-file-option.patch

d0ea73
From ae2d0a507af53563d0b70d28654c9c60a857fd10 Mon Sep 17 00:00:00 2001
d0ea73
From: "Richard W.M. Jones" <rjones@redhat.com>
d0ea73
Date: Thu, 22 Feb 2018 11:43:33 +0000
d0ea73
Subject: [PATCH] v2v: Add -op (output password file) option.
d0ea73
d0ea73
Currently unused, in a future commit this will allow you to pass in a
d0ea73
password to be used when connecting to the target hypervisor.
d0ea73
d0ea73
(cherry picked from commit a4e181137a38f5767dd1bf05dc482959cb7283be)
d0ea73
---
d0ea73
 v2v/cmdline.ml       | 18 ++++++++++++++++++
d0ea73
 v2v/test-v2v-docs.sh |  2 +-
d0ea73
 v2v/virt-v2v.pod     |  7 +++++++
d0ea73
 3 files changed, 26 insertions(+), 1 deletion(-)
d0ea73
d0ea73
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
d0ea73
index 75909ee77..2a067741e 100644
d0ea73
--- a/v2v/cmdline.ml
d0ea73
+++ b/v2v/cmdline.ml
d0ea73
@@ -62,6 +62,7 @@ let parse_cmdline () =
d0ea73
   let output_conn = ref None in
d0ea73
   let output_format = ref None in
d0ea73
   let output_name = ref None in
d0ea73
+  let output_password = ref None in
d0ea73
   let output_storage = ref None in
d0ea73
   let password_file = ref None in
d0ea73
   let vddk_config = ref None in
d0ea73
@@ -219,6 +220,8 @@ let parse_cmdline () =
d0ea73
                                     s_"Set output format";
d0ea73
     [ M"on" ],       Getopt.String ("name", set_string_option_once "-on" output_name),
d0ea73
                                     s_"Rename guest when converting";
d0ea73
+    [ M"op" ],       Getopt.String ("filename", set_string_option_once "-op" output_password),
d0ea73
+                                    s_"Use password from file to connect to output hypervisor";
d0ea73
     [ M"os" ],       Getopt.String ("storage", set_string_option_once "-os" output_storage),
d0ea73
                                     s_"Set output storage location";
d0ea73
     [ L"password-file" ], Getopt.String ("file", set_string_option_once "--password-file" password_file),
d0ea73
@@ -314,6 +317,7 @@ read the man page virt-v2v(1).
d0ea73
   let output_format = !output_format in
d0ea73
   let output_mode = !output_mode in
d0ea73
   let output_name = !output_name in
d0ea73
+  let output_password = !output_password in
d0ea73
   let output_storage = !output_storage in
d0ea73
   let password_file = !password_file in
d0ea73
   let print_source = !print_source in
d0ea73
@@ -461,6 +465,8 @@ read the man page virt-v2v(1).
d0ea73
     | `Glance ->
d0ea73
       if output_conn <> None then
d0ea73
         error_option_cannot_be_used_in_output_mode "glance" "-oc";
d0ea73
+      if output_password <> None then
d0ea73
+        error_option_cannot_be_used_in_output_mode "glance" "-op";
d0ea73
       if output_storage <> None then
d0ea73
         error_option_cannot_be_used_in_output_mode "glance" "-os";
d0ea73
       if qemu_boot then
d0ea73
@@ -472,6 +478,8 @@ read the man page virt-v2v(1).
d0ea73
 
d0ea73
     | `Not_set
d0ea73
     | `Libvirt ->
d0ea73
+      if output_password <> None then
d0ea73
+        error_option_cannot_be_used_in_output_mode "libvirt" "-op";
d0ea73
       let output_storage = Option.default "default" output_storage in
d0ea73
       if qemu_boot then
d0ea73
         error_option_cannot_be_used_in_output_mode "libvirt" "--qemu-boot";
d0ea73
@@ -481,6 +489,8 @@ read the man page virt-v2v(1).
d0ea73
       output_format, output_alloc
d0ea73
 
d0ea73
     | `Local ->
d0ea73
+      if output_password <> None then
d0ea73
+        error_option_cannot_be_used_in_output_mode "local" "-op";
d0ea73
       let os =
d0ea73
         match output_storage with
d0ea73
         | None ->
d0ea73
@@ -500,6 +510,8 @@ read the man page virt-v2v(1).
d0ea73
         error_option_cannot_be_used_in_output_mode "null" "-oc";
d0ea73
       if output_format <> None then
d0ea73
         error_option_cannot_be_used_in_output_mode "null" "-of";
d0ea73
+      if output_password <> None then
d0ea73
+        error_option_cannot_be_used_in_output_mode "null" "-op";
d0ea73
       if output_storage <> None then
d0ea73
         error_option_cannot_be_used_in_output_mode "null" "-os";
d0ea73
       if qemu_boot then
d0ea73
@@ -509,6 +521,8 @@ read the man page virt-v2v(1).
d0ea73
       Some "raw", Sparse
d0ea73
 
d0ea73
     | `QEmu ->
d0ea73
+      if output_password <> None then
d0ea73
+        error_option_cannot_be_used_in_output_mode "qemu" "-op";
d0ea73
       let os =
d0ea73
         match output_storage with
d0ea73
         | None ->
d0ea73
@@ -520,6 +534,8 @@ read the man page virt-v2v(1).
d0ea73
       output_format, output_alloc
d0ea73
 
d0ea73
     | `RHV ->
d0ea73
+      if output_password <> None then
d0ea73
+        error_option_cannot_be_used_in_output_mode "rhv" "-op";
d0ea73
       let os =
d0ea73
         match output_storage with
d0ea73
         | None ->
d0ea73
@@ -531,6 +547,8 @@ read the man page virt-v2v(1).
d0ea73
       output_format, output_alloc
d0ea73
 
d0ea73
     | `VDSM ->
d0ea73
+      if output_password <> None then
d0ea73
+        error_option_cannot_be_used_in_output_mode "vdsm" "-op";
d0ea73
       let os =
d0ea73
         match output_storage with
d0ea73
         | None ->
d0ea73
diff --git a/v2v/test-v2v-docs.sh b/v2v/test-v2v-docs.sh
d0ea73
index 5d034c465..0e3bd916a 100755
d0ea73
--- a/v2v/test-v2v-docs.sh
d0ea73
+++ b/v2v/test-v2v-docs.sh
d0ea73
@@ -22,4 +22,4 @@ $TEST_FUNCTIONS
d0ea73
 skip_if_skipped
d0ea73
 
d0ea73
 $top_srcdir/podcheck.pl virt-v2v.pod virt-v2v \
d0ea73
-  --ignore=--debug-overlay,--ic,--if,--it,--no-trim,--oa,--oc,--of,--on,--os,--vmtype
d0ea73
+  --ignore=--debug-overlay,--ic,--if,--it,--no-trim,--oa,--oc,--of,--on,--op,--os,--vmtype
d0ea73
diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
d0ea73
index 0ea5fa97f..00ba45555 100644
d0ea73
--- a/v2v/virt-v2v.pod
d0ea73
+++ b/v2v/virt-v2v.pod
d0ea73
@@ -569,6 +569,13 @@ If not specified, then the input format is used.
d0ea73
 Rename the guest when converting it.  If this option is not used then
d0ea73
 the output name is the same as the input name.
d0ea73
 
d0ea73
+=item B<-op> file
d0ea73
+
d0ea73
+Supply a file containing a password to be used when connecting to the
d0ea73
+target hypervisor.  Note the file should contain the whole password,
d0ea73
+B<without any trailing newline>, and for security the file should have
d0ea73
+mode C<0600> so that others cannot read it.
d0ea73
+
d0ea73
 =item B<-os> storage
d0ea73
 
d0ea73
 The location of the storage for the converted guest.
d0ea73
-- 
d0ea73
2.20.1
d0ea73