Blame SOURCES/0028-v2v-Replace-broken-VMware-Tools-uninstall-command-ms.patch

61e9b3
From 2bf5fc815d53e581398e787ae96444c438945ab3 Mon Sep 17 00:00:00 2001
61e9b3
From: "Richard W.M. Jones" <rjones@redhat.com>
61e9b3
Date: Tue, 19 Jan 2021 12:17:49 +0000
61e9b3
Subject: [PATCH] v2v: Replace broken VMware Tools uninstall command msiexec /i
61e9b3
 with /x.
61e9b3
61e9b3
Fixes: https://bugzilla.redhat.com/1917760
61e9b3
Thanks: Chetan Nagarkar
61e9b3
(cherry picked from commit f7496b0a7e76a06bda8d7ec1aba36741f8cb295c)
61e9b3
---
61e9b3
 v2v/convert_windows.ml | 15 ++++++++++++---
61e9b3
 1 file changed, 12 insertions(+), 3 deletions(-)
61e9b3
61e9b3
diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml
61e9b3
index 84db742f..44cef5ed 100644
61e9b3
--- a/v2v/convert_windows.ml
61e9b3
+++ b/v2v/convert_windows.ml
61e9b3
@@ -135,7 +135,7 @@ let convert (g : G.guestfs) inspect _ output rcaps static_ips =
61e9b3
   (* Locate and retrieve all the uninstallation commands for installed
61e9b3
    * applications.
61e9b3
    *)
61e9b3
-  let uninstallation_commands pretty_name matchfn extra_uninstall_params =
61e9b3
+  let uninstallation_commands pretty_name matchfn modfn extra_uninstall_params =
61e9b3
     let path = ["Microsoft"; "Windows"; "CurrentVersion"; "Uninstall"] in
61e9b3
     let uninstval = "UninstallString" in
61e9b3
     let ret = ref [] in
61e9b3
@@ -155,6 +155,7 @@ let convert (g : G.guestfs) inspect _ output rcaps static_ips =
61e9b3
                    let valueh = g#hivex_node_get_value uninstnode uninstval in
61e9b3
                    if valueh <> 0L then (
61e9b3
                      let reg_cmd = g#hivex_value_string valueh in
61e9b3
+                     let reg_cmd = modfn reg_cmd in
61e9b3
                      let cmd =
61e9b3
                        sprintf "%s /quiet /norestart /l*v+ \"%%~dpn0.log\" REBOOT=ReallySuppress REMOVE=ALL %s"
61e9b3
                          reg_cmd extra_uninstall_params in
61e9b3
@@ -183,14 +184,22 @@ let convert (g : G.guestfs) inspect _ output rcaps static_ips =
61e9b3
      *)
61e9b3
     let extra_uninstall_params =
61e9b3
       "PREVENT_REBOOT=Yes LAUNCHED_BY_SETUP_EXE=Yes" in
61e9b3
-    uninstallation_commands "Parallels Tools" matchfn extra_uninstall_params in
61e9b3
+    uninstallation_commands "Parallels Tools" matchfn identity
61e9b3
+      extra_uninstall_params in
61e9b3
 
61e9b3
   (* Locate and retrieve all uninstallation commands for VMware Tools. *)
61e9b3
   let vmwaretools_uninst =
61e9b3
     let matchfn s =
61e9b3
       String.find s "VMware Tools" != -1
61e9b3
     in
61e9b3
-    uninstallation_commands "VMware Tools" matchfn "" in
61e9b3
+    (* VMware Tools writes the install command (MsiExec /I) into the
61e9b3
+     * UninstallString key in the registry, rather than the uninstall
61e9b3
+     * command.  Try to spot this and rewrite.  (RHBZ#1917760).
61e9b3
+     *)
61e9b3
+    let re1 = PCRE.compile ~caseless:true "msiexec" in
61e9b3
+    let re2 = PCRE.compile ~caseless:true "/i" in
61e9b3
+    let msifn s = if PCRE.matches re1 s then PCRE.replace re2 "/x" s else s in
61e9b3
+    uninstallation_commands "VMware Tools" matchfn msifn "" in
61e9b3
 
61e9b3
   (*----------------------------------------------------------------------*)
61e9b3
   (* Perform the conversion of the Windows guest. *)
61e9b3
-- 
8984ae
2.31.1
61e9b3